akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

ll dp[222222];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> d(M);
    REP(i,M) cin >> d[i];
    REP(i,202020) dp[i] = INF;

    dp[0] = 0;
    for(int i=0; i < M; ++i) {
        for(int j=0; j <= 200000; ++j) {
            chmin(dp[j+d[i]], dp[j] + 1);
        }
    }
    cout << dp[N] << '\n';
    return 0;
}


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

int main(){

  int a,b;
  cin>>a>>b;

  string x;

  if(a-b>0)x=" > ";
  else if(a-b==0)x=" == ";
  else x=" < ";

  cout<<"a"<<x<<"b"<<endl;
  
  return 0;
}



Measured memory_bytes: 3164
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        double c = Double.parseDouble(a + b);
        double sq = Math.sqrt(c);
        double rem = sq % (int) sq;
        if (rem == 0D) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[99][99];
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	rep(i,0,h)scanf("%s",s[i+10]+10);
	rep(i,0+10,h+10){
		rep(j,0+10,w+10){
			if(s[i][j]=='#')putchar('#');
			else{
				ll cnt=0;
				rep(x,-1,2)rep(y,-1,2)if(x!=0||y!=0){
					if(s[i+x][j+y]=='#')cnt++;
				}
					printf("%lld",cnt);
			}
		}
		puts("");
	}
}

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

int main() {
  int a, b;
  cin >> a;
  int S, S1;
  S = 0;
  S1 = 0;
  int OOTJNY;
  OOTJNY = 0;
  b = 0;
  while(b < a){
    cin >> S >> S1;
    b++;
    if(S == S1){
      OOTJNY++;
    }
    else{
      OOTJNY += (S1 - S) + 1;
    }
  }
  cout << OOTJNY << endl;
  
  
}

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


int main()
{
	int i, j=0,arr[50];
	float v,y,t;

	
	while (scanf("%f", &v)!=EOF)
	{
		
		t = v / 9.8;
		y = 4.9 * t * t;
		arr[j] = (int)((y + 5) / 5) + 1;     //arr[j] = (int)(v*v / 98 + 1);
		
		++j;
	}

	for (i = 0; i < j; i++)
	{
		printf("%d\n",arr[i]);
	}
	return 0;
}


Measured memory_bytes: 624
n, m, l = map(int, input().split())
A_list = [list(map(int, input().split())) for i in range(n)]
B_list = [list(map(int, input().split())) for j in range(m)]

for i in range(n):
    _list = [sum(A_list[i][j] * B_list[j][k] for j in range(m)) for k in range(l)]
    print(*_list)



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

