akhauriyash/Code-Regression huggingface dataset:
<?php
$n = (int)trim(fgets(STDIN));

$input = explode(' ', trim(fgets(STDIN)));
$vs = [];
foreach ($input as $v) {
	$vs[] = (int)$v;
}

$input = explode(' ', trim(fgets(STDIN)));
$cs = [];
foreach ($input as $v) {
	$cs[] = (int)$v;
}

$sum = 0;
for ($i=0; $i < $n; $i++) { 
	if ($vs[$i] > $cs[$i]) {
		$sum += ($vs[$i] -  $cs[$i]);
	}
}

echo $sum;

Measured memory_bytes: 4856
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
using namespace std;

int main() {
 
  int a,b,c;
  cin >>a>>b;
  c=a-2*b;
  if(c>0){
  cout << c<< endl;
  }else if(c<=0){
    cout << 0<< endl;
  }
}

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

int main() {
  string a, b;
  string c="No";
 
  cin >> a >> b ;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  
  if(a<b)
    c="Yes";
  cout << c << endl;
  
}

Measured memory_bytes: 256
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[]*n for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()
    


Measured memory_bytes: 101436
import java.awt.Point;
import java.awt.Polygon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String tmpStr = br.readLine();

			if(tmpStr == null){
				break;
			}

			String[] tmpArray = tmpStr.split(" ");
			int[] input = new int[8];
			//??\?????¨
			for(int i = 0; i < 8; i++){
				input[i] = (int)(Double.parseDouble(tmpArray[i])*1000);
			}

			int[] x = {input[0],input[2],input[4]};
			int[] y = {input[1],input[3],input[5]};

			Polygon triangle = new Polygon(x, y, 3);


			if(triangle.contains(new Point(input[6],input[7]))){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}

}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

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

	int n, a, b;
	cin >> n >> a >> b;
	int d = b-a;

	cout << (d % 2 ? "Borys" : "Alice") << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,ans;
  scanf("%d",&n);
  
  int b[n];
  for(int i=1;i<n;i++){
    scanf("%d",&b[i]);
  }
  
  ans=0;
  
  for(int i=1;i<n-1;i++){
    if(b[i]>b[i+1]){
      ans=ans+b[i+1];
    }else{
      ans=ans+b[i];
    }
  }
  ans=ans+b[1]+b[n-1];
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main(){
    int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++){
		cout<<a[n-1-i];
		if(i==n-1)
			cout<<endl;
		else
			cout<<" ";
	}
	return 0;
}

Measured memory_bytes: 1160
from collections import Counter

S = [i for i in input()]
c = Counter(S)
if len(c) == 1:
    if len(S) == 1:
        print("YES")
    else:
        print("NO")
elif len(c) == 2:
    if len(S) == 2:
        print("YES")
    else:
        print("NO")
else:
    dif = c.most_common()[0][1] - c.most_common()[2][1]
    print("YES" if dif<=1 else "NO")
    

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
   if(s[s.size()-1] != 's'){
     s += "s";
     cout<<s;
   }
  else{
    s += "es";
      cout<<s;
  }
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

#define iso(i) (i%400==0||(i%100!=0 &&i%4==0))

int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int OY = 366, SUMY = 365;

