akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD = 1e9 + 7;
const int MAX_N = 200005;
int fact[MAX_N];
int fact_inv[MAX_N];
int bin_pow_mod(int x, int y) {
      if (x == 0) return 0;
      int prod=1;
      while(y>0) {
          if (y & 1) prod = (prod * x) % MOD;
          x = (x * x) % MOD;
          y >>= 1;
      }
      return prod % MOD;
}
struct init_fact {
    init_fact() {
        fact[0] = 1, fact_inv[0] = 1;
        for (int i = 1; i < MAX_N; ++i) {
            fact[i] = (fact[i - 1] * i) % MOD;
            fact_inv[i] = bin_pow_mod(fact[i], MOD - 2);
        }
    }
} init_fact;
int combination(int n, int r) {
    return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}

signed main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    vector<vi> dp(N + 1, vi(N + 1, 0));
    dp[A - 1][0] = 1;
    REPF(i, A, B + 1) {
        REP(j, N + 1) {
            (dp[i][j] += dp[i - 1][j]) %= MOD;  // i人グループは作らない
            REPF(k, C, D + 1) {
                if (j < i * k) break;
                int p = fact[N - (j - i * k)] * fact_inv[N - j] % MOD;
                (dp[i][j] += 
                    dp[i - 1][j - i * k] * p % MOD * bin_pow_mod(bin_pow_mod(fact[i], k), MOD - 2) % MOD * fact_inv[k] % MOD)
                    %= MOD;  // i人グループをj個作る
            }
        }
    }
    cout << dp[B][N] << endl;
    return (0^_^0);
}



