akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int ds(int n) {
  int r = 0;
  while (n > 0) {
    r += n % 10;
    n /= 10;
  }
  return r;
}

int main(void) {

  int h, a;
  cin >> h >> a;
  int ans = 0;
  while (h > 0) {
    h -= a;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A[510000],n,w[510000],x[510000],num[510000],B[510000];
const int mo=1e9+7;
int add(int *A,int k1,int k2){
	for (;k1<=n;k1+=k1&(-k1)) A[k1]=(A[k1]+k2)%mo;
}
int find(int *A,int k1){
	int ans=0; for (;k1;k1-=k1&(-k1)) ans=(ans+A[k1])%mo; return ans;  
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]),w[x[i]]++; w[0]=0;
	for (int i=1;i<=n;i++) w[i]+=w[i-1];
	for (int i=1;i<=n;i++) w[i]=i-w[i];
	num[n]=1; int tot=w[n]; //cout<<tot<<" "<<w[1]<<" "<<w[2]<<" "<<w[3]<<endl;
	for (int i=n-1;i;i--) num[i]=1ll*num[i+1]*(n-i)%mo;
	int pre=0,pre1=0,pre2=0;
	for (int i=1;i<=n;i++) if (x[i]) pre1=(pre1+1ll*w[x[i]]*num[i])%mo;
	int nu=1ll*tot*(tot-1)/2%mo,way=1,way2=1;
	for (int i=1;i<=tot-2;i++) nu=1ll*nu*i%mo;
	for (int i=1;i<=tot;i++) way=1ll*way*i%mo;
	for (int i=1;i<tot;i++) way2=1ll*way2*i%mo;
	int ans=0;
	for (int i=n;i;i--)
		if (x[i]){
			pre=(pre+tot-w[x[i]])%mo; 
			pre1=(pre1-1ll*w[x[i]]*num[i])%mo;
			add(A,x[i],1);
			ans=(ans+1ll*find(A,x[i]-1)*num[i]%mo*way)%mo;
		//	cout<<"fa "<<i<<" "<<num[i]<<" "<<find(A,x[i]-1)<<endl;
		} else {
		//	cout<<pre<<" "<<pre1<<" "<<nu<<endl;
			ans=(ans+(1ll*num[i]*pre+pre1)%mo*way2)%mo;
			ans=(ans+1ll*nu*pre2%mo*num[i])%mo;
			pre2++;// cout<<ans<<endl;
		}
	ans=(ans+way)%mo;
	printf("%d\n",(ans+mo)%mo);
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll ans[111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  vi lpo,rpo;
  ll n=s.size();
  for(int i=0;i<n-1;i++){
    if(s[i]=='R'&&s[i+1]=='L'){
      lpo.pb(i);
      rpo.pb(i+1);  
    }
  }
  rpo.pb(llINF);
  for(ll i=0;i<n;i++){
    if(s[i]=='R'){
      auto lb=lower_bound(ALL(lpo),i);
      ll num= *lb;
      ll po=num-i;
      //cout<<"R"<<" "<<num<<" "<<po<<endl;
      if(po%2){
	ans[num+1]++;
	//cout<<num+1<<endl;
      }else{
	ans[num]++;
	//cout<<num<<endl;
      }
    }else{
      auto ub=upper_bound(ALL(rpo),i);
      --ub;
    ll num=(*ub);
      ll po=i-num;
  
      //cout<<"L"<<" "<<num<<" "<<po<<endl;
      if(po%2){
	ans[num-1]++;
      }else{
	ans[num]++;
      }
    }
  }
  for(int i=0;i<n;i++)
    cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2372
///Bismillahir Rahmanir Rahim
#define ll long long
#define scf1(a)  scanf("%lld",&a);
#define scf2(a,b)  scanf("%lld %lld",&a,&b)
#define pf    printf
#define pb    push_back
#define rsrt(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define ff first
#define ss second
#define spd ios_base::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
ll mark[200];
int main()
{
     ll a=1,b=1,i,j,t,res;

     ll n,mn;

     scf1(n);
     mn = 1e15;
     for(i=1;i<=sqrt(n)+1;i++)
     {
         if(n%i==0)
         {
             j = n/i;

             res = abs(a-i)+abs(b-j);

             mn = min(mn,res);
         }
     }
     pf("%lld\n",mn);

}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
   int a;
   int b;
   int k;
   int n = 0;
   

   cin >> a >> b;

   if(a < b){
      while (a <= b){
         if(a == b){
            n = a;
         }
         a++;
         b--;
      }
   }

   else {
      while(a >= b){
         if(a == b){
            n = a;
         }
         b++;
         a--;
      }
   }

   if(n != 0){
      cout << n;
   }

   else{
      cout << "IMPOSSIBLE\n";
   }

   return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        int res = 0;
        for (int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        for (int i=0; i<k; i++) {
            res += arr[i];
        }
        System.out.println(res);

    }
}

Measured memory_bytes: 38920
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int a, b;
	scanf("%d%d", &a, &b);
	int answer = max(a + b, max(a + a - 1, b + b - 1));
	printf("%d\n", answer);
}


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

