akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

int main(){
    int N, M;
    while(std::cin >> N >> M, N){
        int parts[1010];
        REP(i, N){
            std::cin >> parts[i];
        }
        parts[N] = 0;

        std::vector<int> half;
        REP(i, N+1){
            REP(j, N+1){
                if(parts[i] + parts[j] <= M){
                    half.push_back(parts[i] + parts[j]);
                }
            }
        }

        int res = 0;

        std::sort(half.begin(), half.end());
        REP(i, half.size()){
            int v = half[i],
                index = std::lower_bound(half.begin(), half.end(), M-v) - half.begin();
            if(half[index] + v == M){
                res = M;
            }else if(index - 1 >= 0){
                res = std::max(res, v + half[index-1]);
            }
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 9328
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#include<iostream>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define VI vector<int>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=605;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int n,K,f[MAXN][MAXN],g[MAXN][MAXN];
int A[MAXN],B[MAXN],id[MAXN];
int cho[MAXN],coef[MAXN];
int main()
{
	#ifdef Rose
		double BeginJudgeTime=clock();
	#endif
	coef[0]=1;
	for(int i=2;i<MAXN;i+=2)coef[i]=1LL*coef[i-2]*(i-1)%mod;
	n=read();K=read();
	for(int i=1;i<=K;i++)A[i]=read(),B[i]=read(),cho[A[i]]=cho[B[i]]=1,id[A[i]]=B[i],id[B[i]]=A[i];
	for(int i=1;i<=2*n;i++)cho[i]+=cho[i-1];
	for(int i=1;i<=2*n;i++)
	{
		int mn=1e9,mx=0;
		for(int j=i;j<=2*n;j++)
		{
			if(id[j])chkmax(mx,id[j]),chkmin(mn,id[j]);
			if(mn>=i&&mx<=j)f[i][j]=coef[j-i+1-(cho[j]-cho[i-1])];
		}
	}
	for(int L=2;L<=2*n;L++)
		for(int x=1;x+L-1<=2*n;x++)
		{
			int y=x+L-1;
			if(!f[x][y])continue;int S=f[x][y];
			for(int k=x+1;k<y;k+=2)dl(S,1LL*g[x][k]*f[k+1][y]%mod);
			g[x][y]=S;
		}
	int ans=0;
	for(int x=1;x<=2*n;x++)for(int y=x;y<=2*n;y++)if(g[x][y])
	{
		int ls=2*n-(y-x+1)-cho[2*n]+(cho[y]-cho[x-1]);
		ad(ans,1LL*g[x][y]*coef[ls]%mod);
	}pr2(ans);
	#ifdef Rose
		double EndJudgeTime=clock();
		cerr<<"JudgeTime is"<<" ";
		cerr<<(EndJudgeTime-BeginJudgeTime)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 
#define REP(i, n) for (int i = 0; i < (n); i++)

int main(int argc, char const *argv[])
{
    int N;
    vector<int> a;
    cin >> N;
    REP(i, N) {
        int x;cin >> x;
        a.push_back(x);
    }
    int pre = 0;
    int res = 0;
    REP(i, N) {
        if (pre == a[i]) {
            res++;
            pre = 0;
            continue;
        }
        pre = a[i];
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int n;
	int a;
	int sum=0;
	for(; ; ) {
		scanf("%d", &n);
		if(n==0) break;
		sum=0;
		for(a=5; n/a>0; a*=5) {
			sum+=n/a;
		}
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 600
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

#define rep(i, n)	        for(int i = 0; i < (int)(n); i++)
#define rep_1(i, n) 	    for(int i = 1; i <=(int)(n); i++)

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

void solve() {
    int a,b,c,ans = 0;
    read(a);
    read(b);
    read(c);
    for(int i = a;i <= b;i++){
        if(c % i == 0){
            ans++;
        }
    }
    println(ans);
}

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


Measured memory_bytes: 3128
import numpy as np


if __name__ == '__main__':
    List = [list(map(int, input().split())) for i in range(2)]
    N=List[0][0]
    M=List[0][1]

    Time=np.array(List[1][:])
    sum_time= sum(Time)
    if(sum_time <= N):
        print(N-sum_time)
    else:
        print(-1)



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

int main() {
	int n, t, e; scanf("%d%d%d", &n, &t, &e);
	rep(i, n) {
		int x; scanf("%d", &x);
		int k = (t + e) / x;
		if (t - e <= k*x) {
			printf("%d\n", i + 1);
			return 0;
		}
	}
	puts("-1");
}

Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sysin = new Scanner(System.in);
		final long a = sysin.nextLong();
		final long b = sysin.nextLong();
		final long c = sysin.nextLong();
		final long d = sysin.nextLong();
		sysin.close();

		
		long min = a - 1;
		long max = b;
		long lowerDivisor = Math.min(c, d);
		long higherDivisor = Math.max(c, d);
		
		long factor1 = max / lowerDivisor - min / lowerDivisor;
		long factor2 = max / higherDivisor - min / higherDivisor;

		long gcd = gcd(higherDivisor, lowerDivisor);
		long lcm = lowerDivisor * higherDivisor / gcd;
		long dup = max / lcm - min / lcm;

		System.out.println(max - min - factor1 - factor2 + dup);
	}

	private static long gcd(long higher, long lower) {
		return (lower == 0) ? higher : gcd(lower, higher % lower);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int main(){
  string s;
  int K;
  cin >> s >> K;
  vector<string> vec;
  rep(i,0,s.size() - 1){
    for(int j = 1;j <= 5 && i + j <= s.size();j++){
      vec.push_back(s.substr(i,j));
    }
  }
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  cout << vec[K - 1] << endl;
}


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

num_count = {}
for num in a:
    if num in num_count:
        num_count[num] += 1
    else:
        num_count[num] = 1
ans = 0
for key in num_count:
    if key < num_count[key]:
        ans += num_count[key] - key
    elif key > num_count[key]:
        ans += num_count[key]
print(ans)


Measured memory_bytes: 23284
import bisect

A, B, Q = map(int, input().split())
s = [0]*A
for i in range(A):
    s[i] = int(input())
t = [0]*B
for i in range(B):
    t[i] = int(input())
X = [0]*Q
for i in range(Q):
    X[i] = int(input())

INF = 10 ** 18
s = [-INF] + s + [INF]
t = [-INF] + t + [INF]

for x in X:
    sr, tr = bisect.bisect_right(s, x), bisect.bisect_left(t, x)
    res = INF
    for S in [s[sr-1], s[sr]]:
        for T in [t[tr-1], t[tr]]:
            d1, d2 = abs(S-x)+abs(T-S), abs(T-x)+abs(S-T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 16708
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define sort(v)  sort(v.begin(),v.end());
#define sortd(v) sort(v.begin(),v.end(),greater<int>());
#define pb 		push_back
#define ll 		long long
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
#define mod 	1000000007
#define endl "\n"
using namespace std;
int prime[10000001];
void solve(){
   ll n;cin>>n;

   for(ll i=1;i<=n;i++){
           for(ll j=i;j<=n;j+=i){
                prime[j]++;
            } 
        
   }

    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ans += i*prime[i];
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 42680
implicit none
  integer(8) :: N, A,B
  integer(8) :: i
  integer(8) :: out, tmp1, tmp2
  read(*,*) N,A,B
  tmp1 = mod (N,A+B)
  tmp2 = N/(A+B)
  out = tmp2*A + min(tmp1,A)
  write(*,'(i0)') out
end


Measured memory_bytes: 256
let popcnt x =
  let x = (x land 0x5555555555555555) + ((x lsr 1) land 0x5555555555555555) in
  let x = (x land 0x3333333333333333) + ((x lsr 2) land 0x3333333333333333) in
  let x = (x land 0x0f0f0f0f0f0f0f0f) + ((x lsr 4) land 0x0f0f0f0f0f0f0f0f) in
  let x = (x land 0x00ff00ff00ff00ff) + ((x lsr 8) land 0x00ff00ff00ff00ff) in
  let x = (x land 0x0000ffff0000ffff) + ((x lsr 16) land 0x0000ffff0000ffff) in
  (x land 0x00000000ffffffff) + ((x lsr 32) land 0x00000000ffffffff)

let log2 x =
  let x = x lor (x lsr 1) in
  let x = x lor (x lsr 2) in
  let x = x lor (x lsr 4) in
  let x = x lor (x lsr 8) in
  let x = x lor (x lsr 16) in
  let x = x lor (x lsr 32) in
  popcnt x

let () = Scanf.scanf "%d\n" @@ fun l ->
  let n = log2 l in
  let es = List.concat @@ Array.to_list @@ Array.init (n - 1) @@ fun i ->
    [(i + 1, i + 2, 0); (i + 1, i + 2, 1 lsl i)] @
    if l land (1 lsl i) = 0 then []
    else [i + 1, n, l lxor (l land ((1 lsl (i + 1)) - 1))] in
  Printf.printf "%d %d\n" n (List.length es);
  List.iter (fun (u, v, w) -> Printf.printf "%d %d %d\n" u v w) es



Measured memory_bytes: 384
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        char[] tanto = sc.next().toCharArray();

        int mod = 10007;
        int[][] dp = new int[n][1<<3];

        for(int i=0; i<n; i++){
            int idx = 0;
            if(tanto[i]=='O') idx = 1;
            else if(tanto[i]=='I') idx = 2;
            for(int bit=0; bit<(1<<3); bit++){
                if(i==0 && (bit&(1<<0))==0) continue;
                if((bit&(1<<idx))==0) continue;
                if(i==0){
                    dp[i][bit] = 1;
                    continue;
                }
                for(int bit2=0; bit2<(1<<3); bit2++){
                    boolean boo = false;
                    for(int j=0; j<3; j++){
                        if((bit&(1<<j))>0 && (bit2&(1<<j))>0) boo = true;
                    }
                    if(!boo) continue;
                    dp[i][bit] += dp[i-1][bit2];
                    dp[i][bit] %= mod;
                }
            }
        }

        int sum = 0;
        for(int i=0; i<(1<<3); i++) sum = (sum + dp[n-1][i]) % mod;
        System.out.println(sum);
    }

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

Measured memory_bytes: 19536
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

string S;
int TAP=1;

int main(void) {
  cin >> S;
  
  int N=S.length();
  
  for(int i=0; i<N; i++){
    if(i%2==1){
      if(S[i]!='L' && S[i]!='U' && S[i]!='D') TAP=0;
    }
    if(i%2==0){
      if(S[i]!='R' && S[i]!='U' && S[i]!='D') TAP=0; 
    }
  }
  
  if(TAP==1) cout << "Yes" << endl;
  if(TAP==0) cout << "No" << endl;

  return 0;
}


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

int main() {
  int n,m,c,answer = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i = 0;i < m;i++){
    cin >> b.at(i);
  }
  vector<vector<int>>data(n,vector<int>(m));
  for(int i = 0;i < n; i++){
    for(int j = 0;j < m; j++){
      cin >> data.at(i).at(j);
    }
  }
  for(int i = 0;i < n;i++){
    int sum = 0;
    for(int j = 0;j < m;j++){
      sum += data.at(i).at(j)*b.at(j);
    }
    if(sum+c > 0){
      answer++;
    }
  }
  cout << answer << endl;
}

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

int	main(void)
{
	int n, m;
	cin >> n >> m;
	n -= (n % 2 == 0);
	int start = 1;
	int end = n / 2;
	int cnt = 0;
	while (1)
	{
		if (start >= end - start + 1 || cnt == m) break;
		cout << start << " " << end - start + 1 << endl;
		start++; cnt++;
	}
	start = n / 2 + 1;
	end = n;
	while (1)
	{
		if (start >= end - start + (n / 2 + 1) || cnt == m) break;
		cout << start << " " << end - start + (n / 2 + 1) << endl;
		start++; cnt++;
	}
	return (0);
}


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll n,m;
        cin>>n>>m;

        ll ar[n];
        ll total=0;

        for(ll i=0;i<m;i++)
        {
            cin>>ar[i];
            total+=ar[i];
        }

        if(n-total<0)
        cout<<-1;
        else
        {
            cout<<n-total;
        }
        

        
    }
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=300005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N, K[MAXN], L[MAXN], R[MAXN];

int compute(vector<pi> x){
	int n = sz(x);
	FOR(i,0,n-1) x[i].first = min(x[i].first, n);
	vector<vi> freq(n+1);
	FOR(i,0,n-1) freq[x[i].first].pb(x[i].second);
	int res = 0;
	priority_queue<int> pq;
	DEC(i,n,1){
		for (auto j:freq[i]) pq.push(j);
		if (sz(pq)){
			res += pq.top();
			pq.pop();
		}
	}
	return res;
}
void solve(){
	cin>>N;
	int ans = 0;
	vector<pi> l,r;
	FOR(i,1,N){
		cin>>K[i]>>L[i]>>R[i];
		ans += min(L[i], R[i]);
		if (L[i] >= R[i]){
			l.pb({K[i], L[i]-R[i]});
		}
		else{
			r.pb({N-K[i], R[i]-L[i]});
		}
	}
	cout<< ans + compute(l) + compute(r)<<"\n";
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int T; cin >> T;
	FOR(tc,1,T){
		solve();
	}
}


Measured memory_bytes: 20072
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		int result = 0;
		for (int i = a; i <= b; i++) {
			if (i % c == 0) {
				result++;
			}
		}

		System.out.println(result);

	}
}


Measured memory_bytes: 35484
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
int main(){
    string s;
    cin>>s;
    int j=s.size();
    int a=0;
    rep(i, s.size()){
        j--;
        if(s[i]!=s[j]){
            a++;
        }
    }
    cout<<(a+1)/2<<endl;
}

Measured memory_bytes: 256
import std.stdio;
void main() {
	int w, h;
	for (;;) {
		"%d %d\n".readf(&w, &h);
		if (w == 0 && h == 0) break;
		foreach (j; 0..w) {
			foreach (i; 0..h) "#".write;
			"".writeln;
		}
		"".writeln;
	}
}

Measured memory_bytes: 2428
import sys
sys.setrecursionlimit(10**6)

N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    s, t, w = map(int, input().split())
    G[s].append([t, w])
    G[t].append([s, w])


def dfs(n):
    visited = [False] * N
    stack = [[n, 0]]
    longest = [-1, -1]

    while stack:
        node, weight = stack.pop()
        if visited[node]:
            continue
        visited[node] = True
        if longest[1] < weight:
            longest = [node, weight]

        for n, w in G[node]:
            if not visited[n]:
                stack.append([n, w + weight])

    return longest


xn, xw = dfs(0)
yn, yw = dfs(xn)
print(yw)



Measured memory_bytes: 41352
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    vector<int> v(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> v[i];
    }
    int k;
    cin >> k;
    if (v[4] - v[0] <= k)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    d:isize,
    }
    println!("{}",if (a-c).abs()<=d||((a-b).abs()<=d&&(b-c).abs()<=d) {"Yes" }else{"No"})
}

Measured memory_bytes: 2100
def change(n):
    x=n[0]
    count=1
    ans=""
    for i in n[1:]:
        if i==x:count+=1
        else:
            ans+=str(count)
            ans+=x
            x=i
            count=1
    ans+=str(count)
    ans+=x
    return(ans)
while 1:
    n=int(input())
    if n==0:break
    word=input()
    for i in range(n):
        word=change(word)
    print(word)


Measured memory_bytes: 5708
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/29
// =====================================================
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<vi> vvi;

#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) { return b ? "true" : "false"; }
str ts(vector<bool> v) { str res; F0R(i,sz(v)) res += char('0'+v[i]); return res; }
template<size_t SZ> str ts(bitset<SZ> b) { str res; F0R(i,SZ) res += char('0'+b[i]); return res; }

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

const ll MOD = 1e9+7; // 998244353;
const int MX = 1e6+5;

int tree[1];

int sum(int k) {
    int a = 0;
    while (k >= 1) {
        a += tree[k];
        k -= k&-k;
    }
    return a;
}

void add(int k, int x) {
    while (k <= MX) {
        tree[k] += x;
        k += k&-k;
    }
}

void solve() {
    int n;
    cin >> n;
    vll A(n);
    F0R(i, n)
        cin >> A[i];
    ll sum = 0;
    ll ans = 0;
    F0R(i, n-1) {
        sum += A[i];
        sum %= MOD;
        ans += sum*A[i+1]%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 4776
fun main(args: Array<String>) {

    var (S) = readStrings()

    if (S[0] == 'A' && countC(S, 2 .. S.length - 2) == 1 && countNotLowerCase(S) == 0)
        println("AC")
    else
        println("WA")
}

private fun countC(str: String, range: IntRange) = str.substring(range).count { it == 'C' }

private fun countNotLowerCase(str: String) =
    str.replaceFirst('A', 'a').replaceFirst('C', 'c').count { c -> !c.isLowerCase() }

fun readInts(): List<Int> = readStrings().map { it.toInt() }
fun readStrings(): List<String> = readLine()!!.split(" ")

Measured memory_bytes: 37912
import std.stdio,std.conv,std.algorithm,std.range,std.string;void main(){((N,a)=>writeln(std.algorithm.reduce!(std.algorithm.min)(std.algorithm.map!(i=>std.algorithm.sum(std.algorithm.map!(e=>(e-i)^^2)(a)))(std.range.iota(-100, 101)))))(std.conv.to!int(std.string.chomp(std.stdio.readln)),std.conv.to!(int[])(std.range.split(std.stdio.readln)));}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int A,B,C;
   cin>>A>>B>>C;
   if( (A==B && A==5 && C==7) || (A==C && A==5 && B==7) || (C==B && C==5 && A==7) )
   {
       cout<<"YES"<<endl;
   }
   else
   {
       cout<<"NO"<<endl;
   }
}


Measured memory_bytes: 3584
class Main{
    public static void main(String[] a){
		int x,y,z;
		for(int i=1;i<=9;i++) {
			x=i;
			for(int j=1;j<=9;j++) {
				y=j;
				z=x*y;
				System.out.println(x+"x"+y+"="+z);
			}
		}
		
    }
}


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

namespace abc_055_C
{
    class Program
    {
        public static long a = 0;
        static void Main(string[] args)
        {
            long[] gf = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long s = gf[0], c = gf[1];
            if (s * 2 < c)
            {
                c -= s * 2;
                Console.WriteLine(s + c / 4);
            }
            else
            {
                Console.WriteLine(c / 2);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
int main(){
	int N;
	int sum=0;
	//Nの値を入力する
	scanf("%d",&N);
	if(1<=N&&N<=100){
		for(int i=1;i<=N;i++){
			sum=sum+i;
		}
	printf("%d",sum);
	}
	return 0;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

void solve(){
    int N;
    cin >> N;
    vector<int> h(N+1);
    rep(i,N) cin >> h[i+1];
    
    vector<int> dp(N+2, INF);
    dp[1] = 0;
    for(int i=1; i<N; i++){
        chmin(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
        chmin(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
    }
    
    cout << dp[N] << endl;
}


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


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return (is);
}

int main() {
	int N, K;
	double P[200005];

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		P[i] = (P[i] + 1) / 2.0;
	}
	double sum = 0;
	for (int i = 0; i < K; i++) sum += P[i];
	double maxv = sum;
	for (int i = K; i < N; i++) {
		sum -= P[i-K];
		sum += P[i];
		maxv = max(maxv, sum);
	}

	cout << fixed << setprecision(10) << maxv << endl;
	return (0);
}


Measured memory_bytes: 1792
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(int n, int m, vector<int>& A, vector<int>& B, vector<int>& C) {

        sort(A.begin(), A.end(), greater<int>());
        sort(B.begin(), B.end(), greater<int>());
        sort(C.begin(), C.end(), greater<int>());

        while (A.size() < n) {
            A.push_back(0);
        }
        while (A.size() > n) {
            A.pop_back();
        }
        while (B.size() < m) {
            B.push_back(0);
        }
        while (B.size() > m) {
            B.pop_back();
        }

        int N = C.size();
        for (int i = 0, j = n - 1, k = m - 1; i < N && (j >= 0 || k >= 0); ++i) {
            while (j >= 0 && A[j] >= C[i]) {
                --j;
            }
            while (k >= 0 && B[k] >= C[i]) {
                --k;
            }

            if (j >= 0 && (k < 0 || A[j] <= B[k])) {
                A[j--] = C[i];
            } else if (k >= 0) {
                B[k--] = C[i];
            }
        }

        long long res = 0;
        for (auto x : A) {
            res += x;
        }
        for (auto x : B) {
            res += x;
        }
        return res;
    } 
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    vector<int> A(a);
    vector<int> B(b);
    vector<int> C(c);

    for (int i = 0; i < a; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> B[i];
    }
    for (int i = 0; i < c; ++i) {
        cin >> C[i];
    }

    Solution sol;
    cout << sol.solve(n, m, A, B, C) << "\n";
    return 0;
}

Measured memory_bytes: 1408
//
//  main.cpp
//  E
//
//  Created by 曾憲揚 on 2020/8/21.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
const int MOD = 1e9+7;
int Gcd[maxn];

int mul(int a, int b){
    return (1LL*a*b)%MOD;
}
int quickpow(int a, int pow){
    int ans = 1;
    while(pow>0){
        if(pow&1) ans = mul(ans, a);
        a = mul(a, a);
        pow>>=1;
    }
    return ans;
}

int main(int argc, const char * argv[]) {
    int n, k; cin>>n>>k;
    for(int i=k; i>0; i--){
        Gcd[i] = quickpow(k/i, n);
        for(int j=i+i; j<=k; j+=i){
            Gcd[i] -= Gcd[j];
            if(Gcd[i]<0) Gcd[i] += MOD;
        }
    }
    int ans=0;
    for(int i=1; i<=k; i++){
        ans = (ans + mul(Gcd[i], i))%MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

int a,b;

int main() {
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout);
	scanf("%d%d",&a,&b);
	int k=1;
	while (k<=b) k*=10;
	int c=k*a+b;
	bool f=false;
	int i=1;
	while (i*i<=c) {
		if (i*i==c) f=true;
		i++;
	}
	if (f) printf("Yes\n"); else printf("No\n");
	fclose(stdin);
	fclose(stdout);
	return 0;
}


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

#print(b)
ans=[]
for i in range(N):
    for j in range(len(b)):
        if b[len(b)-1-j]==len(b)-j:
            ans.append(len(b)-j)
            del b[len(b)-1-j]
            #print(b)
            break
if b!=[]:
    print(-1)
else:
    ans=ans[::-1]
    for i in range(N):
        print(ans[i])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println( solve(s) );
    }

    private static String solve(String s) {
        char first = s.charAt(0);
        char last = s.charAt(s.length()-1);

        if( first == last ) {
            // aba
            if( s.length() % 2 == 0 ) {
                return "First";
            } else {
                return "Second";
            }
        } else {
            // abab
            if( s.length() % 2 == 1 ) {
                return "First";
            } else {
                return "Second";
            }
        }
    }
}

Measured memory_bytes: 25488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)
#define co(n) cout << fixed << setprecision(n)

int main() {
  int N;
  cin >> N;
  cout << N * N * N << endl;
}  

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

int main()
{
	int num;
	int c = 0;
	while (cin >> num)
	{
		c = 0;
		if (num > 36 || num < 0)
		{
			cout << 0 << endl;
			continue;
		}
		else
		{
			for (int i = 0; i <= 9; i++)
				for (int j = 0; j <= 9; j++)
					for (int k = 0; k <= 9; k++)
						for (int v = 0; v <= 9; v++)
						{
							if (i + j + k + v == num)
								c++;
						}
			cout << c << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1156
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, D1, D2;

int main() {

	cin >> N;
	int cnt = 0, ans = 0;

	rep(i, N) {
		cin >> D1 >> D2;
		if (D1 == D2) {
			cnt++;
			ans = max(ans, cnt);
		}
		else cnt = 0;
	}

	if (ans >= 3) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3636
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    if (n < (b-1)) {
        cout << ((a*n)/b) << "\n"; 
    } else {
        cout << (a*(b-1))/b << "\n";
    }
}



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

int main() {
  int a;
  cin >> a;
  vector<int> b(a);
  for (int i = 0; i < a; i++) {
    cin >> b.at(i);
  }
  bool c = true;
  int kauntoa = 0;
  int kauntob = 0;
  for (int i = 0; i < a; i++) {
    if (b.at(i) % 2 == 0) {
      kauntoa++;
    }
  }
  vector<int> d(kauntoa);
  for (int i = 0; i < a; i++) {
    if (b.at(i) % 2 == 0) {
      d.at(kauntob) = b.at(i);
      kauntob++;
    }
  }
  for (int i = 0; i < kauntoa; i++) {
    if (d.at(i) % 3 != 0 && d.at(i) % 5 != 0) {
      c = false;
      cout << "DENIED" << endl;
      break;
    }
  }
  if (c) {
    cout << "APPROVED" << endl;
  }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

	vector<pii> a;
	rep(i, 0, n){
		int t;
		cin >> t;
		a.emplace_back(t, i);
	}

	sort(all(a));

	rep(i, 0, n){
		cout << a[i].second+1 << " \n"[i==n-1];
	}

	return 0;
}


Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
int di[]={-1,0,1,0};
int dj[]={0,-1,0,1};
int INF=1e9;
int main(){
  int h,w;
  cin>>h>>w;
  int si,sj;
  cin>>si>>sj;
  int ti,tj;
  cin>>ti>>tj;
  si--;sj--;ti--;tj--;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin>>s[i];
  vector<vector<int>> dist(h,vector<int>(w,INF));
  deque<pair<int,int>> q;
  dist[si][sj]=0;
  q.emplace_back(si,sj);
  while(!q.empty()){
    int i=q.front().first;
    int j=q.front().second;
    int d=dist[i][j];
    q.pop_front();
    if(dist[i][j]!=d) continue;
    for(int v=0;v<4;v++){
       int ni=i+di[v],nj=j+dj[v];
      if(ni<0||ni>=h||nj<0||nj>=w) continue;
      if(s[ni][nj]=='#') continue;
      if(dist[ni][nj]<=d) continue;
      dist[ni][nj]=d;
      q.emplace_front(ni,nj);
    }
    for(int ei=-2;ei<=2;ei++){
      for(int ej=-2;ej<=2;ej++){
        int ni=i+ei,nj=j+ej;
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(s[ni][nj]=='#') continue;
        if(dist[ni][nj]<=d+1) continue;
        dist[ni][nj]=d+1;
        q.emplace_back(ni,nj);
      }
    }
  }
  int ans=dist[ti][tj];
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
  return 0;
}

  


Measured memory_bytes: 9436
import math
A, B, H, M = list(map(int,input("").split(" ")))

hun = H*60+M

angleB = 360*(hun%60) / 60
angleA = 360*(hun/720)

if( angleB > angleA ):
    diff = angleB - angleA
else:
    diff = angleA - angleB

if( diff >= 180):
    diff = 360 - diff


c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.pi*diff/180))

print(c)

Measured memory_bytes: 9452
#include <iostream>
#include<stdio.h>
#include <string>
#include <cstring>
#include<vector>
#include<algorithm>
using namespace std;
struct node
{
    int p;
    long long y;
    int num;
    int order;
} s;
bool operator<(const node &a,const node &b)
{
    if(a.p==b.p)
        return a.y<b.y;
    return a.p<b.p;
}
bool cmp(const node &a,const node &b)
{
    return a.order<b.order;
}
vector<node>q;
int main()
{
    int n,m;
    cin>>n>>m;
    int y,p;
    for(int i=0; i<m; i++)
    {
        cin>>p>>y;
        s.p=p;
        s.y=y;
        s.order=i+1;
        q.push_back(s);
    }
    sort(q.begin(),q.end());
    //for(int i=0;i<m;i++)
        //cout<<q[i].order<<" "<<q[i].p<<" "<<q[i].y<<endl<<endl;
    q[0].num=1;
    int num=1;
    for(int i=1; i<m; i++)
    {
        if(q[i].p==q[i-1].p)
        {
            num++;
        }
        else if(q[i].p!=q[i-1].p)
        {
            num=1;
        }
        q[i].num=num;

    }
    //for(int i=0;i<m;i++)
        //cout<<q[i].order<<" "<<q[i].p<<" "<<q[i].y<<" "<<q[i].num<<endl;
    sort(q.begin(),q.end(),cmp);
    for(int i=0; i<m; i++)
        printf("%06d%06d\n",q[i].p,q[i].num);
    return 0;
}


Measured memory_bytes: 4724
#include<stdio.h>
int MAX[500001];
int maxheapify(int);
int i,x,H,r,l,n=0;
int main(void){
  scanf("%d",&x);
  for(i=1;i<=x;i++){
    scanf("%d",&MAX[i]);
  }
  for(i=x/2;i>0;i--){
    maxheapify(i);
  }
  for(i=1;i<=x;i++){
    printf(" %d",MAX[i]);
  }
  printf("\n");
  return 0;
}
int maxheapify(i){
  l=2*i;
  r=2*i+1;
  if(l<=x && MAX[l]>MAX[i])H=l;
  else H=i;
  if(r<=x && MAX[r]>MAX[H])H=r;
  if(H!=i){
    n=MAX[i];
    MAX[i]=MAX[H];
    MAX[H]=n;
    return maxheapify(H);
  }
  return 0;
}



Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int n;

cin >> n;

ll d[100010];
ll s[100010];
d[0] = 0;
d[n+1] = 0;
s[0] = 0;
for(int i = 1; i <= n+1; i++){
cin >> d[i];
s[i] = s[i-1] + abs(d[i] - d[i-1]);
}


for(int i = 1; i <= n; i++){
cout << s[i-1] + (s[n+1] - s[i+1]) + abs(d[i+1] - d[i-1]) << endl;
}
return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        long x = (new Scanner(System.in)).nextLong();
        long ans = x / 11 * 2;
        x %= 11;
        System.out.println(ans + (x == 0 ? 0 : x > 6 ? 2 : 1));
    }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n, m;
  cin >> n >> m;

  vi a(m), b(m);
  vvi c(m);
  rep(i, 0, m){
    cin >> a[i] >> b[i];
    rep(j, 0, b[i]){
      int C;
      cin >> C;
      c[i].emplace_back(C-1);
    }
  }

  vvi dp(m+1, vi(1<<n, inf));
  dp[0][0] = 0;
  rep(i, 0, m) rep(j, 0, 1<<n){
    chmin(dp[i+1][j], dp[i][j]);

    int mask = j;
    rep(k, 0, b[i]) mask |= (1<<c[i][k]);
    chmin(dp[i+1][mask], dp[i][j]+a[i]);
  }

  int ans = dp[m][(1<<n)-1];
  if(ans == inf) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 32512
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int Max=100005;

int main()
{
	int n;
	scanf("%d",&n);
	int a[Max],b[Max],c[Max];
	long long ans=0;
	for(int i=1;i<=n;i++)  scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)  scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)  scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	int i=0,j=1,k=0;
	while(j<=n)
	{
		while(a[i+1]<b[j] && i+1<=n) i++;
		while(k+1<=n && b[j]>=c[k+1]) k++;
		if (b[j]>c[n]) break;
    	ans+=(long long)i*(n-k);
		j++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define MAX 500000
using namespace std;

int H, A[MAX + 1];

inline int parent(int i) { return i / 2; }
inline int right(int i) { return 2 * i + 1; }
inline int left(int i) { return 2 * i; }

void maxHeapify(int i) {
	int l = left(i);
	int r = right(i);
	int largest;
	if (l <= H && A[l] > A[i])  largest = l;
	else  largest = i;
	if (r <= H && A[r] > A[largest])  largest = r;

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int main() {
	cin >> H;
	for (int i = 1; i <= H; i++) cin >> A[i];
	for (int i = H / 2; i >= 1; i--) maxHeapify(i);
	for (int i = 1; i <= H; i++) cout << " " << A[i];
	cout << endl;
}

Measured memory_bytes: 4944
/*
 * 
 * Author : yash1402_
 * 
*/

#include <bits/stdc++.h>
 
using namespace std;

typedef long long int lli;
typedef vector<lli> vlli;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<lli,lli>> vplli;
typedef pair<lli,lli> plli;

#define rep(_I,_A,_B) for(lli _I=_A;_I<_B;_I++)

#define opv(_VAR) cout << #_VAR << ":" << _VAR << "\n";
#define opvec(_VEC) cout << #_VEC << ":"; for(auto _ELE:_VEC) cout << _ELE << " "; cout<<"\n";
 
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define B begin()
#define E end()
#define A assign
#define S size()

#define ipa(_VEC) for(auto &_ITER:_VEC) cin>>_ITER;
#define all(_VEC) _VEC.B,_VEC.E

void solve(){
	lli n,d,c=0,x,y;
	cin >> n >> d;
	
	for(lli i=0;i<n;i++) {
		cin >> x >> y;
		if(sqrt(x*x+y*y) <= d) {
			c++;
		}
	}
	
	cout << c << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	lli t=1;
	//cin>>t;
	rep(tt,1,t+1){
		solve();
	}
}



Measured memory_bytes: 3640
import java.util.Collections
import java.math.*

fun main(args: Array<String>) {
    val minusInf = -1000000000000000L
    val plusInf = 1000000000000000L

    val (a, b, q) = readInputLine().split(" ").map{it.toInt()}
    
    val shrines = mutableListOf<Long>()
    for (i in 1..a) {
        shrines.add(readInputLine().toLong())
    }
    
    val temples = mutableListOf<Long>()
    for (i in 1..b) {
        temples.add(readInputLine().toLong())
    }

    for (i in 1..q) {
        val x = readInputLine().toLong()
        
        val rightShrineIndex = lowerBound(shrines, x)
        val rightShrine = if (rightShrineIndex == a) plusInf else shrines[rightShrineIndex]
        val leftShrine = if (rightShrineIndex == 0) minusInf else shrines[rightShrineIndex - 1]
        val rightTempleIndex = lowerBound(temples, x)
        val rightTemple = if (rightTempleIndex == b) plusInf else temples[rightTempleIndex]
        val leftTemple = if (rightTempleIndex == 0) minusInf else temples[rightTempleIndex - 1]

        var distance = Long.MAX_VALUE

        distance = Math.min(distance, Math.abs(x - rightShrine) + Math.abs(rightShrine - rightTemple))
        distance = Math.min(distance, Math.abs(x - rightShrine) + Math.abs(rightShrine - leftTemple))
        distance = Math.min(distance, Math.abs(x - leftShrine) + Math.abs(leftShrine - rightTemple))
        distance = Math.min(distance, Math.abs(x - rightTemple) + Math.abs(rightTemple - rightShrine))
        distance = Math.min(distance, Math.abs(x - leftTemple) + Math.abs(leftTemple - rightShrine))
        distance = Math.min(distance, Math.abs(x - leftShrine) + Math.abs(leftShrine - leftTemple))
        distance = Math.min(distance, Math.abs(x - rightTemple) + Math.abs(rightTemple - leftShrine))
        distance = Math.min(distance, Math.abs(x - leftTemple) + Math.abs(leftTemple - leftShrine))
        
        println(distance)
    }
}

fun readInputLine(): String {
    return readLine()!!
}

fun <T: Comparable<T>> lowerBound(list: List<T>, value: T): Int {
    return Collections.binarySearch(list, value, {x, y -> if (x >= y) 1 else -1}).inv()
}


Measured memory_bytes: 58596
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var points = new List<int>();
        for (int i = 0; i < 5; i++)
        {
            var temp = int.Parse(Console.ReadLine().Trim());
            if (temp < 40) points.Add(40);
            else points.Add(temp);
        }
        Console.WriteLine(points.Average());
    }
}

Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in3(a, b, c);
  if(a + b < c)
    out("No");
  else
    out("Yes");
  memi;
}

Measured memory_bytes: 256