Measured memory_bytes: 11264
// author @hello_hell
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n , m;scanf("%d%d",&n,&m);
    string a = "";
    string b = "";
    for(int i=0;i<n;++i){
        a+=to_string(m);
    }
    for(int i=0;i<m;++i){
        b+=to_string(n);
    }
    if(a>b){
        cout<<b<<endl;
    }else{
        cout<<a<<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++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> x(n);
    int cnt = 0;
    ll d=INF;
    rep(i,n){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        if(i+k-1<n){
            ll t;
            if((ll)x[i+k-1] * x[i] >=0){
                //cout << x[i+k-1] << " " << x[i] << endl;
                t = max(abs(x[i+k-1]),abs(x[i]));
                //cout << t << endl;
            }else {
                //cout << x[i+k-1] << " " << x[i] << endl;
                t = min(x[i+k-1]-x[i] + abs(x[i]), x[i+k-1]-x[i] + abs(x[i+k-1]));
                //cout << t << endl;
            }
            d = min(d,t);
        }
    }
    cout << d << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int r,d,x,ans; cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        if(i==0){
            ans = x*r-d;
        }else{
            ans = ans*r-d;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, K;
vv<int> B, W, Bcnt, Wcnt;

int main() {
	cin >> N >> K;
	B = W = Bcnt = Wcnt = vvec(K + 1, K + 1, 0);
	rep(i, N) {
		int x, y; char c;
		cin >> x >> y >> c;
		bool isBlack = c == 'B';

		if (x % (2 * K) >= K) {
			isBlack = !isBlack;
		}
		if (y % (2 * K) >= K) {
			isBlack = !isBlack;
		}
		if (isBlack) {
			B[x % K][y % K]++;
		}
		else {
			W[x % K][y % K]++;
		}
    }

	rep(i, 1, K + 1) {
		rep(j, 1, K + 1) {
			Bcnt[i][j] = Bcnt[i - 1][j] + Bcnt[i][j - 1] - Bcnt[i - 1][j - 1] + B[i - 1][j - 1];
			Wcnt[i][j] = Wcnt[i - 1][j] + Wcnt[i][j - 1] - Wcnt[i - 1][j - 1] + W[i - 1][j - 1];
		}
	}

	int ans = -INF;
	rep(i, K + 1) {
		rep(j, K + 1) {
			chmax(ans, (Bcnt[K][K] - Bcnt[i][K] - Bcnt[K][j] + 2 * Bcnt[i][j]) + (Wcnt[i][K] + Wcnt[K][j] - 2 * Wcnt[i][j]));
			chmax(ans, (Wcnt[K][K] - Wcnt[i][K] - Wcnt[K][j] + 2 * Wcnt[i][j]) + (Bcnt[i][K] + Bcnt[K][j] - 2 * Bcnt[i][j]));
			/*
				白黒　だけじゃなく　黒白　もあるよ!!!!!!!!!!11!!1!!!!!
				黒白　　　　　　　　白黒			
			*/
		}
	}
	write(ans);
}

Measured memory_bytes: 16000
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans=0
j=M
for i in range(N + 1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

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

int main(){
	int N;
	int A[100000];
	int count=0;
	
	cin >> N;
	for(int i=0; i<N; ++i){
			cin >> A[i];
	}
	
	for(int i=0; i<N; ++i){
		if(A[i]%2==1) ++count;
	}
	
	if(count%2==1) cout << "NO" << endl;
	else cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};

struct Node gNode[MAX];
int gDepth[MAX];

void print(int node){
  int i,left;
  
  printf("node %d: ",node);
  printf("parent = %d, ",gNode[node].parent);
  printf("depth = %d, ",gDepth[node]);

  if(gNode[node].parent==NIL) printf("root, ");
  else if(gNode[node].left==NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  
  left=gNode[node].left;
    
  for(i=0;left!=NIL;i++){
    if(i!=0) printf(", ");

    printf("%d",left);
    left=gNode[left].right;
  }

  printf("]\n");
}

void rec(int node,int parent){
  gDepth[node]=parent;
  
  if(gNode[node].right!=NIL){
    rec(gNode[node].right,parent);
  }

  if(gNode[node].left!=NIL){
    rec(gNode[node].left,parent+1);
  }
}

int main(){
  int num,id,node,left,root,n,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    gNode[i].parent=gNode[i].left=gNode[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&num);

    for(j=0;j<num;j++){
      scanf("%d",&node);

      if(j==0) gNode[id].left=node;
      else gNode[left].right=node;

      left=node;
      gNode[node].parent=id;
    }
  }

  for(i=0;i<n;i++){
    if(gNode[i].parent==NIL) root=i;
  }

  rec(root,0);

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;
}



Measured memory_bytes: 6420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			String r = in.nextString();
			String g = in.nextString();
			String b = in.nextString();
			int num = Integer.parseInt(r+g+b);

			out.println(num % 4 == 0 ? "YES" : "NO");
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();

    int total = 0;
    for (int i = A; i <= B; i++) {
      String s = String.valueOf(i);
      StringBuffer sb = new StringBuffer(s);
      String r = new String(sb.reverse());
      if (s.equals(r)) {
        total++;
      }
    }
    System.out.println(total);

  }

}


Measured memory_bytes: 39892
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int par[100010],dep[100010];
void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        dep[i] = 0;
    }
}

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

void merge(int a,int b){
    a = find(a);
    b = find(b);
    if (dep[a] > dep[b]){
        par[b] = a;
        dep[a] += b;
    } else {
        par[a] = b;
        dep[b] += a;
    }
}


int main(){
    vector<pair<int,int> > g[100010];
    int n; cin >> n;
    vector<pair<int,int> > v,v2;
    init(n);
    for(int i = 0; i < n; i++){
        int a,b; cin >> a >> b;
        v.push_back({a,i});
        v2.push_back({b,i});
    }
    sort(v.begin(),v.end());
    sort(v2.begin(),v2.end());
    vector<pair<int,pair<int,int> > > edges;
    for(int i = 0; i < n-1; i++){
        g[v[i].second].push_back({v[i+1].second,v[i+1].first-v[i].first});
        g[v[i+1].second].push_back({v[i].second,v[i+1].first-v[i].first});
        edges.push_back({v[i+1].first-v[i].first,{v[i].second,v[i+1].second}});
    }
    for(int i = 0; i < n-1; i++){
        g[v2[i].second].push_back({v2[i+1].second,v2[i+1].first-v2[i].first});
        g[v2[i+1].second].push_back({v2[i].second,v2[i+1].first-v2[i].first});
        edges.push_back({v2[i+1].first-v2[i].first,{v2[i].second,v2[i+1].second}});
    }
    sort(edges.begin(),edges.end());
    int cost = 0;
    for(auto z : edges){
        int x = find(z.second.first), y = find(z.second.second);
        if (x != y){
            cost += z.first;
            merge(x,y);
        }
    }
    cout << cost << endl;
}