int main() {
  int a11,a12,a13,a21,a22,a23,a31,a32,a33,n;
  cin >> a11>>a12>>a13>>a21>>a22>>a23>>a31>>a32>>a33>>n;

  int b11,b12,b13,b21,b22,b23,b31,b32,b33;
  b11=b12=b13=b21=b22=b23=b31=b32=b33=0 ;

  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    if(vec.at(i)==a11){b11=1;}
    else if(vec.at(i)==a12){b12=1;}
    else if(vec.at(i)==a13){b13=1;}
    else if(vec.at(i)==a21){b21=1;}
    else if(vec.at(i)==a22){b22=1;}
    else if(vec.at(i)==a23){b23=1;}
    else if(vec.at(i)==a31){b31=1;}
    else if(vec.at(i)==a32){b32=1;}
    else if(vec.at(i)==a33){b33=1;}

    if(b11*b12*b13 + b21*b22*b23 + b31*b32*b33 + b11*b21*b31 + b12*b22*b32 + b13*b23*b33 + b11*b22*b33 + b13*b22*b31 == 1){
      cout << "Yes";
      break;
    }
  }

  if(b11*b12*b13 + b21*b22*b23 + b31*b32*b33 + b11*b21*b31 + b12*b22*b32 + b13*b23*b33 + b11*b22*b33 + b13*b22*b31 == 0){
    cout << "No";
  }
}

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

using ll = long long;
using ull = unsigned long long;

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

void solve() {
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] +abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << "\n";
}

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


Measured memory_bytes: 3972
#include <iostream>

using namespace std;

