akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    tot=[[] for _ in range(N+1)]
    ys=[0]*M
    for i in range(N):
        heapify(tot[i])
    for i in range(M):
        P, Y = map(int, input().split())
        heappush(tot[P],[Y,i])
        ys[i]=Y
    tset=[]
    ans=['']*M
    for i in range(N+1):
        t1=tot[i]
        if len(t1)<1:continue
        p=str(i).zfill(6)
        j=0
        while len(t1):
            t, i1=heappop(t1)
            tx=str(j+1).zfill(6)
            ans[i1]=''.join((p,tx))
            j+=1
    print('\n'.join(ans))





if __name__ == "__main__":
    main()

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

int main()
{
	long long int X, K, D;
	scanf("%lld%lld%lld", &X, &K, &D);
	
	if(X == 0)
	{
		if(K % 2 == 1)
			printf("%lld", D);
			
		else
			printf("0");
			
		return 0;
	}
	
	long long mod = abs(X) % D;
	if(X < 0)
		mod = mod * (-1);
	
	long long numSteps = abs(X - mod) / D;
	if(numSteps >= K)
	{
		if(X < 0)
			printf("%lld", abs(X + K * D) );
			
		else
			printf("%lld", abs(X - K * D) );
	}
	
	else if((K - numSteps) % 2 == 0)
		printf("%lld", abs(mod) );
		
	else
	{
		if(X < 0)
			printf("%lld", abs(mod + D));
			
		else
			printf("%lld", abs(mod - D));
	}
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = (1 << 30);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    stack<char> st;
    rep(i,s.size()){
        if(s[i]=='S'){
            st.push(s[i]);
        }else{
            if(st.size()!=0&&st.top()=='S'){
                st.pop();
            }else{
                st.push(s[i]);
            }
        }
    }
    cout<<st.size()<<endl;

    return 0;
}

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

double distance(int i,int j,int X[],int Y[]){
    double dx = X[i] - X[j];
    double dy = Y[i] - Y[j];
    return pow(dx * dx + dy * dy,0.5);
}

int main() {
    int N;
    cin >> N;
    int X[N] = {};
    int Y[N] = {};
    for (int i = 0;i < N;i++){
        cin >> X[i];
        cin >> Y[i];
    }
    double ans = 0.0;
    int V[N];
    for (int i = 0;i < N;i++) V[i] = i;
    do {
       for(int i = 0;i < N - 1;i++){
           ans += distance(V[i],V[i + 1],X,Y);
       }
    } while (next_permutation(V ,V + N));

    double fact = 1;
    for (int i = 1;i <= N;i++){
        fact = fact * i;
    }
    ans = ans / fact;
    cout << setprecision(15) << ans << endl;
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(1){
    C=C-B;
    if(C<=0) break;
    A=A-D;
    if(A<=0) break;
  }
  if(A>0)cout <<"Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 3624
a=int(input())
b=a//200
if b==2:
  print(8)
elif b==3:
  print(7)
elif b==4:
  print(6)
elif b==5:
  print(5)
elif b==6:
  print(4)
elif b==7:
  print(3)
elif b==8:
  print(2)
elif b==9:
  print(1)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int s,t,x;
}T;

