akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif







const ll MOD = 1e9+7;

template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
	constexpr u64 &value() noexcept { return a; }
	constexpr const u64 &value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint &operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint &operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint &operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
	
	friend ostream &operator<<(ostream &s,const modint &rhs) noexcept {
		return s << rhs.a;
	}
	
	modint pow(ll y) noexcept {
		modint result(1);
		modint x(a);
		
		while ( y ){
			if ( y & 1 )
				result *= x;
			x *= x;
			y >>= 1;
		}
		return result;
	}
};

using mint = modint<MOD>;

ll n, k;

int main(){
	cin >> n >> k;
	
	mint sum = 0;
	for ( ll i = k; i <= n+1; i++ ){
		// i個の数を選ぶと？
		
		ll smin = i*(i-1)/2; // i個選んだ時の和の下限
		ll smax = n*i - smin;
		
		sum += (smax-smin+1);
	}
	
	cout << sum << endl;
	
	return 0;
}




Measured memory_bytes: 3612
N,M=map(int,input().split())
A=[0]*N
B=[0]*N
pen=0
for i in range(M):
  p,S=input().split()
  if S=="AC":
    A[int(p)-1]=1
  elif S == "WA" and A[int(p)-1] == 0:
    B[int(p)-1] += 1
penalty=[A[i]*B[i] for i in range(N)]
print(sum(A),sum(penalty))


Measured memory_bytes: 5528
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
string s;
int ans;
int main(){
    cin>>s;
    ans=700;
    for(int i=0;i<s.length();i++){
     	if(s[i]=='o')ans+=100;
	}
	cout<<ans;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String Helix = sc.next();
        if (Helix.equals("A")) {
            System.out.println("T");
        } else if (Helix.equals("T")) {
            System.out.println("A");
        } else if (Helix.equals("G")) {
            System.out.println("C");
        } else if (Helix.equals("C")) {
            System.out.println("G");
        }
    }

}


Measured memory_bytes: 20564
s = ''.join(reversed(input()))
multiplier = 1
divisor = 10 ** 9 + 7
p = [0 for i in range(13)]
if s[0] != '?':
  p[int(s[0])] = 1
else:
  for j in range(10):
    p[j] = 1
for i in range(1, len(s)):
  multiplier = (10 * multiplier) % 13
  np = [0 for j in range(13)]
  if s[i] != '?':
    r = int(s[i]) * multiplier
    for j in range(13):
      np[(j + r) % 13] = p[j]
  else:
    for j in range(10):
      r = j * multiplier
      for k in range(13):
        np[(k + r) % 13] += p[k]
  for j in range(13):
    p[j] = np[j] % divisor
print(p[5] % divisor)


Measured memory_bytes: 51276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main(){
  double a,b,h,m;
  cin>>a>>b>>h>>m;

  double ang=30*h-5.5*m;
  
  double cc=a*a+b*b-2*a*b*cos(pi*ang/180);

  cout << fixed << setprecision (20);
  cout << sqrt(cc) << endl;
}


Measured memory_bytes: 4228
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int N, K;
  int n = 0;
  std::cin >> N;
  std::cin >> K;
  for (int i = 0; i < N; i++) {
    int buffer;
    std::cin >> buffer;
    if (buffer >= K) {
      n++;
    }
  }
  std::cout << n;
  return 0;
}

Measured memory_bytes: 256
/*
Date: 3/9/2020
Context: ZR3月省选集训
if (sum[x] >= 2 * max[x]) {
	f[x] = sum[x] / 2;
}
else {
	int u = mp[x];
	sum[x] - max[x] + max(0 \leq k \leq f[u], 2 * k \leq 2 * max[u] - sum[u]);
}
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 20000 + 10;
char ch[N];
int mx[N], sum[N], f[N], ver[N * 2], head[N], nex[N], tot, mp[N], ans;
int n, dist, cnt[N];
inline void add(int x, int y) {
	ver[++tot] = y;
	nex[tot] = head[x];
	head[x] = tot;
}
void dfs(int x, int fa) {
	
	for (int i = head[x]; i; i = nex[i]) {
		int y = ver[i];
		if (y == fa) continue;
		dfs(y, x);
		cnt[x] += cnt[y];
		sum[x] += sum[y] + cnt[y];
		if (sum[y] + cnt[y] > mx[x]) { 
			mp[x] = y;
			mx[x] = sum[y] + cnt[y];
		}
		/*
		mistake:
		if (sum[y] > mx[x]) {
			mp[x] = y;
			mx[x] = sum[y];
		}
		*/
	
	}
	if (ch[x] == '1') {
		cnt[x]++;
	}
	if (head[x] == 0) return;

	if (sum[x] - mx[x] >= mx[x]) {

		f[x] = sum[x] / 2;
	}
	else {
		int u = mp[x];
		f[x] = sum[x] - mx[x] + min(f[u], (2 * mx[x] - sum[x]) / 2);
	}
	// cout << "dfs::x " << x << endl;
}