Measured memory_bytes: 13544
#define _USE_MATH_DEFINES

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define LL long long


int main() {
	int N, A[100000], Even = 0, Odd = 0, Amax = 0;
	vector<int> Card(100000,0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		Card[A[i] - 1]++;
		if(Amax < A[i]) Amax = A[i];
	}
	for (int i = 0; i < Amax; i++) {
		if (Card[i] % 2 == 0 && Card[i] / 2 > 0) {
			Even++;
		}
		if (Card[i] % 2 == 1) {
			Odd++;
		}
	}
	cout << Odd + Even - Even % 2 << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<vector>
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t,a,b,c,d,n,m,k=0,sum=0;
  cin>>a>>b>>c>>d;
  if(a>=0 && b>=0 && c>=0 && d>=0)
  {
  	cout<<b*d<<endl;
  	
  }
  else if(a<0 && b<0 && c<0 && d<0)
  {
  	cout<<a*c<<endl;
  }
  else if(a>=0 && b>=0 && c<0 && d<0)
  {
  	cout<<a*d<<endl;
  	
  }
  else if(a<0 && b<0 && c>=0 && d>=0)
  {
  	cout<<b*c<<endl;
  	
  }
  else if(a<0 && b>=0 && c<0 && d>=0)
  {
  	cout<<max((a*c),(b*d))<<endl;
  }
  else if(a<0 && b>=0 && c>=0 && d>=0)
  {
  	cout<<b*d<<endl;
  }
  else if(a<0 && b<0 && c<0 && d>=0)
  {
  	cout<<max((a*c),(b*d))<<endl;
  }
  else if(a<0 && b>=0 && c<0 && d<0)
  {
  	cout<<max((a*c),(b*d))<<endl;
  }
  else if(a>=0 && b>=0 && c<0 && d>=0)
  {
  	cout<<max((a*c),(b*d))<<endl;
  }
   
  
   
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>

int main()
{
	int a;
	int b;
	while (std::cin >> a >> b) {
	int c = a + b;
	if (c < 10)
	{
		std::cout << 1 << std::endl;
	} else if (10 <= c && c < 100)
	{
		std::cout << 2 << std::endl;
	} else if (100 <= c && c < 1000)
	{
		std::cout << 3 << std::endl;
	} else if (1000 <= c && c < 10000)
	{
		std::cout << 4 << std::endl;
	} else if (10000 <= c && c < 100000)
	{
		std::cout << 5 << std::endl;
	} else if (100000 <= c && c < 1000000)
	{
		std::cout << 6 << std::endl;
	} else if (1000000 <= c)
	{
		std::cout << 7 << std::endl;
		} 
	}
	return 0;
}

Measured memory_bytes: 3004
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const size_t INF=1uLL<<57;

size_t num_coin(vector<size_t> c, size_t n) {
    vector<size_t> dp(n+1, INF); dp[0]=0;

    size_t m=c.size();
    for (size_t i=0; i<m; ++i)
        for (size_t j=c[i]; j<=n; ++j)
            if (dp[j] > dp[j-c[i]] + 1)
                dp[j] = dp[j-c[i]] + 1;

    return dp[n];
}

int main() {
    size_t n, m;
    scanf("%zu %zu", &n, &m);

    vector<size_t> c(m);
    for (size_t i=0; i<m; ++i)
        scanf("%zu", &c[i]);

    printf("%zu\n", num_coin(c, n));
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) {
	    res=res*x;
	    res%=mod;
	}
	x=x*x;
	x%=mod;
	y=y/2;
    }
    
    res%=mod;
    res+=mod;
    return res%mod;
}

int n, k;

ll dp[maxn];

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

    cin>>n>>k;

    dp[k]=1;
    ll ans = k;
    for (int i=k-1; i>=1; i--) {
	ll nums = k / i;
	dp[i] = pw(nums, n);
	for (int j=i+i; j<=k; j+=i) {
	    dp[i] -= dp[j];
	    dp[i] %= mod;
	}
	ans += 1ll*i*dp[i]%mod;
	ans %= mod;
    }

    ans %= mod;
    ans += mod;
    ans %= mod;

    cout<<ans<<endl;
  

    return 0;
}


