akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

bool check (string s){
  int n = s.length();
  if (n%2==1){
    return false;
  }
  else {
    return (s.substr(0,n/2-1)==s.substr(n/2));
  }
}

int main(){
  vvi c(3,vi(3));
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      cin >> c.at(i).at(j);
    }
  }

  vi a(3), b(3);
  a.at(0) = 0;
  for (int i=0; i<3; i++){
    b.at(i) = c.at(0).at(i) - a.at(0);
  }
  for (int i=0; i<3; i++){
    a.at(i) = c.at(i).at(0) - b.at(0);
  }

  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      if (a.at(i)+b.at(j) != c.at(i).at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a<=8) && (b<=8))
    {
        cout<<"Yay!";
    }
    else
    {
        cout<<":(";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  int f[n][10];
  for(int i=0;i<n;i++)
    for(int j=0;j<10;j++)
      cin>>f[i][j];
  int p[n][11];
  for(int i=0;i<n;i++)
    for(int j=0;j<=10;j++)
      cin>>p[i][j];
  int ans=-1000000001;
  for(int i=1;i<1<<10;i++){
    int open[10];
    int sum=0;
    for(int j=0;j<10;j++){
      open[j]=(i>>j)%2;
      }
    int match[n];
    for(int k=0;k<n;k++){
      match[k]=0;
      for(int j=0;j<10;j++){
        if(open[j]&&f[k][j])
          match[k]++;}
      sum+=p[k][match[k]];
      }
    ans=max(ans,sum);
    }
  cout<<ans<<endl;
  return 0;
  }


Measured memory_bytes: 256
def resolve():
    S = list(input())

    ans = 0
    for i in range(1, len(S)):
        if (S[i - 1] == S[i]):
            ans += 1

            if S[i] == '0':
                S[i] = '1'
            else:
                S[i] = '0'

    print(ans)


resolve()

Measured memory_bytes: 3956
#include <stdio.h>


int main(void){
    int n, i, count;
    count = 0;
    scanf("%d", &n);
    int a[n];
    for(i = 0 ; i < n ; i++){
        scanf("%d", &a[i]);
        while(a[i] % 2 == 0){
            a[i] /= 2;
            count++;
        }
    }
    printf("%d", count);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
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() {
  string s;
  cin >> s;
  string ans;
  rep(i, s.size()) {
    if(s[i] == 'B') {
      if(!ans.empty()) ans.pop_back();
    } else
      ans.push_back(s[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())
drink = [tuple(map(int, input().split())) for _ in range(m)]
for i in range(m):
    ans = 0
    for j in range(n):
        if drink[i][0] == j + 1:
            ans += drink[i][1]
        else:
            ans += t[j]
    print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] ary = {"AC","WA","TLE","RE"};
    String[] s = new String[n];
    int[] s_ans = new int[n];
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i=0; i<n; i++) {
      s[i] = in.readLine();
      for(int j=0; j<4; j++) {
        if(s[i].equals(ary[j]))
          s_ans[i] = j;
      }
      if(s_ans[i]==0)
        ac++;
      if(s_ans[i]==1)
        wa++;
      if(s_ans[i]==2)
        tle++;
      if(s_ans[i]==3)
        re++;
    }
    System.out.println("AC x " + ac);
    System.out.println("WA x " + wa);
    System.out.println("TLE x " + tle);
    System.out.println("RE x " + re);
  }
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	long long n;
	cin >> n;

	long long res;
	res = n * (n - 1) / 2;
	cout << res;

    return 0;
}


Measured memory_bytes: 256
#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,d,x;
  cin >>n >>d >>x;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int cnt = 0;
  rep(i,n){
    for(int j = 1;j<=d;j+=a[i]){
      cnt++;
    }
  }
  cout << cnt + x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll a,b,k;
   cin>>a>>b>>k;
   
   if(k>=a+b)
   {
       cout<<0<<" "<<0;
       return 0;
   }
   
   if(k>=a)
   {
       cout<<0<<" "<<b-(k-a);
       return 0;
   }
   
   cout<<a-k<<" "<<b;
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>

