akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ribhav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAirplane solver = new AAirplane();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAirplane {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int p = s.nextInt();
            int q = s.nextInt();
            int r = s.nextInt();
            out.println(Math.min(p + q, Math.min(q + r, p + r)));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22484
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double N = sc.nextDouble();
    long ans = 0;
    for (int i=1; i<=N; i++) {
      if (i%3 != 0 && i%5 != 0)
        ans += i;
    }
    
    
    System.out.println(ans);
  }
}  

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> s(n);
  
  for(int i = 0;i < n;++i) cin >> s[i];
  
  sort(s.begin(),s.end());
  
  for(int i = 0;i < n;++i){
    x -= s[i];
    if(x < 0){
      cout << i << endl;
      break;
    }
    if(x == 0 && i == n - 1){
      cout << i+1 << endl;
    }else if(x > 0 && i == n-1){
      cout << i << endl;
    }
  }
  return 0;
}

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


void solve(){
    int n;
    cin >> n;
    if(n>999) cout << "ABD" << endl;
    else cout << "ABC" << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mems(a,x) memset(a,x,sizeof(a))
#define first fi
#define second se
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=105;
const double eps=1e-8,pi=3.1415926535898;
ll inv(ll x){return x==1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll inv(ll x,ll mod){return x==1?x:(mod-mod/x)*inv(mod%x,mod)%mod;}
ll qpow(ll a,ll n){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
ll qpow(ll a,ll n,ll mod){ll ans=1;while(n){if(n&1) ans=ans*a%mod;a=a*a%mod;n>>=1;}return ans;}
ll mul(ll a,ll b,ll mod){ll ans=0;while(b){if(b&1) ans=(ans+a)%mod;a=(a+a)%mod;b>>=1;};return ans;}
struct vec
{
    double x,y;
    int id;
    vec(double x=0,double y=0):x(x),y(y){}
    vec operator+(const vec&o)const{ return vec(x+o.x,y+o.y);}
    vec operator-(const vec&o)const{ return vec(x-o.x,y-o.y);}
    double operator*(const vec&o)const{ return x*o.x+y*o.y;}
    double operator^(const vec&o)const{ return x*o.y-y*o.x;}
    vec operator/(const double&o)const{ return vec(x/o,y/o);}
    vec operator*(const double&o)const{ return vec(x*o,y*o);}
    void sc(){scanf("%lf%lf",&x,&y);}
    double len(){return sqrt(x*x+y*y);}
}a[N],s[N];
int n,top;
bool cmp(vec x,vec y)
{
    double k1=atan2(x.y-a[1].y,x.x-a[1].x),k2=atan2(y.y-a[1].y,y.x-a[1].x);
    if(fabs(k1-k2)<eps) return x.x<y.x;
    return k1<k2;
}
double ans[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) a[i].sc(),a[i].id=i;
    for(int i=1;i<=n;i++)
        if(a[i].y<a[1].y||a[i].y==a[1].y&&a[i].x<a[1].x)
        swap(a[i],a[1]);
    sort(a+2,a+1+n,cmp);
    for(int i=1;i<=n;i++)
    {
        while(top>=2&&((s[top-1]-a[i])^(s[top]-a[i]))<=0) top--;
        s[++top]=a[i];
    }
    if(top==1) ans[s[1].id]=1;
    else if(top==2) ans[s[1].id]=ans[s[2].id]=0.5;
    else
        for(int i=1;i<=top;i++)
        {
            vec l,r;
            if(i==1) l=s[top];
            else l=s[i-1];
            if(i==top) r=s[1];
            else r=s[i+1];
            r=r-s[i];l=s[i]-l;
            double res=atan2(r.y,r.x)-atan2(l.y,l.x);
            if(res<0) res+=2*pi;
            ans[s[i].id]=res/(2*pi);
        }
    for(int i=1;i<=n;i++)
        printf("%.10f\n",ans[i]);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}
void solve() {
	ll a, b; cin >> a >> b;
	if (b%a == 0) {
		cout << -1 << endl; return;
	}
	ll d = (b + a - 1) / a;
	ll num = d * a;
		ll le = num / a + num % a;
		ll ri = num / b + (num%b / a) + (num%b%a);
		if (le < ri) {
			cout << num << endl; return;
		}
		else {
			cout << -1 << endl;
		}
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}



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

int main() {

  int s;
  cin >> s;
  vector<int> a(1000000);
  a.at(0)=s;
  for (int i = 1; i < 1000000; i++) {
    if(s%2==0) a.at(i)=s/2;
    else a.at(i)=3*s+1;
    s=a.at(i);
    for (int j = 0; j < i; j++) {
        if(s==a.at(j)) {
            cout << i+1 << endl;
            return 0;
        }
    }  
  }
}

Measured memory_bytes: 4096
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static void swap(ref long x,ref long y)
        {
            var tmp = x;
            x = y;
            y = tmp;
        }
        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();
            var a = new long[n];
            var b = new long[n];
            for (int i = 0; i < n; i++)
            {
                var input = Reads();
                a[i] = input[0];
                b[i] = input[1];
            }
            long ans = 0;
            for (long i = n-1; i >= 0; i--)
            {
                var tmp = a[i] + ans;
                if (tmp %b[i]!=0)
                    ans += (tmp / b[i] + 1) * b[i] - tmp;
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 18784
#include <cstdio>

using namespace std;

const int mod=1e9+7;
char sir1[100],sir2[100];

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int n,sol=0;
    scanf("%d\n",&n);
    scanf("%s\n",sir1+1);
    scanf("%s",sir2+1);
    int poz=1;
    if(sir1[1]==sir1[2]) {poz=3;sol=6;}
    else {poz=2;sol=3;}
    while(poz<=n)
    {
        if(sir1[poz]==sir1[poz+1])
        {
            if(sir1[poz-1]==sir2[poz-1]) sol=2LL*sol%mod;
            else sol=3LL*sol%mod;
            poz+=2;
        }
        else
        {
            if(sir1[poz-1]==sir2[poz-1]) sol=2LL*sol%mod;
            poz++;
        }
    }
    printf("%d",sol);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <string>
#define N 100005
#define INF (1 << 30)
typedef long long ll;
using namespace std;

vector<int> child[N];
int parent[N];
int GetDepth(int idx)
{
	if (parent[idx] == -1)
		return 0;
	return GetDepth(parent[idx]) + 1;
}
const char *str[3] = { "root", "internal node", "leaf" };
int main()
{
	int n;
	cin >> n;
	fill(parent, parent + n, -1);
	int id, k, c;
	for (int i = 0; i < n; ++i)
	{
		cin >> id >> k;
		for (int j = 0; j < k; ++j)
		{
			cin >> c;
			parent[c] = id;
			child[id].push_back(c);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		int depth = GetDepth(i);
		int status;
		if (depth == 0)
			status = 0;
		else if (child[i].size())
		{
			status = 1;
			sort(child[i].begin(), child[i].end());
		}
		else
			status = 2;
		printf("node %d: parent = %d, depth = %d, %s, ", i, parent[i], depth, str[status]);
		printf("[");
		for (int j = 0; j < child[i].size(); ++j)
		{
			if (j)
				printf(", ");
			printf("%d", child[i][j]);
		}
		printf("]\n");
	}
	return 0;
}

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

using namespace std;
using ll = long long int;

int main()
{
  ll r, d, x2000;
  cin >> r >> d >> x2000;
  for(int i = 0; i < 10; i++)
  {
    x2000 = r * x2000 - d;
    cout << x2000 << endl;
  }
}


Measured memory_bytes: 888
#include<stdio.h>

int main(){
    int H,W,i,j;
    scanf("%d %d",&H,&W);
    while(H!=0&&W!=0){
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                printf("#");
            }printf("\n");
        }printf("\n");
        scanf("%d %d",&H,&W);
    }
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


   string s;
   cin >> s;
   int n = s.size();
   ll a[n];
   a[n - 1] = (s[n - 1] == '0' ? 1 : 3);
   ll till = 3;

   for (int i = n - 2; i >= 0; i--) {
        if (s[i] == '1') {
            a[i] = 2 * a[i + 1] + till;
        }

        else {
            a[i] = a[i + 1];
        }

        a[i] %= mod;
        till = (till * 3) % mod;
   }

   cout << a[0];


}




Measured memory_bytes: 1232
#include<stdio.h>
#include<math.h>
#include<string.h>
typedef struct node{int seq[16],weight;long long time;}node;
typedef struct K{int n,d,w;}K;

int n,i,j,k,t,r;
node dp[1<<16][15];
K kura[15];

int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d%d%d",&kura[i].n,&kura[i].d,&kura[i].w);
	for(i=0;i<=(1<<n)-1;i++)
		for(j=0;j<n;j++)
		{
			memset(dp[i][j].seq,-1,sizeof(dp[i][j].seq));
			dp[i][j].time=1e18;
			if(i==(1<<j))
			{
				dp[i][j].seq[0]=kura[j].n;
				dp[i][j].time=0;
				dp[i][j].weight=kura[j].w;
			}
		}
	for(i=1;i<(1<<n)-1;i++)
		for(j=0;j<n;j++)
			for(k=0;k<n;k++)
			{
				if(i>>k&1)
					continue;
				else if(dp[i|(1<<k)][k].time>dp[i][j].time+abs(kura[j].d-kura[k].d)*dp[i][j].weight)
				{
					dp[i|(1<<k)][k]=dp[i][j];
					for(t=0;dp[i|(1<<k)][k].seq[t]!=-1;t++);
					dp[i|(1<<k)][k].seq[t]=kura[k].n;
					dp[i|(1<<k)][k].time+=abs(kura[j].d-kura[k].d)*dp[i][j].weight;
					dp[i|(1<<k)][k].weight+=kura[k].w;
				}
			}
	for(i=r=0;i<n;i++)
		r=dp[(1<<n)-1][i].time<dp[(1<<n)-1][r].time?i:r;
	for(i=0;i<n;i++)
		printf("%d%c",dp[(1<<n)-1][r].seq[i],i==n-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 39500
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> g(h, vector<char>(w, '.'));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cin >> g[i][j];
  }

  vector<bool> sr(h, false);
  for (int i = 0; i < h; i++) {
    bool skip = true;
    for (int j = 0; j < w; j++) {
      if (g[i][j] == '#') skip = false;
    }
    sr[i] = skip;
  }

  vector<bool> sc(w, false);
  for (int j = 0; j < w; j++) {
    bool skip = true;
    for (int i = 0; i < h; i++) {
      if (g[i][j] == '#') skip = false;
    }
    sc[j] = skip;
  }

  for (int i = 0; i < h; i++) {
    if (sr[i]) continue;
    for (int j = 0; j < w; j++) {
      if (!sc[j]) cout << g[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3640
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    s = input()

    if s == "RRR":
        print(3)
        return
    if "RR" in s:
        print(2)
        return
    if "R" in s:
        print(1)
        return
    print(0)

main()


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

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

    int counter = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '1') {
            counter++;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
    dl = tl - pl
    tmp = set()
    t = 1
    for _ in range(pl):
        t = (t * base) & mask
    e = 0
    for i in range(pl):
        e = (e * base + f[i]) & mask
    for i in range(dl):
        tmp.add(e)
        e = (e * base - t * f[i] + f[i + pl]) & mask
    tmp.add(e)
    return tmp
t = tuple(ord(c) for c in input())
tl = len(t)
q = int(input())
h = dict()
c = dict()
a = []
for _ in range(q):
    p = input()
    if p in c:
        a.append(c[p])
        continue
    p = tuple(ord(c) for c in p)
    pl = len(p)
    if pl > tl:
        a.append("0")
        continue
    bs = min(19, pl)
    keys = calc_hash(p, bs, pl)
    if bs not in h:
        h[bs] = calc_hash(t, bs, tl)
    a.append("1" if keys <= h[bs] else "0")
print('\n'.join(a))


Measured memory_bytes: 1072672
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
 
  int main(){
      lint h,w,m;
      cin>>h>>w>>m;
      set<P>st;
      lint x[w];
      lint y[h];
      fill(x,x+w,0);
      fill(y,y+h,0);
      rep(i,m){
          lint a,b;
          cin>>a>>b;
          --a;--b;
          x[b]++;
          y[a]++;
          st.emplace(a,b);
      }
      lint mxx=*max_element(x,x+w);
      lint myy=*max_element(y,y+h);
      set<lint> xx;
      set<lint>yy;
      rep(i,w){
          if(x[i]==mxx)xx.emplace(i);
      }
      rep(i,h){
          if(y[i]==myy)yy.emplace(i);
      }
      lint ans=mxx+myy;
      lint count=0;
      for(auto x:st){
          if((xx.count(x.second)&&yy.count(x.first))){
              count++;
          }
      }
      if(count==(xx.size()*yy.size()))cout<<ans-1<<endl;
     else cout<<ans<<endl;
      
  }

Measured memory_bytes: 55144
def solve():
    N = int(input())
    d = list(map(int, input().split()))

    d.sort()

    if d[int(N/2)] == d[int(N/2 - 1)]:
        print(0)
        return
    else:
        print(d[int(N/2)] - d[int(N/2 - 1)])

solve()


Measured memory_bytes: 14396
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int d,t,s;
  cin>>d>>t>>s;
  
  if(d<=t*s) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3616
n,m=map(int,input().split())
bri=[tuple(map(int,input().split())) for i in range(m)]
bri.sort()

#「共通の範囲」を記録した配列作り、答えはその長さ
common=[[bri[0][0],bri[0][1]]]
j=0 #今、何番目のcommonを調べてるか

for i in range(1,m):
  a,b=bri[i]
  c,d=common[j] #変数に分解したら、流石にその中身は参照渡しにならない模様
  if d<=a:
    common.append([a,b])
    j+=1
  else:
    c=a
    d=min(b,d)
    common[j][0]=c
    common[j][1]=d

#print(common)
print(len(common))

Measured memory_bytes: 16984
import sys, math, collections, heapq, itertools
from bisect import bisect
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    X, Y = map(int, line_input())
    p = [0] * X
    q = [0] * Y
    for x in range(X): p[x] = int(single_input())
    for y in range(Y): q[y] = int(single_input())
    total_cost = sum(p) + sum(q)
    p.sort()
    total_sum_p = [0] * (X + 1)
    for x in range(X):
        total_sum_p[x+1] = p[x] + total_sum_p[x]
    for y in range(Y):
        x_smaller_than_y = bisect(p, q[y])
        total_cost += q[y] * (X - x_smaller_than_y) + total_sum_p[x_smaller_than_y]
    return total_cost
  
if __name__ == "__main__":
    print(solve())

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vi a(N+1);
    ll div = -1;
    Rep(i,N+1){
        Scd(a[i]);
        div += a[i];
    }

    if( div < 0 ){
        printf ("%d\n", -1 );
        return 0;
    }

    ll ans = 0;
    ll t = 1;
    bool ok = true;

    Rep(i,N+1){
        ans += t;
        t -= a[i];
        if( t < 0 ) ok = false;
        ll tmp = min( t, div );
        t += tmp;
        div -= tmp;
    }

    if( !ok ) ans = -1;
    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int N;
   cin>>N;
   map<int ,int> m ;
    map<int, int>::iterator iter;
   for(int i=1;i<=N;i++)
   {
       int x;
       cin>>x;
       m.insert(pair<int ,int>(x,i));
   }
   for(int i=1;i<=N;i++)
   {
       iter=m.find(i);
       cout<<iter->second<<" ";
   }

}

Measured memory_bytes: 5504
n = int(input())
summm = 0.0

for i in range(n):
    xu = list(map(str, input().split()))
    if xu[1] == "JPY":
        summm = summm + float(xu[0])
    else:
        summm = summm + float(xu[0]) * 380000.0

print(summm)

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int main(){
    int N,M,K;
    cin >> N >> M >> K;
    UnionFind uf(N);
    vector<int> fri(N);
    vector<vector<int>> block(N, vector<int>());
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
        fri[a]++; fri[b]++;
    }
    rep(i,K){
        int a,b;
        cin >> a >> b;
        a--; b--;
        block[a].push_back(b);
        block[b].push_back(a);
    }
    rep(i,N){
        int ans = uf.size(i) -1 -fri[i];
        for(int j: block[i]) if(uf.same(i,j)) ans--;
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 6784
#include<iostream>
using namespace std;
int main(){
  int n,a[10000],m,b,ans=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  cin>>m;
  while(m--){
    cin>>b;
    for(int i=0;i<n;i++)
      if(a[i]==b){ans++;break;}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  int a, b, h;
  cin >> a >> b >> h;
  FINA((a+b)*h/2);

 return 0;
}


Measured memory_bytes: 256
n = int(input())
data = list(map(int,input().split()))

def mapColor(rate):
    if rate<=399:
        return 'grey'
    if rate<=799:
        return 'tea'
    if rate<=1199:
        return 'green'
    if rate<=1599:
        return 'water'
    if rate<=1999:
        return 'blue'
    if rate<=2399:
        return 'yellow'
    if rate<=2799:
        return 'orange'
    if rate<=3199:
        return 'red'
    return 'any'

s = set()

x = 0

for d in data:
    c = mapColor(d)
    if c=='any':
        x+=1
    else:
        s.add(c)

if len(s)!=0:
    print(len(s),end=" ")
else:
    print("1",end=" ")
print(x+len(s))


Measured memory_bytes: 3064
using System;

namespace A___Weather_Prediction
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            string[] Weather = new string[3];
            Weather[0] = "Sunny";
            Weather[1] = "Cloudy";
            Weather[2] = "Rainy";

            for (int i = 0; i < 2; i++)
            {
                if(S == Weather[i])
                {
                    Console.WriteLine(Weather[i+1]);
                    return;
                }
            }
            Console.WriteLine(Weather[0]);
            return;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  ll dx = x2 - x1;
  ll dy = y2 - y1;
  printf("%d %d %d %d\n", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M, K;
std::vector<ll> as, bs;
ll Sa[200010], Sb[200010];

int main()
{
  std::cin >> N >> M >> K;

  rep( i, N ) {
    ll A;
    std::cin >> A;
    as.emplace_back(A);
    Sa[i+1] = Sa[i]+A;
  }

  rep( i, M ) {
    ll A;
    std::cin >> A;
    bs.emplace_back(A);
    Sb[i+1] = Sb[i]+A;
  }

  ll ans = 0;

  rep( i, N+1 ) {
    ll idx = std::upper_bound( Sb, Sb+M+1, K-Sa[i] )-Sb;

    if( idx-1 < 0 )
      continue;

    chmax( ans, i+idx-1 );
  }

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

  return 0;
}

Measured memory_bytes: 10532
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>

using namespace std;

long long int dfs(int id, bool use[], long long int m , long long int a, long long int r, long long int c , long long int h) {
    if(id == 5) {
        int count = 0;
        for(int i = 0; i < 5; i++) {
            if(use[i]) count++;
        }
        if(count == 3) {
            long long int ret = 1;
            if(use[0]) ret *= m;
            if(use[1]) ret *= a;
            if(use[2]) ret *= r;
            if(use[3]) ret *= c;
            if(use[4]) ret *= h;
            return ret;
        } else {
            return 0;
        }
    }

    long long ret = 0;
    ret += dfs(id+1,use,m,a,r,c,h);
    use[id] = true;
    ret += dfs(id+1,use,m,a,r,c,h);
    use[id] = false;
    return ret;
}

int main() {
    int n;
    cin >> n;
    long long int m = 0;
    long long int a = 0;
    long long int r = 0;
    long long int c = 0;
    long long int h = 0;
    string s[n];
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for(int i = 0; i < n; i++) {
        if(s[i][0] == 'M') m++;
        if(s[i][0] == 'A') a++;
        if(s[i][0] == 'R') r++;
        if(s[i][0] == 'C') c++;
        if(s[i][0] == 'H') h++;
    }
    bool ax[5];
    for(int i = 0; i < 5; i++) {
        ax[i] = false;
    }

    long long int ans = dfs(0,ax,m,a,r,c,h);

    cout << ans << endl;



}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

// 最大公約数
long long gcd(long long a, long long b){
    long long c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

signed main(void){
    int n; cin >> n;
    set<int> num;
    REP(i, n){
        int tmp = in();
        num.insert(tmp);
    }
    if(num.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int end = str.length() - 3;
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i <= end; i++) {
            String tmp = str.substring(i, i + 3);
            int toInt = Integer.parseInt(tmp);
            // 753が存在する場合は終了
            if (tmp.equals("753")) {
                System.out.println(0);
                return;
            }
            if (Math.abs(753 - toInt) < ans) {
                ans = Math.abs(753 - toInt);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner cin = new Scanner(System.in);
        
        int X = cin.nextInt();
        int A = cin.nextInt();
        int B = cin.nextInt();
        String result;
        if(B<=A){
            result = "delicious";
        }else{
            if(B-A<=X){
                result = "safe";
            }else{
                result ="dangerous";
            }
        }        
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int M = 1e5 + 10;
int a[M];
int main() {
    int n , m , u , v;
    scanf("%d%d" , &n , &m);
    memset(a , 0 , sizeof(a));
    while(m--) {
        scanf("%d%d" , &u , &v);
        a[u]++;
        a[v]++;
    }
    int flag = 1;
    for(int i = 0 ; i < M ; i++) {
        if(a[i] != 0) {
            if(a[i] % 2 != 0) {
                flag = 0;
                break;
            }
        }
    }
    if(flag) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		for(int i=1; i<=10000; i++)
		{		
			int n = scanner.nextInt();
			
			if(n == 0)
			{
				System.out.println("");
				break;
			}
			else
				System.out.println("Case "+i+": "+n);
		}
	}
}

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

int main(){
    long N;
    long long A[100002];

    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A, A+N, greater<long long>());

    int counter = 0;
    vector<long long> stick(2, 0);

    for(int i=1;i<N;i++){
        if(A[i-1] == A[i]){
            stick[counter] = A[i];
            counter++;
            i++;
        }
        if(counter == 2) break;
    }
    cout << stick[0] * stick[1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int a,b,c,d,e,n,k;
	scanf("%d %d %d %d",&n,&k,&d,&e);
	if(n>k)
	{
	
	a=(n-k)*e;
	b=k*d;
	c=a+b; 
	printf("%d",c);
	}
	if(n<=k)
	{
		printf("%d",n*d);
	}
	
	return 0;
 } 

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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(){
    cout << fixed << setprecision(10);
    int h,w;
    cin >> h >> w;
    vector<vector<int>> dp(h+10,vector<int>(h+10, inf));
    string s[h];
    rep(i,h) cin >> s[i];
    if(s[0][0] == '.') dp[0][0] = 0;
    else dp[0][0] = 1;
    rep(i,h){
        rep(j,w){
            rep(k,2){
                int dx[] = {1, 0};
                int dy[] = {0, 1};
                int ni = i + dx[k], nj = j + dy[k];
                if(ni >= h || nj >= w) continue;
                if(s[ni][nj] == '#' && s[i][j] == '.') chmin(dp[ni][nj], dp[i][j] + 1);
                else chmin(dp[ni][nj], dp[i][j]);
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}


Measured memory_bytes: 3664
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())

uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)
print(uf.group_count() - 1)    

Measured memory_bytes: 75416
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,Q;
  cin >> N >> Q;
  priority_queue<pair<int,P>,vector<pair<int,P>>,greater<pair<int,P>>> que;
  for(int i=0; i<N; i++){
    int s,t,x;
    cin >> s >> t >> x;
    que.emplace(x,P(s-x,t-x));
  }
  set<int> se;
  map<int,int> ans;
  for(int i=0; i<Q; i++){
    int d;
    cin >> d;
    se.emplace(d);
    ans[d] = -1;
  }
  se.emplace(inf);
  while(que.size()){
    // [l,r)
    int x,l,r;
    x = que.top().first;
    l = que.top().second.first;
    r = que.top().second.second;
    que.pop();
    int now = *se.lower_bound(l);
    while(now < r){
      ans[now] = x;
      se.erase(now);
      now = *se.lower_bound(now);
    }
  }
  for(auto m : ans){
    cout << m.second << "\n";
  }
  return 0;
}

Measured memory_bytes: 24308
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

// Damerau???Levenshtein distance
// Levenshtein distance ??? transposition (??£????£????swap) ?????????
// ca -> ac ????????????1
// https://en.wikipedia.org/wiki/Damerau???Levenshtein_distance
// wiki ???????£?????????????????????£?????????????????????????????£?????????
// https://doi.org/10.1145%2F363958.363994
// ????????????????§£??§????????????
int damerauLevenshteinDistance(const string &a, const string &b) {
	int m = a.size(), n = b.size();
	vector<vector<int>> d(m + 1, vector<int>(n + 1, INF));
	static int da[128];
	memset(da, 0, sizeof(da));
	rep(i, 0, m + 1)d[i][0] = i;
	rep(j, 0, n + 1)d[0][j] = j;
	rep(i, 1, m + 1) {
		int db = 0;
		rep(j, 1, n + 1) {
			int k = da[b[j - 1]];
			int l = db;
			int cost = 1;
			if (a[i - 1] == b[j - 1]) {
				cost = 0;
				db = j;
			}
			d[i][j] = min({
				d[i - 1][j] + 1,
				d[i][j - 1] + 1,
				d[i - 1][j - 1] + cost
			});
			if (k - 1 >= 0 && l - 1 >= 0) {
				chmin(d[i][j], d[k - 1][l - 1] + (i - k - 1) + 1 + (j - l - 1));
			}
		}
		da[a[i - 1]] = i;
	}
	return d[m][n];
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int n; cin >> n&&n;) {
		int d; cin >> d;
		vector<string> s(n); rep(i, 0, n) {
			cin >> s[i];
		}
		sort(all(s));
		int x = 0;
		rep(i, 0, n)rep(j, i + 1, n) {
			int dst = damerauLevenshteinDistance(s[i], s[j]);
			if (dst <= d) {
				cout << s[i] + "," + s[j] << endl;
				x++;
			}
		}
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <iostream>

using namespace std;

int W, H, N;

int main(void)
{
	cin >> W >> H >> N;
	
	int x, y, a;
	int lx = 0, ux = W, ly = 0, uy = H;
	for(int i = 0; i < N; i++){
		cin >> x >> y >> a;
		if(a == 1) lx = max(lx, x);
		if(a == 2) ux = min(ux, x);
		if(a == 3) ly = max(ly, y);
		if(a == 4) uy = min(uy, y);
	}
	
	if(ux < lx) ux = lx;
	if(uy < ly) uy = ly;
	
	cout << (ux - lx) * (uy - ly) << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
    $prime = new SplFixedArray(1000000);
    for($i=0; $i<1000000; $i++) $prime[$i] = 0;
    for($i=2; $i<1000000; $i++) {
        if($prime[$i] == 1) continue;
        for($j=$i*$i; $j<1000000; $j+=$i) $prime[$j] = 1;
    } 
    while($stdin = trim(fgets(STDIN))) {
        $count=0;
        for($i=2; $i<=(int)$stdin; $i++) if($prime[$i]==0) $count++;
        echo $count.PHP_EOL;
    }


Measured memory_bytes: 64616
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  ll N;cin>>N;
  ll M;cin>>M;
  vector<int> p(M);
  vector<string> s(M);

  REP(i,M){
    cin>>p[i];
    cin>>s[i];
  }
  vector<int> data(N);
  REP(i,N){
    data[i]=0;
  }
  int r=0;
  int w=0;
  vector<int> data2(N);
  REP(i,N){
    data2[i]=0;
  }
  REP(i,M){
    if(s[i]=="AC"){
      data2[p[i]]=1;
    }
  }
  REP(i,M){
    if(s[i]=="WA"&&data[p[i]]==0&&data2[p[i]]==1){
      w=w+1;
    }
    else if(s[i]=="WA"&&data[p[i]]==1){
    }
    else if(s[i]=="AC"&&data[p[i]]==0){
      r=r+1;
      data[p[i]]=1;
    }
    else if(s[i]=="AC"&&data[p[i]]==1){

    }
  }
  cout<<r<<" "<<w<<endl;



}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int a,b;

main(){
  cin>>a>>b;
  cout<<a+b/2<<endl;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  string s;
  cin >> s;
  int n = s.size();
  ll k;
  cin >> k;
  rep (i, n) {
    if (s[i] == 'a') continue;
    int add = 'z' - s[i] + 1;
    if (add <= k) {
      s[i] = 'a';
      k -= add;
    }
    else {
      continue;
    }
  }
  k %= 26;
  while (k > 0) {
    int add = 'z' - s.back() + 1;
    if (add <= k) {
      s.back() = 'a';
      k -= add;
    }
    else {
      s.back() += k;
      k = 0;
    }
  }
  cout << s << endl;
}
    


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

int main(){
  int n,m;
  cin >> n >> m;
  
  int r,l;
  int rmax = 0, lmin = n;
  vector<int> c(n+1);
  
  for(int i = 0; i < m; ++i){
    cin >> r >> l;
    rmax = max({rmax,r});
    lmin = min({lmin,l});
  }
  
  int res = max({lmin-rmax+1,0});
  
  cout << res << endl;
}

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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;



int main() {
	int A,N,M;cin>>A>>N>>M;
	int ans=0;
	for (int y_a = 1; y_a <= sqrt(M); ++y_a) {
		long long int x=1;
		for (int k = 0; k < N; ++k) {
			x*=y_a;
		}
		if(x>M)break;
		string st=to_string(x);
		int sum=0;
		for (auto c : st) {
			sum += c - '0';
		}
		if(sum+A==y_a)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3260
a,b,c,k = map(int,input().split())
tmp,result = 0,0

if k>=a:
  tmp = k-a
  result = 1*a
else:
  result = 1*k
 
if tmp>=b:
  tmp = tmp-b

if tmp>=c:
  result += (-1)*c
else:
  result += (-1)*tmp
  
print(result)
  

Measured memory_bytes: 9180
// C - Monsters Battle Royale
#include <bits/stdc++.h>
using namespace std;

int in(){int x;scanf("%d",&x);return x;}

int gcd(int a, int b){return b? gcd(b, a%b): a;}

int main(){
	int N; cin>>N;
	int g = in();
	for(int i=0; i<N; ++i) g = gcd(g, in());
	cout<< g <<endl;
}

Measured memory_bytes: 256