Measured memory_bytes: 4384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef double db;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	vector<ll> ans(n);
	ans[0] = 0;
	if (n >= 2)
		ans[1] = max(a[1], a[0]);
	ll cur = a[0];
	for (int i = 2; i < n; ++i)
	{
		if (i & 1)
		{
			cur += a[i - 1];
			ans[i] = max(ans[i - 2] + a[i], cur);
		}
		else
			ans[i] = max(ans[i - 1], ans[i - 2] + a[i]);
	}
	cout << ans[n - 1];
	return 0;
}

Measured memory_bytes: 5568
#include <cstdio>

int sp[]={20,20,20,20,20,20,20,20,20,20,20,20};
int normal[]={20,20,19,20,19,20,19,20,19,20,19,20};

const int year=20*5+19*5;

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

    auto today=999*year+1+(999/3)*5;
    for(int i=0;i<n;i++){
        int Y,M,D;
        scanf("%d%d%d",&Y,&M,&D);

        auto birth=year*(Y-1)+((Y-1)/3)*5+D;
        for(int m=1;m<M;m++) 
            if (Y%3) birth+=normal[m];
            else birth+=sp[m];

        printf("%d\n",today-birth);
    }

    return 0;
}


Measured memory_bytes: 2696
firstLine = input().split(" ")
valn = int(firstLine[0])
valk = int(firstLine[1])
valh = []

for vali in range(valn):
    valh.append(int(input()))

valh.sort()

smallest = 1000000001
for vali in range(valn - valk + 1):
    diff = valh[vali + valk - 1] - valh[vali]
    if diff < smallest:
        smallest = diff

print(smallest)


Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;

// AtCoder Beginner Contest 139
int main(){

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i, n)cin >> a[i];
    a.push_back(1000000007);

    int ans = -1;
    int now = 0;
    rep(i, n){
        now++;
        if(a[i] < a[i + 1]){
            chmax(ans, now);
            now = 0;
        }
    }

    cout << ans - 1 << endl;
    return 0;

}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>
main(){
  char str[100];
  int upper,lower,right,left,back,current,i,tmp[4];
  scanf("%d%d%d%d%d%d",&current,&lower,&right,&left,&upper,&back);
  scanf("%s",str);
  for(i=0;str[i]!='\0';i++){
    if(str[i]=='S'){
      tmp[0]=current;
      tmp[1]=upper;
      tmp[2]=back;
      tmp[3]=lower;
      current=tmp[1];
      upper=tmp[2];
      back=tmp[3];
      lower=tmp[0];
    }
    if(str[i]=='N'){
      tmp[0]=current;
      tmp[1]=upper;
      tmp[2]=back;
      tmp[3]=lower;
      current=tmp[3];
      upper=tmp[0];
      back=tmp[1];
      lower=tmp[2];
   }
    if(str[i]=='E'){
      tmp[0]=current;
      tmp[1]=right;
      tmp[2]=left;
      tmp[3]=back;
      current=tmp[2];
      right=tmp[0];
      left=tmp[3];
      back=tmp[1];
    }
    if(str[i]=='W'){
      tmp[0]=current;
      tmp[1]=right;
      tmp[2]=left;
      tmp[3]=back;
      current=tmp[1];
      right=tmp[3];
      left=tmp[0];
      back=tmp[2];
    }
  }
  printf("%d\n",current);
  return 0;
}

Measured memory_bytes: 596
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

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

  n %= k;
  ll ans = lmin(n, k-n);
  cout << ans << endl;
}


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

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

  rep(i, s.size()) {
    cout << "x";
  }
  cout << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    D = list(input().split())

    while True:
        if all([True if n not in D else False for n in list(str(N))]):
            break
        N += 1
    print(N)


if __name__ == "__main__":
    main()


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