bool comp(const T& l, const T&r){
  if(l.x == r.x) return l.s < r.s;
  return l.x < r.x;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,Q;cin >> N >> Q;
  vector<T> v(N);
  rep(i,N)cin >> v[i].s >> v[i].t >> v[i].x;
  sort(all(v),comp);
  set<PII> st;
  rep(i,Q){
    int x;cin >> x;
    st.insert(PII(x,i));
  }
  vector<int> ans(Q,-1);
  rep(i,N){
    int s = v[i].s - v[i].x, t = v[i].t - v[i].x, x = v[i].x;
    auto  it = st.lower_bound(PII(s,-1));
    while( it != st.end() ){
      if(it->first >= t) break;
      ans[it->second] = x;
      st.erase(it++);
    }
  }
  rep(i,Q)cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 14464
fun main(args: Array<String>) {
    data class Point(val x: Double, val y: Double) {
        override fun toString(): String {
            return "$x $y"
        }
    }

    fun koch(n: Int, p1: Point, p2: Point): List<Point> {
        if (n == 0) {
            return emptyList()
        }

        val s = Point((2 * p1.x + 1 * p2.x) / 3, (2 * p1.y + 1 * p2.y) / 3)
        val t = Point((1 * p1.x + 2 * p2.x) / 3, (1 * p1.y + 2 * p2.y) / 3)

        val th = Math.PI * 60 / 180

        val ux = (t.x - s.x) * Math.cos(th) - (t.y - s.y) * Math.sin(th) + s.x
        val uy = (t.x - s.x) * Math.sin(th) + (t.y - s.y) * Math.cos(th) + s.y

        val u = Point(ux, uy)

        val r = mutableListOf<Point>()

        r.addAll(koch(n - 1, p1, s))
        r.add(s)
        r.addAll(koch(n - 1, s, u))
        r.add(u)
        r.addAll(koch(n - 1, u, t))
        r.add(t)
        r.addAll(koch(n - 1, t, p2))

        return r
    }

    val n = readLine()!!.toInt()

    val p1 = Point(0.0, 0.0)
    val p2 = Point(100.0, 0.0)

    val ans = mutableListOf<Point>()
    ans.add(p1)
    ans.addAll(koch(n, p1, p2))
    ans.add(p2)

    ans.forEach { println(it) }
}


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

int n, a[10000], ans;
int ma = 10010;

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

    for(int i = 1; i < n; i++){
        if(a[i-1] == a[i]){
            a[i] = ma;
            ++ans;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int inf = 10000000;
int n;
int map[101][101];
int dep[101];
int all = 0;
int total = 0;
void solve() {
	vector<int>v;
	v.push_back(0);
	dep[0] = 1;
	total = 1;
	while (total != n)
	{
		int min = inf;
		int k ;
		for (int i = 0; i < v.size(); i++) {
			for (int j = 0; j < n; j++) {
				if (!dep[j] && map[v[i]][j] < min) {
					min = map[v[i]][j];
					k = j;
				}
			}
		}
		v.push_back(k);
		dep[k] = 1;
		all += min;
		total++;
	}
}
int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int k;
			cin >> k;
			map[i][j] = (k == -1) ? inf : k;
		}
	}
	solve();
	cout << all << endl;
}


Measured memory_bytes: 3144
N, M = map(int, input().split())
K = [[int(i) for i in input().split()] for j in range(M)]
P = [int(i) for i in input().split()]
ALL = 0
for i in range(2**N):
    state = [((i >> j) & 1) for j in range(N)]
    for j in range(M):
        k = K[j][1:]
        p = sum([int(state[l-1]) for l in k])%2
        if p != P[j]:
            break
    else:
        ALL += 1
print(ALL)





Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

int Power(int n, int x, int mod) {
  if (x == 0) return 1;
  int res = Power(n, x / 2, mod);
  res = 1ll * res * res % mod;
  if (x & 1) res = 1ll * res * n % mod;
  return res;
}

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

  int n;
  string x;
  cin >> n >> x;
  int ones = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] == '1') {
      ones++;
    }
  }
  int plus = 0;
  for (int i = 0; i < n; i++) {
    plus = 2 * plus % (ones + 1);
    if (x[i] == '1') {
      plus += 1;
    }
  }
  int minus = -1;
  if (ones > 1) {
    minus = 0;
    for (int i = 0; i < n; i++) {
      minus = 2 * minus % (ones - 1);
      if (x[i] == '1') {
        minus += 1;
      }
    }
  }
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    if (x[i] == '0') {
      int y = plus;
      y += Power(2, n - i - 1, ones + 1);
      y %= ones + 1;
      int cnt = 1;
      while (y > 0) {
        cnt++;
        y %= __builtin_popcount(y);
      }
      ans[i] = cnt;
    } else {
      if (minus == -1) {
        continue;
      }
      int y = minus;
      y -= Power(2, n - i - 1, ones - 1);
      y %= ones - 1;
      if (y < 0) y += ones - 1;
      int cnt = 1;
      while (y > 0) {
        cnt++;
        y %= __builtin_popcount(y);
      }
      ans[i] = cnt;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 4400
#include <stdio.h>
#include <string.h>

#define N 2

int matrix(double **x);
 
int main(void){
	double x[N][N+1];
	double *y[N];
	double su1=0,su2=0;
	int i,j,k,n;
	char str[100],*line;
    
	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		for(i=0;i<(N+1)*N;i++){
			if(i==0)
				line = strtok(str," ");
			else
				line = strtok(NULL," ");
			sscanf(line,"%d",&n);
			x[i/(N+1)][i%(N+1)]=n;
			
		}
		for(i=0;i<N;i++)
			y[i]=x[i];
		matrix(y);
		for(i=0;i<N;i++){
			if(i) printf(" ");
			printf("%3.3f",x[i][N]);
		}
		printf("\n");
	}
	return 0;
}