inline void solve(int x) {
	memset(mx, 0, sizeof(mx));
	memset(sum, 0, sizeof(sum));
	memset(cnt, 0, sizeof(cnt));
	dist = 0;
	dfs(x, 0);

	if (sum[x] % 2) return;
	if (f[x] == sum[x] / 2) {
		ans = min(f[x], ans);
	}
}
signed main() {
	ans = 1e9 + 7;
	ios::sync_with_stdio(0);
	cin >> n;
	cin >> ch + 1;
	for (int i = 1, u, v; i <= n - 1; i++) {
		cin >> u >> v;
		add(u, v);
		add(v, u);
	}
	for (int i = 1; i <= n; i++) {
		solve(i);
	}
	if (ans == 1e9 + 7) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int a,b,ab,na,nb;cin>>a>>b>>ab>>na>>nb;
	int ans1,ans2,ans3;
	ans1 = a*na+b*nb;
	ans2 = nb*2*ab+max(0LL,na-nb)*a;
	ans3 = na*2*ab+max(0LL,nb-na)*b;
	//cout<<ans1<<" "<<ans2<<" "<<ans3<<" ";
	cout<<min({ans1,ans2,ans3});
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    PUTS(min(n*a,b));
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int H, int W, string[] S)
        {
            long sum = 0;
            bool[][] visited = new bool[H][];
            for (int i = 0; i < H; ++i) { visited[i] = new bool[W]; }
            for (int i = 0; i < H; ++i)
            {
                for (int j = 0; j < W; ++j)
                {
                    long white = 0;
                    long black = 0;
                    if (!visited[i][j])
                    {
                        var queue = new Queue<Tuple<int, int>>();
                        queue.Enqueue(new Tuple<int, int>(i, j));
                        visited[i][j] = true;
                        if (S[i][j] == '#') { ++black; } else { ++white; }
                        while (queue.Count > 0)
                        {
                            var p1 = queue.Dequeue();
                            int i1 = p1.Item1;
                            int j1 = p1.Item2;
                            foreach (var p2 in new[] { new Tuple<int, int>(i1 - 1, j1),
                                                       new Tuple<int, int>(i1 + 1, j1),
                                                       new Tuple<int, int>(i1, j1 - 1),
                                                       new Tuple<int, int>(i1, j1 + 1) })
                            {
                                int i2 = p2.Item1;
                                int j2 = p2.Item2;
                                if (0 <= i2 && i2 < H && 0 <= j2 && j2 < W && !visited[i2][j2] && S[i1][j1] != S[i2][j2])
                                {
                                    queue.Enqueue(p2);
                                    visited[i2][j2] = true;
                                    if (S[i2][j2] == '#') { ++black; } else { ++white; }
                                }
                            }
                        }
                    }
                    sum += black * white;
                }
            }
            return sum;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int H = V[0], W = V[1];
            var S = new string[H];
            for (int i = 0; i < H; ++i) { S[i] = Read(); }
            Console.WriteLine(Solve(H, W, S));
        }
    }
}