int main() {
    bool a = false;
    bool b = false;
    bool c = false;
    string abc;
    cin >> abc;
    for(int i = 0;i < abc.size();i++) {
        if(abc[i] == 'a') {
            a = true;
        }
        if(abc[i] == 'b') {
            b = true;
        }
        if(abc[i] == 'c') {
            c = true;
        }
    }
    if(a && b && c) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int h,w;
   cin >> h >> w ;
   char c[h][w] ;
  
  for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
       cin >> c[i][j] ;
     }   
   }
  
  bool ans= true;
  
  for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
       if(c[i][j]=='#'){
         if(i!=0 && c[i-1][j]=='#')
           continue; //above
         else if(j!=0 && c[i][j-1]=='#')
           continue; //left
         else if(j!=(w-1) && c[i][j+1]=='#')
           continue ; //right
         else if(i!=(h-1) && c[i+1][j]=='#')
           continue ; //below
         else 
           ans = false ;
       }
     }   
   }
  
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		for(int i = 0;i < s.length;i = i+2){
			System.out.print(s[i]);
		}
		System.out.println("");

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

int main() {
    string str1,str2;
    cin >> str1 >> str2;
    int c = 0;
    for (int i = 0; i < str1.size(); i++) {
        if (str1[i] != str2[i]) {
            c++;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3892
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in); 
         
        double r;
     
        r = scan.nextDouble();
         
        System.out.println(String.format("%.6f", r * r * Math.PI) + " " + String.format("%.6f", r * 2 * Math.PI));
         
    }
 
}

Measured memory_bytes: 28156
L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(L[K-1])

Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
	int a[26]={};
	string s;
	cin>>s;
	for (int i = 0; i < s.size(); i++) {

		a[s[i]-'a']++;
	}
	bool jud=true;

	for (int i = 0; i < 26; i++) {
		if(a[i]%2!=0)jud=false;
	}
	if(jud)cout<<"Yes\n";
	else cout<<"No\n";



	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
name = []
hantei = [1,27,703,18279,475255,12356631,321272407,8353082583,217180147159,5646683826135,146813779479511,3817158266467287]

for i in range(len(hantei)-1):
    if hantei[i] <= n < hantei[i+1]:
        n -= hantei[i]
        while n > 0:
            name.insert(0,n%26)
            n //= 26
        while i+1 > len(name):
            name.insert(0,0)

name = [chr(ord('a')+i) for i in name]

