akhauriyash/Code-Regression huggingface dataset:
/* 
   AOJ 1148
   Analyzing Login/Logout Records
   2015/9/7
*/

#include<stdio.h>
#define REC_MAX 1000

struct record
{
  int time, pc_id, stu_id, log_flg;
};

struct record records[REC_MAX];

int ans_f(int start_t, int end_t, int questioned_stu_id, int records_n)
{
  int i, login_pc_count = 0, start = 0, timer = 0;

  for(i = 0; i < records_n; i++)
    {
      if(records[i].stu_id == questioned_stu_id)
	{
	  if(records[i].log_flg)
	    {
	      /* login */
	      login_pc_count++;
	      if(login_pc_count == 1)
		{
		  /* first login */
		  if(records[i].time < start_t)
		    {
		      /* login before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* login after start_t && before end_t*/
		      start = records[i].time;
		    }
		  else
		    {
		      /* login after end_t */
		      return timer;
		    }
		}
	    }
	  else
	    {
	      /* logout */
	      login_pc_count--;
	      if(login_pc_count == 0)
		{
		  /* last logout */
		  if(records[i].time < start_t)
		    {
		      /* logout before start_t */
		    }
		  else if(records[i].time >= start_t && records[i].time <= end_t)
		    {
		      /* logout after start_t && before end_t */
		      if(start == 0)
			{
			  /* first login before start_t*/
			  timer += records[i].time - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += records[i].time - start;
			}
		    }
		  else
		    {
		      /* logout after end_t */
		      if(start == 0)
			{
			  /* first login before start_t */
			  timer += end_t - start_t;
			}
		      else
			{
			  /* first login after start_t */
			  timer += end_t - start;
			}
		      return timer;
		    }
		}
	    }
	}
    }
  return timer;
}

int main(void)
{
  int i, pcs_n, stus_n, records_n, questions_n, start_t, end_t, questioned_stu_id, ans = 0;

  while(1)
    {
      scanf("%d %d", &pcs_n, &stus_n);

      if(pcs_n == 0 && stus_n == 0)
	{
	  break;
	}

      scanf("%d", &records_n);
      for(i = 0; i < records_n; i++)
	{
	  scanf("%d %d %d %d", &records[i].time, &records[i].pc_id, &records[i].stu_id, &records[i].log_flg);
	}
      scanf("%d", &questions_n);
      for(i = 0; i < questions_n; i++)
	{
	  scanf("%d %d %d", &start_t, &end_t, &questioned_stu_id);
	  ans = ans_f(start_t, end_t, questioned_stu_id, records_n);
	  printf("%d\n", ans);
	}
    }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <sstream>
using namespace std;

#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C 9/++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()
 
//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)

//#define for(int i=1; i<=n ; i++) for(int i=0; i<n; i++)
#define forl(i,n) for(ll i=0; i<n; i++)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
const  llu int_max = pow(2,32) - 1 ;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.ff < j.ff;
}

