akhauriyash/Code-Regression huggingface dataset:
/* This code was submitted by
  "Anand Dubey" on 
   14th January 2019
*/


#include <bits/stdc++.h> // Include every standard library 
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--) 
  
inline string IntToString(LL a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline LL StringToInt(string a) 
{ 
    char x[100]; 
    LL res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
inline string GetString(void) 
{ 
    char x[1000005]; 
    scanf("%s", x); 
    string s = x; 
    return s; 
} 
  
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    REP(i, n) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    REP(i, n) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
} 
  
inline void OPEN(string s) 
{ 

} 
  
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL a,b,c;
    cin>>a>>b>>c;
    if((a+b+c) >=22)
        cout<<"bust";
    else
        cout<<"win";
    return 0; 
} 

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

int main()
{
    int n, w;
    cin>>n>>w;
    int arr[n][2];
    long long int dp[2][w + 1];
    for(int i = 0; i < n; i++) {
        cin>>arr[i][0]>>arr[i][1];
    }
    dp[0][0] = 0;
    for(int i = 0; i < n; i ++) {
        for(int j = 0; j <= w; j++) {
            dp[i%2][j] = 0;
            if(i > 0)
                dp[i%2][j] = dp[(i - 1) % 2][j];
            if(arr[i][0] <= j) {
                if(i > 0)
                dp[i%2][j] = max(dp[i%2][j], dp[(i - 1)%2][j - arr[i][0]] + arr[i][1]);
                else if(j == arr[i][0]) {
                    dp[i%2][j] = arr[i][1];
                }
            }
        }
    }
    long long int mx = INT_MIN;
    for(int i = 0; i <= w; i++) {
        mx = max(mx, dp[(n - 1)%2][i]);
    }
    if(mx < 0) mx = 0;
    cout<<mx<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const int H = 7;
const int W = 7;
const int P = H * W + 10;
const int INF = P * P;

class C{
  public:
    int y, x, cy, cx, s, p;
    C(int _y, int _x, int _cy, int _cx, int _s, int _p){
      y = _y;
      x = _x;
      cy = _cy;
      cx = _cx;
      s = _s;
      p = _p;
    }
    bool operator >(const C c) const{
      return p > c.p;
    }
};

int w, h;

int main(){
  while(cin >>w >>h && w){
    vector< vector<int> > v(h, vector<int>(w));
    int sy, sx, scy, scx;
    REP(i, h){
      REP(j, w){
        cin >>v[i][j];
        if(v[i][j] == 4){
          sy = i;
          sx = j;
          v[i][j] = 0;
        }
        if(v[i][j] == 2){
          scy = i;
          scx = j;
          v[i][j] = 0;
        }
      }
    }

    int ans = -1;
    priority_queue<C, vector<C>, greater<C> > open;
    open.push( C(sy, sx, scy, scx, 0, 0) );
    int closed[P][H][W][H][W];
    REP(i, P) REP(j, H) REP(k, W) REP(l, H) REP(m, W) closed[i][j][k][l][m] = INF;


    while(!open.empty()){
      C now = open.top();
      open.pop();

      //debug
      //cout <<now.y <<" " <<now.x <<" " <<now.cy <<" " <<now.cx <<" " <<now.s <<" " <<now.p <<endl;

      if(v[now.cy][now.cx] == 3){
        ans = now.p;
        break;
      }

      //debug
      //cout <<"step 1" <<endl;
      //cout <<now.s <<" " <<closed[now.p][now.y][now.x][now.cy][now.cx] <<endl;

      if(now.s >= closed[now.p][now.y][now.x][now.cy][now.cx]) continue;
      closed[now.p][now.y][now.x][now.cy][now.cx] = now.s;

      //debug
      //cout <<"step 2" <<endl;

      int my[] = {1, -1, 0, 0};
      int mx[] = {0, 0, 1, -1};
      REP(i, 4){
        int ny = now.y + my[i];
        int nx = now.x + mx[i];
        if(ny < 0 || nx < 0 || ny >= h || nx >= w || v[ny][nx] == 1) continue;
        if(ny == now.cy && nx == now.cx){
          int ncy = ny + my[i];
          int ncx = nx + mx[i];
          if(ncy < 0 || ncx < 0 || ncy >= h || ncx >= w || v[ncy][ncx] == 1) continue;
          open.push( C(ny, nx, ncy, ncx, now.s + 1, now.p + 1) );
        } else{
          open.push( C(ny, nx, now.cy, now.cx, now.s + 1, now.p) );
        }
      }
    }

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

Measured memory_bytes: 1796
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

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

		int n = sc.nextInt();
		Set set = new TreeSet();
		for (int i = 0; i < n; i++) {
			int k = sc.nextInt();
			set.add(k);
		}
		if (set.size() % 2 == 0) {
			System.out.println(set.size() - 1);
		} else {
			System.out.println(set.size());
		}
	}
}


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

int main(){
    long long a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f >> g;
    cout << max((a/2)*2+(d/2)*2+(e/2)*2, ((a-1)/2)*2+((d-1)/2)*2+((e-1)/2)*2 + (a > 0 && d > 0 && e > 0 ? 3 : 0))+b << endl;
    return 0;
}

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  
  if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}

	system("pause");
	return 0;
}