int main(){
  int N, cnt=0, tmp, ans=0;
  cin >> N;
  for(int i=1; i<=N; i++){
    tmp = i;
    cnt = 0;
    while(tmp>0){
      tmp /= 10;
      cnt++;
    }
    if(cnt%2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# 146a                     
# 今日の曜日を表す文字列 S が与えられます。   
# S は SUN,MON,TUE,WED,THU,F
# それぞれ日曜日、月曜日、火曜日、水曜日、木曜日、金
# 次の日曜日 (あす以降) が何日後か求めてください
                           
                           
# S に入力されたSUN,MON,TUE,WED,T
S = input()                
                           
                           
                           
# if文で入力に対応した答えを返す         
if S == 'SUN':             
    print(7)               
elif S == 'MON':           
    print(6)               
elif S == 'TUE':           
    print(5)               
elif S == 'WED':           
    print(4)               
elif S == 'THU':           
    print(3)               
elif S == 'FRI':           
    print(2)               
elif S == 'SAT':           
    print(1)               

Measured memory_bytes: 8952
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////
int main(){
	ll a,b,c,k;
  	cin >>a>>b>>c>>k;
  ll ans=0;
  ll count=0;
  REP(i,a){
    
  	ans++;
    count++;
    if(count==k){cout << ans << endl; return 0;}
  }
  REP(i,b){
    
    count++;
    if(count==k){cout << ans << endl; return 0;}
  }
  REP(i,c){
    
    ans--;
    count++;
    if(count==k){cout << ans << endl; return 0;}
  }
}

Measured memory_bytes: 3604
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)


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

int main() {

    int n;
    cin >> n;

    vector<vector<pair<int, int>>> members(n);

    for(int i = 0; i < n; ++i) {
        int a, b;
        cin >> a;
        members[i].resize(a);
        for(int j = 0; j < a; ++j) {
            cin >> members[i][j].first >> members[i][j].second;
            members[i][j].first--;
        }


    }

    decltype(auto) IsCorrect = [&](int bit) {

        for(int i = 0; i < n; ++i) {

            if( !(bit & (1 << i)) )
                continue;
            for(auto member : members[i]) {

                if( (bit & (1 << member.first)) && member.second == 0) return false;
                
                if( !(bit & (1 << member.first)) && member.second == 1) return false;

       
            }
            
        }

    return true;
        
    };

    int maxBit = 1 << n;
    int maxCount = 0;
    for(int bit = 1; bit < maxBit; ++bit) {
        

        if(IsCorrect(bit)) {
            // cout << "Correct " << bitset<8>(bit) << endl;

            int count = 0;
            for(int i = 0; i < n; ++i) {
                if(bit & (1 << i))
                    count++;
            }   

            maxCount = max(maxCount, count);

        }

    }

    cout << maxCount << endl;

    return 0;

}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	public void run()
	{
		Scanner file = new Scanner(System.in);
		int[] in = new int[5];
		for(int i = 0;i<6;i++)
			in[file.nextInt()]++;
		int odd = 0;
		for(int x:in)
			if(x%2==1)
				odd++;
		System.out.println(odd == 2? "YES":"NO");
	}
	
}


Measured memory_bytes: 23508
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 205
using namespace std;
int n;
const int mod=998244353;
struct po{
	int x,y;
	friend po operator-(po x,po y){return (po){x.x-y.x,x.y-y.y};}
	friend int operator*(po x,po y){return x.x*y.x+x.y*y.y;}
	friend int operator/(po x,po y){return x.y*y.x-x.x*y.y;}
}p[MN];
int pow(int x,int y){
	int tmp=1;
	while(y){
		if(y&1)tmp=1ll*tmp*x%mod;y>>=1;x=1ll*x*x%mod;
	}return tmp;
}
void dec(long long &x,int y){(x-=y)<0?x+=mod:0;}
long long ans=0;
int main(){
	scanf("%d",&n);ans=pow(2,n);dec(ans,n+1);
	for(int i=1;i<=n;i++)scanf("%d%d",&p[i].x,&p[i].y);
	for(int i=1;i<=n;i++)
		for(int j=i+1,cnt=0;j<=n;j++,dec(ans,pow(2,cnt)),cnt=0)
			for(int k=1;k<=n;k++)if((p[k]-p[i])/(p[k]-p[j])==0&&(p[k]-p[i])*(p[k]-p[j])<0)cnt++;
	printf("%lld\n",ans);
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, K, S = map(int, input().split())

if S == 10**9:
    ans = [S] * K + [1] * (N - K)
else:
    ans = [S] * K + [10**9] * (N - K)
print(*ans)


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

using namespace std;

void failure () {
  cout << "NO" << endl;
  exit(0);
}

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

  int ac = 0, bc = 0, cc = 0;
  for (char c : s) {
    if (c == 'a') ac++;
    if (c == 'b') bc++;
    if (c == 'c') cc++;
  }

  int n = s.size();
  int ce = (n + 2) / 3;
  int fl = n / 3;

  if (ac != ce && ac != fl) failure();
  if (bc != ce && bc != fl) failure();
  if (cc != ce && cc != fl) failure();
  cout << "YES" << endl;
}


Measured memory_bytes: 3736
#include <stdio.h>
  
int main(void) {
    int max = 0;
    int n;
    char str[101];
    int cnt[26];

    scanf("%d%s", &n, str);

    for (int i = 1; i <= n - 1; i++) {
        for (int i = 0; i < 26; i++) {
            cnt[i] = 0;
        }           
                
        for (int j = 0; j < i; j++) {
            for (int k = i; k <= n - 1; k++) {
                if (str[j] == str[k]) {
                    cnt[str[j] - 'a']++;
                }
            }
        }

        int kind = 0;
        for (int i = 0; i < 26; i++) {
            if (cnt[i] != 0) kind++;
        }
            
        if (max < kind) max = kind;
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
 	int n, y;
  	cin >> n >> y;
  	bool found = false;
	for (int i = 0; i <= n && !found; i++) {
      for (int j = 0; j + i <= n && !found; j++) {
       	int k = n - i - j;
        if (i * 10000 + j * 5000 + k * 1000 == y) {
         	found = true;
          cout << i << " " << j << " " << k << endl;
        }
      }
    }
  	if (!found) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

template <class Cost = int>
struct Centroid {
    Graph<Cost> graph;
    std::vector<bool> deleted;
    std::vector<int> sz;

    explicit Centroid(const Graph<Cost>& graph)
        : graph(graph), deleted(graph.size(), false), sz(graph.size()) {}

    int szdfs(int v, int p = -1) {
        sz[v] = 1;
        for (auto e : graph[v]) {
            if (e.dst == p || deleted[e.dst]) continue;
            sz[v] += szdfs(e.dst, v);
        }
        return sz[v];
    }

    int find(int v) {
        int n = szdfs(v);

        int p = -1;
        while (true) {
            int nxt = -1;
            for (auto e : graph[v]) {
                if (e.dst == p || deleted[e.dst]) continue;
                if (nxt == -1 || sz[e.dst] > sz[nxt]) nxt = e.dst;
            }

            if (nxt == -1 || sz[nxt] <= n / 2) return v;
            p = v;
            v = nxt;
        }
    }
};

void solve() {
    int n;
    std::cin >> n;

    Graph<int> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v, w;
        std::cin >> u >> v >> w;
        graph[u].emplace_back(u, v, w);
        graph[v].emplace_back(v, u, w);
    }

    Centroid<int> cent(graph);

    int ans = 0;
    std::queue<int> cents;
    cents.push(0);

    std::vector<int> dist(n);
    while (!cents.empty()) {
        int r = cents.front();
        cents.pop();
        r = cent.find(r);
        cent.deleted[r] = true;

        std::vector<int> fars({0, 0});
        for (auto e : graph[r]) {
            if (cent.deleted[e.dst]) continue;
            cents.push(e.dst);

            // BFS
            std::queue<std::pair<int, int>> que;
            que.emplace(e.dst, -1);
            dist[e.dst] = e.cost;

            int far = 0;
            while (!que.empty()) {
                int v, p;
                std::tie(v, p) = que.front();
                que.pop();
                far = std::max(far, dist[v]);

                for (auto f : graph[v]) {
                    if (f.dst == p || cent.deleted[f.dst]) continue;
                    dist[f.dst] = dist[v] + f.cost;
                    que.emplace(f.dst, v);
                }
            }
            fars.push_back(far);
        }

        std::sort(fars.rbegin(), fars.rend());
        if (fars.size() >= 2) ans = std::max(ans, fars[0] + fars[1]);
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 18752
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;


int main() {
  int n;
  scanf("%d", &n);

  if (n % 10 == 3) {
    printf("bon");
  } else if (n % 10 == 0 || n % 10 == 1 || n % 10 ==6 || n % 10 == 8) {
    printf("pon");
  } else 
    printf("hon");

  return 0;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a[5000],i,max=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        max+=a[i]-1;
    }
    cout<<max<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s[n];
    map <string, int> m;
    for(int i = 0; i < n; i++)
    {
        cin >> s[i];
        m[s[i]]++;
    }
    int max_cnt = -1;
    for(auto u : m)
    {
        max_cnt = max(max_cnt, u.second);
    }
    for(auto u : m)
    {
        if(u.second == max_cnt)
        {
            cout << u.first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 26752
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] agrs){
        long A, B, C, D;
        long ans;
        while(sc.hasNext()){
            ans = 0;
            A = sc.nextInt();
            B = sc.nextInt();
            C = sc.nextInt();
            D = sc.nextInt();
            ans = ((B + C) < (B + D) ? (B + C) : (B + D)) < ((A + C) < (A + D) ? (A + C) : (A + D)) ? ((B + C) < (B + D) ? (B + C) : (B + D)) : ((A + C) < (A + D) ? (A + C) : (A + D));
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

signed main() {
  int N, X[1000], Y[1000]; cin >> N;
  int type = -1;
  for(int i = 0; i < N; ++i) {
    int x, y; cin >> x >> y;

    int t = (x + y) % 2 == 0 ? 0 : 1;
    if(type == -1) type = t;
    if(type != t) {
      cout << -1 << endl;
      return 0;
    }

    X[i] = x - y;
    Y[i] = x + y;
  }

  vector<int> use;
  int sum = 0;
  for(int i = 31; i >= 0; --i) {
    use.push_back(1LL << i);
    sum += 1LL << i;
  }

  cout << use.size() + (type == 0) << endl;
  for(int i = 0; i < use.size(); ++i) {
    cout << use[i] << endl;
  }

  if(type == 0) {
    cout << 1;
    for(int j = 0; j < N; ++j) {
      X[j]--, Y[j]--;
    }
  }
  cout << endl;


  for(int i = 0; i < N; ++i) {
    int l = (X[i] + sum) / 2;
    int m = (Y[i] + sum) / 2;
    for(int j = 31; j >= 0; --j) {
      int t1 = (l >> j) & 1;
      int t2 = (m >> j) & 1;
      if(t1 == 0 && t2 == 0) cout << "L";
      else if(t1 == 1 && t2 == 1) cout << "R";
      else if(t1 == 1 && t2 == 0) cout << "D";
      else cout << "U";
    }
    if(type == 0) cout << "R";
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<ll> s;
const ll MAX=400000000;
void dfs(ll x)
{
	if(x>MAX)return;
	s.insert(x);
	if(x%10 !=9){s.insert(x*10+(x%10+1));dfs(x*10+(x%10+1));}
	if(x%10>0)
	{s.insert(x*10+(x%10-1));dfs(x*10+(x%10-1));}
	s.insert(x*10+(x%10));
	dfs(x*10+(x%10));
	
}
int main()
{
	dfs(1);
	dfs(2);
	dfs(3);
	dfs(4);
	dfs(5);
	dfs(6);
	dfs(7);
	dfs(8);
	dfs(9);
	vector<ll> a;
	for(auto i: s)a.push_back(i);
	int k;
	cin>>k;
	cout<<a[k-1];
	
}

Measured memory_bytes: 6648
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n,m = inpm()
    dic = defaultdict(int)
    x = 0
    y = 0
    for _ in range(m):
        ps = inpls()
        ps[0] = int(ps[0])
        if ps[1] == 'WA':
            dic[ps[0]] += 1
        elif ps[1] == 'AC' and dic[ps[0]]<10**6:
            x += 1
            y += dic[ps[0]]
            dic[ps[0]]= 10**6
    print(x,y)



if __name__ == "__main__":
    main()

Measured memory_bytes: 57940
import sys
read = sys.stdin.read
def main():
    n = int(input())
    a = list(map(int, read().split()))
    odd = 0
    div4 = 0
    div2 = 0
    for ae in a:
        odd += ae % 2 != 0
        div4 += ae % 4 == 0
        div2 += ae % 2 == 0 and ae % 4 != 0
    div2r = div2 % 2
    if odd +div2r  > div4 + 1:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 19956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};

int main()
{
    int h,w; cin >> h >> w;
    vector<string> a;

    for( int i = 0; i < h; ++i )
    {
        string s; cin >> s;
        a.push_back(s);
    }
    vector< vector<int> > color(h,vector<int>(w,-1));
    vector< vector<int> > dist(h,vector<int>(w,0));
    int z = 0;
    for( int i = 0; i < h; ++i )
    {
        for( int j = 0; j < w; ++j )
        {
            if( a[i][j] == '#' )
            {
                color[i][j] = 1;
                z++;
            }
        }
    }

    int count = 0;
    int cnt = 0;
    queue< pair<int,int> > q;
    for( int i = 0; i < h; ++i )
    {
        for( int j = 0; j < w; ++j )
        {
            if( a[i][j] == '#' )
            {
                q.push(make_pair(i,j));
                cnt++;
            }
        }
    }
    
    while( !q.empty() )
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        for( int i = 0; i < 4; ++i )
        {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if( nx < 0 || ny < 0 || nx >= h || ny >= w )
            {
                continue;
            }
            else if( color[nx][ny] != -1 )
            {
                continue;
            }
            color[nx][ny] = 1;
            q.push(make_pair(nx,ny));
            dist[nx][ny] = dist[x][y] + 1;
        }
    }
    
    int max = -100;
    for( int i = 0; i < h; ++i )
    {
        for( int j = 0; j < w; ++j )
        {
            if( max < dist[i][j] )
            {
                max = dist[i][j];
            }
        }
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 17424
n, s = map(int, input().split())
A = list(map(int, input().split()))

MOD = 998244353
 
# dp[i][j] = i 番目までの選択をして、1 つめの選択肢を選んだ k に対する ak の和が j であるような場合の数
dp = [[0] * (s + 1) for _ in range(n + 1)]
dp[0][0] = 1

for i in range(n):
  for j in range(s + 1):
    dp[i + 1][j] += dp[i][j] * 2
    dp[i + 1][j] %= MOD
    if j + A[i] <= s:
      dp[i + 1][j + A[i]] += dp[i][j]
      dp[i + 1][j + A[i]] %= MOD

print(dp[-1][-1])

Measured memory_bytes: 139076
#include <stdio.h>

int main(void)
{
    int a, b, x;
    
    while (1) {
        scanf("%d %d", &a, &b);
        
        if (a == 0 && b == 0)   break;
        
        if (a > b)
        {
            x = a;
            a = b;
            b = x;
        }
        printf("%d %d\n", a, b);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 55;
vector <int> G[N];
vector < pair <int, int> > edge;
#define fi first
#define se second
int vis[N], fa[N],dep[N],  n, m;
LL path[N][N];
map < pair <int, int> , int > no;
vector < pair <int, int> > con;
void DFS(int u, int f) {
	vis[u] = true;
	fa[u] = f;
	dep[u] = dep[f] + 1;
	for (auto v:G[u]) {
		if (!vis[v]) DFS(v, u); 
	}
}
void __debug_move(int x, int y) {
//	cerr << "DEBUG:" << x << "->" << y << endl;
}
void __debug_ins(int x) {
//	cerr << "DEBUG:INS " << x << endl;
}
void getPath(int x, int y) {
//	cerr << "CALL GETPATH(" << x << ',' << y << ")" << endl;
	int xx = x, yy = y;
	if (dep[x] > dep[y]) swap(x, y);
	while (dep[y] != dep[x]) {
		__debug_move(y, fa[y]);

		path[xx][yy] |= lshll(no[mp(y, fa[y])]); __debug_ins(no[mp(y, fa[y])]);		y = fa[y];
	}
	while (x != y) {
		__debug_move(x, fa[x]);
		path[xx][yy] |= lshll(no[mp(x, fa[x])]); __debug_ins(no[mp(x, fa[x])]);x = fa[x];
		__debug_move(y, fa[y]); 
		path[xx][yy] |= lshll(no[mp(y, fa[y])]); __debug_ins(no[mp(y, fa[y])]);	y = fa[y]; 
	}
////	cerr << "path[" << xx << "][" << yy  << "] = " << path[xx][yy] << endl;
} 
LL calc(int x) {
	LL msk = 0;
	for (int i = 0; i < m; i++) {
		if (x & lsh(i)) {
			msk |= path[con[i].fi][con[i].se];
		}
	}
	return __builtin_popcountll(msk);
}
int main() {
	cin >> n;
	repn(i, n - 1) {
		int u, v;
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
		edge.pb(mp(u, v));
		no[mp(u, v)] = i;
//		cerr << u << ' ' << v << " encoded as " << i << endl; 
		no[mp(v, u)] = i;
	}
	DFS(1, 0);
	fa[1] = 1;
//	repn(i, n) cerr << fa[i] << ' '; cerr << endl;
	repn(i, n) for (int j = i + 1; j <= n; j++) getPath(i, j);
	cin >> m;
	LL ans = 0;
	repn(i, m) {
		int x, y;
		cin >> x >> y;
		con.pb(mp(x, y));
	}
	for (LL i = 0; i < lshll(m); i++) {
		int sz = __builtin_popcountll(i);
	//	cerr << lshll(n - 1 - calc(i)) << endl;
		if (sz % 2 == 0)ans += lshll(n - 1 - calc(i));
		else ans -= lshll(n - 1 - calc(i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var N, M, ans int

type PX struct {
	P, X int
}

func main() {
	fmt.Scan(&N)
	T := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&T[i])
		ans += T[i]
	}

	fmt.Scan(&M)
	m := make([]PX, M)
	for i := 0; i < M; i++ {
		var p, x int
		fmt.Scan(&p, &x)
		m[i] = PX{p, x}
	}

	for i := 0; i < M; i++ {
		fmt.Println(ans - T[m[i].P-1] + m[i].X)
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll c=min(x/d,k);
    x-=(c*d);
    k-=c;
    ll ans=x;
    if(k&1)
    {
        ans=min(abs(ans-d),abs(ans+d));
    }
    cout<<ans<<endl;



    return 0;
}


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

int main()
{
    string str;

    while( getline( cin, str ) )
    {
        if( str == "END OF INPUT" )
            break;

        int cnt = 0;
        for( int i = 0; i < str.size(); i++ )
        {
            if( str[i] != ' ' )
                cnt++;
            else
            {
                cout << cnt;
                cnt = 0;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<ll> p(n), mi(n);
    rep(i, n)cin >> p.at(i);
    mi[0] = p.at(0);
    REP(i, n-1){
        mi[i] = min(mi[i-1], p.at(i));
    }
    ll ans = 0;
    rep(i, n){
        if(mi[i] >= p.at(i))ans++;
    }
    cout << ans << endl;
}

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

using i64 = int64_t;

string func(int n){
    string res = "";
    for(int i=0;i<3;++i){
        res.insert(res.begin(), (char)('0'+(n%10)));
        n /= 10;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<1000;++i){
        string t = func(i);
        int idx = 0;
        for(int j=0;j<n;++j){
            if(s[j] == t[idx]){
                idx++;
                if(idx == 3){
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*ex4_1
series2*/
 
# include <stdio.h>
# include <math.h>
int main(void){
    //各文字の箱を作って読み取り
    int tree,range;
    scanf("%d %d", &tree,&range);
    //一人当たり監視できる木は2*range+1である。余りがある場合はもう一人担当が必要。余りを表現するためにintから型変換
    printf("%d",(int)ceil((float)tree/(2*range+1)));
    return 0;
}


Measured memory_bytes: 128
S=input()
K=int(input())

SL=list(S)
seq=0
for i in range(len(SL)-1):
  if SL[i]==SL[i+1]:
    SL[i+1]=SL[i+1].upper()
    seq+=1

if K==1 or SL[0]!=SL[-1]:
  print(seq*K)
else:
  SL2=list(S)
  SL2[0]="#"
  seq2=1
  for i in range(1,len(SL2)-1):
    if SL2[i]==SL2[i+1]:
      SL2[i+1]=SL2[i+1].upper()
      seq2+=1
  
  if SL2[-1]!=S[0]:
    if K%2==0:
      print((seq+seq2)*(K//2))
    else:
      print(seq*((K+1)//2)+seq2*(K//2))
  else:
    print(seq+seq2*(K-1))

Measured memory_bytes: 3064
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

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

    int s, w;
    cin >> s >> w;
    if(w >= s)puts("unsafe");
    else puts("safe");
    return 0;
}
// Write Here


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#define ll long long
#define INF 100000000000
#define N 10000000
using namespace std;


int main(void){
    ll n,m;
    ll k;
    cin>>n>>m>>k;
    ll a[n+1],b[m+1];
    
    a[0]=0;
    for (ll i=1; i<=n; i++){
        ll p;
        cin>>p;
        a[i]=a[i-1]+p;
    }
    
    b[0]=0;
    for (ll i=1; i<=m; i++){
        ll p;
        cin>>p;
        b[i]=b[i-1]+p;
    }
    
    vector<ll> bb;
    for (ll i=0; i<=m; i++){
        bb.push_back(b[i]);
    }
    
    ll ans=0;
    for(ll i=0; i<=n; i++){
        if (k<a[i]) break;
        ll x=k-a[i];
        
        auto it=upper_bound(bb.begin(),bb.end(),x);
        ll index=it-bb.begin()-1;
        
        if(x<b[1]) index=0;
        if(x>=b[m]) index=m;
        
        if (ans<index+i) ans=index+i;
        
        //cout<<x<<" "<<b[m]<<" "<<index<<endl;
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 8488
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int mx = 0, mn = MOD;

map<int,int> co;

int main() {
    int n; cin >> n;
    vi a(n); F0R(i,n) {
        cin >> a[i];
        co[a[i]] ++;
        mx = max(mx,a[i]);
        mn = min(mn,a[i]);
    }
    if (mx-mn > 1) {
        cout << "No";
        return 0;
    }
    if (mx == mn) {
        if (mx == n-1) {
            cout << "Yes";
            return 0;
        }
        int minposi = 1; // all equal to S
        int maxposi = n/2;
        if (minposi <= mx && mx <= maxposi) cout << "Yes";
        else cout << "No";
    } else {
        int minposi = co[mn]+1;
        int maxposi = co[mn]+co[mx]/2;
        if (minposi <= mx && mx <= maxposi) cout << "Yes"; 
        else cout << "No";
    }
}

Measured memory_bytes: 5376
mod = 10**9+7
N, M = map(int, input().split())
A_ = [int(input()) for _ in range(M)]
A = [0] * (N+3)
for a in A_:
    A[a] = 1
dp = [0] * (N+3)
dp[0] = 1
for i in range(1, N+1):
    if A[i-1] == 0:
        dp[i] += dp[i-1]
    if A[i-2] == 0:
        dp[i] += dp[i-2]
    dp[i] %= mod
print(dp[N])


Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std;
int x, y;
int main() {
    cin >> x >> y;
    int a[12] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
    if(a[x-1] == a[y-1]) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ReadLine();
        var re = 0;
        for (var i = 0; i < 4; i++)
            if (num[i] == '2') re++;
        WriteLine(re);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

int main(void){
    long long n, k,sum;
    cin >> n >> k;
    sum = k;
    for (int i = 0; i < n - 1; i++){
        sum *= (k - 1);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
    /*
        Problem URL : http://agc001.contest.atcoder.jp/tasks/agc001_b

        Score  :
        Result :
        Time   : ms
        Memory : KB
     */

    ini_set('display_errors', 'Off');
    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    fscanf(STDIN, "%d %d", $N, $X);

    function uec($a, $b) {
        if (abs($a - $b) == 1) return 1;
        while ($a != $b) {
            $c = floor($a / $b) - 1;
            if ($c < 1) $c = 1;
            if ($a > $b) {
                $a -= $b * $c;
            } else {
                $b -= $a * $c;
            }
        }
        return $a;
    }

    echo ($N - uec($N, $X)) * 3 . "\n";


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

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin >> a[i];

  vector< vector<int> > c(H,vector<int>(W));
  int n=1,k=0;
  for(int i=0;i<H;i++){
    if(i%2==0){
      for(int j=0;j<W;j++){
        if(a[k] == 0) {n++; k++;}
        a[k]--;
        c[i][j] = n;
      }
    }else{
      for(int j=W-1;j>=0;j--){
        if(a[k] == 0) {n++; k++;}
        a[k]--;
        c[i][j] = n;
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j) cout << " ";
      cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  vector<int> vec(a);
  int ans = 0;
  for (int i = 0; i < a; i++) cin >> vec.at(i);
  if (a == 1) ans++;
  for (int i = 0; i < a - 1; i++) {
    if (vec[i] == vec[i + 1]) continue;
    else if (vec[i] < vec[i + 1]) {
      ans++;
      while (vec[i] <= vec[i + 1] && i < a) i++;
      if (i == a - 2 && vec[i] > vec[i + 1]) ans++;
    }
    else if (vec[i] > vec[i + 1]) {
      ans++;
      while (vec[i] >= vec[i + 1] && i < a) i++;
      if (i == a - 2 && vec[i] < vec[i + 1]) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

#define N 2000000

void maxHeapInsert(int);
int extractMax();
void maxHeapify(int);

int H[N];
int heapSize;


int main()
{
  int n, i, key;
  char str[8];
  
  heapSize=0;
  for(i=0; i<N; i++)
    {
      scanf("%s", str);
      if(str[0]=='i')
	{
	  scanf("%d", &key);
	  maxHeapInsert(key);
	}
      else if(str[1]=='x')
	{
	  printf("%d\n", extractMax());
	}
      else
	break;
    }
  return 0;
}

int extractMax()
{
  int max = H[0];

  H[0]=H[heapSize-1];
  heapSize--;
  maxHeapify(0);
  return max;
}
void maxHeapInsert(int key)
{
  int i, tmp;
  
  H[heapSize]=key;
  heapSize++;
  i=heapSize;

  if(i/2 >= 1)
    {
      while(H[i/2 -1] <= H[i-1])
	{
	  tmp = H[(i)/2 -1];
	  H[(i)/2 -1] = H[i-1];
	  H[i-1] = tmp;
	  if((i/=2) <= 1) break;
	}
    }
}
void maxHeapify(int i)
{
  int maxi=i;
  int tmp;

  if((i+1)*2 <= heapSize)
    {
      if(H[(i+1)*2 -1] >= H[i])
	maxi = (i+1)*2 -1;
    }
  if((i+1)*2 +1 <= heapSize)
    if(H[(i+1)*2] >= H[i])
      if(H[(i+1)*2] >= H[maxi])
	maxi = (i+1)*2;

  if(maxi != i)
    {
      tmp = H[i];
      H[i] = H[maxi];
      H[maxi] = tmp;
      
      maxHeapify(maxi);
    }
}

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

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

  vector<int> x(N),y(N);
  vector<int> xary,yary;

  for(int i=0;i<N;++i){
    cin >> x[i] >> y[i];
    xary.push_back(x[i]);
    yary.push_back(y[i]);
  }

  sort(begin(xary),end(xary));
  sort(begin(yary),end(yary));

  long long ans = 1LL * (xary[N-1] - xary[0]) * (yary[N-1] - yary[0]);

  for(int xi=0; xi<N; ++xi){
    for(int xj=xi+1;xj<N; ++xj){
      for(int yi=0; yi<N; ++yi){
        for(int yj=yi+1; yj<N; ++yj){
          int cnt = 0;
          for(int i=0;i<N;++i){
            if(xary[xi]<=x[i] and x[i]<=xary[xj] and yary[yi]<=y[i] and y[i]<=yary[yj]){
              cnt += 1;
            }
          }
          if(cnt>=K){
            ans = min(ans,1LL*(xary[xj]-xary[xi])*(yary[yj]-yary[yi]));
          }
        }
      }
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e5 + 5;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	ll n, u, v;
	cin >> n;
	ll res = n;
	for (ll i = 1; i < n; i++) {
		cin >> u >> v;
		if (u > v)
			swap(u, v);
		res += (i + 1) * (n - i);
		res -= u * (n - v + 1);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner tan = new Scanner(System.in);
        int n,i=0,l;
        n = tan.nextInt();
        String st=tan.next();
        l=st.length();
        for(char c : st.toCharArray()){i++;
            System.out.print(c);
            if(i==n)
                break;
        }
        if(l>n)
            System.out.println("...");
        else
            System.out.println();
    }
}


Measured memory_bytes: 35776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
int main(){
 
int N; cin >> N;
vector<int> a(N);
for(int i = 1; i <= N;i++) cin >> a[i];
int count = 0;
for(int i = 1; i <= N; i++){
	if(a[a[i]] == i){
		count++;
	}
}
cout << count / 2<< endl;
}

Measured memory_bytes: 640
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  string S;
  cin >> S;
  int ans = 700;
  for(int i=0; i <3; ++i){
    if(S[i] == 'o') ans += 100;
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

ll n, m, a, b;

signed main(){
//	freopen("PERFECT1.inp","r",stdin);
//	freopen("PERFECT1.out","w",stdout);
//	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m >> a >> b;
	f(i,1,n){
		f(j,1,m){
			if(i <= b){
				if(j <= a) cout << 1;
				else cout << 0;
			}else{
				if(j <= a) cout << 0;
				else cout << 1;
			}
		}
		cout <<"\n";
	}
}



Measured memory_bytes: 1280
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

template <typename T, class F = function<T(const T&, const T&)>>
struct SparseTable {
  int n;
  vector<vector<T>> sp;
  F func;

  SparseTable() {}

  void init(const vector<T>& a, const F& f) {
    func = f;
    n = static_cast<int>(a.size());
    int max_log = 32 - __builtin_clz(n);
    sp.resize(max_log);
    sp[0] = a;
    for (int j = 1; j < max_log; ++j) {
      sp[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); ++i) {
        sp[j][i] = func(sp[j - 1][i], sp[j - 1][i + (1 << (j - 1))]);
      }
    }
  }

  T query(int l, int r) const {
    int lg = 32 - __builtin_clz(r - l + 1) - 1;
    return func(sp[lg][l], sp[lg][r - (1 << lg) + 1]);
  }
};

SparseTable<int> sparse_table_gcd, sparse_table_min;

map<int, vector<int>> occ;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int x;
  cin >> x;
  cout << 360 / __gcd(360, x) << endl;

  return 0;
}

Measured memory_bytes: 3648