const int MAX_H = 100000;

int main(void) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);  
  
  std::priority_queue<int> *pq = new std::priority_queue<int>();

  std::string command;
  std::cin >> command;
  
  while (command != "end") {
    if (command[0] == 'i') {
      int k = 0;

      std::cin >> k;

      pq->push(k);
    } else if (command[0] == 'e') {
      int v = pq->top();
      pq->pop();
      
      std::cout << v << std::endl;
    }

    std::cin >> command;
  }
  
  return 0;
}

Measured memory_bytes: 6524
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] f = new int[100003];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            f[a]++;
            f[b + 1]--;
        }
        int sum = 1;
        int ans = 0;
        for (int i = 0; i <= 100002; i++) {
            sum += f[i];
            if (i <= sum) {
                ans = i;
            }
        }
        System.out.println(ans - 1);
    }

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}



Measured memory_bytes: 27248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N;
    bool first = false, second = false;
    cin >> N;
    string ans = "No"; 
    REP(i, 0, N){
        int d1, d2;
        cin>> d1 >> d2;
        if(d1 == d2){
            if(!first) first = true;
            else if(!second) second = true;
            else{
                ans = "Yes";
            }
        }else{
            first = second = false;
        }
    } 
    cout << ans << endl;
}

Measured memory_bytes: 3620
n = int(input())
a = [int(x) for x in input().split()]

a.sort()
max_a = a[-1]
ans = 1

l, r = 0, n-1
while r-l > 1:
  key = (r+l)//2
  sub = a[key]
  judge = False
  if sub*2 >= max_a:
    judge = True
  for i in range(n):
    if judge:
      break
    if i == key:
      continue
    if a[i] <= sub*2:
      sub += a[i]
    if sub*2 >= max_a:
      judge = True
      break
  if judge:
    r = key
  else:
    l = key
key = r
if r == n-1 or r == 1:
  sub = a[l]
  judge = False
  if sub*2 >= max_a:
    judge = True
  for i in range(n):
    if judge:
      break
    if i == l:
      continue
    if a[i] <= sub*2:
      sub += a[i]
    if sub*2 >= max_a:
      judge = True
      break
  if judge:
    key = l
print(n-key)