int matrix(double **x){
	int i,j,k;
	double su1=0,su2=0;

	for(k=0;k<=N-2;k++){
		for(j=k+1;j<=N-1;j++){
			su1=x[k][k];
			su2=x[j][k];
			for(i=0;i<=2;i++){
				x[j][i]=x[j][i]-x[k][i]*su2/su1;
			}
		}
	}	
	for(k=0;k<=N-2;k++){
		for(j=k+1;j<=N-1;j++){
			su1=x[1-k][1-k];
			su2=x[1-j][1-k];
			for(i=0;i<=2;i++){
				x[1-j][i]=x[1-j][i]-x[1-k][i]*su2/su1;
			}
		}
	}
	su1=0;
	for(j=0;j<=N-1;j++){
	su1=x[j][j];
		for(i=0;i<=N;i++){
		x[j][i]=x[j][i]/su1;
		}	
	}
	return 0;
}

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

int l, r, d;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> l >> r >> d;
	int ll = l - l % d;
	if(ll < l) ll += d;
	int rr = r - r % d;
	cout << max(0, (rr - ll) / d + 1) << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int A, B = 0;
    cin >> A >> B;
    int out = 0;
    
    if(B % A == 0)
    {
        out = A + B;
    }
    else
    {
        out = B - A;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

constexpr int dx[] = {1, 1, 1, 1, -1, -1, -1, -1};
constexpr int dy[] = {1, -1, -1, 1, 1, 1, -1, -1};
constexpr int dz[] = {1, 1, -1, -1, 1, -1, 1, -1};

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

    vector<int64_t> x(N), y(N), z(N);
    vector<vector<int64_t>> sum(8, vector<int64_t>(N));
    for(int i = 0; i < N; ++i){
        cin >> x[i] >> y[i] >> z[i];
        for(int j = 0; j < 8; ++j){
            sum[j][i] = x[i] * dx[j] + y[i] * dy[j] + z[i] * dz[j];
        }
    }
    for(int i = 0; i < 8; ++i){
        sort(sum[i].begin(), sum[i].end());
    }

    int64_t ans = 0;
    for(int j = 0; j < 8; ++j){
        int64_t now = 0;
        for(int i = 0; i < M; ++i){
            now += sum[j][N-1-i];
        }
        ans = max(now, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

bool is_prime[30001];

int main(){
  int side_sum;

  memset(is_prime,true,sizeof(is_prime));
  is_prime[0] = false;
  is_prime[1] = false;
  vector<int> prime;
  for(int i=0;i<=30000;i++){
    if(!is_prime[i]) continue;
    prime.push_back(i);
    for(int j=i+i;j<=30000;j+=i){
      is_prime[j] = false;
    }
  }

  while(~scanf("%d",&side_sum)){
    if(side_sum == 0) break;
    int res = 0;
    map<vector<int>,bool> visited;

    for(int prime_i = 0; prime_i < prime.size(); prime_i++){

      int center_side = prime[prime_i];
      if(2 * center_side >= side_sum) break;

      int remainings = side_sum - center_side;
      if(remainings <= 0) break;
      
      for(int prime_j = 0; prime_j < prime.size(); prime_j++){
        int left_side = prime[prime_j];
        if(left_side >= remainings) break;

        int right_side = remainings - left_side;
        if(right_side <= 0) break;
        if(!is_prime[right_side]) continue;
        if(left_side > right_side) break;

        vector<int> used;
        used.push_back(center_side);
        used.push_back(left_side);
        used.push_back(right_side);
        sort(used.begin(),used.end());
        if(used[0] + used[1] <= used[2]) continue;

        if(visited.find(used) != visited.end()) continue;

        visited[used] = true;
        res++;
      }
    }
    printf("%d\n",res);
  }
}

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

int main(){
    long long int n;
    cin >> n;
    long long int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    long long int pre[n]={0};
    pre[n-1]=(arr[n-1]%1000000007);
    for(long long int i=n-2; i>=0; i--){
        pre[i]=((arr[i]%1000000007)+(pre[i+1]%1000000007))%1000000007;
    }
    long long int sum=0;
    for(long long int i=0; i<n-1; i++){
        sum=(sum + ((arr[i]%1000000007)*(pre[i+1]%1000000007))%1000000007)%1000000007;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 6700
#include <string>
#include <cstdlib>
#include <stack>
#include <iostream>
using namespace std;

int main(){
  string word;
  stack<int> S;
  while(cin >> word){
    if(word == "+"){
      int m = S.top();
      S.pop();
      int n = S.top();
      S.pop();
      S.push(m+n);
    }
    else if(word == "-"){
      int m = S.top();
      S.pop();
      int n = S.top();
      S.pop();
      S.push(n-m);
    }
    else if(word == "*"){
      int m = S.top();
      S.pop();
      int n = S.top();
      S.pop();
      S.push(m*n);
    }
    else{
      S.push(atoi(word.c_str()));
    }
  }
  int p = S.top();
  cout << p << endl;
  
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  Int n;
  cin>>n;
  vector<string> vs(n+1);
  for(Int i=0;i<=n;i++) cin>>vs[i];

  const Int INF = 1e15;
  auto calc=[&](string s){
    vector<Int> res;
    Int n=s.size();
    for(Int i=0;i<n;i++){
      if(isalpha(s[i])){
	res.emplace_back(INF + Int(s[i]));
	continue;
      }
      Int tmp=0;
      while(isdigit(s[i])){
	tmp=tmp*10+s[i]-'0';
	i++;
      }
      i--;
      res.emplace_back(tmp);
    }
    return res;
  };
  
  string s=vs[0];
  auto check=[&](string t)->Int{
    if(s==t) return 1;
    if(s.size()<t.size())
      if(t.substr(0,s.size())==s) return 1;
    if(s.size()>t.size())
      if(s.substr(0,t.size())==t) return 0;
    
    auto x=calc(s);
    auto y=calc(t);
    for(Int i=0;i<(Int)min(x.size(),y.size());i++){
      if(x[i]<y[i]) return 1;
      if(x[i]>y[i]) return 0;
    }

    assert(0);
    return 0;
  };
  
  for(Int i=1;i<=n;i++){
    if(check(vs[i])) cout<<"+"<<endl;
    else cout<<"-"<<endl;    
  } 
  
  return 0;
}



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

int N,A[100010];
set<int> s[100010];

int main(){
  cin >> N;
  int ans = 0;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    s[A[i]].insert(i);
  }
  for(int i=1;i<=N;i++) if(s[i].count(A[i])==1) ans++;
  cout << ans/2 << endl;
}

Measured memory_bytes: 9984
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n);
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end());
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a)      reverse((a).begin(), (a).end());
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d);
#define outl(d)         std::cout<<(d)<<"\n";
#define Yes()           printf("Yes\n");
#define No()            printf("No\n");
#define YES()           printf("YES\n");
#define NO()            printf("NO\n");
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  char a, b; cin >> a >> b;

  if (a == b) {
    outl("H")
  } else {
    outl("D")
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  solve();
}