int main(){
    ll n, ans; cin >> n; ans = 0;
    rep(i, n){
        if((i+1) % 3 != 0){
            if((i+1) % 5 != 0) ans += i + 1;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main(){
    double x, y, x1, y1, x2, y2;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    x = x2 - x1;
    y = y2 - y1;
    
    printf("%f\n", sqrt(x * x + y * y));
    
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll n, x, t;
	cin >> n >> x >> t;
	cout << ((n-1) / x + 1) * t << endl;
	return 0;

}

Measured memory_bytes: 3628
s = input().rstrip()

gnum, pnum = 0,0
point = 0
for c in s:
    if c == "g":
        if gnum >= pnum+1:
            point += 1
            pnum += 1 
        else:
            gnum += 1
    elif c == "p":
        if gnum >= pnum+1:
            pnum += 1 
        else:
            gnum += 1
            point -= 1

print(point)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

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

    for (int i = 0; i < n - 1; i++)
    {
        cpt -= a[i];
        b[i] = cpt % MOD;
    }

    ll ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        ans += a[i] * b[i] % MOD;
    }

    ans %= MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6364
use proconio::input;
use std::cmp;

fn main() {
    input! {
        n : usize,
        a : [i64; n]
    };
    let mut dp = vec![[-(1 << 50); 3]; n];
    for i in 0..cmp::min(n, 3) {
        dp[i][i] = a[i];
    }
    for i in 0..n {
        for j in 0..3 {
            for k in 0..3 {
                if i+k+2 >= n || j+k >= 3 { break;}
                dp[i+k+2][j+k] = cmp::max(dp[i+k+2][j+k], dp[i][j] + a[i+k+2]);
            }
        }
    }
    let res = if n%2 == 1 {
        cmp::max(dp[n-1][2], cmp::max(dp[n-2][1], dp[n-3][0]))
    } else {
        cmp::max(dp[n-1][1], dp[n-2][0])
    };
    println!("{}", res);
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if( a > b && a > c )
        cout << 'A' << endl;
    else if( b > a && b > c )
        cout << 'B' << endl;
    else
        cout << 'C' << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

long long powmp(long long x,long long n){
	if(n==0) return 1;
	long long y = x;
	if(n==1) return y;
	long long tmp = powmp(y,n/2);
	if(n%2==0) return tmp*tmp;
	else return powmp(y,n-1)*y;
}

int main(int argc, char const *argv[])
{
	int N,P;
	cin >> N >> P;
	int ne=0,no=0;
	REP(i,N){
		int a;
		cin >> a;
		if(a%2==0) ne++;
		else no++;
	}
	if(no==0){
		if(P==1) cout<<0;
		else cout <<powmp(2,ne);
	}
	else {
		cout<<powmp(2,ne+no-1);
	}
	cout << "\n";
	return 0;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL Q,H,S,D;
LL N;
typedef pair<LL,LL>P;
vector<P>v;
int main(){
    cin>>Q>>H>>S>>D;
    v.push_back(P{(Q*8)/1,1});
    v.push_back(P{(H*8)/2,2});
    v.push_back(P{(S*8)/4,4});
    v.push_back(P{(D*8)/8,8});
    sort(v.begin(),v.end());
    cin>>N;
    N*=4;
    LL ans=0;
    REP(i,v.size()){
        int a=v[i].first;
        int b=v[i].second;
       // cout<<N<<" "<<a<<" "<<b<<endl;
        ans+=(N/v[i].second*v[i].second*v[i].first)/8;
        N-=(N/b)*b;
    }
    cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000001
int X[N];
main(){
  int i, j, n, m=0, A[N], C[10001];
  
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    scanf("%d", &A[i]);
    
    if(A[i]>m){
      m=A[i];
    }
  }
  
  for(i=0; i<m+1; i++){
    C[i]=0;
  }
  for(j=1; j<n+1; j++){
    C[A[j]]++;
  }
  for(i=1; i<m+1; i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n; j>0; j--){
    X[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1; i<n; i++){
    printf("%d ", X[i]);
  }
  printf("%d\n", X[n]);
  
  return 0;
}

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

int r,g,b,n;
int res = 0;
int main()
{
    cin>>r>>g>>b>>n;
    for(int x1 = 0;x1<3001;x1++)
        for(int x2 = 0;x2<3001;x2++){
            if(x1*r+x2*g<=n && (n-x1*r-x2*g)%b==0)
                res+=1;
        }
    cout<<res<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	int N = 0;
	cin >> N;
	vector<int> H(N);
	REP(i, N) cin >> H[i];
	int m = 0;
	int x = 0;
	for (int i = 0; i < N-1; i++) {
		if (H[i] >= H[i + 1]) {
			x += 1;
		}
		else {
			if (x > m){
				m = x;
			}
			x = 0;
		}
	}
	if (x > m) {
		m = x;
		x = 0;
	}
	cout << m << endl;
	
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()

	if 1 <= A && A <= 9 && 1 <= B && B <= 9 {
		fmt.Println(A * B)
	} else {
		fmt.Println(-1)
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

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

  ll N = S.size();

  vl num(N);
  rep(i, S.size()){
    num[i] = S[i] - '0';
  }

  ll pat = 1;
  rep(i, N - 1){
    pat *= 2;
  }
  
  ll ans = 0;

  rep(i, pat){
    ll div = 1;
    ll tmp = num[0];
    
    rep2(j, 1, N){
      if((i % (2*div)) / div == 1){
		ans += tmp;
		tmp = 0;
      }
      
      tmp = 10 * tmp + num[j];
      div *= 2;
    }
    ans += tmp;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    int n, a[212345];
    ll sum[212345];

    cin >> n;

    sum[0] = 0;
    REP(i, n)
    cin >> a[i + 1], sum[i + 1] = sum[i] + a[i + 1];

    ll res = LLONG_MAX;

    for (int i = 2; i < n - 1; i++)
    {
        ll num[4];

        int l = 1, r = i;
        while (r - l > 1)
        {
            int mid = (l + r) / 2;

            if (sum[i] - sum[mid - 1] <= sum[mid - 1])
                r = mid;
            else
                l = mid;
        }

        if (abs(sum[i] - sum[r - 1] - sum[l]) < abs((sum[i] - sum[l - 1] - sum[l - 1])))
        {
            num[0] = sum[l];
            num[1] = sum[i] - sum[l];
        }
        else
        {
            num[0] = sum[l - 1];
            num[1] = sum[i] - sum[l - 1];
        }

        l = i + 1, r = n;
        while (r - l > 1)
        {
            int mid = (l + r) / 2;

            if (sum[n] - sum[mid - 1] <= sum[mid - 1] - sum[i])
                r = mid;
            else
                l = mid;
        }

        if (abs(sum[n] - sum[l] - (sum[l] - sum[i])) < abs(sum[n] - sum[l - 1] - (sum[l - 1] - sum[i])))
        {
            num[2] = sum[l] - sum[i];
            num[3] = sum[n] - sum[l];
        }
        else
        {
            num[2] = sum[l - 1] - sum[i];
            num[3] = sum[n] - sum[l - 1];
        }

        // cout << num[0] << " " << num[1] << " " << num[2] << " " << num[3] << endl;

        sort(num, num + 4);

        res = min(res, num[3] - num[0]);

        //cout << i << " " << num[3] - num[0] << " " << num[0] << " " << num[1] << endl;
    }

    cout << res << endl;

    return 0;
}

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

int main(void){
    int h,n;
    cin >> h >> n;

    int sum = 0;
    for(int i=0;i<n;i++){
        int p;
        cin >> p;
        sum += p;
    }
    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
list_m=[]
list_f=[]
list_r=[]
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    else:
        list_m.append(m)
        list_f.append(f)
        list_r.append(r)

for i in range(len(list_m)):
    M=list_m[i]
    F=list_f[i]
    R=list_r[i]
    score=M+F
    if M==-1 or F==-1:
        grade="F"
    elif score>=80:
        grade="A"
    elif 65<= score <80:
        grade="B"
    elif 50<= score <65:
        grade="C"
    elif 30<= score <50:
        if R>=50:
            grade="C"
        else:
            grade="D"
    else:
        grade="F"
    print(grade)
      


Measured memory_bytes: 5600
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;


int main(){
    priority_queue<int> q;
    char s[10];
    int n;
    while(1){
        scanf("%s",s);
        if(s[0]=='i'){
            scanf("%d",&n);
            q.push(n);
        }else if(s[1]=='x'){
            cout<<q.top()<<endl;q.pop();
        }else{
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 7032
/**
 *   created: 09 June 2019  14:03:36
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vll v(n);
		rep(i,0,n){
			ll x,y;
			cin>>x>>y;
			v[i] = {y,x};
		}
		sort(all(v));
		ll sum = 0;
		rep(i,0,n){
			sum += v[i].second;
			if(sum>v[i].first){
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
	}	
	return 0;
}

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

int a[2][103]={0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<2;++i)
        for(int j=0;j<n;++j)
            cin >> a[i][j];

    int ans = 0;
    for(int i=0;i<n;++i){
        int sum = 0;
        for(int j=0;j<n;++j){
            if(j <= i)sum += a[0][j];
            if(j >= i)sum += a[1][j];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
Imports System

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim H As Integer = CInt(tmp(0))
        Dim A As Integer = CInt(tmp(1))

        Dim dbl As Double = H / A
        Console.WriteLine(Math.Ceiling(dbl))

    End Sub

End Module


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

int main()
{
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<long long> a,b,c;
    
    for(int i = 0;i<A;i++)
    {
        long long temp;
        cin >> temp;
        a.push_back(temp);
    }
    for(int i = 0;i<B;i++)
    {
        long long temp;
        cin >> temp;
        b.push_back(temp);
    }
    for(int i = 0;i<C;i++)
    {
        long long temp;
        cin >> temp;
        c.push_back(temp);
    }
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
    
    bool checkend = false;
    
    int a_num = X;
    int b_num = Y;
    int c_num = 0;
    
    
    for(int i = 0;i<C;i++)
    {
        if(checkend)
        {
            break;
        }
        
        //A OK
        if(a_num > 0 &&c[i] > a[a_num-1])
        {
            //B OK
            if(b_num > 0 &&c[i] > b[b_num-1])
            {
                //change A
                if(a[a_num-1] < b[b_num-1])
                {
                    a_num--;
                    c_num++;
                }
                //change B
                else
                {
                    b_num--;
                    c_num++;
                }
                
            }
            //B NG
            else
            {
                a_num--;
                c_num++;
            }
        }
        //A NG
        else
        {
            //B OK
            if(b_num > 0 &&c[i] > b[b_num-1])
            {
                b_num--;
                c_num++;
            }
            //B NG
            else
            {
                checkend = true;
            }
        }
        
    }
    
    long long score = 0;
    for(int i=0;i<a_num;i++)
    {
        score += a[i];
    }
    for(int i=0;i<b_num;i++)
    {
        score += b[i];
    }
    for(int i=0;i<c_num;i++)
    {
        score += c[i];
    }
    
    cout << score << endl;
    
    return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

void solve(){
    ll x;
    cin>>x;
    ll cnt = x/500*1000;
    x %= 500;
    cnt += x/5*5;
    cout << cnt << endl;

}

int main(){
    #ifdef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main()
{
    int a,b;

    cin>>a>>b;

    if((a==3&&b==2)||(a==2&&b==3)) cout<<"1";
    else if((a==3&&b==1)||(a==1&&b==3)) cout<<"2";
    else cout<<"3";
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll x, r, d;
int main() {
	doin();
	cin >>r >> d >> x;
	for(int i = 0; i < 10; i++) {
		cout << fixed << (x = r*x - d) << "\n";
	}
}


Measured memory_bytes: 256
backet = {}
# get
first_input = input().split(" ")
N = int(first_input[0])
K = int(first_input[1])

data_input = input().split(" ")

# sort
data_input.sort()

# unique
unique = set(data_input)


# create backet
for n in unique:
    backet[n] = 0

# backet setting
for m in data_input:
    value = backet[m]
    value += 1
    # update
    backet[m] = value

backet_list = list(backet.values())
backet_list.sort()
backet_list.reverse()
if K < len(unique):
    ball_value = backet_list[K:]
    goukei = sum(ball_value)
    print(goukei)
else:
    print("0")



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

int main(void){
	int n,y;
	int man = -1,gosen = -1,sen = -1;
	cin >> n >> y;
	
	for(int m=0;m<=n;m++){
		for(int g=0;g<=n-m;g++){
			int s = n - m - g;
			if((10000*m) + (5000*g) + (1000*s) == y){
				man = m;
				gosen = g;
				sen = s;
			}
		}
	}
	
	cout << man << " " << gosen << " " << sen << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, K, P = 1000000007;
  std::cin >> N >> K;
  std::vector<ll> A(N);
  vvl dp = vv(N, K+1, 0, ll);
  for(int i=0;i<N;i++) scanf("%lld", &A[i]);
  vvl pre = vv(N, K+1, 0, ll);
  for(int j=N-1;j>=0;j--){
    if(j==N-1){
      for(int i=0;i<=K;i++) {
        if(i<=A[j]) dp[N-1][i] = 1;
        pre[j][i] = ((i==0?0:pre[j][i-1]) + dp[j][i])%P;
      }
    }else{
      for(int i=0;i<=K;i++){
        dp[j][i] = (pre[j+1][i]-(i>=A[j]+1?pre[j+1][i-A[j]-1]:0)+P)%P;
        pre[j][i] = ((i==0?0:pre[j][i-1]) + dp[j][i])%P;
      }
    }
  }
  std::cout << dp[0][K] << '\n';
  return 0;
}


Measured memory_bytes: 157552
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n;
    cin>>n;
    ll int a[n];
    ll int i,val=0,w,q,ans=0;
    for(i=0;i<n;i++)
    	cin>>a[i];

    ll int s[n];
    s[0]=a[0];
    for(i=1;i<n;i++)
    {
    	s[i]=s[i-1]+a[i];
    }
    val=s[n-1];
    for(i=0;i<n;i++)
    {
    	w=val-s[i];
    	q=((w%MOD)*(a[i]%MOD))%MOD;
    	ans=(ans%MOD+q%MOD)%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] V = new int[N];
        int[] C = new int[N];
        V = Console.ReadLine().Split().Select(int.Parse).ToArray();
        C = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int output = 0;
        for (int i = 0; i < N; i++)
        {
            if (V[i] - C[i] > 0) output += V[i] - C[i];
        }
        Console.WriteLine(output);


    }

}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

struct Mo {
    vector<int> left, right, order;
    vector<bool> v;
    int width;
    int nl, nr, ptr;

    Mo(int n) : width((int)sqrt(n)), nl(0), nr(0), ptr(0), v(n,false) {}

    // [l,r)
    void insert(int l, int r) {
        left.push_back(l);
        right.push_back(r);
    }

    void build() {
        order.resize(left.size());
        iota(begin(order),end(order),0);
        sort(begin(order),end(order),[&](int a, int b) {
            if (left[a]/width != left[b]/width) return left[a] < left[b];
            return bool((right[a] < right[b]) ^ (left[a] / width % 2));
        });
    }

    int process() {
        if (ptr == order.size()) return -1;
        const auto id = order[ptr];
        while (nl > left[id]) distribute(--nl);
        while (nr < right[id]) distribute(nr++);
        while (nl < left[id]) distribute(nl++);
        while (nr > right[id]) distribute(--nr);
        return order[ptr++];
    }

    inline void distribute(int idx) {
        v[idx].flip();
        if (v[idx]) add(idx);
        else del(idx);
    }

    void add(int idx);
    void del(int idx);
};

int n, q;
int a[500000];
int ans[500000];
int cnt[500001], sum;

void Mo::add(int idx) {
    if (cnt[a[idx]]++ == 0) sum++;
}

void Mo::del(int idx) {
    if (--cnt[a[idx]] == 0) sum--;
}

int main() {
    cin >> n >> q;
    rep(i,n) cin >> a[i];
    Mo mo(n);
    rep(i,q) {
        int x, y; cin >> x >> y;
        mo.insert(--x,y);
    }
    mo.build();
    rep(i,q) {
        int idx = mo.process();
        ans[idx] = sum;
    }
    rep(i,q) printf("%d\n",ans[i]);
}

Measured memory_bytes: 15736
#include <stdio.h>
char s1[20]="CODEFESTIVAL2016";
char s2[20];
int t;
int main()
{
  fgets(s2, 20, stdin);
  for(int i=0; i<16; i++)
    if(s1[i]!=s2[i])
      t++;
  
  printf("%d\n", t);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	type arm struct{ l, r int }
	as := make([]arm, n)
	for i := range as {
		x, l := scanInt(), scanInt()
		as[i].l = x - l
		as[i].r = x + l

	}
	sort.Slice(as, func(i, j int) bool { return as[i].r < as[j].r })

	ans := 1
	r := as[0].r
	for i := 1; i < n; i++ {
		if as[i].l >= r {
			ans++
			r = as[i].r
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5852
import Data.List (transpose)
import Data.Bool (bool)

main :: IO ()
main = do
  getLine
  xus <- map words . lines <$> getContents
  let
    [xs, us] = transpose xus
    s = sum $ zipWith (*) (map read xs) (map (bool 1.0 380000.0 . (== "BTC")) us) :: Double
  print s


Measured memory_bytes: 636
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

const ll MOD = 2019;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L, R;
    cin >> L >> R;
    vector<ll> num;
    for (ll i = L; i <= min(L + 5000, R); i++) {
        num.push_back(i % MOD);
    }
    ll ans = 2019;
    for (int i = 0; i < num.size(); i++) {
        for (int j = i + 1; j < num.size(); j++) {
            ans = min(ans, (num[i] * num[j]) % MOD);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define len(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define lb lower_bound
#define ub upper_bound
#define mine min_element
#define maxe max_element
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <class T> void __f(const char* name, T&& a) {
    cerr << name << ": " << a << '\n';
}
template <class T, class... Ts> void __f(const char* names, T&& a, Ts&&... b) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << a << " /";
    __f(comma + 1, b...);
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T> bool mini(T& a, const T& b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, const T& b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef double db;
typedef pair<int, int> pi;
typedef pair<int, pi> ti;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ti> vti;
typedef vector<vpi> vvpi;

const int inf = (int)0x3f3f3f3f3f3f3f3f;
const int ninf = (int)0xc0c0c0c0c0c0c0c0;
const int M = (int)1e9 + 7;
const int N = 1e6;

int n, a[N + 3], p[N + 3], GCD = -1;
bool vis[N + 3];
vi pr;

void sieve() {
    fort(i, 2, N) {
        if (!p[i]) {
            p[i] = i;
            pr.pb(i);
        }
        for (int j = 0; j < len(pr) && i * pr[j] <= N; ++j) {
            p[i * pr[j]] = pr[j];
            if (i % pr[j] == 0) break;
        }
    }
}

signed main() {
//    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    fort(i, 1, n) {
        cin >> a[i];
        if (GCD == -1) GCD = a[i];
        else GCD = __gcd(GCD, a[i]);
    }
    sieve();
    fort(i, 1, n) {
        while (a[i] != 1) {
            int tmp = p[a[i]];
            while (a[i] % tmp == 0) a[i] /= tmp;
            if (vis[tmp] == 1) {
                if (GCD == 1) cout << "setwise coprime\n";
                else cout << "not coprime\n";
                return 0;
            }
            vis[tmp] = 1;
        }
    }
    cout << "pairwise coprime\n";
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ll inf = 1e18 + 7;
const int maxN = 5e4 + 5;

string s;
int ans = 0;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> s;
	int carry = 0;
	int fives = 0;
	FORD(i, sz(s) - 1, 0) {
		int dig = s[i] - '0' + carry;
		if (dig == 5) {
			fives++;
			carry = 0;
		} else {
			bool f = false;
			if (fives > 0) {
				f = true;
				if (fives == 1 && dig <= 4) {
					ans += 5;
					carry = 0;
				}
				else {
					ans += 5;
					ans += (fives - 1) * 4;
					carry = 1;
				}
				fives = 0;
			}
			if (f) dig += carry;
			//int dig = s[i] - '0' + carry;
			if (dig == 5) {
				fives++;
				carry = 0;
			} else {
				fives = 0;
				if (dig <= 4) {
					ans += dig;
					carry = 0;
				} else {
					ans += (10 - dig);
					carry = 1;
				}
			}
		}
	}
	if (fives > 0) {
		//cout << "Here\n";
		if (fives == 1) {
			ans += 5;
			carry = 0;
		}
		else {
			ans += 5;
			ans += (fives - 1) * 4;
			carry = 1;
		}
	}
	cout << ans + carry << endl;
	return 0;
}


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

using namespace std;

int main()
{
  string N;
  cin >> N;
  int ans = N[0] - '0' - 1 + 9 * (N.size() - 1), tmp = 0;
  for (char t : N)
    tmp += t - '0';
  cout << max(ans, tmp) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nin = in.nextInt();
		long point = in.nextInt();
		int ave = in.nextInt();
		int san[] = new int[nin+1];
		
		long line = point - ave;
		if(line>0){
		    for(int i = 0; i < nin ; i++){
		        System.out.println("Yes");
		    }
		        System.exit(0);
		}else{
		    for(int i = 1 ; i <= ave ; i++){
		      san[in.nextInt()] += 1; 
		    }
		}
		    long dist = 1 - line;
	        for(int i = 1 ; i <= nin ; i++){
		       if(san[i]>=dist){
		            System.out.println("Yes");
		       }else{
		            System.out.println("No");
		       }
		    }
	}
}


Measured memory_bytes: 69628
#include  <stdio.h>
int main (void)
{
	int i,j,n,an,bn,box,w,W[30] = {0};
	
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=0;i<w;i++){
		W[i]=i+1;
	}
	for(i=1;i<=n;i++){
		scanf("%d,%d",&an,&bn);
		box=W[an-1];
		W[an-1]=W[bn-1];
		W[bn-1]=box; 
	}
	
	for(i=0;i<w;i++){
		printf("%d\n",W[i]);
	}
	
	return(0);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    for(int i = 0;i < n; i++){
        int ipt;
        cin >> ipt;
        ans[ipt-1] = i+1;
    }
    for(int i = 0;i < n;i++){
        if(i == n-1){
          cout << ans[i];
        }else{
          cout << ans[i] << " ";
        }
    }
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define lol(i,n) for(int i-0;i<n;i++)
using namespace std;
bool ok[100010],bk[100010];
int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	ok[0]=true,bk[0]=true;
	for(int i=0;i<5000;i++){
		if(ok[i]==true){
			ok[i+a]=true;
			ok[i+b]=true;
		}
		if(bk[i]==true){
			bk[i+c]=true;
			bk[i+d]=true;
		}
	}
	double best=-1.0;
	int ans1,ans2;
	for(int i=0;i<=f;i++){
		for(int j=0;j<=f;j++){
			if(i*100+j>f)continue;
			if(ok[i]==true&&bk[j]==true){
				if(j<=i*e){
					double k=j/(i+j+0.0);
					if(best<k){
						best=k;
						ans1=i,ans2=j;
					}
				}
			}
		}
	}
	cout<<ans1*100+ans2<<" "<<ans2<<endl;
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
lh=0
rh=10**9
for i in range(m):
  l,r=map(int,input().split())
  if lh<=l:
    lh=l
  if rh>=r:
    rh=r
if rh-lh<0:
  print(0)
else:
  print(rh-lh+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<(b);i++)
#define ROF(i,a,b) for(int i = (a);i>(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 70
#define M 51
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}

ll dp[N][2][2];
int bit[N];
int main()
{
    ll n;
    while(cin>>n)
    {
        int id = 0;
        while(n)
        {
            bit[++id] = n%2;
            n>>=1;
        }
        MST(dp,0);
        dp[0][0][0] = 1;
        FOR(i,1,id+1)
        {
            if(bit[i] == 0)
            {
                dp[i][0][0] = dp[i-1][0][0];
                dp[i][0][1] = (dp[i-1][0][0]+2*dp[i-1][0][1]+dp[i-1][1][0]+dp[i-1][1][1])%MOD;
                dp[i][1][0] = (dp[i-1][0][0]+dp[i-1][1][0])%MOD;
                dp[i][1][1] = (dp[i-1][0][1]+dp[i-1][1][0]+2*dp[i-1][1][1])%MOD;
            }
            else
            {
                dp[i][0][0] = (2*dp[i-1][0][0]+dp[i-1][0][1]+dp[i-1][1][0])%MOD;
                dp[i][0][1] = (dp[i-1][0][1]+dp[i-1][1][1])%MOD;
                dp[i][1][0] = (dp[i-1][0][0]+dp[i-1][0][1]+2*dp[i-1][1][0]+dp[i-1][1][1])%MOD;
                dp[i][1][1] = dp[i-1][1][1];
            }
        }
        cout<<dp[id][0][0]<<endl;
    }
    return 0;
}


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

yoki = dame = d = 0

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            yoki += 1
        else:
            dame += 1
    else :
        d += 1

if dame >= 1:
    print("DENIED")
elif yoki >= 1 or d >= 1:
    print("APPROVED")

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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)

int N, K;
int X1[55], X2[55];
int Y1[55], Y2[55];
int Z1[55], Z2[55];

vector<int> X, Y, Z;

int cnt[110][110][110];

int compress(int *x1, int *x2, vector<int> &res)
{
    rep(i, N) {
        res.push_back(x1[i]);
        res.push_back(x2[i]);
    }

    sort(all(res));
    res.erase(unique(all(res)), end(res));

    return res.size();
}

int get_index(vector<int> &a, int v)
{
    return lower_bound(all(a), v) - begin(a);
}

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

    rep(i, N) {
        cin >> X1[i] >> Y1[i] >> Z1[i];
        cin >> X2[i] >> Y2[i] >> Z2[i];
    }

    int x = compress(X1, X2, X);
    int y = compress(Y1, Y2, Y);
    int z = compress(Z1, Z2, Z);

    rep(i, N) {
        for (int j = get_index(Z, Z1[i]), j_len = get_index(Z, Z2[i]); j < j_len; ++j) {
            for (int k = get_index(Y, Y1[i]), k_len = get_index(Y, Y2[i]); k < k_len; ++k) {
                for (int l = get_index(X, X1[i]), l_len = get_index(X, X2[i]); l < l_len; ++l) {
                    cnt[j][k][l]++;
                }
            }
        }
    }

    long long ans = 0;

    rep(i, z - 1) rep(j, y - 1) rep(k, x - 1) {
        if (cnt[i][j][k] >= K) {
            ans += 1ll * (Z[i + 1] - Z[i]) * (Y[j + 1] - Y[j]) * (X[k + 1] - X[k]);
        }
    }

    cout << ans << endl;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

int main()
{
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    rep(i,n){
        if(i == k-1){
            if(s[i] == 'A')cout << 'a';
            else if(s[i] == 'B')cout << 'b';
            else if(s[i] == 'C')cout << 'c';
        }
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    A,B,M=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    ans=INF
    for i in range(M):
        x,y,c=map(int,input().split())
        x-=1; y-=1
        ans=min(ans,a[x]+b[y]-c)
    a.sort()
    b.sort()
    ans=min(ans,a[0]+b[0])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64700
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
char a[5],b[5];
int main()
{
    scanf("%s%s",a+1,b+1);reg int i,ans=0;
    for(i=1;i<=3;++i)if(a[i]==b[i])ans++;
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a, b;
    cin >> a;
    cin >> b;
    if (((a*b)%2)!=0){
        cout << "Odd" << endl;
    }
    else{
        cout << "Even" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# ABC129D - Lamp
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for x1 in range(H):
        for y1 in range(W):
            if S[x1][y1] == ".":  # left and upper sides of S[i][j]
                U[x1][y1] = U[x1 - 1][y1] + 1
                L[x1][y1] = L[x1][y1 - 1] + 1
            x2, y2 = -x1 - 1, -y1 - 1
            if S[x2][y2] == ".":  # right and under sides
                D[x2][y2] = D[x2 + 1][y2] + 1
                R[x2][y2] = R[x2][y2 + 1] + 1
    cand = [
        L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3 for i in range(H) for j in range(W)
    ]
    ans = max(cand)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 318736
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;

#define rep(i,l,r) for(int i=l;i<=r;i++)
#define dow(i,l,r) for(int i=r;i>=l;i--)
#define rep0(i,r) for(int i=0,rr=(int)r;i<rr;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second

typedef long long LL;

typedef pair<LL,int> piir;
const int N=200200;

int f[N],p[N],n,v[N],cnt[20];

int bfs(int st)
{
    rep(i,0,1<<16) f[i]=n+1;
    int h=1,t=1,k,nxt,now;
    p[1]=st;
    f[st]=0;
    while (h<=t) {
		st=p[h++];
		rep(i,1,15)
			if (st>>i&1) {
				rep(j,1,15)
					if (i!=j && (st>>j&1)) {
                        k=i^j;
                        now=f[st]+1;
                        if (st>>k&1) now++;
                        nxt=st^((1<<i)|(1<<j)|(1<<k));
                      //  printf("%d %d %d %d %d\n"
						//	,st,nxt,i,j,k);
                        if (f[nxt]==n+1) {
							if (!nxt) return now;
							p[++t]=nxt;
							f[nxt]=now;
                        }
					}
			}
    }
}

void solve()
{
    scanf("%d",&n);
	rep(i,1,n-1) {
		int j,k,l;
		scanf("%d %d %d",&j,&k,&l);
		j++,k++;
		v[j]^=l;
		v[k]^=l;
	}
	rep(i,1,n) cnt[v[i]]++;
//	rep(i,1,n) printf("%d ",v[i]);puts("");
	int ans=0,st=0;
	rep(i,1,15) {
		ans+=cnt[i]/2;
		st|=(cnt[i]%2)*(1<<i);
	}
	//printf("%d %d\n",ans,st);
    printf("%d\n",bfs(st)+ans);
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 768
# sys.stdin.readline()
import sys
import time
input = sys.stdin.readline
import math
import heapq

N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
A = [-i for i in A]
# print(A)
heapq.heapify(A)
# print(heapq.heappop(A))

# t1 = time.time()
for i in range(M):
    a = -heapq.heappop(A) // 2
    heapq.heappush(A, -a)
    # j = A.index(max(A))
    # A[j] = a
    # A[0] = A[0]//2
    # A.sort(reverse=True)
    # if sum(A) <1:
    #     break

print(-sum(A))

Measured memory_bytes: 69224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	ll N,A[3],B[3];
	cin >> N;
	FOR(i,0,3)cin>>A[i];
	FOR(i,0,3)cin>>B[i];
	ll M = 5000*5002;
	vector<ll> dpAB(M,0),dpBA(M,0);
	FOR(i,0,M){
		if(i){
			dpAB[i] = max(dpAB[i],dpAB[i-1]);
			dpBA[i] = max(dpBA[i],dpBA[i-1]);
		}
		FOR(j,0,3){
			if(i+A[j]<M)
				dpAB[i+A[j]] = max(dpAB[i+A[j]],dpAB[i]+(B[j]-A[j]));
			if(i+B[j]<M)
				dpBA[i+B[j]] = max(dpBA[i+B[j]],dpBA[i]+(A[j]-B[j]));
		}
	}
	cout << dpBA[dpAB[N]+N]+dpAB[N]+N << endl;
}

Measured memory_bytes: 391168
#include<stdio.h>
#include<stdlib.h>
#define N 100

int main(){
  int i,j,f,c=0,top=0;
  char n[N];
  int m,S[N];
  while(scanf("%s",n)!=EOF){
    if(isdigit(n[0])){
      S[top] = atoi(n);
      top++;
    }
    if(n[0] == '+'){
      m = S[top-2] + S[top-1];
      top-=2;
      S[top] = m;
      top++;
    }
    if(n[0] == '-'){
      m = S[top-2] - S[top-1];
      top-=2;
      S[top] = m;
      top++;
    }
    if(n[0] == '*'){
      m = S[top-2] * S[top-1];
      top-=2;
      S[top] = m;
      top++;
    }
    if(n[0] == '/'){
      m = S[top-2] / S[top-1];
      top-=2;
      S[top] = m;
      top++;
    } 
  }
  printf("%d\n",m);
}



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

int main(){
  string s;
  int ans=700;
  cin>>s;
  REP(i,3) if(s.at(i)=='o') ans+=100;
  cout<<ans;
}

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


int main(void)
{
    long long int K;
    cin >> K;

    /*
    if( K < 10000000000000){
        cout << 2 << endl;
        if( K % 2 == 0){
            cout << 1 + K/2 << " " << K/2;
        }else {
            cout << (K-1)/2 << " " << 1+(K+1)/2;
        }
    }else{*/
        cout << 50 << endl;
        for( int i = 49; i >= 0; i--){
            cout << i%50 + (K+i)/50 << " ";
        }
        cout << endl;
    //}
    return 0;
}

Measured memory_bytes: 256