int main(){

	fastio
	//total - a[i] % 2 == 0
	int n;
	cin>>n;
	bool a[n+1], val[n+1] = {0};
	//int total[n] = {0} ;
	for(int i=1; i<=n; i++){
		cin>>a[i];
		if(a[i] == 1)
			val[i] = 1;

	}
	for(int i = n/2; i>=1 ; i--){
		int total = 0, ax = i;
		for(int j=i ; j<=n; j+=i){
			if(val[j])
				total++;
		}
		if((total-a[i]) % 2 == 0)
			continue;
		else{
			if(val[i] == 0){
				val[i] = 1;
			}
			else{
				val[i] = 0;
			}
		}
	}
	int m=0;
	for(int i=1; i<=n ; i++){
		if(val[i])
			m++;
	}
	cout<<m<<endl;
	for(int i=1; i<=n ; i++)
		if(val[i])
			cout<<i<<" ";

	return 0 ;
	
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define watch(x) cout << (#x) << " is: " << (x) << endl
#define vw(v)                        \
    cout << endl << endl << (#v) << " is: " << endl; \
    for (int B : (v))                \
    {                                \
        cout << B << " ";            \
    }                                \
    cout << endl
#define check(x) cout << "here " << (x) << "?" << endl
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a) for (long long i = (a - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rv(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
ll const MAX = 2147483647, REALMAX = 9223372036854775806;
//const int N =
int main()
{
    FAST_IO
    int n , m , x;
    cin>>n>>m>>x;
    if(n + m + x >= 22) cout<<"bust";
    else cout<<"win";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>
#include<list>
#include<queue>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int n, m;
priority_queue<ll> a;

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		ll ai;
		cin >> ai;
		a.push(ai);
	}
	
	for (int i = 0; i < m; i++) {
		ll tmp = a.top()/2;
		a.pop();
		a.push(tmp);
	}
	ll ret = 0;
	for (int i = 0; i < n; i++) {
		ret += a.top();
		a.pop();
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1400
n = gets.to_i
ss = {}

n.times{
	s = gets.chomp
	if ss[s] == nil then
		ss[s] = 1
	else
		ss[s] += 1
	end
}

sss = ss.to_a.sort{ |a,b| b[1] <=> a[1] }

count = sss[0][1]

result = []

sss.each{ |s|
	if s[1] == count then
		result << s[0]
	end
}

puts result.sort.join("\n")


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

int main() {

  int K, N;
  cin >> K >> N;
  
  int max = 0;
  int first = 0;
  int prev = 0;
  for(int i = 0; i < N; ++i) {
    int crnt;
    cin >> crnt;
    
    if(i==0) {
      first = prev = crnt;
      continue;
    }
    
    int delta = crnt - prev;
    max = delta < max ? max : delta;
    prev = crnt;
    
    if(i==(N-1)) {
      int delta = K - crnt + first;
      max = delta < max ? max : delta;
    }
  }
  
  cout << (K - max) << endl;

  return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

struct warshall_floyd {
	static void solve(vector<vector<ll>>& d) {
		int n = d.size();
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
};

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

int main() {
	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> graph(n, vector<ll>(n, INF));
	vector<edge> es;
	rep(i, m) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
		es.push_back({ a, b, c });
		graph[a][b] = c;
		graph[b][a] = c;
	}
	warshall_floyd::solve(graph);
	ll sum = 0;
	rep(i, m) {
		auto e = es[i];
		if (graph[e.from][e.to] < e.cost) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3688
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {

	int a,b,c;
	int w,x,y;
	cin>>a>>b>>c;

	w=a+b;
	x=a+c;
	y=b+c;

	if(w<x&&w<y){
		cout<<w<<endl;
	}
	if(x<w&&x<y){
		cout<<x<<endl;
	}
	if(y<w&&y<x){
		cout<<y<<endl;
	}
	if(w==x&&x==y){
		cout<<w<<endl;
	}




	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll Powb(ll b,ll n,ll m);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l=0,r=0,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n;
    map<ll,ll> M;
    for(i=0;i<n;i++)
    {
        cin >> u;
        M[u]++;
        M[u+1]++;
        M[u-1]++;
    }
    for(auto it:M)
        a = max(a,it.S);
    cout << a;
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 9420
import java.util.Scanner;

class Main{
    static boolean hikaku(int a,int b){
	if(a < b)
	    return (true);
	else
	    return(false);
    }

    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int x = stdIn.nextInt();
	int y = stdIn.nextInt();
	int z = stdIn.nextInt();
	if(hikaku(x,y) && hikaku(y,z))
	    System.out.println("Yes");
	else
	    System.out.println("No");
    }
}

Measured memory_bytes: 17160
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

	vector<int> C;
	for (int i = 0; i < N; i++) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			C.push_back(c);
		}
	}

	if (C.size() == 0) {
		cout << "TLE" << endl;
		return 0;
	}

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

	cout << C[0] << endl;
	
		
	
}




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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

using namespace std;
typedef long long ll;

int main(){
	int N,M;
	cin >>N >> M;
	int hidari = -1;
    int migi = 50000000;
	REP(i,M){
		int H,MM;
		cin >> H >> MM;
        hidari = max(hidari,H);
		migi = min(migi,MM);
	}
	cout << max(0,migi-hidari+1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    if(N%2==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    N=N/2;
    while(N!=0){
        N=N/5;
        ans+=N;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	int ma=-inf,mi=inf;
	int at,ai;
	rep(i,n){
		if(ma<in[i]){
			ma=in[i];
			at=i+1;
		}
		if(in[i]<mi){
			mi=in[i];
			ai=i+1;
		}
	}
	cout<<2*n-1<<endl;
	if(-mi<ma){
		rep(i,n)cout<<at<<" "<<i+1<<endl;
		rep(i,n-1)cout<<i+1<<" "<<i+2<<endl;
	}else{
		rep(i,n)cout<<ai<<" "<<i+1<<endl;
		rep(i,n-1)cout<<n-i<<" "<<n-i-1<<endl;
	}
}





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

int n;
vector<pair<int, int>> tasks;

int main(){
    int i=0;
cin >> n;

while(i<n){
    int a,b;
    cin >> a >> b;
    tasks.emplace_back(b,a);
    i++;
}

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

int aa=0; int bb=0; int yy=0;

for(auto v: tasks){
    aa += v.second;
    if(aa > v.first){
        yy++;
        break;
    }
}

if(yy != 0) cout << "No" << endl;
else cout << "Yes" << endl;

return 0;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    set<int> r, g, b;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r.insert(i);
        } else if (s[i] == 'G') {
            g.insert(i);
        } else {
            b.insert(i);
        }
    }

    long long ans = r.size() * g.size() * b.size();
    for (auto& x : r) {
        for (auto& y : g) {
            if (b.end() != b.find(2 * y - x)) ans--;
            if (b.end() != b.find(2 * x - y)) ans--;
            if ((x + y) % 2 == 0 && b.end() != b.find((x + y) / 2)) ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3412
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	int num=a+b;
	num=max(num,a-b);
	num=max(num,a*b);
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;

int main(){
	int i,N;
	float x,SUM;
	string u;

	int Ans;

	cin>>N;
	for(i=0;i<N;i++){
		cin>>x>>u;
		
		if(u == "JPY"){
			SUM += x;
		}
		else if(u == "BTC"){
			SUM += x*380000;
		}
	}

	

	cout<<SUM<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#define INF 10009310
using namespace std;
int t,n,a,b,c,q;
long long sum=0;
map <int,int> tim;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a);
        ++tim[a];
        sum+=a;
    }
    scanf("%d",&q);
    for(int i=1;i<=q;i++){
        scanf("%d%d",&b,&c);
        sum=sum+(long long)(-tim[b]*b+tim[b]*c);
        tim[c]+=tim[b];
        tim[b]=0;
        printf("%lld\n",sum);
    }
}

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

/// Defining variable types.
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

/// Defining usable key words
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

/// Defining constant variables.
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

/// Defining some useful lines.
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);


/// Code of debugger.
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


int main()
{
    optimize();

    int a,b;
    cin>>a>>b;

    if(a==1 && b==2 || a==2 && b==1)
        cout<<3;

    else if(a==3 && b==2 || a==2 && b==3)
        cout<<1;
    else
        cout<<2;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]
s.sort()
ans = 0
if sum(s) % 10 != 0:
  ans = sum(s)
else:
  for S in s:
    if S % 10 != 0:
      ans = sum(s) - S
      break
print(ans)

Measured memory_bytes: 3060
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

type py struct {
	p    int
	y    int
	rank int
}

func (p py) String() string {
	return fmt.Sprintf("p(%d %d %d)", p.p, p.y, p.rank)
}

type pyList [](*py)

func (p pyList) Len() int {
	return len(p)
}

func (p pyList) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pyList) Less(i, j int) bool {
	return p[i].y < p[j].y
}

func main() {
	loadint()
	m := loadint()
	pys := make([]py, m)
	ps := make(map[int]pyList)
	for i := 0; i < m; i++ {
		p := loadint()
		pys[i].p = p
		pys[i].y = loadint()
		ps[p] = append(ps[p], &pys[i])
	}
	for _, vs := range ps {
		sort.Sort(vs)
		for i, v := range vs {
			v.rank = i + 1
		}
	}
	for _, py := range pys {
		fmt.Printf("%06d%06d\n", py.p, py.rank)
	}
}


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

bool binary_search(int S[], int begin, int end, int key) {
  if (end <= begin) {
    return false;
  }

  int middle = (begin + end) / 2;
  if (key == S[middle]) {
    return true;
  } else if (key < S[middle]) {
    return binary_search(S, begin, middle, key);
  } else {
    return binary_search(S, middle + 1, end, key);
  }
}

int main() {
  int n, q, S[100000], t, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (binary_search(S, 0, n, t)) {
      sum++;
    }
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3468
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

int digit_sum(int n){int sum=0 , tmp=n; while(tmp>0){sum+=tmp%10; tmp/=10;} return sum;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    Yn(n%digit_sum(n)==0);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main() {
    long long n;
    cin>>n;
    long long result,mid,result1 = 0;
    for(int i =1;i<=n;++i) {
        for(int j = 1;j<=n;++j) {
            for(int k =1;k<=n;++k) {
                mid = gcd(i,j);
                result = gcd(mid,k);
                result1 += result;
            }
        }
    }
    cout<<result1;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>

using namespace std;


int main() {
	int N, M;
	int *x;
	bool *f;
	cin >> N >> M;

	x = new int[N];//個数
	f = new bool[N];//赤があるかどうか
	int n = 1;//可能性がある箱の個数

	for (int i = 0; i < N; i++) {
		x[i] = 1;
		f[i] = false; 
		if (i == 0) { f[i] = true; }
	}
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		x[a]--; x[b]++;
		if (f[a] == true && f[b]==false) {
			f[b] = true;
			n++;
		}
		if (x[a] == 0 && f[a]==true) {
			f[a] = false;
			n--;
		}
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 768
v = 0
i = 0
b = []
while v == 0:
    a = input().split()
    if a[1] == '+':
        b.append(int(a[0])+int(a[2]))
        i = int(i) + 1
    elif a[1] == '-':
        b.append(int(a[0])-int(a[2]))
        i = int(i) + 1
    elif a[1] == '*':
        b.append(int(a[0])*int(a[2]))
        i = int(i) + 1
    elif a[1] == '/':
        b.append(int(a[0])//int(a[2]))
        i = int(i) + 1
    else:
        v = 1

for j in range(int(i)):
    print(b[j])


Measured memory_bytes: 5600
#include <stdio.h>

int main(void) {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a > 0) {
        printf("Positive\n");
    } else if (b >= 0) {
        printf("Zero\n");
    } else if((a - b) % 2 == 0) {
        printf("Negative\n");
    } else {
        printf("Positive\n");
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = 26;
    int D = scanner.nextInt();
    int[] c = new int[N];
    int[][] s = new int[D][N];
    for (int i = 0; i < N; i++) c[i] = scanner.nextInt();
    for (int i = 0; i < D; i++) for (int j = 0; j < N; j++) s[i][j] = scanner.nextInt();

    int[] t = new int[D];
    for (int i = 0; i < D; i++) t[i] = scanner.nextInt() - 1;

    int score = 0;
    List<Integer>[] last = new List[N];
    for (int i = 0; i < N; i++) {
      last[i] = new ArrayList<>();
      last[i].add(0);
    }
    for (int i = 0; i < D; i++) {
      int type = t[i];
      score += s[i][type];
      last[type].add(i + 1);
      for (int j = 0; j < N; j++) score -= c[j] * (i + 1 - last[j].get(last[j].size() - 1));
    }
    for (int i = 0; i < N; i++) last[i].add(D + 1);

    int M = scanner.nextInt();
    int[] newd = new int[M];
    int[] newt = new int[M];
    for (int i = 0; i < M; i++) {
      newd[i] = scanner.nextInt();
      newt[i] = scanner.nextInt() - 1;
    }
    for (int i = 0; i < M; i++) {
      int d = newd[i];
      int oldType = t[d - 1];
      int newType = newt[i];
      int p1 = upperBound(last[newType], d);
      int p2 = upperBound(last[oldType], d);
      score += s[d - 1][newType] - s[d - 1][oldType];
      score += c[newType] * (d - last[newType].get(p1)) * (last[newType].get(p1 + 1) - d) - c[oldType] * (d - last[oldType].get(p2)) * (last[oldType].get(p2 + 2) - d);
      System.out.println(score);
      t[d - 1] = newType;
      last[oldType].remove(p2 + 1);
      last[newType].add(p1 + 1, d);
    }
  }

  // Returns the largest index of the array where a_i < k.
  // If no element is smaller than or equal to k, returns -1.
  public static int upperBound(List<Integer> a, int k) {
    int left = -1;
    int right = a.size();
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a.get(mid) < k) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }
}


Measured memory_bytes: 71300
<?php
    fscanf(STDIN, "%d", $total);
    $input = trim(fgets(STDIN));
    $sticks = explode(" ", $input);
    $sizes = array_count_values($sticks);
    $pair = array();
    foreach ($sizes as $key => $value) {
    	if ($value >= 4) {
    		array_push($pair, $key);
    	}
    	if ($value >= 2) {
    		array_push($pair, $key);
    	}
    }
    rsort($pair);
    if (isset($pair[1])) { $area = $pair[0] * $pair[1]; }
    else { $area = 0; }
    echo $area . "\n";
?>


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

int main(){
  int i,X,N,M,A,cost0=0,costN=0;
  cin >> N >> M >> X;
  for(i=0;i<M;i++){
    cin >> A;
    if(A<X) cost0++;
    else costN++;
  }
  cout << min(cost0,costN) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    int ans = 0;
    repr(i, 1, N+1) {
        if (i % 2 == 0) {
            continue;
        }
        int di = 0;
        repr(j, 1, i+1) {
            if (i % j == 0) {
                di += 1;
            }
        }
        if (di == 8) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int ar[4],ans;
int main()
{
    for (int i=0;i<3;i++){
        cin>>ar[i];
    }
    sort(ar,ar+4,greater<int>());
    ans+=ar[0]-ar[1];
    ans+=ar[1]-ar[2];
    cout<<ans;
}


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

using namespace std;

static void inputArray(int A[], int num) {
  for (int i = 0; i < num; i++) {
    cin >> A[i];
  }
}

static inline bool solve(int A[], int i, int n, int m) {
  if (m == 0) {
    return true;
  }
  
  if (i < n) {
    return solve(A, i + 1, n, m) || solve(A, i + 1, n, m - A[i]);
  } else {
    return false;
  }
}

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

  vector<int> A(n);
  inputArray(&A[0], n);

  int q;
  cin >> q;

  int m;
  bool ans;
  for (int i = 0; i < q; i++) {
    cin >> m;
    ans = solve(&A[0], 0, n, m);
    cout << (ans ? "yes" : "no") << endl;
  }
  
  return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  string s, t;
  cin >> s >> t;
  ll a, b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (s == u) {
    a--;
  } else if (t == u) {
    b--;
  }

  cout << a << " " << b << endl;

  return 0;
}


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

using namespace std;
int main(void){
    string S,T;
    cin >> S >> T;
    int sum = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == T.at(i))
        sum++;
    }
    if(sum == S.size() && S.size()+1 == T.size()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
}


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

int main() {
  int N;
  cin >> N;
  double T, A;
  cin >> T >> A;
  double mi = 100000000, pmi = -1;
  for (int i = 0; i < N; ++i) {
    double h;
    cin >> h;
    double t = T - h * 0.006;
    if (mi > abs(t - A)) mi = abs(t - A), pmi = i+1;
  }
  cout << pmi << endl;
}

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

int main(){
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}

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

using namespace std;
int main() {
	double n, m, d;
	cin >> n >> m >> d;
	double ans = (m - 1.0)*(n - d);
	if (d != 0) {
		ans *= 2.0;
	}
	ans /= n;
	ans /= n;
	printf("%.10f\n", ans);
}


Measured memory_bytes: 3788
n,g[21][21],i;m,x,X,y,Y;D(S,G){int c[21],f[21]={0},d,t;memset(c,1,84);for(c[S]=0;;){for(d=i=0;++i<=n;)d=f[i]||d&&c[i]>=c[d]?d:i;if(!d)return c[G];f[d]=1;for(i=n+1;--i;c[i]=t<c[i]?t:c[i])t=c[d]+g[d][i];}}main(){memset(g,1,1764);scanf("%d%d",&n,&i);for(i++;i--;i&&(g[x][X]=y,g[X][x]=Y))scanf("%d,%d,%d,%d",&x,&X,&y,&Y);exit(!printf("%d\n",y-Y-D(x,X)-D(X,x)));}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef bitset<61> Bitset;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = INT_MAX;
const int MAX = 300000;
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); }
//------------------------------------------------------------------------------------------------------------------------------
const ll M = 26;
int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char s[M] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'
            ,'q','r','s','t','u','v','w','x','y','z'};
    ll n;cin>>n; 
    string ans = "";
    while(n){
        n--;
        ans += s[n%M];
        n /= M;

    }
    for(int i = 0; i < ans.size()/2; i++) {
        swap(ans[i],ans[ans.size()-i-1]);
    }
    cout << ans << endl;


}


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

using lint = long long;

struct lca_t {
    int logn{0}, preorderpos{0};
    vector<int> invpreorder, height;
    vector<vector<int>> jump_binary, edges;
    lca_t(int n, vector<vector<int>>& adj) : 
    edges(adj), height(n), invpreorder(n) { 
        while((1<<(logn+1)) <= n) ++logn;
        jump_binary.assign(n+1, vector<int>(logn+1, 0));
        dfs(0, -1, 0);
    } 
    void dfs(int v, int p, int h) { 
        invpreorder[v] = preorderpos++;
        height[v] = h;
        jump_binary[v][0] = p < 0 ? v : p;
        for (int l = 1; l <= logn; ++l)
            jump_binary[v][l] = jump_binary[jump_binary[v][l-1]][l-1];
        for (int u : edges[v]) {
            if (u == p) continue; 
            dfs(u, v, h + 1);
        }
    }
    int climb(int v, int dist) { 
        for (int l = 0; l <= logn; ++l)
            if (dist & (1 << l)) v = jump_binary[v][l];
        return v;
    }
    int query(int a, int b) { 
        if (height[a] < height[b]) swap(a, b);
        a = climb(a, height[a] - height[b]);
        if (a == b) return a;
        for (int l = logn; l >= 0; --l) 
            if (jump_binary[a][l] != jump_binary[b][l]) 
                a = jump_binary[a][l], b = jump_binary[b][l];
        return jump_binary[a][0];
    } 
    int dist(int a, int b) {
        return height[a] + height[b] - 2 * height[query(a,b)];
    }
    bool is_parent(int p, int v) { 
        if (height[p] > height[v]) return false;
        return p == climb(v, height[v] - height[p]);
    }
    bool on_path(int x, int a, int b) {
        int v = query(a, b);
        return is_parent(v, x) && (is_parent(x, a) || is_parent(x, b));
    }
    int get_kth_on_path(int a, int b, int k) {
        int v = query(a, b);
        int x = height[a] - height[v], y = height[b] - height[v];
        if (k < x) return climb(a, k);
        else return climb(b, x + y - k);
    }
};

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    for (int i = 0; i < n; ++i) {
        int node;
        cin >> node;
        for (int j = 0; j < node; ++j) {
            int v;
            cin >> v;
            edges[i].push_back(v);
            edges[v].push_back(i);
        }
    }
    lca_t lca(n, edges);
    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        cout << lca.query(u, v) << '\n';
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int o = 0;
  for(int i = 0; i < s.length(); i++) { o += (s[i] != t[i]); }
  cout << o << '\n';
}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }

template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }



int main() {
	long long N,K;
  cin>>N>>K;
  long long A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<bool>ans;
  long long tmp=0;
  long long B[N];
  B[0]=A[0];
  for(int i=1;i<N;i++){
    B[i]=B[i-1]+A[i];
  }
  for(int i=K;i<N;i++){
    if(i==K){
      if(B[i]-B[i-K]>B[i-1]){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }else{
      if(B[i]-B[i-K]>B[i-1]-B[i-K-1]){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }
  }

  
}


Measured memory_bytes: 6720
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int a[5], x, y;
  for(int i=0;i<4;i++)a[i]=0;
  for(int i=0;i<3;i++){
    cin >> x >> y;
    a[x]++;
    a[y]++;
  }
  int cnt=0;
  for(int i=0;i<4;i++){
    if(a[i]==2)cnt++;
  }
  if(cnt==2)puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
s = str(input())
n = len(s)
RL = [0] * n
ans = [0] * n
for i in range(n-1):
    if s[i] == 'R' and s[i+1] == 'L':
        RL[i] = 1
        RL[i+1] = -1
for i in range(n):
    if RL[i] == 1:
        cnt = 1
        i_temp = i
        while i_temp > 0 and s[i_temp-1] == 'R':
            i_temp -= 1
            cnt += 1
        ans[i] += (cnt + 1) // 2
        ans[i+1] += cnt // 2
    if RL[i] == -1:
        cnt = 1
        i_temp = i
        while i_temp + 1 < n and s[i_temp+1] == 'L':
            i_temp += 1
            cnt += 1
        ans[i] += (cnt + 1) // 2
        ans[i-1] += cnt // 2
for i in range(n-1):
    print(ans[i], end=" ")
print(ans[n-1])

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  int n;
  cin >> n;

  vector<string> w(n);
  rep (i, 0, n)
    cin >> w[i];

  set<string> st;
  st.insert(w[0]);
  char last = w[0][w[0].size() - 1];
  rep (i, 1, n) {
    if (st.find(w[i]) != st.end()) {
      cout << "No" << endl;
      return 0;
    }

    if (last != w[i][0]) {
      cout << "No" << endl;
      return 0;
    }

    st.insert(w[i]);
    last = w[i][w[i].size() - 1];
  }

  cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
S = input().split(" ")
N = int(S[0])
K = int(S[1])
ARR = [int(s) for s in input().split(" ")]

def calculate(n, k, arr):
    dict = {}

    for ar in arr:
        if dict.get(ar) == None:
            dict.__setitem__(ar,1)
        else:
            tmp = dict.get(ar)
            tmp = tmp + 1
            dict.__setitem__(ar,tmp)

    sortedDict = sorted(dict.items(),key=lambda k:-k[1])


    sum = 0
    for i in sortedDict[k:]:
        sum = sum + i[1]


    print(sum)


calculate(N, K, ARR)


Measured memory_bytes: 39044
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <iostream>
#include <iomanip>

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

int main(){
    int K, N;
    cin >> N >> K;
    vector<LL> p(N);
    REP(i,N)cin>>p[i];

    priority_queue<double> que;
    double sum = 0;
    REP(i,K){
        sum += (p[i] + 1) * 0.5;  
    }
    que.push(sum);

    for(int j=1; j+K-1<N; j++){
        sum -= (p[j-1] + 1) * 0.5;
        sum += (p[j+K-1] + 1) * 0.5;
        que.push(sum);
    }

    double ans = que.top();

    cout << fixed << setprecision(7) << ans << endl;
    
}

Measured memory_bytes: 6832
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

typedef long long ll;

int main(){
	ll n, ans = 0;
	cin >> n;
	string s;
	map<string, ll> mp;
	for(int i = 0 ; i < n ; i++){
		cin >> s;
		sort(s.begin(), s.end());
		++mp[s];
	}
	for(auto it = mp.begin() ; it != mp.end() ; it++){
		ans += (it->second  * (it->second - 1)) >> 1;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

int s,n,t,p,m;
string w,ti;
int can[11000];
const int halfday = 720;
const int week = 10080;

int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  while(cin >> s >> n >> t >> w >> ti >> p >> m,w!="None"){
    for(int i=0;i<week;i++)can[i] = false;

    int loop = (w == "All")?7:1;
    
    if(ti == "All"){
      for(int i=0;i<loop;i++){
	for(int j=0;j<2*halfday;j++)can[i*2*halfday+j] = true;
      }
    }else if(ti == "Day"){
      for(int i=0;i<loop;i++){
	for(int j=0;j<halfday;j++){
	  can[i*2*halfday + j + halfday/2] = true;
	}
      }
    }else{
      for(int i=0;i<loop;i++){
	for(int j=0;j<halfday/2;j++){
	  can[i*2*halfday + j] = true;
	  can[i*2*halfday + j + 3*halfday/2] = true;
	}
      }
    }

    int res = 0;
    int lim = (w=="All")?2*halfday:week;
    for(int start = 0;start < lim; start++){
      int now = start;
      int cnt = 0;
      for(int i=0;i<m;i++){
	if(can[now%week] && can[(now+s)%week])cnt++;
	now += t;
      }
      res = max(res,cnt);
    }
    printf("%.10lf\n",1-pow(1-1.0/p,n*res));
  }
}

Measured memory_bytes: 1336
N = int(input())
S = input()
count = [0, 0, 0]

for s in S:
    if s == 'R': count[0] += 1
    elif s == 'G': count[1] += 1
    else: count[2] += 1

ans = count[0] * count[1] * count[2]

for j in range(N):
    for i in range(j):
        k = j + j-i
        
        if k < N:
            if S[i] == S[j]: continue
            if S[i] == S[k]: continue
            if S[k] == S[j]: continue
            ans -= 1
            
print(ans)

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

int main(){
  vector<vector <int>>b(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int k=0;k<3;k++){
      cin >>b.at(i).at(k);
    }
  }
  int n,z=0;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(a.at(i)==b.at(j).at(k))b.at(j).at(k)=0;
      }
    }
  }
  for(int i=0;i<3;i++){
    if(b[0][i]==0&&b[1][i]==0&&b[2][i]==0)z++;
    if(b[i][0]==0&&b[i][1]==0&&b[i][2]==0)z++;
  }
  if(b[0][0]==0&&b[1][1]==0&&b[2][2]==0)z++;
  if(b[2][0]==0&&b[1][1]==0&&b[0][2]==0)z++;
  if(z!=0)cout <<"Yes";
  else cout <<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(RALL(a));
    ll ans = a[0];
    int now = 1;
    int cnt = 0;
    rep(i,n-2){
        if(cnt < 2) {
            ans += a[now];
            cnt++;
        }
        else{
            cnt = 1;
            now++;
            ans += a[now];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4840
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
K, S = MAP()

ans = 0

for X in range(K+1):
	for Y in range(K+1):
		Z = S - X - Y
		if 0 <= Z <=K:
			ans += 1

print(ans)

Measured memory_bytes: 15300
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
using namespace std;
typedef long long ll;
int inf = 1000000000;
template<typename T>
T GCD(T a, T b) {
	while (max(a, b) % min(a, b)) {
		if (a > b)a = a % b;
		else b = b % a;
	}
	return min(a, b);
}
template<typename T>
T LCM(T a, T b) {
	return a / GCD(a, b)*b;
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 0; i <= 100; i++) {
		if (a % 2 || b % 2 || c % 2) {
			cout << i << endl;
			return 0;
		}
		int d, e, f;
		d = (b + c) / 2;
		e = (a + c) / 2;
		f = (a + b) / 2;
		a = d;
		b = e;
		c = f;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
As = list(map(int, input().split()))

Ws= [0 for i in range(N)]

sum_w1_wn = 0
for i in range((N-1)//2):
    sum_w1_wn += As[2*i+1]

#print('sum_v1_wn:', sum_w1_wn)

Ws[0] = sum(As) - 2*sum_w1_wn
#print('Ws[0]:', Ws[0])


print(Ws[0], end='')
for i in range(1,N):
    Ws[i] = 2*As[i-1] - Ws[i-1]
    print('', Ws[i], end='')


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

const int mod = 1e9 + 7;

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N), B(M);
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int j = 0; j < M; ++j) cin >> B[j];
  sort(A.begin(), A.end(), greater<int>());
  sort(B.begin(), B.end(), greater<int>());
  
  long long p = 1;
  for(int d = N * M, i = 0, j = 0; d; --d){
    if(i < N && j < M && A[i] == d && B[j] == d){
      ++i; ++j;
    }else if(i < N && A[i] == d){
      p *= j;
      ++i;
    }else if(j < M && B[j] == d){
      p *= i;
      ++j;
    }else{
      p *= (d - N * M + i * j);
    }
    p %= mod;
  }
  
  cout << (p + mod) % mod << endl;
  
  return 0;
}

Measured memory_bytes: 3656