Measured memory_bytes: 3720
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();

    int a, b; cin >> a >> b;
    
    int ans = -1;
    rep(i, 1, 1200){
    	int ta = (i * 8) / 100;
    	int tb = (i * 10) / 100;

    	if (ta == a && tb == b){
            ans = i;  break;
    	}	
    }
    cout << ans << endl;

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
    	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int main()
{
  int A,B,C,X,res=0;
  cin >> A >> B >> C >> X;
  for(int i=0;i<=A;i++)
    for(int j=0;j<=B;j++)
      for(int k=0;k<=C;k++){
        if((500*i+100*j+50*k) == X){
          res++;
        }
      }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}



Measured memory_bytes: 256
using System;
namespace tst
{
    class Program
    {
        public static bool Chk(int n, int i)
        {
            int val = n / i;
            if(n%i==0 && 1<=val && val <= 9)
            {
                return true;
            }
            return false;
        }
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            bool flag = false;
            for(int i=1; i<=9; i++)
            {
                if(Chk(n, i))flag=true;
            }
            if (flag) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }

    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int mo = 1e+9+7;
const int N = 2e+3;

int f[N*2+3][N*2+3];
LL ny[N*4+3],js[N*4+3];
int n;
LL ans;
int ad[N*2+3][N*2+3];
struct point{
	int x,y;
}a[200003];

LL quickmi(LL x,LL tim){
	LL ans=1;
	x%=mo;
	for(;tim;tim/=2,x=x*x%mo)if (tim&1)ans=ans*x%mo;
	return ans;
}

inline int add(int x,int y){
	return x+y>=mo?x+y-mo:x+y;
}

LL calc(int x,int y){
	return js[x*2+y*2]*ny[x*2]%mo*ny[y*2]%mo;
}

int main(){
	n=get();
	fo(i,1,n){
		int x=get(),y=get();
		a[i].x=x;a[i].y=y;
		ad[N-a[i].x][N-a[i].y]++;
	}
	js[0]=1;
	fo(i,1,8000)js[i]=js[i-1]*i%mo;
	ny[8000]=quickmi(js[8000],mo-2);
	fd(i,7999,0)ny[i]=ny[i+1]*(i+1)%mo;
	fo(i,0,4000)
		fo(j,0,4000){
			if (i>0)f[i][j]=add(f[i][j],f[i-1][j]);
			if (j>0)f[i][j]=add(f[i][j],f[i][j-1]);
			f[i][j]=add(f[i][j],ad[i][j]);
		}
	ans=0;
	fo(i,1,n)ans=add(ans,f[a[i].x+N][a[i].y+N]);
	fo(i,1,n)ans=(ans+mo-calc(a[i].x,a[i].y))%mo;
	ans=ans*((mo+1)/2)%mo;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 98304
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans1 = a+b;
        int ans2 = b-a;

        System.out.println(b%a == 0 ? a+b:b-a);
    }
}

