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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N, A, B;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    cin >> A >> B;
    cout << (A + B) << endl;
  }
	return 0;
}



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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	double a,b;
	vector<int> ans(4);
	vector<int> ans_2(4);
	
	while(cin >> a >> b)
	{
		if(a >= 1.1) ans[0]++;
		else if(a >= 0.6) ans[1]++;
		else if(a >= 0.2) ans[2]++;
		else ans[3]++;

		if(b >= 1.1) ans_2[0]++;
		else if(b >= 0.6) ans_2[1]++;
		else if(b >= 0.2) ans_2[2]++;
		else ans_2[3]++;
	}

	rep(i,4)
	{
		cout << ans[i] << " " << ans_2[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a<b&&b>(a+w)){
		cout<<abs(b-(a+w));
	}else if(a>b){
		cout<<abs(a-(b+w));
	}else if(a<=b<=(a+w)){
		cout<<"0";
	}
}

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

using namespace std;

vector<long long> ans;
vector<pair<int, int>> bridges;

vector<int> parent;

void init(int n) {
	parent = vector<int>(n, -1);
}


int find(int x) {
	if (parent[x] < 0) {
		return x;
	}
	else {
		return parent[x] = find(parent[x]);
	}
}

int size(int x) {
	return -parent[find(x)];
}

bool unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return false;

	if (size(x) < size(y)) swap(x, y);

	parent[x] += parent[y];
	parent[y] = x;

	return true;
}


int main() {
	int N, M;
	long long dans;

	cin >> N >> M;
	init(N);

	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		bridges.push_back(make_pair(x - 1, y - 1));
	}

	dans = ((long long)N*(N - 1)) / 2;
	ans.insert(ans.begin(), dans);

	for (int i = M - 1; i >= 1; i--) {
		if (find(bridges[i].first) == find(bridges[i].second)) {
			ans.insert(ans.begin(), dans);
		}
		else {
			dans -= size(bridges[i].first) * size(bridges[i].second);
			ans.insert(ans.begin(), dans);
			unite(bridges[i].first, bridges[i].second);
		}
	}

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

	return 0;
}

Measured memory_bytes: 3444
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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



int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	if (a <= x && x <= a + b) wrln("YES");
	else wrln("NO");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const ll CFMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF (((int)1e9) + 7)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,n,m) for(int i=(n);i<(m);i++)
#define vec vector
#define __ <<' '<<
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int dp[3010][3010];
pii tran[3010][3010];
void solve(){
    string a, b;
    
    cin >> a >> b;
    
    int n = sz(a), m = sz(b);
    
    rep1(i,n) rep1(j,m){
        dp[i][j] = max({dp[i-1][j], dp[i][j-1], dp[i-1][j-1] + (a[i-1] == b[j-1])});
        
        if(dp[i][j] == dp[i-1][j])
            tran[i][j] = {-1,0};
        else if(dp[i][j] == dp[i][j-1])
            tran[i][j] = {0,-1};
        else
            tran[i][j] = {-1,-1};
        //cout << tran[i][j].F << '-' << tran[i][j].S << " \n"[j == m];
    }
    
    int x = n, y = m;
    int tmpx, tmpy;
    vec<char> ans;
    
    while(x > 0 && y > 0){
        if(tran[x][y] == MP(-1,-1))
            ans.EB(a[x-1]);
        tmpx = tran[x][y].F;
        tmpy = tran[x][y].S;
        
        x += tmpx;
        y += tmpy;
    }
    
    for(int i=sz(ans)-1;i>=0;i--)
        cout << ans[i] ;
    cout << '\n';
    
}

 
int main(){
    int t = 1;
    
    while(t--){
        solve();
    }
}


Measured memory_bytes: 106368
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
used = [-1]*N 
renketu = []
index = 0
def dfs(fr,cur,parent,index,li):
    Next = fr[cur]
    Next -= 1
    for chi in [Next]:
        if chi == parent or used[chi] != -1:
            continue
        used[chi] = index
        li.append(chi)
        dfs(fr,chi,cur,index,li)