Measured memory_bytes: 17984
fn main() {
    // input
    let input = read_vec::<i32>();

    // K
    let k = input[0];
    // X
    let x = input[1];


    let mut min = x  - (k-1);
    let mut max = x  + k;


    if min < -1000000 {
        min = -1000000;
    }
    if max > 1000000 {
        max = 1000000;
    }

    let ans = (min..max).map(|i| i.to_string() ).collect::<Vec<_>>().join(" ");

    println!("{}", ans);
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
	
	int x1,x2,x3,x4,x5;
	cin>>x1>>x2>>x3>>x4>>x5;
	
	if(x1==0)
	{
		
		cout<<"1"<<endl;
		
		
	}
	
	else if(x2==0)
	{
		
		
		cout<<"2"<<endl;
		
	}
	
	
	else if(x3==0)
	{
		
		cout<<"3"<<endl;
		
	}
	
	
	else if(x4==0)
	{
		
		cout<<"4"<<endl;
		
	}
	
	
	else if(x5==0)
	{
		
		cout<<"5"<<endl;
		
	}
	
	
	return 0;
	
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e18;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	v<ll> pre(n);
	pre[0]=a[0];
	for(int i=1;i<n;i++){
		pre[i]=a[i]+pre[i-1];
	}
	v<v<ll>> dp(n,v<ll>(n));
	for(int i=n-1;i>=0;i--){
		for(int j=0;i+j<n;j++){
			if(j==0){
				dp[i][j]=0;
			}
			else if(j==1){
				dp[i][j]=a[i]+a[i+1];
			}
			else{
				ll min=INF;
				for(int k=0;k<j;k++){
					ll h;
					if(i!=0)
						h=dp[i][k]+dp[i+k+1][j-k-1]+pre[i+j]-pre[i-1];
					else
						h=dp[i][k]+dp[i+k+1][j-k-1]+pre[i+j];
					if(h<min){
						min=h;
					}
				}
				dp[i][j]=min;
			}
		}
	}
	cout<<dp[0][n-1]<<"\n";
}	

int main(){
	boost_io;
	cout<<setprecision(10);
	solve();
	return 0;
}


Measured memory_bytes: 4528
#include <stdio.h>
#define N 6
#define MAX 102

typedef struct{
	int face[N];
} dice;

void rollDiceE(dice *d){
	int temp = d->face[3];
	d->face[3] = d->face[5];
	d->face[5] = d->face[2];
	d->face[2] = d->face[0];
	d->face[0] = temp;
}

void rollDiceS(dice *d){
	int temp = d->face[4];
	d->face[4] = d->face[5];
	d->face[5] = d->face[1];
	d->face[1] = d->face[0];
	d->face[0] = temp;
}

int main(void){

	dice d;
	int i, j;
	char str[MAX];
	
	for(i = 0; i < N; i++){
		scanf("%d", &d.face[i]);
	}
	while(fgets(str, MAX, stdin) != NULL){
		for(i = 0; str[i] != '\n'; i++){
			if(str[i] == 'E'){
				rollDiceE(&d);
			}
			else if(str[i] == 'W'){
				for(j = 0; j < 3; j++){
					rollDiceE(&d);
				}
			}
			else if(str[i] == 'S'){
				rollDiceS(&d);
			}
			else if(str[i] == 'N'){
				for(j = 0; j < 3; j++){
					rollDiceS(&d);
				}
			}
		}
	}
	printf("%d\n", d.face[0]);	
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double 
#define foi(a,n) for(int i = a; i < n; i++)
#define ee 1000000007
#define pb push_back

ll fast(ll base, ll power, ll mod=ee){
    ll ans =1;
    base%=mod;
    while(power){
        if(power&1){
            ans*=base;
            ans%=mod;
        }
        base*=base;
        base%=mod;
        power>>=1;
    }
    return ans;
}

void solve() {
    ll n;
    cin >> n;
	ll x = fast(10, n);
	x -= 2LL * fast(9, n);
	x += fast(8, n);
	x %= ee;
	if(x < 0) x += ee;
	x %= ee;
	cout << x;
}

int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t = 1;
    //~ cin >> t;
    while(t--){
		solve();
		//~ cout << '\n';
	}
}