Measured memory_bytes: 256
import math
import statistics
N = int(input())

A = input().rstrip().split()
#print(A)
i = 0
kari =[]
for j in A:
    i +=1
    B = int(j)-i
    kari.append(B)
#print(kari)
b = statistics.median(kari)

sum = 0
for i in kari:
    sum+=abs(i-b)
print(int(sum))

Measured memory_bytes: 29484
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
const int hell=1000000007;
 
 int h[100010]={0};
 int dp[100010];
 int n;

int frog(int index)
{
  if(index>=n)return 0;
  if(dp[index]!=-1)return dp[index];
  
  int ans=hell;
  rep(i,1,3)
  {
    if(index+i<=n)
    {
      ans=min(ans,abs(h[index+i]-h[index])+frog(index+i));
    }
  }
  // if(dp[index]!=-1)dp[index]=ans;
  // else dp[index]=min(dp[index],ans);

  return dp[index]=ans;
}


int solve(){    

  memset(dp,-1,sizeof(dp));
  cin>>n;
  rep(i,0,n)cin>>h[i+1];
  cout<<frog(1);


return 0;
}

 
signed main()
{    
   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  

   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);  

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

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

using namespace std;

#define ll long long

const int N=1e6+5;

int n,a[N],ans,x,cnt[N];