for i in range(N):
    if used[i] != -1:
        continue
    li = [i]
    used[i] = index
    dfs(P,i,-1,index,li)
    index += 1
    renketu.append(li)
n = len(renketu)
ans = -1*10**20
for i in range(n):
    li = renketu[i]
    nn = len(li)
    val = 0
    nnow = li[0]
    for jj in range(nn):
        val += C[P[nnow]-1]
        nnow = P[nnow]-1
    if val <= 0:
        for k in range(nn):
            now = li[k]
            v = 0
            for j in range(nn):
                v += C[P[now]-1]
                ans = max(ans,v)
                now = P[now]-1
    else:
        vvv = val*(K//nn)
        vvv -= val
        nnn = K % nn
        nnn += nn
        for k in range(nn):
            now = li[k]
            v = 0
            for j in range(nnn):
                v += C[P[now]-1]
                now = P[now]-1
                ans = max(ans,vvv+v)
print(ans)

    

        


Measured memory_bytes: 96940
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a_list = [int(x) for x in stdin.readline().rstrip().split()]

pick = [ x for x in a_list if x >= sum(a_list) / 4 / m]

print("Yes" if len(pick) >= m else "No")

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	int ans[1001][1001];
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			ans[i][j] = n*i + m*j - 2*i*j;
		}
	}
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(ans[i][j]==k){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <cstdio> //tolower?
using namespace std;
     
int main(){
    int n,k;
    string  s;
    cin >>n >>k >>s;
//transform(s.begin(),s.end(),s.begin,tolower);
for(int i=0; i<n; i++){
    if(i==k-1)s[i]=tolower(s[i]);//小文字に変換
}
cout <<s <<endl;
     
    return 0;
    }

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
ans,con = [0]*2, 0
for i in range(f//100+1):
    #操作1,2はどちらか片方だけで良い.両方やると濃度が下がる?
    if i%a==0 or i%b==0:
        w=i*100 #水の量を基準にして, 砂糖の量を決めていく.
        x=min(f-w, i*e) # 残り加えられる砂糖の量
        s=0
        
        # 砂糖を操作3で加える
        for j in range(x//c+1):
            s3 = j*c
            #操作4も織り交ぜて, 砂糖の最大値を見つける.
            s=max(s, s3+((x-s3)//d)*d)
            
        if w!=0: #ゼロ割回避
            if con<=(100*s)/(w+s):
                ans = [w,s]
                con = (100*s)/(w+s)
print(sum(ans), ans[1])

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


int main(){
  int n,h,w;
  int cnt = 0;
  cin >> n >> h >> w;
  int in_h;
  int in_w;

  for(int i = 0; i < n; i ++){
    cin>> in_h >> in_w;
    if(in_h >= h && in_w >= w){
    	cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
INF = 10 ** 11
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
from heapq import heapify,heappush,heappop   

def main():
    n = int(input())
    p = [int(input()) for _ in range(n)]
    p.sort()
    ans = 0
    for i in range(n - 1):
        ans += p[i]
    ans += p[-1]//2
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 3828
fun main(args: Array<String>)
{
    val (n, k) = readLine()!!.split(" ").map{ it.toInt() }
    val h = readLine()!!.split(" ").map{ it.toInt() }.toIntArray()

    var cnt = 0
    for (i in 0 until n)
        if (h[i] >= k) cnt++

    println(cnt)
}


Measured memory_bytes: 48264
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 15 12:28:59 JST 2020
 **/

const string RCP = "rsp";
signed main() {
    Int n, K;
    cin >> n >> K;
    vector<Int> scores(3);
    REP(i, 3) cin >> scores[i];
    string t;
    cin >> t;
    vector<Int> used(n, -1);
    Int ans = 0;
    REP(i, n) {
        Int x = (RCP.find(t[i]) + 2) % 3;
        if (i - K < 0 || used[i - K] != x) {
            used[i] = x;
            ans += scores[x];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1232
H, W = map(int, input().split())
S = [input() for _ in range(H)]
horizontal_lights = [[0]*W for _ in range(H)]
vertical_lights = [[0]*W for _ in range(H)]

for h in range(H):
    num = 0
    s = 0
    t = 0
    while t < W:
        if S[h][t] == '#':
            for k in range(s, t):
                horizontal_lights[h][k] = num
            num = 0
            t += 1
            s = t
        else:
            t += 1
            num += 1
    for k in range(s, t):
        horizontal_lights[h][k] = num


for w in range(W):
    s = 0
    t = 0
    num = 0
    while t < H:
        if S[t][w] == '#':
            for k in range(s, t):
                vertical_lights[k][w] = num
            num = 0
            t += 1
            s = t
        else:
            t += 1
            num += 1
    for k in range(s, t):
        vertical_lights[k][w] = num

ans = 0
for h, line in enumerate(S):
    for w, c in enumerate(line):
        if c == '.':
            tmp = horizontal_lights[h][w] + vertical_lights[h][w]
            ans = max(ans, tmp-1)
print(ans)



Measured memory_bytes: 123224
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll n, k; cin >> n >> k;
    map<ll, ll>mp;
    rep(i, n){
        ll a, b; cin >> a >> b;
        mp[a] += b;
    }
    ll ans, cnt = 0;
    for(ll i=1; i<= 100000; i++){
        ll num = mp[i];
        cnt += num;
        if(cnt >= k){ ans = i; break;}
    }
    cout << ans << ln;
}


Measured memory_bytes: 6528
using System;

namespace atcoder_BegginerContest94_Question1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);
            int x = Int32.Parse(input[2]);

            if (a <= x)
            {
                if (a + b >= x)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG
/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"
#else
#define print(...)
#endif

void solve() {
    ll K;
    cin >> K;
    string s = "ACL";
    string ans = "";
    rep(i, K) {
        ans += s;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
    int n, x;
    
    int i, j, k, count = 0;
    while(scanf("%d %d", &n, &x))
    {
        count = 0;
        
        if(n == 0 && x == 0)
        {
            return 0;
        }

        for(i = 1; i <= n; ++i)
        {
            for(j = i + 1; j <= n; ++j)
            {
                for(k = j + 1; k <= n; ++k)
                {
                    count += (i + j + k == x);
                }
            }
        }

        printf("%d\n", count);
    }
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int n;
int p[14][14][8];
void work(int v){
	//cout<<v<<endl;
	int l=0,a[14];
	memset(a,0,sizeof(a));
	while(v){
		a[++l] = v%10;
		v /= 10;
	}
	p[a[1]][a[l]][l] ++;
}
int main(){
	memset(p,0,sizeof(p));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		work(i);
	}
	ll ans=0;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			for(int k=1;k<=8;k++){
				for(int l=1;l<=8;l++){
					ll delta;
					delta = p[i][j][k] * p[j][i][l];
					ans += delta;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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


int main() {
    int n, q, a_i, b, c;
    vector <int> a(100000,0);
    cin >> n;
    long long sum=0;
    for (int i=0; i<n; i++){
        cin >> a_i;
        a[a_i-1] ++;
        sum += a_i;
    }
    cin >> q;
    for (int i=0; i<q; i++){
        cin >> b >> c;
        sum += a[b-1] * (c - b);
        cout << sum << endl;
        a[c-1] += a[b-1];
        a[b-1] = 0;
    }
    return 0;
}

Measured memory_bytes: 3716
N, Y = map(int, input().split())
for x in range(min(Y // 10000 + 1, N + 1)):
  for y in range(min(Y // 5000 + 1, N + 1)):
    r = Y - x * 10000 - y * 5000
    if r >= 0 and r // 1000 == N - x - y: 
      print(x, y, r // 1000)
      exit()
      
print(-1, -1, -1)

Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

typedef pair<double,double> P;
typedef vector<P> PV;

double room, w[10], wts[1 << 10];
int s;

bool onlyOne(int bit){
  int cnt = 0;
  for(int i = 0; i < s; i++){
    if(bit & (1 << i)){
      cnt++;
    }
  }
  return cnt == 1;
}

PV solve(double x, int rem){
  PV res;

  if(onlyOne(rem)){
    res.push_back(P(x, x));
    return res;
  }

  for(int l = 1; l <= rem; l++){
    if((rem | l) != rem) continue;

    double wl = wts[l];

    for(int r = 1; r <= rem; r++){
      if(l & r) continue;
      if((l | r) != rem) continue;

      double wr = wts[r];
      double a = wr / (wl + wr);

      PV pvl = solve(x - a, l);
      PV pvr = solve(x + (1.0 - a), r);

      for(int i = 0; i < pvl.size(); i++){
	for(int j = 0; j < pvr.size(); j++){
	  double L = min(pvl[i].first, pvr[j].first);
	  double R = max(pvl[i].second, pvr[j].second);
	  if(R - L > room) continue;
	  res.push_back(P(L, R));
	}
      }
    }
  }

  return res;
}

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

  while(T--){
    cin >> room >> s;
    for(int i = 0; i < s; i++){
      cin >> w[i];
    }

    for(int i = 0; i < (1 << s); i++){
      wts[i] = 0;

      for(int j = 0; j < s; j++){
	if(i & (1 << j)){
	  wts[i] += w[j];
	}
      }
    }

    PV pv = solve(0, (1 << s) - 1);

    double ans = -1;

    for(int i = 0; i < pv.size(); i++){
      ans = max(ans, pv[i].second - pv[i].first);
    }

    if(ans == -1){
      cout << -1 << endl;
    }
    else{
      cout << fixed << setprecision(10) << ans << endl;
    }
  }
}

Measured memory_bytes: 2224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;

  char res[10];
  int len = 0;
  REP(i,s.length()){
    if(s[i] == 'B'){
      if(len != 0){
        len--;
      }
    }else{
      res[len] = s[i];
      len++;
    }
  }

  REP(i,len){
    cout << res[i];
  }
  cout << "\n";

  return 0;
}



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

void solve(long long N, long long K, vector<long long> x, vector<long long> y){
	long long res = LLONG_MAX;
	for (int i=0; i<N; i++) {
		for (int j=0; j<N; j++) {
			if (x[i]>=x[j]) continue;
			for (int k=0; k<N; k++) {
				for (int l=0; l<N; l++) {
					if (y[k]>=y[l]) continue;
					int count = 0;
					for (int m=0; m<N; m++) {
						if (x[i] <= x[m] && x[m] <= x[j] && y[k] <= y[m] && y[m] <= y[l]) count++;
						if (count >= K) res = min(res, (x[j]-x[i])*(y[l]-y[k]));
					}
				}
			}
		}
	}
	cout << res << endl;
}

int main(){	
	long long N;
	long long K;
	scanf("%lld",&N);
	vector<long long> y(N-1+1);
	vector<long long> x(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	solve(N, K, x, y);
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
import math
input = sys.stdin.readline


def main():
    a, b = map(int, input().split())
    ab = int(str(a) + str(b))
    sqrt_ab = math.sqrt(ab)
    ans = 'Yes'

    if int(sqrt_ab) - sqrt_ab != 0.0:
        ans = 'No'

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t = "";
    cin >> s;
    rep(i,s.length()){
        if (i%2 == 0) t += s[i];
    }
    PRINT(t);
}



Measured memory_bytes: 592
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
my $gcd = sub {
  my ($x, $y) = @_;
  while ($y) {
    my $r = $x % $y;
    $r += $y if $r < 0;
    $x = $y;
    $y = $r;
  }
  return $x;
};
my $ans = $a[0];
for my $i (1..$n-1) {
  $ans = $gcd->($ans, $a[$i]);
}
say $ans;

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

int main(){
	int N,M;
	cin>>N>>M;
	
	int L[M],R[M];
	
	for(int i=0;i<M;i++){
		cin>>L[i];
		cin>>R[i];
	}
	
	sort(L,L+M);
	sort(R,R+M);
	
	int ans;
	
	if(R[0]>=L[M-1])
		ans=R[0]-L[M-1]+1;
	else
		ans=0;
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

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

    int n;
    cin >> n;
    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        ans += a-1;
    }
    cout << ans << endl;
}


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

using namespace std;

#define MAX 1000000

int main()
{
  bitset<MAX + 1> is_prime;
  is_prime.set();
  is_prime[0] = false, is_prime[1] = false;
  for (int i = 2; i * i <= MAX; i++) {
    for (int j = i + i; j <= MAX; j += i) {
      is_prime[j] = false;
    }
  }
  vector<int> prime;
  for (int i = 0; i <= MAX; i++) {
    if (is_prime[i]) {
      prime.push_back(i);
    }
  }
  if (prime.size() < 10000) {
    printf("error\n");
    return 0;
  }

  int N;
  while (scanf("%d ", &N) == 1) {
    if (N == 0) {
      break;
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += prime[i];
    }
    printf("%d\n", sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(A);
  IN(B);
  if (A <= 0 && B >= 0)
    OUT("Zero");
  else if (A > 0)
    OUT("Positive");
  else if (B < 0)
    OUT(((B-A) % 2 == 0 ? "Negative" : "Positive"));

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

const int kMaxN = 100;
const int kMaxM = 100;

int N, M;
string s[kMaxN];
string t[kMaxM];
int ans = 0;

signed main() {
  cin >> N;
  REP(i, N) { cin >> s[i]; }
  cin >> M;
  REP(i, M) { cin >> t[i]; }

  REP(i, N) { ans = MAX(ans, count(s, s+N, s[i]) - count(t, t+M, s[i])); }

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, Q, M, t;
    int table[101];
    while (cin >> N >> Q) {
        if (N == 0 && Q == 0) { break; }

        fill(table, table+101, 0);

        while (N--) {
            cin >> M;
            while (M--) {
                cin >> t;
                table[t]++;
            }
        }
        int max_v = 0, a = 0;
        for (int i = 0; i < 101; i++) {
            if (max_v < table[i]) {
                max_v = table[i];
                a = i;
            }
        }
        cout << (max_v < Q ? 0 : a) << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

const int MAX_L = 1000001;
const int MAX_SQRT_B = 1000001;
bool is_prime_array[MAX_L];
bool is_prime_small[MAX_SQRT_B];

vector<ll> divisor(ll n) {
	vector<ll> res;
	for(ll i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

ll f(ll x) {
	ll rsl = 0;
	while(x > 0) {
		rsl++;
		x /= 10;
	}
	return rsl;
}
		
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N;
	cin >> N;
	vector<ll> v = divisor(N);
	vsort(v);
	vector<ll> v2;
	rep(i, 0, v.size()) v2.push_back(v[v.size() - i - 1]);

	ll rsl = 1e18;
	rep(i, 0, v.size()) {
		rsl = min(rsl, max(f(v[i]), f(v2[i])));
	}

	cout << rsl << endl;
	
}


Measured memory_bytes: 384
#include<stdio.h>

int main()
{
  int l,w,h,n,r,i;

  while(1)
    {
      scanf("%d %d %d",&l,&w,&h);
      if(l==0 && w==0 && h==0)break;
      else
	{
	  scanf("%d",&n);
	  for(i=0;i<n;i++)
	    {
	      scanf("%d",&r);
	      if(r*r*4 > (w*w + l*l) || r*r*4 > (l*l + h*h) || r*r*4 > (w*w + h*h))
		printf("OK\n");
	      else
		printf("NA\n");
	    }
	}
    }
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int>dp(N + 1, 1e9);
	dp[0] = 0;
	int a = 1;
	int b = 1;
	int c = 1;
	for (int i = 1; i < 1 + N; ++i) {
		while (b * 6 <= i) {
			b *= 6;
		}
		while (c * 9 <= i) {
			c *= 9;
		}
		dp[i] = min(min(dp[i - a] + 1, dp[i - b] + 1), dp[i - c] + 1);
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
int n, mx[maxn + 10], fa[maxn + 10];
int f[maxn + 10];
vector<int> g[maxn + 10];
map<int, int> mp[maxn + 10];

int ask(int x, int y) {
	if (mp[x].count(y)) return mp[x][y];
	int ans = 1;
	for (int i = 0; i < (int)g[x].size(); ++i) {
		int e = g[x][i];
		if (e != fa[x] && e < y) ans += ask(e, y);
	}
	return mp[x][y] = ans;
}

void dfsfa(int p) {
	mx[p] = max(mx[fa[p]], fa[p]);
	for (int i = 0; i < (int)g[p].size(); ++i) {
		int e = g[p][i];
		if (e != fa[p]) {
			fa[e] = p; dfsfa(e);
		}
	}
}

void dfs(int p) {
	if (p > 1) f[p] = f[fa[p]] + (p > mx[fa[p]] ? ask(p, mx[p]) : ask(p, mx[p]) - ask(p, mx[fa[p]]));
	for (int i = 0; i < (int)g[p].size(); ++i) {
		int e = g[p][i];
		if (e != fa[p]) dfs(e);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int l, r; scanf("%d%d", &l, &r);
		g[l].push_back(r); g[r].push_back(l);
	}
	dfsfa(1);
	dfs(1);
	for (int i = 2; i <= n; ++i) printf("%d ", f[i]);
}


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

int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d));
  for(int i=0;i<n;i++) {
    for (int j=0;j<d;j++){
      cin >> x[i][j];
    };
  };
  int ans=0;
  for(int i=0;i<n;i++) {
    for(int j=i+1;j<n;j++){
      int dis=0;
      for(int k=0;k<d;k++){
        dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      };
      for(int k=1;k*k<=dis;k++){
        if(k*k==dis) ans++;
      };
    };
  };
  cout << ans << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 10000005;

ll primes[N], v[N];

void solve(){
	int k;
	cin >> k;
	for(int i = 0; i <= k; i++)
		primes[i] = v[i] = 1;
	for(int i = 2; i <= k; i++){
		if(primes[i]){
			for(int j = i ; j <= k; j += i){
				primes[j] = 0;
				int temp = j, qt = 0;
				while((temp % i) == 0)
					temp /= i, qt++;
				v[j] *= (qt+1);
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i <= k; i++)
		ans += i*v[i];
	cout << ans << endl;
}

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


Measured memory_bytes: 159848
input_str = input()
process_flag = 'process'
ans_flag = 'NO'
d_e = ''
ans_list = []

def pre_str_process(now_str):
  ans_list.append(now_str[:5])
  now_str = now_str[5:]
  return now_str

def dream(now_str):
  now_str = pre_str_process(now_str)
  if (now_str == '') or (now_str == 'er'):
    return now_str, 'OK'
  if now_str[:5] == 'dream':
    return now_str, 'dream'
  if now_str[:2] == 'er':
    if now_str[:5] == 'erase':
      return now_str, 'erase'
    if now_str[:7] == 'ererase':
      now_str = now_str[2:]
      return now_str, 'erase'
    if now_str[:7] == 'erdream':
      now_str = now_str[2:]
      return now_str, 'dream'
    else:
      return now_str, 'NG'

  else:
    return now_str, 'NG'

def erase(now_str):
  now_str = pre_str_process(now_str)
  if (now_str == '') or (now_str == 'r'):
    return now_str, 'OK'
  if now_str[0] == 'r':
    now_str = now_str[1:]
    if now_str[:5] == 'dream':
      return now_str, 'dream'
    if now_str[:5] == 'erase':
      return now_str, 'erase'
    else:
      return now_str, 'NG'
  if now_str[:5] == 'erase':
    return now_str, 'erase'
  if now_str[:5] == 'dream':
    return now_str, 'dream'
  else:
    return now_str, 'NG'

first_str = input_str[:5]
process_num = 0
while process_flag == 'process':
  process_num += 1
  if process_num == 1:
    if first_str == 'dream':
      now_str = input_str
      d_e = 'dream'
    elif first_str == 'erase':
      now_str = input_str
      d_e = 'erase'
    else:
      break
  elif d_e == 'dream':
    now_str, d_e = dream(now_str)
  elif d_e == 'erase':
    now_str, d_e = erase(now_str)
  elif d_e == 'OK':
    ans_flag = 'YES'
    break
  elif d_e == 'NG':
    break
print(ans_flag)

Measured memory_bytes: 10160
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
    cin >> n;
    vector<int> v(n + 1, 0);
    int c = 0;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        if (v[i] != i) c++;
    }
    if (c > 2)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}


Measured memory_bytes: 3608
from collections import Counter


def solve(N, As):
    c = Counter(As)
    ans = 0
    for k, v in c.items():
        if k < v:
            ans += v - k
        elif k == v:
            pass
        else:
            ans += v
    return ans

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 18676
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=[[] for _ in range(N)]
    for i in range(N):
        a[i]=LI()
    
    #dp[S]は状態Sから何通りあるか？男性は1から順に，女性マッチング情報がS   
    M=pow(2,N) 
    dp=[0]*M
    dp[0]=1
    
    def bit_cnt(N):
        B=bin(N)
        return B.count("1")

    
    for S in range(M-1):
        if dp[S]==0:
            continue
        man=bit_cnt(S)
        for i in range(N):
            if (S>>i)&1==0:#i桁目が立っていない
                if a[man][i]==1:
                    dp[S+(1<<i)]+=dp[S]
                    dp[S+(1<<i)]%=mod
                        
        
    
    print(dp[-1])

                    
                    
    
        
    

main()


Measured memory_bytes: 59868
#include <iostream>

using namespace std;

int main(){

    int nyuryoku;
    int h,m,s;
    cin >> nyuryoku;

    h=nyuryoku/3600;
    nyuryoku=nyuryoku%3600;
    m=nyuryoku/60;
    s=nyuryoku%60;


    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 3100
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

//計算量はO(log max(a,b))
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

//計算量はO(log max(a,b))
ll lcm(ll x,ll y){
  ll mindata,maxdata;
  mindata=min(x,y);
  maxdata=max(x,y);
  while(maxdata%mindata!=0){
    ll temp;
    temp=maxdata%mindata;
    maxdata=mindata;
    mindata=temp;
  }
  return x*(y/mindata);
}
int main(){
  ll t,ans;
 int N;
 cin>>N;
 cin>>ans;
 for(int i=0;i<N-1;i++){
   cin>>t;
   ans=lcm(ans,t);
 }
 cout<<ans<<endl;
  
}



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

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    String s = sc.next();

    Set<String> len0 = new HashSet<>();
    len0.add("");
    Set<String> len1 = new HashSet<>();
    Set<String> len2 = new HashSet<>();
    Set<String> len3 = new HashSet<>();

    for (int i = 0; i < n; i++) {
      String c = s.substring(i, i + 1);
      for (String l2 : len2) {
        len3.add(l2 + c);
      }
      for (String l1 : len1) {
        len2.add(l1 + c);
      }
      for (String l0 : len0) {
        len1.add(l0 + c);
      }
    }
    os.println(len3.size());
  }
}


Measured memory_bytes: 89664
#include <iostream>
using namespace std;
void exchange(int* x,int* y)
{
    int tmp=*x;
    *x=*y;
    *y=tmp;
}
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]<a[j]){
                exchange(&a[i],&a[j]);
            }
        }
    }
    int suma=0;
    int sumb=0;
    for(int i=0;i<n;i+=2)suma+=a[i];
    for(int i=1;i<n;i+=2)sumb+=a[i];
    cout<<suma-sumb<<'\n';
    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(1e6,0);
    ll x,y,z;
    for(x = 1;x <= 100;++x){
        for(y = 1;y <= 100;++y){
            for(z = 1;z <= 100;++z){
                ll tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                ++a.at(tmp);
            }
        }
    }
    ll ans = 0;
    for(i = 1;i <= n;++i){
        cout << a.at(i) << endl;
    }
    return 0;
}

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

int main(){
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X), B(Y), C(Z);
  for(int i = 0; i < X; ++i) cin >> A[i];
  for(int i = 0; i < Y; ++i) cin >> B[i];
  for(int i = 0; i < Z; ++i) cin >> C[i];
  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());
  sort(C.rbegin(), C.rend());
  vector<long long> AB;
  for(int i = 0; i < X; ++i){
    for(int j = 0; j < Y; ++j){
      long long t = A[i]+B[j];
      AB.push_back(t);
    }
  }
  sort(AB.rbegin(), AB.rend());
  vector<long long> ans;
  for(int i = 0; i < min(K,X*Y); ++i){
    for(int j = 0; j < Z; ++j){
      ans.push_back(AB[i]+C[j]);
    }
  }
  sort(ans.rbegin(), ans.rend());
  for(int i = 0; i < K; ++i) cout << ans[i] << endl;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int x;
  cin>>x;
  if(x==1)cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll f(ll a)
{
    if (a%4 == 0) return a;
    if (a%4 == 1) return 1;
    if (a%4 == 2) return a+1;
    return 0;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << (f(b)^f(a-1)) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int k,n,p[1000],sum,i;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++)	scanf("%d",&p[i]);
	sort(p,p+n);
	sum=0;
	for(i=0;i<k;i++)	sum+=p[i];
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    
    int n;
    cin >> n;
    vector<string> vs;
    char ch;
    bool ok=true;
    rp(i,n){
        string w;
        cin >> w;
        vs.push_back(w);
        if(i>=1&&ch!=w[0]){
            ok=false;
        }
        reverse(all(w));
        ch=w[0];
    }
    sort(all(vs));
    rp(i,n-1){
        if(vs[i]==vs[i+1]) ok=false;
    }
    Yes(ok);
    return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    arr = list(map(int, input().split()))
    arr.sort(reverse=True)

    ascore = 0
    bscore = 0
    for i in range(N):
        if i%2 == 0:
            ascore += arr[i]
        else:
            bscore += arr[i]

    print(ascore - bscore)
    
resolve()

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
    int a,b,i,max=0;
    scanf("%d %d",&a,&b);
    for(i=0;i<2;i++){
        if(a>b){
            max=max+a;
            a--;
        }else{
            max=max+b;
            b--;
        }
    }
    printf("%d",max);
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	REP(i, n + 1) {
		string x = s.substr(0, i), y = s.substr(i, n - i);
		vi a(26, 0), b(26, 0);
		for (auto c : x)a[c - 'a'] = 1;
		for (auto c : y)b[c - 'a'] = 1;
		int cnt = 0;
		REP(i, 26)cnt += a[i] * b[i];
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int rate;
    cin >> rate;
    if(rate < 1200) {
        cout << "ABC" << endl;
    }else if(rate < 2800) {
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<ll> s;
    for (int i = 0; i < n; ++i)
    {
        ll S = 0;
        for (int j = i; j < n; ++j)
        {
            S += a[j];
            s.push_back(S);
        }
    }
    for (ll i = 41; i >= 0; --i)
    {
        vector<ll> nowy;
        for (int j = 0; j < s.size(); ++j)
            if ((s[j] & (1LL << i)) > 0)
                nowy.push_back(s[j]);
        if (nowy.size() >= k)
            s = nowy;
    }
    ll odp = s[0];
    for (int i = 1; i < k; ++i)
        odp &= s[i];
    cout << odp;
    return 0;
}


Measured memory_bytes: 6124
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int n = sc.nextInt();
    int data[] = new int[n];
    int sum = 0;

    for (int i = 0;i<n ;i++ ) {
      data[i] = sc.nextInt();
      sum +=data[i];
    }

    if (sum>=h) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }



  }
}


Measured memory_bytes: 47796
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i],a[i]*=(-1);
    vector<int> nib;
    rep(i,0,n){
        auto j = upper_bound(nib.begin(),nib.end(),a[i]);
        if (j==nib.end()){
            nib.push_back(a[i]);
        }else{
            *j = a[i];
        }
    }
    cout<<nib.size()<<endl;
}

Measured memory_bytes: 4208