int main()
{
    int y1, m1, d1, y2, m2, d2;
    while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2)
    {
        if(y1<0 || m1<0 || y1 < 0 || y2 <0 || m2<0 || d2<0) break;

        int ans = 0;
        //cout << "year" <<y1 << " " << y2 << endl;
        if( y1 < y2) for(int i=y1 + 1;i < y2;i++)
        {   
            if(iso(i))ans += OY;
            else ans += SUMY;
        }

        if(y1< y2)
        {
            for(int i = m1+1;i < 13; i++) ans += month[i];
            if(m1 < 2 &&iso(y1) ) ans++;

            for(int i = 1; i< m2;i++) ans += month[i];
            if(m2>=2 && iso(y2))ans++;
        }
        else
        {
            if(m1<m2)for(int i = m1+1;i < m2;i++) ans += month[i];
            if(m1 < 2 && m2 >= 2 && iso(y1)) ans++;
        }

        if(y1 < y2 ||(y1 == y2 && m1 < m2) )
        {
            ans += month[m1] - d1 + 1;
            if(d1 == 2 && iso(y1)) ans++;
            ans += d2 - 1;
        }
        else ans += d2 - d1;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
a = [input().split() for l in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
ans = 'No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      a[i][j] = int(a[i][j])
      if a[i][j] == b[k]:
        a[i][j] = 1
if a[0][0] * a[0][1] * a[0][2] == 1:
  ans = 'Yes'
if a[1][0] * a[1][1] * a[1][2] == 1:
  ans = 'Yes'
if a[2][0] * a[2][1] * a[2][2] == 1:
	ans = 'Yes'
if a[0][0] * a[1][0] * a[2][0] == 1:
  ans = 'Yes'
if a[0][1] * a[1][1] * a[2][1] == 1:
  ans = 'Yes'
if a[0][2] * a[1][2] * a[2][2] == 1:
  ans = 'Yes'
if a[0][0] * a[1][1] * a[2][2] == 1:
  ans = 'Yes'
if a[2][0] * a[1][1] * a[0][2] == 1:
  ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = ReadInts();
            var list = new List<string>();

            var tmp = "";
            for (int i = 0; i < ab[0]; i++)
            {
                tmp += ab[1];
            }
            list.Add(tmp);
            tmp = "";
            for (int i = 0; i < ab[1]; i++)
            {
                tmp += ab[0];
            }
            list.Add(tmp);

            list.Sort();
            WriteLine(list[0]);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

void solve(int N, int K, vector<int> A)
{
    for (int k = 0; k < K; k++)
    {
        vector<int> L(N), R(N);
        for (int i = 0; i < N; i++)
        {
            int l = max(0, i - A.at(i));
            int r = min(N - 1, i + A.at(i));
            L.at(l)++;
            R.at(r)++;
        }
        int t = 0;
        bool finished = true;
        for (int i = 0; i < N; i++)
        {
            t += L.at(i);
            A.at(i) = t;
            if (t < N)
                finished = false;
            t -= R.at(i);
        }
        if (finished)
            break;
    }
    for (int i = 0; i < N - 1; i++)
    {
        cout << A.at(i) << " ";
    }
    cout << A.at(N - 1) << endl;
}

int main()
{
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    solve(N, K, move(A));
    return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>  
   
int a[105][105],b[10000+50];  
   
int main ()  
{  
    int h,w;  
    while(scanf("%d %d",&h,&w)!=EOF)  
    {  
        int i,j,t,k=0;  
        scanf("%d",&t);  
        for(i=0;i<t;i++)  
            scanf("%d",&b[i]);  
        for(i=0;i<h;i++)  
        {  
            if(i%2==0)  
                for(j=0;j<w;j++)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
            if(i%2==1)  
                for(j=w-1;j>=0;j--)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
        }  
        for(i=0;i<h;i++)  
        {  
            for(j=0;j<w-1;j++)  
                printf("%d ",a[i][j]);  
            printf("%d\n",a[i][w-1]);  
        }  
    }  
}  



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n+1), maxline(n+1);
    for (int i = 0; i <= n; i++)
    {
        cin>>a[i];
    }

    maxline[n]=a[n];
    for (int i = n-1; i >= 0; i--)
    {
        maxline[i]=maxline[i+1]+a[i];
    }
    
    ll nowline=1;
    ll ans=0;
    bool ok=true;

    for (int i = 0; i <= n; i++)
    {
        //cout<<i<<"\t"<<nowline<<"\t"<<a[i]<<"\t"<<maxline[i]<<endl;

        if(nowline<a[i])
        {
            ok=false;
            break;
        }
        ans+=nowline;
        nowline-=a[i];
        if(i<n)
        {
            nowline=min(nowline*2, maxline[i+1]);

        }
    }
    if(nowline!=0)
    {
        ok=false;
    }

    if(ok)
    {
        cout<<ans<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
    
    return 0;
}

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

int main() {
  
  int n,k;
  cin >> n >> k;
  
  vector<char> t(n);
  
  rep(i,n) {
    cin >> t.at(i);
    if(i == k-1) t.at(i) += 32;
  }  
  
  rep(i,n) cout << t[i];
  cout << endl;
  
}


Measured memory_bytes: 256
//--- pE ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}


class Solution {
	Reader reader;

	public Solution() {
		reader = new Reader();

		// scanner.nextLine();
		try {
			while (reader.br.ready()) {
				run_case();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}


	private void run_case() {
		int N = ni();
		String str = ns();

		List<BIT> list_st = new ArrayList<>();
		for (int i=0; i<26; i++) list_st.add(new BIT(N+1));
		// SegmentTreeRSQ st = new SegmentTreeRSQ(1, N);
		for (int i=0; i<str.length(); i++) {
			int idx = str.charAt(i) - 'a';
			// int t = (int)list_st.get(idx).query(i + 1, i + 1);
			list_st.get(idx).addVal(i, 1);
		}

		int Q = ni();
		StringBuilder str_sb = new StringBuilder(str);
		for (;Q-->0;) {
			// int[] arr = strToIntArray(scanner.nextLine());
			// String[] vals = scanner.nextLine().split("\\s+");

			int q = ni();

			if (q == 1) {
				int i = ni();
				char c = ns().charAt(0);
				int n = str_sb.charAt(i-1) - 'a';
				int m = c - 'a';

				// int t = (int)list_st.get(n).query(i, i);
				list_st.get(n).addVal(i-1, -1);

				str_sb.setCharAt(i-1, c);

				// t = (int)list_st.get(m).query(i, i);
				list_st.get(m).addVal(i-1, 1);
			} else {
				int l = ni()-1;
				int r = ni()-1;
				int cnt = 0;
				for (int i=0; i<26; i++) {
					if (list_st.get(i).getSum(l, r) > 0) cnt ++;
				}
				System.out.println(cnt);
			}
		}
		return;
	}

	private int ni() {
		return Integer.parseInt(reader.next());
	}

	private String ns() {
		return reader.next();
	}
}

class Reader {
	BufferedReader br;
	StringTokenizer st;

	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
}


class BIT {
	public long[] arr;
	public BIT(int n) {
		arr = new long[n];
	}
	public long getSum(int i) {
		long sum = 0;
		for(i++;i > 0;i -= i&-i)sum += arr[i];
		return sum;
	}
	public long getSum(int l, int r) {
		return getSum(r) - getSum(l-1);
	}
	public void addVal(int i, long v) {
		if(v == 0)return;
		int n = arr.length;
		for(i++;i < n;i += i&-i)arr[i] += v;
	}
}


Measured memory_bytes: 162464
n, m = map(int, raw_input().split())
A = []
b = []
     
for i in range(0, n):
   A += [map(int, raw_input().split())]
   
for j in range(0, m):
   b += [input()]
      
for i in range(0, n):
   c = 0
   for j in range(0, m):
      c += A[i][j] * b[j]
   print c

Measured memory_bytes: 6644
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

struct UnionFind {
  vector<int> par;
  vector<int> sz;
  UnionFind(int n) { init(n); }

  void init(int n) {
    par.resize(n);
    sz.resize(n);
    REP(i, n) {
      par[i] = i;
      sz[i] = 1;
    }
  }

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

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) {
      par[x] = y;
      sz[y] += sz[x];
    } else {
      par[y] = x;
      sz[x] += sz[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

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

int main() {
  int n;
  cin >> n;
  UnionFind uf(200000);
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    uf.unite(x, y + 100000);
  }
  map<int, int> mx, my;
  REP(i, 100000) {
    mx[uf.find(i)]++;
    my[uf.find(i + 100000)]++;
  }
  ll ans = 0;
  REP(i, 200000) ans += 1ll * mx[i] * my[i];
  cout << ans - n << endl;
  return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
 
void solve(){
    string s;
    cin >> s;
    int sum = 0;
    for(int c : s)
        sum += c - '0';
    cout << ((sum % 9 == 0) ? "Yes" : "No");
     
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[200010];
bool can[200010];

int main()
{
	int n,x;cin >> n >> x;
	if(x == 1 || x == 2*n-1)cout << "No" << endl;
	else if(n == 2)
	{
		cout << "Yes" << endl;
		REP(i,3)cout << i+1 << endl;
	}
	else
	{
		cout << "Yes" << endl;
		mp[n] = x;can[x] = true;
		mp[n+1] = x+1;can[x+1] = true;
		mp[n-1] = x-1;can[x-1] = true;
		if(x > 2)
		{
			mp[n+2] = x-2;can[x-2] = true;
		}
		else
		{
			mp[n-2] = x+2;can[x+2] = true;
		}
		int cou = 1;
		rep(i,1,2*n)
		{
			if(mp[i] == 0)
			{
				while(can[cou])cou++;
				cout << cou << endl;
				can[cou] = true;
			}
			else
			{
				cout << mp[i] << endl;
			}
		}
	}
		
	return 0;
}

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

int main(){
  int n;
  std::set<int> st;

  cin >> n;
  for(int i=0; i<n; i++){
    int v;
    cin >> v;
    st.insert(v);
  }

  cout << st.size() << endl;
  
  return 0;
}


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

using namespace std;
#define int long long
const int INF = 200000000007;


  
signed main(){
    int n,m;
    cin>>n>>m;
    int iro[n-1];
    for(int i=0;i<n;i++)iro[i]=-1;
    int x,y,z;
    for(int i=0;i<m;i++){
        cin>>x>>y>>z;
        x-=1;y-=1;
        
        while(iro[x]!=-1)x=iro[x];
        while(iro[y]!=-1)y=iro[y];
        if(x>y)swap(x,y);
        if(x!=y)iro[y]=x;
    }
    int ans=0;
    for(int i=0;i<n;i++)if(iro[i]==-1)ans++;
    cout<<ans;
    
   
    
    
    
    return 0;
}


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

    int x[] = new int[3];
     x[0] = sc.nextInt();
     x[1] = sc.nextInt();
     x[2] = sc.nextInt();

    int sum = x[0]+x[1]+x[2];
    int tag =0;
    Arrays.sort(x);
    int ans = 0;
    if((x[1]-x[0])%2!=0){
      tag=(x[2]+1)*3;
    }else{
      tag=x[2]*3;
    }
    System.out.println((tag-sum)/2);

  }
  

  
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<40;
/* -- template -- */

int main() {
    ll N, K; cin >> N >> K;
    vector<vector<ll>> sushi(N);
    rep(i, N) {
        ll t, d; cin >> t >> d;
        --t;sushi[t].push_back(d);
    }
    for(auto &v : sushi) {
        sort(v.begin(), v.end(), greater<ll>());
        if(v.empty())v.push_back(-LLINF);
    }
    sort(sushi.begin(), sushi.end(), [&](vector<ll> a, vector<ll> b){
        return a[0] > b[0];});
    ll cur = 0;
    priority_queue<long long> que;
    for(int i = 0;i < K;++i) {
        cur += sushi[i][0];
        for(int j = 1; j < sushi[i].size(); ++j){
            que.push(sushi[i][j]);
        }
    }
    for(int i = K; i < N; ++i) {
        for(int j = 0; j < sushi[i].size(); ++j)
            que.push(sushi[i][j]);
    }
    ll ans = cur + K * K;
    for(ll i = K - 1;i > 0;--i){
        ll t = que.top();
        if(sushi[i][0] < t) {
            que.pop();
            cur -= sushi[i][0];
            cur += t;
            que.push(sushi[i][0]);
        }
        ans = max(ans, cur + i * i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8696
#include<bits/stdc++.h>
using namespace std;
int func()
{
	int n;
	double sum=0;
	double x;
	string s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x>>s;
		if(s=="JPY")
			sum+=x;
		else sum+=(x*380000.0);
	}
	cout<<setprecision(8)<<sum<<endl;
}
int main()
{
	func();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;

int A,B,C;

int main(){
	cin>>A>>B>>C;
	if((A%2==0)||(B%2==0)||(C%2==0)) cout<<"0\n";
	else {
		ll Min=1e18+1;
		Min=min(1ll*A*B,1ll*B*C);
		Min=min(Min,1ll*A*C);
		cout<<Min;
	}
	return 0;
} 

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == b&&b == c)printf("%d\n", 1);
	else if (a == b || b == c || a == c)printf("%d\n",2);
	else printf("%d\n", 3);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repc(i, b, e) for(auto i = (b); i != (e); i++)

ll gcd(ll a, ll b) {
    ll r = a % b;
    if(r == 0) {
        return b;
    } else {
        return gcd(b, r);
    }
}

int main() {
    vector<ll> v;
    ll t, n;
    cin >> n;
    rep(i, n) {
        cin >> t;
        v.push_back(t);
    }
    if(n == 2) {
        cout << max(v.at(0), v.at(1)) << endl;
        return 0;
    }
    ll d1;
    d1 = gcd(v.at(0), v.at(2));
    repc(i, 3, n) { d1 = gcd(v.at(i), d1); }
    ll d2;
    d2 = gcd(v.at(1), v.at(2));
    repc(i, 3, n) { d2 = gcd(v.at(i), d2); }
    ll d3, d4;
    d3 = d4 = gcd(v.at(0), v.at(1));
    repc(i, 2, n) {
        ll dd = gcd(v.at(i), d3);
        d4 = gcd(v.at(i), d4);
        if(dd < d3) {
            d4 = max(d3, d4);
        }
        d3 = dd;
    }
    cout << max(max(d1, d2), max(d3, d4)) << endl;
    return 0;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
X, Y, A, B, C = (int(i) for i in input().split())
p = [[int(x), "A"] for x in input().split()]
q = [[int(x), "B"] for x in input().split()]
r = [[int(x), "C"] for x in input().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
apples = p+q+r


apples.sort(reverse=True)
#print(apples)
ans = 0
pend = 0


for hapi, col in apples:
    if col == "C":
        pend += 1
        ans += hapi
    elif col == "A":
        if X > 0:
            ans += hapi
            X -= 1

    elif col == "B":
        if Y>0:
            ans += hapi
            Y -= 1

    if (X < 1 and Y < 1) or X+Y == pend:
        break
    #print(ans)
    #print("XY", X, Y, pend)
#print("XY", X, Y, pend)
print(ans)


Measured memory_bytes: 117612
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sat Apr  4 17:53:33 2020

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


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 
	int n=Int;
	int m=Int;
	int arr[n+1];
	int sum =0;
	For(n) arr[i]=Int,sum+=arr[i];
	int cnt =0;
	for(int i=0;i<n;i++){
		double xx=arr[i];
		double xy=((double)1.0/(4.0*(double)m))*(double)sum;
		if(xx>=xy) cnt++; 
	}
	// cout<<cnt<<endl;
	if(cnt>=m) puts("Yes");
	else puts("No");
 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




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

using namespace std;
int a[2010],n,y;

int main()
{
    cin >> n;
    for(int i = 0;i<n;i++)  cin >> a[i];
    sort(a , a + n);
    int Ans = 0;
    for(int i = 0;i<n;i++){
        for(int j = i + 1;j<n;j++){
            y = lower_bound(a , a + n , a[i] + a[j]) - &a[0];
            Ans+=(y - j - 1);
        }
    }
    cout << Ans;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    map<int, int> m;
    rep(i, n) m[a[i]]++;

    int unique = 0, even = 0;
    for (auto e : m) {
        unique++;
        if (e.second % 2 == 0) even++;
    }

    int ans = unique - even % 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8612
#include <stdio.h>

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

  for(int i = 1; i < 10; i++) {
    for(int j = i; j < 10; j++) {
      if(i*j==n) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_map>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;

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

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

ll INF = 1LL << 60;

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> A, B, Z;// A : 1以上, B : 0未満, Z : 0
	for (int i = 0; i < N; i++) {
		ll x; cin >> x;
		if (x < 0) { B.push_back(x); }
		else if (x == 0) { Z.push_back(x); }
		else { A.push_back(x); }
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	ll minus, plus, zero;
	{
		ll a = A.size();
		ll b = B.size();
		minus = a * b;
		plus = a * (a - 1) / 2 + b * (b - 1) / 2;
		zero = N * (N - 1) / 2 - minus - plus;
	}

	ll ans;
	ll L, R;
	if (K <= minus) {
		K = minus + 1 - K;
		for (auto itr = B.begin(); itr != B.end(); itr++) {
			*itr *= -1;
		}
		sort(B.begin(), B.end());
		L = 1;
		R = INF;

		while (R - L > 1) {
			ll C = (L + R) / 2;
			ll count = 0;
			ll c = -1;
			for (ll i = A.size() - 1; i >= 0; i--) {
				while (c < (ll)(B.size() - 1) && A[i] * B[c + 1] <= C){ c++; }
				count += c + 1;
			}
			if (count >= K) { R = C; }
			else { L = C; }
		}
		ans = -R;
	}
	else if (K <= minus + zero) {
		ans = 0;
	}
	else {
		K -= minus + zero;
		L = 1;
		R = INF;

		for (auto itr = B.begin(); itr != B.end(); itr++) {
			*itr *= -1;
		}
		sort(B.begin(), B.end());

		while (R - L > 1) {
			ll C = (L + R) / 2;
			ll count = 0;

			ll a = -1;
			for (ll i = A.size() - 1; i >= 0; i--) {
				while (a < i - 1 && A[i] * A[a + 1] <= C) { a++; }
				count += a + 1;
				a = max(a - 2, -1LL);
			}
			ll b = -1;
			for (ll i = B.size() - 1; i >= 0; i--) {
				while (b < i - 1 && B[i] * B[b + 1] <= C) { b++; }
				count += b + 1;
				b = max(b - 2, -1LL);
			}

			if (count >= K) { R = C; }
			else { L = C; }
		}
		ans = R;
	}

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

Measured memory_bytes: 2676
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
  return (a<b)?a:b;
}
int max(int a,int b){
  return (a>b)?a:b;
}
int fp(int a,int b){
  if(b==0) return 1;
  int x=fp(a,b/2);
  x=(x*x)%mod;
  if(b&1) x=(x*a)%mod;
  return x;
}
int n;
const int N=2e3+5;
vector<array<int,2>> v;
int dp[N][N];
int solve(int pos,int l)
{
  int r=l+n-pos-1;
  if(dp[pos][l]!=-1)
    return dp[pos][l];
  if(pos==n){
    return 0;
  }
  if(l==r)
  {
    return v[pos][0]*abs(v[pos][1]-r);
  }
  int x=v[pos][0]*abs(v[pos][1]-r)+solve(pos+1,l);
  int y=v[pos][0]*abs(v[pos][1]-l)+solve(pos+1,l+1);
  return dp[pos][l]=max(x,y);
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 memset(dp,-1,sizeof(dp));
 cin>>n;
 v=vector<array<int,2>>(n);
 for(int i=0;i<n;i++)
 {
  cin>>v[i][0];
  v[i][1]=i+1;
 }
 sort(v.rbegin(),v.rend());

 int ans=solve(0,1);
 cout<<ans;

}

Measured memory_bytes: 35224
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let k: isize = iterator.next().unwrap().parse().unwrap();
    let x: isize = iterator.next().unwrap().parse().unwrap();

    let mut result = String::new();
    for i in (x - k + 1)..=(x + k - 1) {
        if i >= -1000000 && i <= 1000000 {
            result.push_str(&format!("{} ", i));
        }
    }

    return result.trim().to_string();
}


Measured memory_bytes: 2132
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll mod = 1e9 + 7;
ll power(ll x, ll y) {
	ll ans = 1;
	while(y) {
		if(y & 1) {
			ans = (ans * x)%mod;
		}
		x = (x*x)%mod;
		y/=2;
	}
	return ans;
}
ll freq[1000001];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, ans = 0;
    cin>>n;
    ll a[n], i, l, j, b[n];
    for(i=0; i<n; i++) {
    	cin>>a[i];
    	b[i] = a[i];
    }
    if(n == 1) {
    	cout<<1<<"\n";
    	return 0;
    }
    for(i=0; i<n; i++) {
    	for(j=2; j*j <= a[i]; j++) {
    		ll cnt = 0;
    		while( a[i] % j == 0 && a[i] > 1) {
    			cnt++;
    			a[i] /= j;
    		}
    		freq[j] = max(freq[j], cnt);
    	}
    	if(a[i] > 1) {
    		freq[a[i]] = max(freq[a[i]], (ll)1);
    	} 
    }
    l = 1;
    for(i=2; i<1e6; i++) {
    	if(freq[i]) {
    		l = (l * power(i, freq[i]))%mod;
    	}
    }
    for(i=0; i<n; i++) {
    	ans = (ans + (l * power(b[i], mod - 2))%mod)%mod;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int P, Q, R; cin >> P >> Q >> R;
	cout << P + Q + R - max(max(P, Q), R) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int mod=1e9+7;
long long ans;
int n,p,now,fac;
string s;
map<int,int>mp;
int main()
{
	cin>>n>>p>>s;
	
	if(p==2||p==5)
	{
		for(int i=0;i<n;i++)
		{
			if((s[i]-'0')%p==0)
			{
				ans+=(long long)i+1;
			}
		}
		cout<<ans<<"\n";
		return 0;
	}
		++mp[0];
		int now=0,fac=1;
		for(int i=n-1; ~i; --i) {
			now=(now+(s[i]-'0')*fac%p)%p;
			ans+=mp[now];
			mp[now]++;
			fac=fac*10%p;
		}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


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

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

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


Measured memory_bytes: 3640
H,W = map(int, input().split())
fs = []
for i in range(H):
    fs.append(input())

lefts = [[0]*W for i in range(H)]
rights = [[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        if fs[i][j] == "#":
            lefts[i][j] = 0
        if fs[i][j] == ".":
            if j == 0:
                lefts[i][j] = 1
            else:
                lefts[i][j] = lefts[i][j-1] + 1
        jr = W - j - 1
        if fs[i][jr] == "#":
            rights[i][jr] = 0
        else:
            if jr == W-1:
                rights[i][jr] = 1
            else:
                rights[i][jr] = rights[i][jr+1] + 1
ups = [[0]*W for i in range(H)]
downs = [[0]*W for i in range(H)]
for j in range(W):
    for i in range(H):
        if fs[i][j] == "#":
            ups[i][j] = 0
        else:
            if i == 0:
                ups[i][j] = 1
            else:
                ups[i][j] = ups[i-1][j] + 1
        ir = H - i - 1
        if fs[ir][j] == "#":
            downs[ir][j] = 0
        else:
            if ir == H-1:
                downs[ir][j] = 1
            else:
                downs[ir][j] = downs[ir+1][j] + 1


# for l in lefts:
#     print(*l)
# print("-----------")
# for r in rights:
#     print(*r)
# print("updown")
# for l in ups:
#     print(*l)
# print("-----------")
# for r in downs:
#     print(*r)

ans = 0
for i in range(H):
    for j in range(W):
        x = lefts[i][j] + rights[i][j] + ups[i][j] + downs[i][j]
        # print(i,j,lefts[i][j] ,rights[i][j] ,ups[i][j] ,downs[i][j])
        ans = max(x,ans)
print(ans-3)

Measured memory_bytes: 205684
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

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

		vint v(n+1); v[0] = 0;
		rep(i, n)
			cin >> v[i+1];

		partial_sum(ALL(v), v.begin());

		int res = -1 << 30;

		rep(i, n) REP(j, i + 1, n + 1)
			chmax(res, v[j] - v[i]);

		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
#include<map>
map<int,int>mp;


int fun(int x)
{
  if(x==mp[x])return x;
  return mp[x]=fun(mp[x]);
}
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)mp[i]=i;
  
  for(int i=0;i<m;i++)
  {
    int x,y;
    cin>>x>>y;
    mp[fun(x)]=mp[fun(y)];
  }
  int a[n+1]={0};
  int c=0;
  for(int i=1;i<=n;i++)
  {
    a[fun(i)]++;
    c=max(c,a[fun(i)]);
  }
  cout<<c;
  return 0;
  
  
}


Measured memory_bytes: 32544
fn main(){
    let n: u32 = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().parse().unwrap()
    };
    let a: u32 = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().parse().unwrap()
    };
    println!("{}\n", n*n - a);
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
using namespace std;
#define ll long long
pair<ll,ll> bi(ll x,ll s[],ll A){
  ll l=0,r=A-1;
  ll p;
  while(r-l>1){
    p=(l+r)/2;
    if(x>=s[p])l=p;
    if(x<=s[p])r=p;
  }
  pair<ll,ll> a(s[l],s[r]);
  return a;
}

int main(){
  ll A,B,Q;
  cin >> A >> B >> Q;
  ll s[A],t[B];
  ll i;
  ll ans,tmp;
  ll x;
  ll t1,t2;
  for(i=0;i<A;i++){
    cin >> s[i];
  }
  for(i=0;i<B;i++){
    cin >> t[i];
  }
  for(i=0;i<Q;i++){
    ans=1000000000000;
    cin >> x;
    t1=bi(x,s,A).first;
    t2=bi(t1,t,B).first;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    t1=bi(x,s,A).first;
    t2=bi(t1,t,B).second;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    t1=bi(x,s,A).second;
    t2=bi(t1,t,B).first;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    t1=bi(x,s,A).second;
    t2=bi(t1,t,B).second;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    t1=bi(x,t,B).first;
    t2=bi(t1,s,A).first;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    t1=bi(x,t,B).first;
    t2=bi(t1,s,A).second;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    t1=bi(x,t,B).second;
    t2=bi(t1,s,A).first;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    t1=bi(x,t,B).second;
    t2=bi(t1,s,A).second;
    tmp=abs(t1-x)+abs(t2-t1);
    ans=min(ans,tmp);
    cout << ans <<endl;
  }

  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 300100
using namespace std;
typedef pair<int,int> pii;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int32_t main(){
	fastio;
	int n;
	cin>>n;
	int m = (1LL<<n);
	multiset<int,greater<int> > have;
	multiset<int,greater<int> > need;
	for(int i=0;i<m;i++){
		int x;cin>>x;need.insert(x);
	}
	have.insert(*need.begin());
	need.erase(need.begin());
	for(int i=1;i<=n;i++){
		vector<int> put;
		for(multiset<int,greater<int> >::iterator it = have.begin();it!=have.end();it++){
			multiset<int,greater<int> >::iterator it2 = need.upper_bound(*it);
			if(it2==need.end()){
				cout<<"No"<<endl;
				return 0;
			}
			put.pb(*it2);
			need.erase(it2);
		}
		for(int j=0;j<(int)put.size();j++)have.insert(put[j]);
	}
	cout<<"Yes"<<endl;
}

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

int main () {
	int n;
	cin >> n;
	int a[10000];
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort(a, a+n, std::greater<int>());
	int ascore=0;
	int bscore=0;
	for (int i=0; i<n; i++) {
		if (i%2==0) {
			ascore+=a[i];
		} else bscore+=a[i];
	}
	cout << ascore-bscore;
} 

Measured memory_bytes: 3624
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N, K; cin >> N >> K;
    int ans = 0;
    for(int i=0; i<N; i++) {
        int h; cin >> h;
        if(h >= K) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int k,x;
	cin >> k >> x;

	int rngmax = x + k - 1;
	int rngmin = x - k + 1;

	for ( int count = rngmin; count <= rngmax; count = count + 1 ){
		cout << count << " ";
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 150002


int main(){	
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	int dp[max(k+1,2*a[0])]={0};
	for(int i=0;i<a[0];i++){
		dp[i]=0;
	}
	for (int i = a[0]; i < 2*a[0] ; ++i)
	{
		dp[i]=1;
	}
	for (int i = 2*a[0]; i <=k; ++i)
	{
		dp[i]=0;
		for (int j = 0; j <n; ++j)
		{
			if( (i-a[j]) >=0 && dp[i-a[j]]==0){
				dp[i]=1;
				break;
			}
			
		}
		
	}
	if(dp[k]){
		cout<<"First"<<endl;
	}
	else{
		cout<<"Second"<<endl;
	}
	//cout<<dp[k]<<endl;







		
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<TEN(9) + 7>;
// template<> const Mint Mint::G = Mint(3);

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n, k;
    cin >> n >> k;
    V<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Mint ans = 0;
    Mint i2 = Mint(2).inv();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (a[i] <= a[j]) continue;
            if (i < j) ans += Mint(k) * Mint(k + 1) * i2;
            else ans += Mint(k - 1) * Mint(k) * i2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>

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

using namespace std;

int bit[MAX_N+1],n,q,com,x,y;

int sum(int i)
{
  int s = 0;
  while(i > 0)
    {
      s += bit[i];
      i -= i & -i;
    }
  return s;
}

void add(int i,int x)
{
  while(i <= n)
    {
      bit[i] += x;
      i += i & -i;
    }
}

int main()
{
  cin >> n >> q;
  rep(_,q)
    {
      cin >> com >> x >> y;
      if(com)cout << sum(y) - sum(x-1) << endl;
      else   add(x,y); 
    }
  return 0;
}

Measured memory_bytes: 1548
N=int(input())
box=[0]*4
for i in range(N):
    S=str(input())
    if S=="AC":
        box[0]+=1
    elif S=="WA":
        box[1]+=1
    elif S=="TLE":
        box[2]+=1
    else:
        box[3]+=1
print("AC x ",box[0])
print("WA x ",box[1])
print("TLE x ",box[2])
print("RE x ",box[3])


Measured memory_bytes: 9144