bool sorted(){
    for(int i=1;i<n;i++)
        if (a[i]<a[i-1])
            return false;
    return true;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    if (sorted())
        return !printf("YES\n");
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++){
            swap(a[i],a[j]);
            if (sorted())
                return !printf("YES\n");
            swap(a[i],a[j]);
        }
    printf("NO\n");
}



Measured memory_bytes: 2304
n = int(input())
A = [(i + 1, int(j)) for i, j in enumerate(input().split())]
A.sort(key=lambda x: -x[1])

class BIT:
    def __init__(self, n):
        self.data = [0] * (n + 1)
    def add(self, i, x):
        while i <= n:
            self.data[i] += x
            # 区間の長さ
            i += i & -i

    def get(self, i):
        s = 0
        while i:
            s += self.data[i]
            i -= i & -i
        return s

b = BIT(n)
ans = 0
for i, j in A:
    ans += b.get(i)
    b.add(i, 1)
print(ans)


Measured memory_bytes: 47800
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

int n,m;
struct edge{int y,nex;}a[maxn<<1]; int len,fir[maxn];
inline void ins(const int x,const int y){a[++len]=(edge){y,fir[x]};fir[x]=len;}

int col[maxn],N[2];
bool color(const int x)
{
	bool re=true;
	for(int k=fir[x],y=a[k].y;k;k=a[k].nex,y=a[k].y)
	{
		if(col[y]==-1) N[col[y]=!col[x]]++,re=color(y);
		else if(col[y]!=!col[x]) re=false;
		if(!re) return re;
	}
	return re;
}

int main()
{
	memset(col,-1,sizeof col);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int x,y; scanf("%d%d",&x,&y);
		ins(x,y); ins(y,x);
	}
	N[col[1]=0]++; bool flag=color(1);
	if(flag) printf("%lld\n",(ll)N[0]*N[1]-m);
	else printf("%lld\n",(ll)n*(n-1)/2ll-m);
	
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[n + 2];
	a[0] = a[n + 1] = 0;
	rep(i, n) cin >> a[i + 1];
	int l[n + 2], r[n + 2];
	l[0] = r[n + 1] = 0;
	rep(i, n + 1) {
		l[i + 1] = l[i] + abs(a[i + 1] - a[i]);
		r[n - i] = r[n - i + 1] + abs(a[n - i] - a[n - i + 1]);
	}
	rep(i, n) cout << l[i] + r[i + 2] + abs(a[i] - a[i + 2]) << endl;
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n;
cin >> n;
vi h(n);
rep(i,n) cin >> h[i];

int ans = 0;
while(true){
    if(*max_element(all(h)) == 0) break;
    int i = 0;
    while(i < n){
        if(h[i] == 0) i++;
        else {
            ans++;
            while(i < n && h[i] > 0){
                h[i]--;
                i++;
            }
        }
    }
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}
#include <atcoder/dsu>
using namespace atcoder;