print("".join(name))

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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        String s = br.readLine();
        s = s.replaceAll("ABC", "");
        
        out.println((n - s.length()) / 3);
        out.close();
        
    }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> correct(n, 0);
    for (int i = 0; i < q; ++i) {
        int p;
        cin >> p;
        --p;
        ++correct[p];
    }
    for (int count : correct) {
        cout << (count - q + k > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

bool isPalindrome(string s){
  string t(s.rbegin(),s.rend());
  return s==t;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  string s,ans="No";cin >> s;
  int n=s.size();
  if(isPalindrome(s) and isPalindrome(s.substr(0,(n-1)/2)) and isPalindrome(s.substr((n+1)/2))){
    ans="Yes";
  }
  
  cout << ans << endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n;
    ll k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    cin>>a[i];
    vector<int>pat;
    int vis[n+1];
    memset(vis,0,sizeof(vis));
    
    pat.push_back(0);
    //pat.push_back(1);
    int pos;int z=1;
    for(int i=1;i<=n;)
    {
        if(!vis[a[i]])
        pat.push_back(a[i]);
        else{
            pos=vis[a[i]];
        break;}
        vis[a[i]]=z;z++;
        i=a[i];
    }
    int p=pat.size();
    
    p--;
    p=p-pos+1;
    //cout<<p<<" "<<pos<<"\n";
    vector<int>ans;
  int st=pos/p;
  if(pos%p!=0)
    st++;
  st=st*p;
    for(int i=st;i<pat.size();i++)
    ans.push_back(pat[i]);
    for(int i=pos;i<st;i++)
    ans.push_back(pat[i]);
    if(k<pos)
    cout<<pat[k];
    else
    cout<<ans[k%p];
    return 0;
}

Measured memory_bytes: 6956
package main

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

var (
	uft  []int
	rank []int
	ch   []int
	ans  []int64
)

func find(x int) int {
	if uft[x] == x {
		return x
	}

	uft[x] = find(uft[x])
	return uft[x]
}

func union(a, b, i int) {
	ans[i-1] = ans[i]
	ar, br := find(a), find(b)
	if ar == br {
		return
	}

	ans[i-1] -= int64(ch[ar] * ch[br])

	if rank[ar] < rank[br] {
		uft[ar] = br
		ch[br] += ch[ar]
		return
	} else if rank[ar] == rank[br] {
		rank[ar]++
	}
	uft[br] = ar
	ch[ar] += ch[br]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, m)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}

	uft = make([]int, n+1)
	rank = make([]int, n+1)
	ch = make([]int, n+1)
	for i := range uft {
		uft[i] = i
		ch[i] = 1
	}

	ans = make([]int64, m)
	ans[m-1] = int64(n * (n - 1) / 2)
	for i := m - 1; i >= 1; i-- {
		union(as[i], bs[i], i)
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 7552
#include<stdio.h>
#include<stdlib.h>
 
int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}
 
int main()
{
	int i, n, m, ans = 0;
    
	scanf("%d %d", &n, &m);
	
	int x[m], diff[m - 1];
	
	for(i = 0; i < m; i++){
		scanf("%d", &x[i]);
	}
	
	qsort(x, m, sizeof(int), cmp);
	
	for(i = 0; i < m - 1; i++){
		diff[i] = abs(x[i + 1] - x[i]);
	}
	
	qsort(diff, m - 1, sizeof(int), cmp);
	
	for(i = 0; i < m - n; i++){
		ans += diff[i];
	}
	
	printf("%d", ans);
	
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  for(ll i=0; i<n; i+=2){
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 592
import sys
import itertools
sys.setrecursionlimit(10**6)

N,M=map(int,input().split())
tmp=[x for x in range(1,N)]
Cases=itertools.permutations(tmp)
G=[[] for _ in range(N)]
seen=[0]*N

for _ in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

def solve(v,case,cnt,N):
    if cnt==N-1: return True
    for nv in G[v]:
        if nv==case[cnt]:
            return solve(nv,case,cnt+1,N)
    return False

ans=0
for case in Cases:
    if solve(0,case,0,N): ans+=1
print(ans)


Measured memory_bytes: 8972
// AOJ 2629: Manhattan
// 2017.10.2 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define Root2 1.4142135623730950488016887242097

int main()
{
	double df, di, ans;
	char buf[50];

	scanf("%s", buf);
	di = atoi(buf) + 1;
	sscanf(buf, "%lf", &df);
	df *= Root2;
	ans = di;
	if (ans <= df) ans = df;
	printf("%.15lf\n", ans);
	return 0;
}

Measured memory_bytes: 1800
class ModInt(x: Long) {

    companion object {
        const val MOD = 998244353L
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

class Comb(n: Int) {

    companion object {
        const val MOD = ModInt.MOD
    }

    private val fact = LongArray(n + 1)
    private val factInv = LongArray(n + 1)

    init {
        fact[0] = 1L
        for (i in 1..n) {
            fact[i] = fact[i - 1] * i % MOD
        }
        factInv[n] = ModInt(fact[n]).inv().x
        for (i in n downTo 1) {
            factInv[i - 1] = factInv[i] * i % MOD
        }
    }

    fun comb(n: Int, k: Int): Long {
        if (k !in 0..n) return 0L
        return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD
    }

}

fun main() {
    val cb = Comb(200000)
    val (n, m, k) = run {
        val (n, m, k) = readLine()!!.split(' ').map { it.toInt() }
        Triple(n, m.toLong(), k)
    }

    var ans = ModInt(0L)
    for (i in 0..k) {
        val x1 = ModInt(cb.comb(n - 1, n - 1 - i))
        val x2 = ModInt(m) * ModInt(m - 1).pow((n - 1 - i).toLong())
        ans += x1 * x2
    }
    println(ans)
}


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

using namespace std;

long long int mod = 1000000007;
int n, m;
char g[1001][1001];
int dp[1001][1001]={0};

int main()
{
	cin >> n >> m;
	for(long long int i = 1; i <= n; i++)
	{
		for(long long int j = 1; j <= m; j++)
		{
			cin >> g[i][j];
		}
	}
	for(long long int i = 1; i <= n; i++)
	{
		for(long long int j = 1; j <= m; j++)
		{
			if(g[i][j] == '.')
			{
				if(i == 1 && j == 1) 
				dp[i][j] = 1;
				else
				{
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
					dp[i][j] = dp[i][j]%mod;
				}
			}
			else
			continue;
		}
	}
	cout << dp[n][m] % mod;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define sz(v) ((int)(v).size())
#define INF (1e12)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	double t,tot=0;
	string typ;
	while(n--)
	{
		cin>>t>>typ;
		if(typ=="JPY") tot+=t;
		else tot+=380000*t;
	}
	cout<<tot<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	private static int n;
	private static int m;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		int[] a = new int [n];

		for(int i = 0; i < n; i++) {
			a[i] =-1* sc.nextInt();
		}

		MyHeap heap = new MyHeap(a);

		for(int i = 0; i < m; i++) {
			int max = heap.pop()/2;
			heap.push(max);
		}

		long sum = 0;
		for(int i = 0; i < n; i++) {
			sum -= heap.heap[i];
		}
		System.out.println(sum);

		sc.close();
	}
	private static class MyHeap {

		int[] heap;
		int sz;

		MyHeap(int[] a){
			this.heap = new int[n+1];
			this.sz = 0;
			for(int i = 0; i < a.length; i++) {
				this.push(a[i]);
			}
		}

		void push(int x) {
			int i = sz++;
			while(i > 0) {
				int p = (i-1)/2;
				if(heap[p] <= x) break;
				heap[i] = heap[p];
				i = p;
			}
			heap[i] = x;
		}

		 int pop() {
			int ret = heap[0];
			int x = heap[--sz];
			int i = 0;
			while(i*2+1<sz) {
				int a = i*2+1; int b = i*2+2;
				if(b < sz && heap[b] < heap[a]) a = b;
				if(heap[a] >= x) break;
				heap[i] = heap[a];
				i = a;
			}
			heap[i] = x;
			return ret;
		}
	}
}

Measured memory_bytes: 49464
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a>b) {
            
            System.out.println(a-1);
        }else {
            System.out.println(a);
        }
    }
} 

Measured memory_bytes: 35856
// 2020 3/24 ABC159 A The Number of Even Pairs

#include <iostream>
using namespace std;

int main(){
    int M, N;
    cin >> M >> N;
    int cnt = 0;

    if (M >=2) cnt += M * (M-1) / 2;
    if (N >=2) cnt += N * (N-1) / 2;

    cout << cnt << endl;

    return 0;
}

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

int main(){
    set<int> s;

    int N;
    cin >> N;

    int max = 0;

    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        s.insert(tmp);
        if(tmp > max) max = tmp;
    }

    int ans = 0;

    while(max > 0){
        if(s.count(max) != 0) ans++;
        max--;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	int n;
	std::string str;
	cin >> n >> str;
	if (std::count(str.cbegin(), str.cend(), 'B') < std::count(str.cbegin(), str.cend(), 'R'))
	{
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << "a > b" << endl;
    }
    else if (a < b) {
        cout << "a < b" << endl;
    }
    else if (a == b) {
        cout << "a == b" << endl;
    }
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;

bool isPrime[10000001];
std::vector<int> P, PQ;

int main(){
    std::fill(isPrime, isPrime+10000001, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i=4;i<=10000000;i+=2){
        isPrime[i] = false;
    }

    P.push_back(2);
    for(int i=3;i<=10000000;i+=2){
        if(isPrime[i]){
            P.push_back(i);
            for(int j=i*2;j<=10000000;j+=i){
                isPrime[j] = false;
            }
        }
    }
    
    for(int i=0;i+4<=P.size();i++){
        if(P[i]+2 == P[i+1] && P[i+1]+4 == P[i+2] && P[i+2]+2 == P[i+3]){
            //std::cout << P[i+3] << std::endl;
            PQ.push_back(P[i+3]);
        }
    }

    int n;
    while(std::cin >> n, n){
        int lb = 0, ub = PQ.size();
        while(ub-lb > 1){
            int mid = (lb+ub)/2;
            if(PQ[mid] > n){
                ub = mid;
            }else{
                lb = mid;
            }
        }
        std::cout << PQ[lb] << std::endl;
    }
}

Measured memory_bytes: 16668
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int N, M; scanf("%d%d", &N, &M);
    scc_graph G(N);
    rep(i, M) {
        int u, v; scanf("%d%d", &u, &v);
        G.add_edge(u, v);
    }
    auto ans = G.scc();
    printf("%d\n", ans.size());
    for (auto& V : ans) {
        printf("%d", V.size());
        for (auto v : V) printf(" %d", v);
        printf("\n");
    }
    return 0;
}

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

#define ll long long int

int main()
{
    string s1, s2;
    cin >> s1 >> s2;

    ll l1, l2;

    l1 = s1.size();
    l2 = s2.size();

    ll L[l1 + 1][l2 + 1];

    int i, j;
    for (i = 0; i <= l1; i++)
    {
        for (j = 0; j <= l2; j++)
        {
            if (i == 0 || j == 0)
            {
                L[i][j] = 0;
            }
            else
            {
                ll val1, val2, val3;
                if (s1[i - 1] == s2[j - 1])
                {
                    val1 = 1 + L[i - 1][j - 1];
                }
                else
                {
                    val1 = L[i - 1][j - 1];
                }
                val2 = L[i - 1][j];
                val3 = L[i][j - 1];

                L[i][j] = max(val1, max(val2, val3));
            }
        }
    }

    int index = L[l1][l2];

    // Create a character array to store the lcs string
    // char lcs[index + 1];
    vector<char> lcs;
    // lcs[index] = '\n'; // Set the terminating character

    // Start from the right-most-bottom-most corner and
    // one by one store characters in lcs[]
    i = l1, j = l2;
    while (i > 0 && j > 0)
    {
        // If current character in X[] and Y are same, then
        // current character is part of LCS
        if (s1[i - 1] == s2[j - 1])
        {
            lcs.push_back(s1[i - 1]); // Put current character in result
            i--;
            j--;
            index--; // reduce values of i, j and index
        }

        // If not same, then find the larger of two and
        // go in the direction of larger value
        else if (L[i - 1][j] > L[i][j - 1])
            i--;
        else
            j--;
    }

    // for(i=0;i<=l1;i++)
    // {
    //     for(j=0;j<=l2;j++)
    //     {
    //         cout << L[i][j] << " ";
    //     }
    //     cout << '\n';
    // }

    // cout << L[l1][l2] << '\n';

    for(i=lcs.size()-1;i>=0;i--)
    {
        cout << lcs[i];
    }
    cout << endl;
}

Measured memory_bytes: 70656
from collections import *
n=int(input())
l=[int(input()) for i in range(n)]
dic=Counter(l)
s=set(l)
a=max(s)
if(len(s)>1):
    s.remove(a)
    b=max(s)
for i in range(n):
    if(l[i]==a and dic[a]>1):
        print(a)
    elif(l[i]!=a):
        print(a)
    else:
        print(b)

Measured memory_bytes: 25704
import itertools

if __name__ == "__main__":
    n = input()

    if len(n) < 3:
        print(0)
        exit()

    ans = 0
    seq = ['0', '3', '5', '7']

    tmp = list(itertools.product(seq, repeat=len(n)))

    for t in tmp:
        if int(''.join(t)) <= int(n):
            a = str(int(''.join(t)))
            if '0' not in a and len(set(a)) == 3:
                ans += 1

    print(ans)


Measured memory_bytes: 36980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
int main()
{
	IOS;
	//int t; cin>>t;
	int t=1;
	while(t)
	{
		ll n,w; cin>>n>>w;
		ll dp[w+1]={0};
		for(ll item=0;item<n;item++)
		{
			ll weight,value; cin>>weight>>value;
			for(ll weight_already=w-weight;weight_already>=0;weight_already--)
			{
				dp[weight_already+weight]=max(dp[weight_already+weight],dp[weight_already]+value);
			}
		}
		ll ans=0;
		for(ll i=0;i<=w;i++)
		{
			ans=max(ans,dp[i]);
		}
		cout<<ans;
		t--;
	}
	return 0;
}

Measured memory_bytes: 4300
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
      
        int ans = (a + b) * h / 2;
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
H,W = [int(zz) for zz in input().split()]
L = [list(input()) for _ in range(H)]

p = ['.']*W
while p in L:
    L.remove(p)
    H -= 1

L2 = [[0]*H for _ in range(W)]
for h in range(H):
    for w in range(W):
        L2[w][h] = L[h][w]


q = ['.']*H
while q in L2:
    L2.remove(q)
    W -= 1

ans = [[0]*W for _ in range(H)]
for h in range(H):
    for w in range(W):
        print(L2[w][h], end="")
    print()


Measured memory_bytes: 43752