Measured memory_bytes: 3568
#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 all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N,A,B;
	cin>>N>>A>>B;
	string S;
	cin>>S;
	int cntall=0,cntb=0;
	rep(i,N){
		if(S[i]=='a'&&cntall<A+B){
			cntall++;
			cout<<"Yes"<<endl;
		}
		else if(S[i]=='b'&&(cntall<A+B&&cntb<B)){
			cntall++;
			cntb++;
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 896
from collections import defaultdict
import sys

input = lambda: sys.stdin.readline().rstrip()

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

class mod_int(int):
  def __new__(cls, i=0, *args, **kwargs):
    return int.__new__(cls, i%M, *args, **kwargs)
  
  def __add__(self, x):
    return self.__class__(int.__add__(self, x))
    
  def __sub__(self, x):
    return self.__class__(int.__sub__(self, x))
    
  def __neg__(self):
    return self.__class__(int.__neg__(self, x))
  
  def __mul__(self, x):
    return self.__class__(int.__mul__(self, x))
  
  def __floordiv__(self, x):
    a, b = ext_euc(x, M)
    return self * a
  
  def __pow__(self, x):
    return self.__class__(int.__pow__(self, x, M))

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
  sum_g = defaultdict(mod_int)
  sum_g[0] = (B**(N+1) - B) // (B-1)
  prev = 0
  W = mod_int(1)
  for i in range(1, N+1):
    if i in g:
      W *= B**(i-prev)
      sum_g[g[i]] +=  W
      sum_g[0]  -= W
      prev, W = i, W
  
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = mod_int(0)
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret += sx*sy*sz
  return ret


M = 998244353
B = mod_int(10) ** 18
N = int(input())

edge = [read_edge() for i in range(3)]

print(solve(N, edge))

Measured memory_bytes: 61328
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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 int INF = 1e9;

int N, K;

//アクセスできるのは最大左右からK個
//途中のものを1個戻すたびにアクセスできる個数は2個減る
//いったん取ったら戻す必要があるのは負のもののみ
//Kまでの数字で、Dの左端と右端をシーケンシャルに見る
//全部取り、マイナスが最大のものから残った回数だけ
//戻していく 結果の値が答え


int main() {
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++) cin >> V[i];

    int res = -INF;
    //k...何個取り出すか
    for (int k = 0; k <= min(N,K); k++) {
        //i...左から何個取り出すか
        for (int i = 0; i <= k; i++) {
            int tmp = 0;
            priority_queue<int,vector<int>,greater<int> > que;
            for (int j = 0; j < i; j++) {
                if (V[j] < 0) que.push(V[j]);
                tmp += V[j];
            }
            for (int j = N-1; j > N-1-(k-i); j--) {
                if (V[j] < 0) que.push(V[j]);
                tmp += V[j];
            }
            for (int j = 0; j < K - k; j++) {
                if (!que.empty()) {
                    tmp -= que.top(); que.pop();
                }
            }
            chmax(res,tmp);
        }
        
    }
    cout << res << endl;
}



Measured memory_bytes: 256
// Problem : A - New Year
// Contest : AtCoder - AtCoder Beginner Contest 084
// URL : https://atcoder.jp/contests/abc084/tasks/abc084_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
int n;cin>>n;
cout<<24+(24-n);
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 N, K;
  cin >> N >> K;
  if(K == 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << N - K << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll seg[6*N];
void update(int ind,int rl,int rr,int idx,ll val)
{
       if(rl==rr){
              seg[ind] = val;
              return;
       }
       int mid = (rl+rr)/2;
       if(idx<=mid && idx>=rl){
              update(2*ind,rl,mid,idx,val);
       }
       else{
              update(2*ind+1,mid+1,rr,idx,val);
       }
       seg[ind] = max(seg[2*ind],seg[2*ind+1]);
}
ll q(int ind,int rl,int rr,int ql,int qr)
{
       if(ql>rr || rl>qr){return 0;}
       if(rl>=ql && rr<=qr){return seg[ind];}
       int mid = (rl+rr)/2;
       return max(q(2*ind,rl,mid,ql,qr),q(2*ind+1,mid+1,rr,ql,qr));
}
int main()
{
       memset(seg,0,sizeof seg);
       int n;
       cin>>n;
       ll h[n];
       ll a[n];
       arrin(h,n);
       arrin(a,n);
       fri(i,0,n){h[i]--;}
       ll ans[n];
       ll maxi = 0;
       fri(i,0,n){
              ll qq = q(1,0,n-1,0,h[i]);
              ans[i] = qq+a[i];
              update(1,0,n-1,h[i],ans[i]);
              maxi = max(maxi,ans[i]);
       }
       cout<<maxi<<endl;
}


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

int main(){

  int N; cin>>N;
  
  vector<int> card(N);

  int alice=0,bob=0;

  for(int i=0; i<N; i++){
    cin>> card.at(i);
  }

  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());

  for( int i=0; i<N; i++){

    if( i % 2 == 0) alice += card.at(i);

    if(i % 2 !=0) bob += card.at(i);

  }

  cout<<alice - bob<<endl;

  return 0;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split(' ');
    var n = parseInt(args[0], 10);
    const k = parseInt(args[1], 10);
  	var ans = 0;
  
	while (n > 0) {
      	n = Math.floor(n / k);
      	ans++;
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
def B(info):
    rgb = [0]*3
    *rgb, n = map(int,info.split())
    rgb.sort(reverse = True)
    count = 0
    for i in range(n//rgb[0]+1):
        new_n = n - i*rgb[0]
        if new_n < rgb[2]:
            if new_n == 0:
                count += 1
            continue
        for j in range(new_n//rgb[1]+1):
            if (new_n-rgb[1]*j)%rgb[2] == 0:
                count += 1

    return count

    
if __name__ == '__main__':
    print(B(input()))



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

#define int long long
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF=1l<<60;


signed main(){
	int N;
 	cin>>N;
  	int ans=0;
  	for(int j=1;j<=N;++j){
      int k=N/j;
      ans+=j*k*(k+1)/2;
    }
  	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

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

		String s = sc.nextLine();
		String t = "CODEFESTIVAL2016";

		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != t.charAt(i)) {
				count++;
			}
		}

		System.out.println(count);

		sc.close();
	}
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 1000000007;
const Int MAX = 600000;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
Int 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 main() {
    COMinit();
    int N, M; cin >> N >> M;
    auto f = [&](Int t) -> Int {
        Int ans = COM(M, t) * COM(N, t) % MOD * fac[t] % MOD;
        ans = ans * COM(M - t, N - t) % MOD * COM(M - t, N - t) % MOD;
        ans = ans * fac[N - t] % MOD * fac[N - t] % MOD;
        return ans;
    };
    Int ans = 0;
    ans += COM(M, N) * fac[N] % MOD * COM(M, N) % MOD * fac[N] % MOD;
    for (int t = 1; t <= N; t++) {
        ans += MOD;
        ans += (t % 2 ? -1 : +1) * f(t);
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 17688
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e12;

vector<long long int> divisors(long long int n){// list of divisors (sorted)
    vector<long long int> div;
    for (long long int i=1; i*i<=n; i++){
        if (n % i == 0){
            //div.push_back(i);

            long long int j = n / i;// counterpart
            div.push_back(j);
        }
    }
    sort(div.begin(), div.end());
    return div;
}

int main(){
    long long int n, s;
    cin >> n >> s;
    
    long long int ans = INF;
    for(long long int b=2; b*b<=n; b++){
        long long int sum = 0, nn = n;
        while(nn > 0){
            sum += (nn % b);
            nn /= b;
        }
        if(sum == s){
            ans = min(ans, b);
        }
    }

    vector<long long int> d = divisors(n-s);
    for(int i=0; i<d.size(); i++){
        long long int b = d[i] + 1;

        if(n/b + n%b == s){
            ans = min(ans, b);
        }
    }

    if(n == s) ans = min(ans, s+1);

    if(ans != INF) cout << ans << endl;
    if(ans == INF) cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N+1];
    for(int i = 1; i <= N; i++) h[i] = sc.nextInt();
    int[] dp = new int[N+1];
    dp[1] = 0;
    dp[2] = Math.abs(h[2] - h[1]);
    for(int i = 2; i <= N; i++) {
      int min = Integer.MAX_VALUE;
      for(int k = 1; k <= K && i - k >= 1; k++) {
        min = Math.min(min, dp[i - k] + Math.abs(h[i] - h[i - k]));
      }
      dp[i] = min;
    }
    System.out.println(dp[N]);
  }
}



Measured memory_bytes: 49216
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>

using namespace std;
constexpr int D = 365;
vector<int> c(26);
vector< vector<int> > s(D, vector<int>(26));
vector<int> num(D), num2(D), ans(D);

int score() {
    int sat = 0;
vector<int> last(26);
    for (int d=0; d<D; d++) {
        int j = num[d] - 1;
        last[j] = d + 1;
        for(int i=0; i<26; i++) {
            sat -= (d + 1 - last[i]) * c[i];
        }
        sat += s[d][j];
    }
    return sat;
}

int main(void) {
    int g;
    cin >> g;
    for(int i=0; i<26; i++) {
        cin >> c[i];
    }
    for(int i=0; i<D; i++) {
        for(int j=0; j<26; j++) {
            cin >> s[i][j];
        }
    }
    int temp = numeric_limits<int>::min();
    vector<int> v(26);
    iota(v.begin(), v.end(), 0);
    random_device seed_gen;
    default_random_engine engine(seed_gen());
    uniform_int_distribution<> dist(0, 25);
    int loop = 280000;
    while(--loop) {
        int l = dist(engine);
        int r = dist(engine);
        if(l == r) continue;
        swap(v[l], v[r]);
        for(int d=0; d<D; d++) {
            num[d] = v[d%26] + 1;
        }
        if(int sat = score(); sat > temp) {
            ans = num;
            temp = sat;
        // } else {
        //     num[l] = ans[l];
        //     num[r] = ans[r];
        }
    }

    for(int i=0; i<D; i++) {
        cout << ans[i] << endl;
    }
    cerr << temp << endl;
    return 0;
}


Measured memory_bytes: 3696
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0114
"""
import sys


def lcm(x, y):
    return x*y//gcd(x, y)


def gcd(x, y):
    if x < y:
        temp = x
        x = y
        y = temp
    while y > 0:
        r = x % y
        x = y
        y = r
    return x


def solve(data):
    a1, m1, a2, m2, a3, m3 = data
    x_cycle = y_cycle = z_cycle = 0
    x = y = z = 1

    while True:
        x = (a1 * x) % m1
        x_cycle += 1
        if x == 1:
            break
    while True:
        y = (a2 * y) % m2
        y_cycle += 1
        if y == 1:
            break
    while True:
        z = (a3 * z) % m3
        z_cycle += 1
        if z == 1:
            break

    return lcm(lcm(x_cycle, y_cycle), z_cycle)


def main(args):
    # data = [2, 5, 3, 7, 6, 13]
    #data = [517, 1024, 746, 6561, 4303, 3125]
    while True:
        data = [int(x) for x in input().split(' ')]
        if data.count(0) == 6:
            break
        result = solve(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
bool seen[510][510];
/*void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}*/

//input



//processing




//dpTable
//int dp[100050];
int main(){
    int N,Y;
    cin >> N >> Y;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N - i; j++) {
            int k = N - i - j;
            if ((10000 * i + 5000 * j + 1000 * k) == Y) {
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 3620
import statistics
import math
n = int(input())
A = list(map(int, input().split()))

aa = []

for i in range(n):
    aa.append(A[i] - 1 - i)
# print(aa)
b = int(statistics.median(aa))

ans = 0

for a in aa:
    ans += abs(a-b)

print(ans)


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

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

    int a, b, x;

    cin >> a >> b >> x;
    if(a > x){
        cout << "NO" << endl;
        return 0;
    }

    a + b >= x ? cout << "YES" << endl : cout << "NO" << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
using namespace std;

static const int MAX_N = 100000, MAX_M = 100000;
typedef pair<int, int> Pr;

int main(void){
  int N, M;
  int a[MAX_M], b[MAX_M];
  //入力
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
  }
  Pr dem[MAX_M];

  for(int i = 0; i < M; i++){
    dem[i].first = b[i];
    dem[i].second = a[i];
  }
  sort(dem, dem + M);

  int cntDem = 0, tempFin = 0;
  for(int i = 0; i < M; i++){
    if(tempFin <= dem[i].second){
      cntDem++;
      tempFin = dem[i].first;
    }
  }
  cout << cntDem << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

string s;
map<int, int> dp;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    dp[0] = 0;
    int x = 0;
    for (int i = 0; i < s.size(); i++)
    {
        x ^= 1 << (s[i] - 'a');
        int val = 1e9;
        if (dp.find(x) != dp.end()) val = dp[x];
        for (int u = 0; u < 26; u++) if (dp.find(x ^ (1 << u)) != dp.end()) val = min(val, dp[x ^ (1 << u)] + 1);
        dp[x] = val;
    }
    cout << max(1, dp[x]);
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    string S;
    cin >> S;

    i64 ans=0,cnt=0;
    rep(i,0,S.size()){
        if(S[i]=='B') ++cnt;
        else ans+=cnt;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];

int b[N];
char s[N];
char t[N];
ll f[N];
int used[15];
int cmp1(ll a,ll b)
{
    return b<a;
}

multiset<int> ss;
map<int,int>mp;
int main()
{
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3632
import math
mod = 10**9+7

n,k = map(int,input().split())
cnt = [0]*(k+1)
ans = 0
for i in range(k,0,-1):
    cnt[i] = pow(k//i,n,mod)
    for j in range(2,k//i+1):
        cnt[i] -= cnt[i*j]
        if cnt[i] < 0:
            cnt[i] += mod
    ans += cnt[i]*i
    if ans > mod:
        ans %= mod
print(ans)


Measured memory_bytes: 68980
n = int(input())
t = [0]*n
x = [0]*n
y = [0]*n
for i in range(n):
    t[i],x[i],y[i] = map(int,input().split())
now = 0
ans = 1
x0 = 0
y0 = 0
for i in range(n):
    if i == 0:
        if x[i]+y[i] > t[i]:
            ans = 0
            break
        elif (x[i]+y[i]-t[i])%2 == 1:
            ans = 0
            break
    else:
        if abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) > t[i]-t[i-1]:
            ans = 0
            break
        elif (abs(x[i]-x[i-1])+abs(y[i]-y[i-1])-t[i]+t[i-1])%2 == 1:
            ans = 0
            break
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 11636
N,M = map(int,input().split())
lst = [10**9] * N
flag = False
for i in range(M):
  s,c = map(int,input().split())
  if (lst[s-1] == 10**9):
    lst[s-1] = c
  else:
    if (lst[s-1] != c):
      flag = True
      break

if (flag == True):
  print(-1)
else:
  if (lst[0] == 10**9):
    if (N==1):
      print(0)
    else:
      lst[0] = 1
      for i in range(1,N):
        if (lst[i] == 10**9):
          lst[i] = 0
      str_lst = list((map(str,lst)))
      print(''.join(str_lst))
  else:
    if (lst[0] == 0):
      if (N==1):
        print(0)
      else:
        print(-1)
    else:
      for i in range(N):
        if (lst[i] == 10**9):
          lst[i] = 0
      str_lst = list((map(str,lst)))
      print(''.join(str_lst))


Measured memory_bytes: 38384
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: i64 = read();
    let k: i64 = read();
    let vec: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut set: HashSet<i64> = HashSet::new();
    let mut map: HashMap<i64, i64> = HashMap::new();

    for &i in vec.iter() {
        set.insert(i);
        *map.entry(i).or_insert(0) += 1;
    }
    let mut kezurukazu = set.len() as i64 - k;
    let mut each_num: Vec<(i64, i64)> = Vec::new();
    for (&key, &value) in map.iter() {
        let each: (i64, i64) = (key, value);
        each_num.push(each);
    }

    each_num.sort_by_key(|e| e.1);

    let mut count = 0;
    let mut index = 0;
    while kezurukazu > 0 {
        count += each_num[index].1;
        index+=1;
        kezurukazu-=1;
    }

    println!("{}", count);
}

fn calc_distance(x: i32, y: i32, target_x: i32, target_y: i32) -> i32 {
    let diff_x = (target_x - x).abs();
    let diff_y = (target_y - y).abs();

    return diff_x + diff_y;
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    map<int,int> mp;
    ll sum=0;
    for(auto &x:v){
        cin>>x;
        sum+=x;
        mp[x]++;
    }
    int q,b,c;
    cin>>q;
    while(q--){
        cin>>b>>c;
        sum-=1LL*b*mp[b];
        sum+=1LL*c*mp[b];
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<'\n';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 8228
#include <iostream>
	#include <string> 

	using namespace std;
	//if 3th and 4th same and 5th and 6th same, print yes, else no
	int main(){
		string word;
		cin>>word;
		if(word[2]==word[3] && word[4]==word[5])
			cout<<"Yes"<< endl;
			else
			cout << "No"<< endl;
	return 0;
	}


	

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

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<int> dp(H + 1, 1 << 28);
  dp[0] = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < N; j++) {
      chmin(dp[min(H, i + A[j])], dp[i] + B[j]);
    }
  }
  cout << dp[H] << '\n';
  return 0;
}


Measured memory_bytes: 256
import Debug.Trace
import Data.Char (ord)

solve (a:as) bs cs 0 = solve as bs cs a
solve as (b:bs) cs 1 = solve as bs cs b
solve as bs (c:cs) 2 = solve as bs cs c
solve _ _ _ 0 = "A"
solve _ _ _ 1 = "B"
solve _ _ _ 2 = "C"

charToInt c = ord c - ord 'a'

main = do
    s <- getContents
    let [a, b, c] = map (map charToInt) . lines $ s
    putStrLn $ solve a b c 0


Measured memory_bytes: 508
# -*- coding: utf-8 -*-
import sys

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
A = list(map(int, input().split()))

A.sort()

a = make_divisors(A[0])

a.sort(reverse = True)

for i in a:
    for j in range(N):
        if A[j] % i != 0:
            break
        if j == N - 1:
            print(i)
            sys.exit()

Measured memory_bytes: 14252
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}
$s = getq();
$moji=array();
for($i=0;$i<$s;$i++){
	array_push($moji,getq());
}
for($i=0;$i<$s;$i++){
	for($j=0;$j<$s;$j++){
		if($i!=$j){
		if($moji[$i]==$moji[$j]){
			echo "No\n";
			exit(0);
		}
		}
	}
}
for($i=1;$i<$s;$i++){
	//echo($moji[$i][0] ."-". $moji[$i-1][strlen($moji[$i-1])-1]);
	if($moji[$i][0] != $moji[$i-1][strlen($moji[$i-1])-1]){
		echo "No\n";
		exit(0);
	}
}
echo "Yes\n";
?>

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

using namespace std;
using ll = long long int;

int main () {
    ll n;
    ll m;
    cin >> n >> m;

    ll sum = 0;
    for (size_t i = 0; i < m; i++)
    {
      ll ai;
      cin >> ai;
      sum += ai;
    }

    if (sum > n) {
      cout << -1 << endl;
    } else {
      cout << (n - sum) << endl;
    }
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define DEKAI (int)(1e9+7)
#define lp(i,n) for(int i=0;i<n;i++)
#define INF (1<<28)

int main(){
  while(1){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0&&b==0&&c==0) break;
    int ansa=INF,ansb=INF;
    int i=-1;
    while(1){
      i++;
      if(i>ansa+ansb+10000) break;
      int aa=a*i;
      if(aa>=c&&(aa-c)%b==0){
	if(ansa+ansb>i+(aa-c)/b){
	  ansa=i;
	  ansb=(aa-c)/b;
	}
	else if(ansa+ansb==i+(aa-c)/b){
	  if(ansa*a+ansb*b>i*a+(aa-c)){
	    ansa=i;
	    ansb=(aa-c)/b;
	  }
	}
      }
      if((aa+c)%b==0){
	if(ansa+ansb>i+(aa+c)/b){
	  ansa=i;
	  ansb=(aa+c)/b;
	}
	else if(ansa+ansb==i+(aa+c)/b){
	  if(ansa*a+ansb*b>i*a+(aa+c)){
	    ansa=i;
	    ansb=(aa+c)/b;
	  }
	}
      }
      if(c>=aa&&(c-aa)%b==0){
	if(ansa+ansb>i+(c-aa)/b){
	  ansa=i;
	  ansb=(c-aa)/b;
	}
	else if(ansa+ansb==i+(c-aa)/b){
	  if(ansa*a+ansb*b>i*a+(c-aa)){
	    ansa=i;
	    ansb=(c-aa)/b;
	  }
	}
      }
    }
    cout<<ansa<<" "<<ansb<<endl;
    // cout<<ansa*a<<" "<<ansb*b<<" "<<c<<" "<<abs(ansa*a-ansb*b)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080