void Main()
{
	ll n,m,l,q; ll res=0;

	cin>>n>>q;
	dsu dsu(n);
	ll t,u,v;
	rep(i,q){
		cin>>t>>u>>v;
		if(t==0){
			dsu.merge(u,v);
		}
		if(t==1){
			bool issame=dsu.same(u,v);
			print(issame);
		}
	}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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

int main(){
  int s,w;cin>>s>>w;
  cout<<(w>=s?"unsafe":"safe");
}


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

int main(){
    string s, t; cin >> s >> t;
    int len_s = (int) s.size(), len_t = (int) t.size();
    for(int i = len_s - len_t; i >= 0; i--){
        for(int j = 0; j < len_t; j++){
            if(s[i+j]!=t[j] and s[i+j]!='?') break;
            if(j==len_t-1){
                for(int k = 0; k < len_t; k++) s[i+k] = t[k];
                for(int k = 0; k < len_s; k++){
                    if(s[k] == '?') s[k] = 'a';
                }
                cout << s << '\n';
                return 0;
            }
        }
    }

    cout << "UNRESTORABLE\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> temp(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        temp[i] = a[i];
    }
    sort(temp.begin(), temp.end());
    int maxi1 = temp[n - 1];
    int maxi2 = temp[n - 2];
    for(int i = 0; i < n; i++)
    {
        if(a[i] == maxi1)
        {
            cout << maxi2 << endl;
        }
        else
        {
            cout << maxi1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
<?php
fscanf(STDIN, "%d %d %d %d", $A, $B, $C, $K);

$ans = 0;

$AA = min($A, $K);
$ans += $AA;
$K -= $A;

$BB = min($B, $K);
$K -= $BB;

$CC = min($C, $K);
$ans -= $CC;
$K -= $CC;

printf("%d", $ans);


Measured memory_bytes: 16172
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;

int numOfD(int n) {
    int cnt = 0;
    while (n != 0) {
        n = n / 10;
        cnt += 1;
    }
    return cnt;
}

int main() {

    int N;
    cin >> N;

    int result = 0;

    for (int i = 1; i <= N; i++) {
        if ((numOfD(i)) % 2 == 1) {
            result += 1;
        }
    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;


string solve(int x, int y) {
    vector<int> a = {4, 6, 9, 11};

    auto ax = find(a.begin(), a.end(), x);
    auto ay = find(a.begin(), a.end(), y);

    if (x == 2 and y == 2) {
        return "Yes";
    }
    else if ((x == 2 and y != 2) or (x != 2 and y == 2)) {
        return "No";
    }
    else if (ax == a.end() and ay == a.end()) {
        return "Yes";
    }
    else if (ax != a.end() and ay != a.end()) {
        return "Yes";
    }
    else {
        return "No";
    }
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << solve(x, y) << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

int main(){
  string a;
  cin>>a;
  ll ans=0;
  ll n=a.length()-1;
  for(int mask=0;mask<1<<n;mask++){
    ll lasti=0;
    ll sum=0;
    for(int i=0;i<n;i++){
      if(mask&1<<i){
        string s=a.substr(lasti,i+1-lasti);
        ll val=stoi(s);
        sum+=val;
        lasti=i+1;
      }
    }
    string s=a.substr(lasti,n+1-lasti);
    ll val=stoll(s);
    sum+=val;
    ans+=sum;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <map>
using namespace std;

int main(){
    static char s[2000010];
    map<int,int> q;
    while(1){
        scanf("%s",s);
        if(s[0] == 'e' && s[1] == 'n') break;
        if(s[0] == 'i'){
            int x;
            scanf("%d",&x);
            q[x]++;
        } else {
            printf("%d\n",q.rbegin()->first);
            q.rbegin()->second--;
            if(q.rbegin()->second == 0){
                q.erase(q.rbegin()->first);
            }
        }
    }
}

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

using namespace std;

#define exit cout<<-1<<'\n'; return 0
#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,A,x[50];
	cin >> n >> A;
	ll ans = 0;
	rep(i,n) cin >> x[i];
	ll dp[51][5000];	
	rep(i,51) fill(all(dp[i]),0);
	dp[0][0] = 1;
	rep(i,n)repD(k,n - 1,0)rep(j,2501) dp[k + 1][j + x[i]] += dp[k][j]; 
	rep1(i,n) ans += dp[i][i * A];
	cout << ans << endl;
}


Measured memory_bytes: 2432
/*************************************************************************
> File Name: test.cpp
> Author: Akira 
> Mail: qaq.febr2.qaq@gmail.com 
************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
using namespace std;

#define MaxN 100005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}
template <class T> inline void read(T &ret) {char c; ret=0;while((c=getchar())<'0'||c>'9');while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();}
template <class T> inline void out(T x) {if(x>9) out(x/10);putchar(x%10+'0');}

LL T[110];
int main()
{
    //std::ios::sync_with_stdio(false);
    int N;
    read(N);
    LL tot = 1;
    for(int i=1;i<=N;i++) 
    {
        read(T[i]);
        tot = tot/__gcd(tot,T[i])*T[i];
    }
    out(tot);puts("");
    // system("pause");
    //printf("%lld\n", ((x)%mod+mod)%mod );
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int s = 0;
    for (int i = 0; i < 3; ++i) {
        int a;
        std::cin >> a;
        s += a;
    }

    std::cout << (s >= 22 ? "bust" : "win") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int N, K;
    cin >> N >> K;

    vector<bool> have(N, false);

    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;

        for (int j = 0; j < d; j++) {
            int A;
            cin >> A;
            A--;
            have[A] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (!have[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
struct UnionFind {
private:
    vector<int> par;
    vector<int> count;
    vector<int> rank;
public:
    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y])
            swap(x, y);
        else if (rank[x] == rank[y])
            rank[y]++;
        par[y] = x;
        count[x] += count[y];
        return;
    }

    int size(int x) {
        return count[root(x)];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
using UF = struct UnionFind;

struct bridge{
    ll d,u,v;
    bridge(ll dd, ll uu, ll vv) : d(dd), u(uu), v(vv){};
};
pair<ll, ll> X[100000], Y[100000];


int main() {
    init();
    ll N;
    cin >> N;
    rep(i,N){
        ll x, y;
        cin >> x >> y;
        X[i] = {x, i}, Y[i] = {y, i};
    }
    sort(X, X + N), sort(Y, Y + N);

    UF uf(N);
    auto comp = [](bridge b1, bridge b2) { return b1.d > b2.d; };
    priority_queue<bridge, vc<bridge>, decltype(comp)> pq(comp);
    rep(i, N - 1) pq.emplace(X[i + 1].first - X[i].first, X[i].second, X[i + 1].second);
    rep(i, N - 1) pq.emplace(Y[i + 1].first - Y[i].first, Y[i].second, Y[i + 1].second);

    ll ans = 0;
    while(!pq.empty()){
        bridge b = pq.top();
        pq.pop();
        if (uf.issame(b.u, b.v)) continue;
        ans += b.d;
        uf.unite(b.u, b.v);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12912
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	for(int i = 0; i < N; i++) cin >> d[i];
	sort(d.begin(), d.end());
	cout << d[N / 2] - d[N / 2 - 1] << endl;
	return 0;
}


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

int main()
{
    int n, m;
    int k[10];
    int s[10][10];
    int p[10];
    
    cin >> n >> m;
    for (int i = 0;i < m;i++)
    {
        cin >> k[i];

        for(int j = 0;j < k[i];j++)
        {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for (int i = 0;i < m;i++)
    {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0;i < (1 << n);i++)
    {
        bool f = true;
        for (int j = 0;j < m;j++)
        {
            int cnt = 0;
            for (int l = 0;l < k[j];l++)
            {
                cnt += (i >> s[j][l]) & 1;
            }
            if (cnt % 2 != p[j]) f=false;
        }
        if (f) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

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

int main(){
int h, w;
int m = 1e9 + 7;
cin >> h >> w;
vector<vector<char>>graph(h, vector<char>(w, 0));
for(int i=0; i<h; i++){
  for(int j=0; j<w; j++){
    cin >> graph[i][j];
  }
}
int dp[h][w];
memset(dp, 0, sizeof(dp));
if(graph[0][1] == '.'){
  dp[0][1] = 1;
}if(graph[1][0] == '.'){
  dp[1][0] = 1;
}

for(int i=2;i<h;i++){
  if(graph[i][0] == '.'){
    dp[i][0]=dp[i-1][0];
  }else {
    break;
  }
}
for(int i=2;i<w;i++){
  if(graph[0][i] == '.'){
    dp[0][i] = dp[0][i-1];
  }else{
    break;
  }
}

for(int i=1; i<h; i++){
  for(int j=1; j<w; j++){
    if(graph[i][j] == '.'){
      dp[i][j] = (dp[i-1][j] + dp[i][j-1])%m;
    }
    else if(dp[i][j] == '#'){
      dp[i][j] = 0;
    }
  }
}
int ans = dp[h-1][w-1];
cout << ans; 
return 0;
}



Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main(){
	int a,b;
	while(1){
		a=-1;
		int data[100]={0};
		while(cin >> a >> b && a || b){
			a--;b--;
			data[a]++;
			data[b]++;
		}
		if(a==-1)return 0;

		bool flag = false;
		/*?????????????????´??????????\???°???????????????????????§????????????*/
		if(data[0]%2==0 || data[1]%2==0)flag = true;
		for(int i=2;i<100;i++){
			/*??????????????¨??´????????\???????\???°??????????????°*/
			if(data[i]%2==1 && data[i]){
				flag = true;
			}
		}
		cout << (flag?"NG":"OK") << endl;
	}
}

Measured memory_bytes: 3100
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let c = s.chars().next().unwrap();
    if c.is_lowercase() {
        println!("{}", "a");
    } else {
        println!("{}", "A");
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
LL b[26];

int main() {
	cin >> s;
	
	inc(i, s.size()) { b[s[i] - 'a']++; }
	
	LL n = s.size();
	LL ans = n * (n + 1) / 2 + 1;
	inc(i, 26) {
		ans -= b[i] * (b[i] + 1) / 2;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
def findMaxId(id_x):
	max_x=0
	max_id=0
	for i in range(n):
		if id_x[i]>max_x:
			max_x=id_x[i]
			max_id=i
	return max_id
	
n,r,l=map(int,raw_input().split())
log=[map(int,raw_input().split()) for i in range(r)]
log.insert(0,[1,0,0])
log.append([1,l,0])
id_t=[0]*n
id_x=[0]*n
max_id=0
for i in range(1,r+2):
	cur_id=log[i][0]-1
	id_t[max_id]+=log[i][1]-log[i-1][1]
	id_x[cur_id]+=log[i][2]
	if cur_id==max_id and log[i][2]<0:
		max_id=findMaxId(id_x)
	elif id_x[max_id]<id_x[cur_id] or (id_x[max_id]==id_x[cur_id] and max_id>cur_id):
		max_id=cur_id
print id_t.index(max(id_t))+1

Measured memory_bytes: 145640
import time
start = time.time()

n, k = map(int, input().split())
p = list(map(int, input().split()))
# p = [i for i in range(1, n+1)]
ans = 0
# for i in range(n-k+1):
#     exp = 0
#     for j in range(k):
#         exp += (p[i+j] * (p[i+j] + 1)) / 2 / p[i+j]
#     if exp > ans:
#         ans = exp
total = [0] * n
for i in range(n):
    if i == 0:
        total[i] = p[i]
    else:
        total[i] = total[i-1] + p[i]
maxi_sum = 0
maxi_num = 0
for i in range(k-1, n):
    if i == k-1:
        maxi_sum = total[i]
        maxi_num = i
    else:
        if total[i] - total[i-k] > maxi_sum:
            maxi_sum = total[i] - total[i-k]
            maxi_num = i
# print(maxi_sum, maxi_num)
ans = 0
for i in range(maxi_num - k + 1, maxi_num + 1):
    ans += (p[i] * (p[i] + 1)) / 2 / p[i]
print(ans)

# print(time.time() - start)

Measured memory_bytes: 25600