Measured memory_bytes: 14404
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	deque<int> Q;
	int a;
	cin>>a;
	Q.push_back(a);
	rep(i,N-1){
		cin>>a;
		if(i%2==0){
			Q.push_back(a);
		}else{
			Q.push_front(a);
		}
	}
	if(N%2==1){
		reverse(all(Q));
	}
	rep(i,N){
		cout<<Q.back()<<' ';
		Q.pop_back();
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = 0;
        int count = 1;
        for (int i = 0; i < n; i++) {
            if (a[i] == count) {
                count++;
            } else {
                result++;
            }
        }
        if (n == result) {
            result = -1;
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 53132
n,m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

and_list = set(a) & set(b)
or_list = (set(a) ^ set(b)) ^ set(and_list)

print(len(and_list), len(or_list))
for i in sorted(and_list):
    print(i)
for i in sorted(or_list):
    print(i)



Measured memory_bytes: 40836
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
#define MOD 1000000007
//------------ATCODER TEMPLATE-------------

signed main() {
  int N; cin >> N;
  int x1 = 1, x2 = 1, x3 = 1, x4 = 1;
  REP(i, N) x1 = (x1 * 10) % MOD;
  REP(i, N) x2 = (x2 * 9) % MOD;
  REP(i, N) x3 = (x3 * 9) % MOD;
  REP(i, N) x4 = (x4 * 8) % MOD;

  x2 = (x2 + x3 - x4 + MOD) % MOD;
  cout << (x1-x2 + MOD)%MOD << endl;
  return 0;
}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
# モジュールのインポート
import collections
import math

# 標準入力の取得
N = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


# 求解処理
result = 0
c = collections.Counter(prime_factorize(N))
for p, e in c.items():
    result += int((-1 + math.sqrt(1 + 8*e)) / 2)


# 求解処理
print(result)


Measured memory_bytes: 9472
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b = LI()
    print(a*b)

main()



Measured memory_bytes: 10944
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
    ll K;
    SCLLD(K);

    ll Q,R;
    Q = K / 50;
    R = K % 50;

    ll a[50] = {};

    REP(i,50){
        a[i] = 49 + Q;
    }

    REP(i,50-R){
        a[i] += -R;
    }

    REP(i,R){
        if (R != 0) a[50-R +i] += 50 + 1 - R;
    }

    printf("50\n");
    REP(i,49){
        printf("%lld ",a[i]);
    }
    printf("%lld\n",a[49]);


}






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

#define MAX_N 8

int l[MAX_N], v[MAX_N];
int abc[3];

int dfs(int n, int depth) {
  int ans = 3000;
  if(depth < n) {
    for(int i = 0; i < 4; ++i) {
      v[depth] = i;
      ans = std::min(ans, dfs(n, depth + 1));
    }
    return ans;

  } else {
    int cost = -30;
    int length[3] = {0};

    for(int i = 0; i < n; ++i) {
      if(v[i] < 3) {
        cost += 10;
        length[v[i]] += l[i];
      }
    }

    for(int i = 0; i < 3; ++i) {
      if(length[i] == 0) return ans;
    }

    for(int i = 0; i < 3; ++i) {
      int d = abc[i] - length[i];
      cost += (d >= 0) ? d : -d;
    }
    return cost;
  }

}

int main() {
  int n;

  std::cin >> n;
  for(int i = 0; i < 3; ++i) {
    std::cin >> abc[i];
  }
  for(int i = 0; i < n; ++i) {
    std::cin >> l[i];
  }

  int ans;
  ans = dfs(n, 0);

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

  return 0;
}


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

#define ll long long

int main(void){

    ll a,b,x;
    cin>>a>>b>>x;

    ll ans =b/x+1-((a>0?(a-1)/x+1:0));

    cout<<ans<<endl;

    return 0;
}

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

int main()
{
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r ;

  if( x+r <= W &&  x-r >= 0 &&  y+r <= H && y-r >= 0 )
    {cout << "Yes" << endl;}
  else
    {cout << "No" << endl;}

  return 0;
}



Measured memory_bytes: 3136
n = int(input())
li_a = []
li_b = []
for _ in range(n):
    a, b = map(int, input().split())
    li_a.append(a)
    li_b.append(b)
li_a.sort()
li_b.sort()
if n%2 == 1:
    min_c = li_a[(n-1)//2]
    max_c = li_b[(n-1)//2]
    print(max_c-min_c+1)
else:
    min_c = (li_a[(n//2)-1] + li_a[(n//2)])/2
    max_c = (li_b[(n//2)-1] + li_b[(n//2)])/2
    print(int((max_c-min_c)*2+1))

Measured memory_bytes: 99016
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    --A;
    --B;
    --C;
    --D;

    string S;
    cin >> S;

    for (size_t i = A; i < max(C, D); i++) {
        if (S[i] == '#' && S[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    
    if (D < C) {
        for (size_t i = B; i <= D; i++) {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


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

const ll INF = 1LL << 60;


int main() {
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);

    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3724
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main(void){
  int H,W;
  cin>>H>>W;
  char s[H][W];
  int bc=0;
  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          cin>>s[i][j];
          if(s[i][j]=='#'){
            bc++;  
          }
      }
  }
  int c=0;
  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          if(s[i][j]=='#'&&(s[i-1][j]=='#'||s[i+1][j]=='#'||s[i][j-1]=='#'||s[i][j+1]=='#')){
             c++; 
          }
      }
  }
  if(c==bc){cout<<"Yes";}
  else cout<<"No";
  return 0;
}


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

using namespace std;
typedef long long ll;

ll f[2][100007];

int w[107], v[107];

int main() {
    int n, W;
    cin >> n >> W;

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

    int cur = 0;

    memset(f, -1, sizeof f);
    f[1-cur][0] = 0;
    for(int i = 0; i < n; ++i) {
        memcpy(f[cur], f[1-cur], sizeof f[cur]);
        for(int j = 0; j <= W; ++j) {
            if(j - w[i] >= 0 and f[1-cur][j - w[i]] >= 0) f[cur][j] = max(f[cur][j], f[1 - cur][j - w[i]] + v[i]);
        }
        cur = 1 - cur;
    }

    ll ans = 0;
    for(int j = 0; j <= W; ++j) {
        ans = max(ans, f[1 - cur][j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b)
{
	int temp;
	if (a < b) { temp = a; a = b; b = temp; }//大的在前
	if (a%b == 0)return b;
	gcd(b, a%b);
	
}
int main()
{
	int n, k,i;
	while (scanf("%d%d", &n, &k) == 2) { 
		vector<int>a(n);
		for (i = 0; i < n; i++)scanf("%d", &a[i]);
		sort(a.begin(), a.end());
		int g = a[0];
		for (int i = 1; i < n; i++)g = gcd(g, a[i]);
		bool f = k%g == 0 && a[n - 1] >= k;
		string ans = f ? "POSSIBLE" : "IMPOSSIBLE";
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 640
import sys
operaciones = list()
p=0
lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(int,c))
list(c)
x = c[0]
if x>= 1200:
  print("ARC")
elif x<1200:
  print("ABC")

Measured memory_bytes: 3316
from fractions import gcd

K = int(input())

ans = 0
L = [0]*(K+1)
for a in range(1,K+1):
    for b in range(1,K+1):
        L[gcd(a,b)] += 1


for a in range(1,K+1):
    if L[a] == 0:
        continue
    for c in range(1,K+1):
        ans += L[a]*gcd(a,c)

print(ans)

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

int main() {
  int N, T;
  cin >> N >> T;
  pair<int, int> A[N];
  for(int i=0;i<N;i++) {
    cin >> A[i].first >> A[i].second;
  }
  sort(A, A+N);
  bool ans = false;
  for(int i=0;i<N;i++) {
    if(A[i].second <= T) {
      cout << A[i].first << endl;
      ans = true;
      break;
    }
  }
  if(!ans) cout << "TLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    long long int sum=0;
    for(int i=0;i<n;i++){
        cin >> h[i];
        if(i!=0&&h[i-1]>h[i]){
            sum+=h[i-1]-h[i];
            h[i]=h[i-1];
        }
    }
    cout << sum;
    return 0;
}


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


int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,ans=0;
    string s;
    set<int>st;
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++){
       if(s[i]=='R')st.insert(i);
    }
    for(int i=0;i<n;i++){
    	if(s[i]=='W'){
    		if((int)st.size()>0&&*st.rbegin()>i){
    			ans++;
    			s[*st.rbegin()]='W';
    			s[i]='R';
    			st.erase(st.find(*st.rbegin()));
    		}
    	}
    }
    cout<<ans;

 
    return 0;
} 


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

int main()
{
    string  S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    
    if(U == S){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );
		
		int a = 0;
		int b = 0;
		
		a = sc.nextInt ();
		b = sc.nextInt ();
		
		if ( a < b ) {
			System.out.println ( "a < b" );
		} else if ( b < a ) {
			System.out.println ( "a > b" );
		} else {
			System.out.println ( "a == b" );
		}
	}
}

Measured memory_bytes: 26068
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,n,t,l,r;
    string s;
    cin>>s;
    n=s.size();
    if(s[n-1]!='s')
    {
        char ch1='s';
        cout<<s<<ch1<<'\n';
    }
    else if(s[n-1]=='s')
    {
        char ch2='e';
        char ch3='s';
                 cout<<s<<ch2<<ch3<<'\n';
    }

}









Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    D = int(input())
    C = [int(x) for x in input().split()]
    S = [[int(x) for x in input().split()] for _ in range(D)]


    for i in range(D):
        print(i % 26 + 1)



if __name__ == '__main__':
    main()



Measured memory_bytes: 9496
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
bool is_white[10][1000];

int main(){
	unsigned H, W, K;
	scanf("%u %u %u\n", &H, &W, &K);
	for (unsigned i = 0; i < H; ++i){
		char chocolate[W+1];
		scanf("%s", chocolate);
		for (unsigned j = 0; j < W; ++j){
			is_white[i][j] = chocolate[j] == '1';
		}
	}
	unsigned answer = H + W - 2;
	for (unsigned i = 0; i < 1<<(H-1); ++i){
		vector<unsigned> border;
		border.push_back(0);
		unsigned answer_c = 0;
		for (unsigned j = 0; j < H-1; ++j){
			if(i >> j & 1){
				border.push_back(j+1);
				answer_c++;
			}
		}
		border.push_back(H);
		unsigned n = answer_c + 1;
		vector<unsigned> n_white(n);
		for (unsigned j = 0; j < n; ++j){
			n_white[j] = 0;
		}
		unsigned left = 0;
		bool flag = false;
		for (unsigned j = 0; j < W; ++j){
			for (unsigned p = 0; p < n; ++p){
				for (unsigned q = border[p]; q < border[p+1]; ++q){
					if(is_white[q][j]) n_white[p]++;
					if(n_white[p] > K){
						flag = true;
						break;
					}
				}
				if(flag) break;
			}
			if(flag){
				if(j == left) break;
				else{
					left = j--;
					answer_c++;
					flag = false;
					for (unsigned r = 0; r < n; ++r){
						n_white[r] = 0;
					}
				}
			}
			if(flag) break;
		}
		if(!flag && answer_c < answer) answer = answer_c;
	}
	printf("%u\n", answer);
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)

const int INF = 1000000000;

int MAX_A = 300001;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

int main(){
    int n, k; cin >> n >> k;
    vector <int> a(n);
    rep(i, n) cin >> a.at(i);
    segtree <int, op, e> dp(MAX_A);
    for(auto num: a){
        int m = dp.prod(max(0, num - k), min(MAX_A, num + k + 1));
        int plus_cnt = m + 1;
        dp.set(num, max(dp.get(num), plus_cnt));
    }
    cout << dp.all_prod() << endl;
}

Measured memory_bytes: 9636
#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 FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

int N;

class LazyTree {
public:
	LazyTree() {
		data.resize(DAT_SIZE, 0);
		datb.resize(DAT_SIZE, 0);
	}

	ll sum(ll a, ll b) {
		return sum_impl(a, b, 0, 0, N);
	}

	void add(ll a, ll b, ll x) {
		add_impl(a, b, x, 0, 0, N);
	}

private:
	const ll DAT_SIZE = (1 << 18) - 1;
	vector<ll> data, datb;

	ll sum_impl(ll a, ll b, ll k, ll l, ll r) {
		if (b <= l || r <= a)
			return 0;
		else if (a <= l && r <= b)
			return data[k] * (r - l) + datb[k];
		else
			return (min(b, r) - max(a, l))*data[k]
			+ sum_impl(a, b, k * 2 + 1, l, (l + r) / 2)
			+ sum_impl(a, b, k * 2 + 2, (l + r) / 2, r);
	}

	void add_impl(ll a, ll b, ll x, ll k, ll l, ll r) {
		if (a <= l && r <= b) {
			data[k] += x;
		}
		else if (l < b && a < r) {
			datb[k] += (min(b, r) - max(a, l))*x;
			add_impl(a, b, x, k * 2 + 1, l, (l + r) / 2);
			add_impl(a, b, x, k * 2 + 2, (l + r) / 2, r);
		}
	}
};

int main()
{
	// input
	cin >> N;
	vector<ll> A(N), B(N);
	REP(i, N)cin >> A[i] >> B[i];

	// init
	LazyTree lt;
	REP(i, N) {
		lt.add(i, i + 1, A[i]);
	}

	// calc
	ll res = 0;
	for (int i = N - 1; i >= 0; i--) {
		ll num = lt.sum(i, i + 1);
		ll diff = (B[i] - (num % B[i])) % B[i];
		res += diff;
		lt.add(0, i, diff);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 5888
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const s: string = tmp.shift().split(" ")[0];
    const slen: number = s.length;
    let result = 0;
    for (let i = 0, len = ((slen - (slen % 2)) / 2); i < len; i++) {
      if (s.charAt(i) != s.charAt(slen - 1 - i)) {
        result++;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4;
    int vx = x2 - x1, vy = y2 - y1;
    x3 = x2 - vy;
    y3 = y2 + vx;
    int tmpvx = vx;
    vx = -vy;
    vy = tmpvx;
    x4 = x3 -vy;
    y4 = y3 + vx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;


}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {

        int a, b, c;
        cin >> a;
        int ans = 0;
        for (int i = 1; i <= a; ++i) {
            string s = to_string(i);
            if(s.size() % 2){
                ans++;
            }
        }
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

bool isPrime(int x) {
	if (x <= 1) return false;
	
	for (int i = 2; i * i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return true;
}

int Q;
int sum[112345];

int main() {
	for (int i = 3; i <= 100000; i += 2) {
		if (isPrime(i) && isPrime((i + 1) / 2)) sum[i]++;
	}
	
	REP(i, 112344) sum[i + 1] += sum[i];
	
	cin >> Q;
	REP(i, Q) {
		int l, r;
		scanf("%d %d", &l, &r);
		printf("%d\n", sum[r] - sum[l - 1]);
	}
	
	return 0;
}

Measured memory_bytes: 1024
def gcd(a0, b0):
    res = 1
    a, b = min(a0, b0), max(a0, b0)

    if b % a == 0:
        res *= a
        b //= a
        a = 1

    i = 2
    while i**2 <= b0:
        if a % i == 0 and b % i == 0:
            res *= i
            a //= i
            b //= i
        else:
            i += 1

    return res


a, b = map(int, input().split())

ans = gcd(a, b)
print(ans)



Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {

    static long N, K;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        K = sc.nextLong();

        long ans1 = N % K;
        System.out.println(Math.min(ans1, K - ans1));
    }
}


Measured memory_bytes: 23764
require 'pp'

def c(n, a)
  return [0, 0] if n < a

  t = a
  c = 1
  loop {
    if t * a <= n
      t *= a
      c += 1
    else
      break
    end
  }
  return [t, c]
end



def f(n)
  a = Array.new(n+1, 0)
  1.upto(n) do |x|
    #puts "x: #{x}"
    v9, c9 = c(x, 9)
    #puts "c9: #{v9}, #{c9}"
    v6, c6 = c(x, 6)
    #puts "c6: #{v6}, #{c6}"

    t = []
    t.push(a[x - v9] + 1) if c9 != 0
    t.push(a[x - v6] + 1) if c6 != 0
    t.push(a[x -  1] + 1)

    #p t

    a[x] = t.min
    #puts ""
  end

  # n.times do |i|
  #   puts "#{i} #{a[i]}"
  # end
  return a[n]
end



N = gets.to_i
puts f(N)


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

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

  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());

  int count = 0;
  for (int i = 0; i < N-1; i++) {
      if(S.at(i)==S.at(i+1)) count++;;
  }
  cout << N-count << endl;
}

Measured memory_bytes: 9536
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<cmath>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
int DP[102][1000002];
pair<int, int> ar[100];
int dp(int i, int po){
    if(i == 0){
        if (!po)return 0;
        else return 100000000;
    }
    int &ret = DP[i][po];
    if(ret!=-1)return ret;
    ret = 100000000;
    for(int j = 0; j <= ar[i].x; j++){
        ret= min(ret , j + dp(i - 1, max(0, po - i * 100 * j - (j == ar[i].x ? ar[i].y : 0))));
    }
    return ret;
}
int main(){

   int n, c;
   I2(n, c);
   for(int i = 1;i<=n;i++)I2(ar[i].x, ar[i].y);
   SETR(DP);
   cout<<dp(n, c)<<endl;


    return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for (auto &&item : H)
    {
        cin >> item;
    }
    sort(H.begin(), H.end(), greater<int>());

    i64 sum = 0;
    for (auto &&h : H)
    {
        if (K > 0)
        {
            K--;
            continue;
        }
        sum += h;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int x,a=0,b=0,n;cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>x;vec[i]=x;
    }
    sort(all(vec));
    reverse(all(vec));
    for(int i=0;i<n;i++){
        if(i%2==0)a+=vec[i];
        else b+=vec[i];
    }
    cout<<a-b<<endl;
}


Measured memory_bytes: 3544
import java.util.*;
public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        System.out.println(Math.min(A, B) + Math.min(C, D));
    }

}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, M;
    cin >> N >> M;
    priority_queue<ll> pq;
    REP(i, N){
    	ll A;
    	cin >> A;
    	pq.push(A);
    }
    REP(i, M){
    	ll tmp = pq.top();pq.pop();
    	tmp /= 2;
    	pq.push(tmp);
    }
    ll res = 0;
    while(!pq.empty()){
    	res += pq.top();pq.pop();
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1400
N,K = map(int,input().split())
n = 300001

#####segfunc######
def segfunc(x,y):
    return max(x,y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = -1

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

A = [0]*(300005)
init(A)

for _ in range(N):
    a = int(input())
    nax = query(max(0,a-K),min(300001,a+K+1))
    if nax >= A[a]:
        update(a,nax+1)
    
print(query(0,300001))

Measured memory_bytes: 101956
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    from collections import defaultdict
    dd = defaultdict(int)
    M=10**10

    
    for _ in range(N):
        c=input()
        if "." in c:
            d=c.index(".")
            a=c[:d]
            b=c[d+1:]
            lb=len(b)
            b+="0"*(10-lb)
        else:
            a=c
            b=0
        c=int(a)*M +int(b)
        
        
        if int(a)==0 and int(b)==0:
            dd[10,10]+=1
        else:
            i=0
            j=0
            while c%2==0:
                c=c//2
                i+=1
            while c%5==0:
                c=c//5
                j+=1
            i-=10
            j-=10
            i=min(i,10)
            j=min(j,10)
            dd[(i,j)]+=1

    ans=0
    
    #dd同士の重複に注意
    
    K=[]
    V=[]
    for k,v in dd.items():
        K.append(k)
        V.append(v)
        
    
    for iiii in range(len(K)):
        k=K[iiii]
        v=V[iiii]
    
        ii,jj=k
        for i in range(-10,11):
            for j in range(-10,11):
                if ii+i>=0 and jj+j>=0:
                    if ii==i and jj==j:
                        temp=dd[(i,j)]
                        ans+=temp*(temp-1)
                    else:
                        ans+=dd[(i,j)]*v
        # print(k,v,ans)
                    
                    
                    
    print(ans//2)
            
    

            
                    
                       

 
               

main()


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

using namespace std;

int main() {
  int H, W; cin >> H >> W;
  int h, w; cin >> h >> w;
  int allWhite = H * W;
  int allBlack = (h * W) + ((H - h) * w);
  cout << allWhite - allBlack << endl;
}


Measured memory_bytes: 256
def main():
    q = int(input())
    d = {}
    for i in range(q):
        query = input()
        cmd = int(query[0])
        if cmd == 0:
            _, k, v = query.split(' ')
            v = int(v)
            d[k] = v
        elif cmd == 1:
            _, k = query.split(' ')
            v = d.get(k, None)
            if v:
                print(v)


if __name__ == '__main__':
    main()



Measured memory_bytes: 37508
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <stack>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

char s[20];
char ans[20];

int main()
{
	scanf("%s", s);

	int head = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == '0' | s[i] == '1') {
			ans[head] = s[i];
			head++;
		}
		else if (s[i] == 'B' && head > 0) {
			head--;
		}
	}
	ans[head] = '\0';
	
	printf("%s\n", ans);

	return 0;
}


Measured memory_bytes: 256