Measured memory_bytes: 21332
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
string S;
vector< pair< char, char > > query;
int check(int m) {
	int i = m;
	rep(j, Q) {
		char t = query[j].first, d = query[j].second;
		if (S[i] == t) {
			if (d == 'L') {
				--i;
			} else {
				++i;
			}
		}
		if (i == -1)
			return -1;
		if (i == N)
			return 1;
	}
	return 0;
}
signed main() {
	cin >> N >> Q;
	cin >> S;
	query.resize(Q);
	rep(i, Q) cin >> query[i].first >> query[i].second;
	int l = -1, r = N;
	int ls, rs;
	while (r - l > 1) {
		int m = (l + r) / 2;
		int f = check(m);
		if (f == -1) {
			l = m;
		} else {
			r = m;
		}
	}
	ls = l;
	l = -1;
	r = N;
	while (r - l > 1) {
		int m = (l + r) / 2;
		int f = check(m);
		if (f == 1) {
			r = m;
		} else {
			l = m;
		}
	}
	rs = r;
	int ans = rs - ls - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 900
#include<iostream>
#include<math.h> 
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int lli;
lli mod=1000000007;
vector < lli> primes;

void Sieve(lli n) 
{ 
    bool prime[n+1];
	for(lli i=0;i<n+1;++i)
		prime[i]=true;
    for (lli p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (lli i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(lli p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
lli gcd(lli a,lli b)  
 {
    if(b>a)
        swap(a,b);
    if (a%b==0)  
        return b;  
    else 
        return gcd(a%b,b);  
 }
lli lcm(lli a,lli b)
{
    return (a*b)/gcd(a,b);    
}
lli power(lli x,lli y,lli m)   
{ 
    lli res = 1; 
    x=x%m;   
    while (y > 0) 
    {  
        if (y%2==1) 
            res =(res*x)%m;  
        y=y/2; 
        x=(x*x)%m; 
    } 
    return res; 
}
bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) { 
    return v1[1] < v2[1]; 
}
bool sortcol1( const vector<lli>& v1, const vector<lli>& v2 ) { 
    return v1[0] < v2[0]; 
}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	string s;
	cin>>s;
	lli cnt[26]={0};
	for(lli i=0;i<s.length();++i)
	{
		cnt[s[i]-65]++;
	}
	sort(cnt,cnt+26);
	if(cnt[25]==2&&cnt[24]==2)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def F_symulacja():
    N, D, A = wczytaj_liste()
    monstery = []
    for i in range(N):
        x, h = wczytaj_liste()
        monstery.append((x, h))
    monstery.sort()
    wynik = 0
    while len(monstery) > 0:
        x, h = monstery[0]
        if h <= 0:
            monstery.pop(0)
            continue
        bomba_x = x + D
        wynik += 1
        for i in range(len(monstery)):
            x_i, h_i = monstery[i]
            if bomba_x - D <= x_i <= bomba_x + D:
                monstery[i] = (x_i, h_i - A)

    print(wynik)

def zabij(H, A):
    if H % A == 0:
        return H // A
    else:
        return H // A + 1

def F():
    N, D, A = wczytaj_liste()
    monstery = []
    for i in range(N):
        x, h = wczytaj_liste()
        monstery.append((x, h))
    monstery.sort()

    wynik = 0
    gdzie_sie_koncza_bomby = []
    skonczone = 0
    ile_tu_spadlo = 0
    for x, h in monstery:
        while len(gdzie_sie_koncza_bomby) > skonczone:
            bomby_do, ile_bomb = gdzie_sie_koncza_bomby[skonczone]
            if bomby_do < x:
                ile_tu_spadlo -= ile_bomb
                skonczone += 1
            else:
                break
        if h - ile_tu_spadlo * A > 0:
            zrzucam_tutaj = zabij(h - ile_tu_spadlo * A, A)
            wynik += zrzucam_tutaj
            ile_tu_spadlo += zrzucam_tutaj
            gdzie_sie_koncza_bomby.append((x + 2 * D, zrzucam_tutaj))
    print(wynik)

F()

Measured memory_bytes: 82008
#動的計画法
import numpy as np
H, N = map(int, input().split())

A=np.empty(N,dtype=int)
B=np.empty(N,dtype=int)
for i in range(N):
    A[i],B[i]=map(int,list(input().split(" ")))

DP=np.empty(H+1,dtype=int)

def battle(hp,magic=0):
  #print(hp,magic)
  if hp==0:
    return magic
  t = hp-A
  t[t<0] = 0
  min_power = min(DP[t]+B)
  return magic+min_power

#DP = [0]*(H+1)
for i in range(H+1):
  DP[i] = battle(i)
  #print(DP[i])
ans = DP[H]
print(ans)

#print(*ans, sep='\n')

Measured memory_bytes: 12520
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

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

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

int main(){
	vector<bool> isPN(10000,true);
	ll n,ans=0;
	cin >> n;

	for(ll i=1;i<=n;i++){
		ll count = n/i;
		ans += count*(count+1)/2*i;
	}
	cout << ans << endl;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int idx = n-1; idx >= 0; idx-=2) {
        cout << a[idx] << " ";
    }
    if(n%2==0){
        for(int idx = 0; idx < n; idx+=2) {
            cout << a[idx] << " ";
        }
    }
    else{
        for(int idx = 1; idx < n; idx+=2) {
            cout << a[idx] << " ";
        }
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 2944
N,W = list(map(int,input().split()))
vals = []
weis = []
for i in range( N):
    v,w =list(map(int,input().split()))
    vals.append(v)
    weis.append(w)
dp=[0] * (W+1)
for i,v in enumerate(vals):
    for w in range(weis[i], W+1):
        dp[w] = max(dp[w], dp[w-weis[i]] +v)

print(dp[W])


Measured memory_bytes: 5916
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	int ans=0;
	REP(i,S.size()){
		if(i%2==0){
			if(S[i]=='p'){
				ans--;
			}
		}
		else{
			if(S[i]=='g'){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

int main(){
	string s;
	cin >> s;
	
	map<int,int> M;
	int sum = 0;
	M.insert(P(0,1));
	for(int j = 0 ; j < 26 ; j ++)M.insert(P(1<<j,1));
	for(int i = 0 ; i < s.size() ; i ++){
		sum ^= (1<<(s[i]-'a'));
		int ans = M[sum];
		for(int j = 0 ; j < 26 ; j ++){
			if(M.find(sum^(1<<j)) == M.end()){
				M[sum^(1<<j)] = ans+1;
			}
			else M[sum^(1<<j)] = min( M[sum^(1<<j)] , ans+1 );
		}
	}
	cout << M[sum] << endl;
}



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

using namespace std;

constexpr int primeCount = 25;
constexpr int primes[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37, 41,
                          43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
constexpr int candidateCount = 6;
constexpr int candidates[] = {1, 3, 5, 15, 25, 75};

int count75(int prev, const int counts[], int const startIdx) {
  int const count = counts[startIdx];
  if (count == 0) {
    return prev == 75 ? 1 : 0;
  }
  int ret = 0;
  for (int i = 0; i < candidateCount; ++i) {
    int const candidate = candidates[i];
    if (candidate > count + 1) {
      break;
    }
    int const current = prev * candidate;
    if (current % 9 == 0) {
      continue;
    }
    if (current == 75) {
      ret++;
      break;
    }
    if (current > 75) {
      break;
    }
    ret += count75(current, counts, startIdx + 1);
  }
  return ret;
}

int calc(int n) {
  if (n <= 1) {
    return 0;
  }
  int primeCounts[primeCount + 1] = {0};
  for (int i = 2; i <= n; ++i) {
    int ii = i;
    for (int pIdx = 0; ii > 1 && pIdx < primeCount; ++pIdx) {
      int const prime = primes[pIdx];
      if (ii < prime) {
        break;
      }
      while (ii % prime == 0) {
        ii /= prime;
        primeCounts[pIdx]++;
      }
    }
  }
  std::sort(std::rbegin(primeCounts), std::rend(primeCounts));
  return count75(1, primeCounts, 0);
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::cout << calc(n) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U>
void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, multiset<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } my_init;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
////////////////////////////////
template <class T>
auto make_vv(size_t n, size_t m, T x = {}) {
    return vector<vector<T> >(n, vector<T>(m,x));
}

int32_t main() {
    int n; cin >> n;
    auto a = make_vv<int>(n,3);
    rep (i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];
    
    auto dp = make_vv<int>(n+1,3);
    rep (i,n) rep (j,3) rep (k,3) if (j != k) {
        chmax(dp[i+1][j], dp[i][k] + a[i][j]);
    }
    int ma = 0;
    rep (i,3) chmax(ma, dp[n][i]);
    cout << ma << "\n";
}


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
int main(){
	int a , b , c , d , l;
	int s;
	cin >> l >> a >> b >> c >> d;
	int na = (a + c - 1) / c;
	int nb = (b + d - 1) / d;
	if (na > nb){s = na;}
	else{s = nb;}
	int p = l - s;
	cout << p << endl;
	return 0; 
}


Measured memory_bytes: 3100
from math import gcd
n = int(input())
A = list(map(int, input().split()))

f1 = True
f2 = True

c = [0] * (10**6+5)
for a in A:
  c[a] += 1
for i in range(2, 10**6+5):
  cnt = 0
  for j in range(i, 10**6+5, i):
    cnt += c[j]
  if cnt > 1:
    f1 = False


g = 0
for i in range(len(A)):
  g = gcd(g, A[i])
if g != 1:
  f2 = False

if f1:
  print("pairwise coprime")
elif f2:
  print("setwise coprime")
else:
  print("not coprime")

Measured memory_bytes: 194388
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

random_device rnd;
mt19937 mt(rnd());
uniform_int_distribution<> rand100(1, 100);
uniform_int_distribution<> rand200(1, 200);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int table[55555 + 1] = {0};
    table[0] = table[1] = 1;
    int i = 4;
    while (1) {
        table[i] = 1;
        i *= 2;
        if (i > 55555) break;
    }
    rrep(i, 3, 55555 + 1) {
        int j = i * 2;
        if (j > 55555) break;
        while (1) {
            table[j] = 1;
            j += i;
            if (j > 55555) break;
        }
    }
    vector<int> v;
    rep(i, 55555 + 1) {
        if (table[i] == 0 && i % 5 == 1) v.push_back(i);
    }
    rep(i, n) cout << v[i] << endl;
}


Measured memory_bytes: 512
fun main(args : Array<String>) {
    val s = readLine()!!

    println(when (s) {
        "SUN" -> 7
        "MON" -> 6
        "TUE" -> 5
        "WED" -> 4
        "THU" -> 3
        "FRI" -> 2
        "SAT" -> 1
        else -> 0
    })
}


Measured memory_bytes: 31660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[110][10];

int main() {
    int n,m;cin>>n>>m;
    if(n==1){
        cout << m << endl;
        return 0;
    }
    vector<int> v;
    for(int i = 2; i*i <= m; i++){
        if(m%i==0)v.push_back(i);
    }
    int ans = 1;
    rep(i,v.size()){
        if(v[i] <= m/n){
            ans = max(ans,v[i]);
        }
        if(m/v[i]<=m/n){
            ans = max(ans, m/v[i]);
        }
    }
    cout << ans << endl;
}



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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

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

    ll n;
    cin>>n;

    ll ans = n*(n-1);
    ans /= 2;
    cout<<ans<<endl;
    
    return 0;
}

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

string S;

int main(){
    cin>>S;
    if(S=="Sunny"){cout<<"Cloudy"<<endl;
    }else if(S=="Cloudy"){cout<<"Rainy"<<endl;
    }else if(S=="Rainy"){cout<<"Sunny"<<endl;}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        sc.close();

        int count = 0;
        for(int i = 0; i < N; i++){
            while(a[i] % 2 == 0){
                count++;
                a[i] /= 2;
            }
        }
        System.out.println(count);        
    }
}

Measured memory_bytes: 35368
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
char s[10001];
main() {
	cin>>s;
	for(int i=1; i<strlen(s); i++)
		if(s[i]==s[i-1]) printf("Bad"),exit(0);
	printf("Good");
}


Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end


n = input_n

# スタート地点(1, 1)から(i, j)に到達するまでの移動回数はx座標について考えたとき、i - 1でありy座標について考えたとき、j - 1なので合わせてi + j - 2となる。よって、移動回数 i + j - 2 が最小になるように考える。
# 到達したいマスの値Nはi*jで記されているが、N <= 10 ** 12 なのでそのまま全探索するのは無理
# 一般に、N = i * j であるとき、 i <= N ** 0.5 かつ j <= N ** 0.5 であるため、探索範囲は N ** 0.5 までで良い
ans = n + 1 - 2 # (i, j) = (1, N)
max = (n ** 0.5).to_i + 1
(1..max).each do |i|
  if n % i == 0
    ans = [ans, i + (n / i) - 2].min # 「i * j = N」 より、 「j = N / i」
  end
end
puts ans

Measured memory_bytes: 1788
def ex2019b():
    N = int(raw_input())
    S = raw_input()
    s = list(S)

    r = 0
    b = 0

    for i in range(N):
        if s[i] == "R":
            r = r + 1
        elif s[i] == "B":
            b = b + 1
    
    if r > b:
        print "Yes"
    else:
        print "No"

def main():
    ex2019b()
	
if __name__ == '__main__':
    main()

Measured memory_bytes: 2568
//Let's join Kaede Takagaki Fun Club !!
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int x,y,a,b,c;
int p[100005],q[100005],r[100005];
vector<int>za;

int main(){
	cin>>x>>y>>a>>b>>c;
	rep(i,a) cin>>p[i];
	rep(i,b) cin>>q[i];
	rep(i,c) cin>>r[i];
	int lb = 0, ub = INF+5;
	
	while(ub-lb > 1){
		int mid = (lb+ub)/2, A = 0, B = 0, C = 0;
		rep(i,a) A += p[i] >= mid;
		rep(i,b) B += q[i] >= mid;
		rep(i,c) C += r[i] >= mid;
		
		
		if(max(0,x-A) + max(0,y-B) <= C) lb = mid;
		else ub = mid;
	}
	ll ans = 0;
	int cnt = 0;
	vector<P>vec;
	rep(i,a) if(p[i] >= lb) vec.pb(mp(p[i],0));
	rep(i,b) if(q[i] >= lb) vec.pb(mp(q[i],1));
	rep(i,c) if(r[i] >= lb) vec.pb(mp(r[i],-1));
	SORT(vec);
	reverse(vec.begin(), vec.end());
	
	int zan[2] = {x,y}, use = 0;
	rep(i,vec.size()){
		if(vec[i].sc == 0 && zan[0]){
			zan[0]--; use++; ans += vec[i].fi;
		}
		else if(vec[i].sc == 1 && zan[1]){
			zan[1]--; use++; ans += vec[i].fi;
		}
		else if(vec[i].sc == -1 && use < x+y){
			use++; ans += vec[i].fi;
		}
		
		if(use == x+y) break;
	}
	o(ans);
}

Measured memory_bytes: 6256
#!/usr/bin/python

# AtCoder Beginner Contest 077
# C - Snuke Festival

from sys import stdin

def solve(As, Bs, Cs):
    As.sort()
    Bs.sort()
    Cs.sort()
    # Bs :: [(b, # of bottom parts > b)]
    # Bs = [(b, sum([1 for c in Cs if c > b])) for b in Bs]
    j = 0
    for i in range(len(Bs)):
        while j < len(Cs) and Bs[i] >= Cs[j]: j += 1
        Bs[i] = (Bs[i], len(Cs) - j)
    # Accumulate Bs[][1]
    for i in range(len(Bs) - 1, 0, -1):
        Bs[i-1] = (Bs[i-1][0], Bs[i-1][1] + Bs[i][1])
    # As :: [# of mid & bottom parts > a]
    # As = [sum([b[1] for b in Bs if b[0] > a]) for a in As]
    j = 0
    for i in range(len(As)):
        while j < len(Bs) and As[i] >= Bs[j][0]: j += 1
        As[i] = Bs[j][1] if j < len(Bs) else 0
    return sum(As)

N = int(stdin.readline())  # <= 1e+5
As = [int(w) for w in stdin.readline().split()]
Bs = [int(w) for w in stdin.readline().split()]
Cs = [int(w) for w in stdin.readline().split()]
if len(As) != N or len(Bs) != N or len(Cs) != N: raise
print(solve(As, Bs, Cs))

Measured memory_bytes: 24924
import sys
input=sys.stdin.readline
#N = int(input())
#S = input()[:-1]
x,y,z = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#print()
print(z,x,y)

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

int main(){
  int k,x;
  cin >> k >> x;
  int a = x-(k-1);
  for(int i = 0;i<k*2-1;i++){
    if(a<-1000000||a>1000000)continue;
    cout << a << " ";
    a++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define ppi pair<int,pair<int,int> >
#define fr first
#define sc second
#define PI acos(-1)
#define mp make_pair
using namespace std;

#define sim template < class c

#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

vector<int>v[100100];

int main()
{
    int n,m; cin >> n >> m;
    for(int i = 0;i<n;i++){
        int  x,y; cin >> x >> y;
        v[x].push_back(y);
    }
    priority_queue<int>q;
    int ans = 0;
    for(int i =1 ;i<=m;i++){
        for(auto j : v[i])q.push(j);
        if(q.empty())continue;
        ans += q.top();
        q.pop();
    }
    cout << ans;
    return 0;
}


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

const int maxn = 100010;
int n, C, K, a[maxn];

int main() {
    scanf("%d %d %d", &n, &C, &K);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + n + 1);
    int cur = 1, i, ans = 0;
    while (cur <= n) {
        for (i = cur; i <= min(cur + C - 1, n); i++) {
            if (a[i] > a[cur] + K) break;
        }
        cur = i, ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4156
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int i,j=0,n,m;
  vector <int> v,z;
  string s,t;
  
  cin>>s>>t;
  n=s.length();m=t.length();
  for(i=0;i<n;i++)
    v.push_back(s[i]+0);
  for(i=0;i<m;i++)
    z.push_back(t[i]+0);
  
  sort(v.begin(),v.end());
  sort(z.begin(),z.end(),greater<int>());
  
  for(i=0;i<min(n,m);i++){
    if(v[i]<z[i]){
      j++;
      break;
    }
    else if(v[i]>z[i]){
      j--;
      break;
    }
  }
  
  if(j>0)
    cout<<"Yes"<<endl;
  else if(j<0)
    cout<<"No"<<endl;
  else{
    if(n<m)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
      }
  
  return 0;
}

Measured memory_bytes: 256
N, P=map(int, input().split())
S=input()

ans=0
if 10%P==0:
    for r in range(N):
        if int(S[r])%P==0:
            ans+=r+1
else:
    d=[0 for _ in range(N+1)] # Pで割った余りの累積和
    ten=1 # 10の何乗か
    for i in range(N-1, -1, -1): # 右から見ていく
        a=int(S[i])*ten%P
        d[i]=(d[i+1]+a)%P
        ten=(ten*10)%P
    cnt=[0 for _ in range(P)]
    for i in range(N, -1, -1):
        ans+=cnt[d[i]]
        cnt[d[i]]+=1
print(ans)

Measured memory_bytes: 53344
#include <iostream>
#include <string.h>
using namespace std;


int main(){
  
  string t;		//問題文の文字列T
  
  cin >> t;		//tに標準入力
  


  // size_tは配列の長さなどを表すための正の整数のデータ型
  size_t position_hatena;	//"?"の位置

  //文字列tに"?"がある限り、文字の置換処理を続ける
  while(t.find("?") != string::npos){
    if((position_hatena = t.find("?")) != string::npos){
    	t[position_hatena] = 'D';	//"?"の位置を'D'で置換
    }
  }  
  
  cout << t;
  
  return 0;
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int A,B,C;
    cin>>A>>B>>C;

    if(22<=(A+B+C)){
        cout << "bust"<<endl;
    }else{
        cout << "win"<<endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    ll boobu[5];
    cin >> n;
    for(ll i=0;i<5;i++) cin >> boobu[i];

    ll mn = INF;
    for(ll i=0;i<5;i++){
        chmin(mn, boobu[i]);
    }
    ll p;
    if(n % mn == 0) p = n / mn - 1;
    else p = n / mn;
    cout << 5 + p << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

ll N, K;
vector<ll> A;
vector<ll> fac, finv, inv;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < N+2; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n <= 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main(){
  cin >> N >> K;
  A.resize(N);
  fac.resize(N+2);
  finv.resize(N+2);
  inv.resize(N+2);
  COMinit();
  rep(i,N) cin >> A[i];
  sort(all(A));
  ll ans = 0;
  rep(i,N) {
    ans += A[i] * (COM(i,K-1) - COM(N-1-i, K-1)) % mod;

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


Measured memory_bytes: 3328
a,b,c,x,y=map(int,input().split())
k=min(x,y)
ans=0

if 2*c < a+b:
  ans+=2*c*k
  d=x-y
  if d>=0:
    ans+=min(a*d,2*c*d)
  else:
    ans+=min(b*(-d),2*c*(-d))
else:
  ans+=min(a*x,2*c*x)+min(b*y,2*c*y)
print(ans)

Measured memory_bytes: 9160
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.append(0)

    base = abs(a[0])
    for i in range(n):
        base += abs(a[i+1] - a[i])
    
    ans = []
    for i in range(n):
        if (a[i] - a[i-1]) * (a[i+1] - a[i]) >= 0:
            ans.append(base)
        else:
            ans.append(base - 2 * min(abs(a[i] - a[i-1]), abs(a[i+1] - a[i])))
    
    for i in ans:
        print(i)

main()

Measured memory_bytes: 20640
#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	int a = -1, z = -1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' && a == -1) a = i;
		if (s[i] == 'Z') z = i;
	}
	cout << (z - a + 1) << endl;
	return 0;
}


Measured memory_bytes: 640