akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
char ch[N];
int n;
void GG(){
	puts("-1"); exit(0);
}
int main(){
	scanf("%s",ch+1);
	n=strlen(ch+1);
	for(int i=1;i<n;i++)if(ch[i]!=ch[n-i])GG();
	if(ch[n]=='1')GG();
	if(ch[1]=='0')GG();
	int dq=1;
	ch[n]='1';
	
	for(int i=2;i<=n;i++)if(ch[i]=='1'){
		for(int j=dq;j<i;j++){
			wri(j); writeln(i);
		}
		dq=i;
	}
}


Measured memory_bytes: 1536
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

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 main() {
    let a: isize = read();
    let b: isize = read();

    println!("{}", max(0, a - b * 2));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long int
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

void solve(){
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979311599796346854418516159057617187500
#define endl '\n'
const ll N=150000+5,mod=1e9+7,bit=31;
signed main()
{
    fast;
    ll pro=1,temp,t,m,k,i,j,l,r,n,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,nxt,sum=0,flag=1,i1=-1,i2=-1;
	cin>>n;
	ll a[n];
	ld inv=0.000;
	rep(i,0,n-1)
	{
		cin>>a[i];
		inv+=(1.000000000/(ld)a[i]);
	}
	inv=1.000000000000000000/inv;
	cout<<fixed<<setprecision(15)<<inv<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
	int a[5],i,j,n;
	for(i=0;i<5;i++){
	std::cin>>a[i];
	}
	for(i=0;i<4;i++){
		for(j=i+1;j<5;j++){
			if(a[i]<a[j]){
			n=a[i];
			a[i]=a[j];
			a[j]=n;
			}
		}
	}
	std::cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<std::endl;
	return 0;
}

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e4 + 4;
int a[N];

void pre() {
    REP(x, 1, 100) {
    	REP(y, 1, 100) {
    		REP(z, 1, 100) {
    			ll p = x*x + y*y + z*z + x*y + y*z + z*x;
    			if(p < N) ++a[p];
    		}
    	}
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int n;
    cin >> n;
    REP(i, 1, n+1) cout << a[i] << "\n";	
    return 0;
}


Measured memory_bytes: 3648
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n = int(lines.pop(0))
b_list = [int(b) for b in lines.pop(0).split(" ")]
b_list.append(sys.maxsize)
def _iter():
    prev_b = sys.maxsize
    for b in b_list:
        yield min(prev_b, b)
        prev_b = b
answer = sum(_iter())
print(answer)


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

using namespace std;

int main(void) {
  cout << fixed << setprecision(10);
  int n; cin >> n;
  double invans = 0.0;

  for (int i = 0; i < n; i++) {
    double d; cin >> d;
    invans += 1.0/d;
  }

  double ans = 1.0 / invans;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 100005;

int n, sz[MAXN], smax[MAXN];
vector<pi> gph[MAXN];
int flag;

lint dfs(int x, int p){
	sz[x] = 1;
	lint ret = 0;
	for(auto &i : gph[x]){
		if(i.second == p) continue;
		ret += dfs(i.second, x);
		smax[x] = max(smax[x], sz[i.second]);
		int szz = 2 * min(n - sz[i.second], sz[i.second]);
		if(szz == n){
			flag = i.first;
		}
		ret += 1ll * szz * i.first;
		sz[x] += sz[i.second];
	}
	smax[x] = max(smax[x], n - sz[x]);
	return ret;
}

int main(){
	scanf("%d",&n);
	for(int i=0; i<n-1; i++){
		int s, e, x;
		scanf("%d %d %d",&s,&e,&x);
		gph[s].push_back(pi(x, e));
		gph[e].push_back(pi(x, s));
	}
	lint k = dfs(1, -1);
	if(flag == 0){
		int w = min_element(smax + 1, smax + n + 1) - smax;
		flag = 1e9;
			for(auto &j : gph[w]){
				flag = min(flag, j.first);
		}
	}
	cout << k - flag << endl;
}


Measured memory_bytes: 11904
a=gets.chomp.split(" ")
a.map!{|x| x.to_i}
suma=a.inject{|sum,n| sum + n}

b=gets.chomp.split(" ")
b.map!{|x| x.to_i}
sumb=b.inject{|sum,n| sum + n}

if suma >= sumb
	puts suma
elsif suma < sumb
	puts sumb
end


Measured memory_bytes: 6864
import scala.io.StdIn

object Main extends App {
  val s = StdIn.readLine.split(" ")
  val a = s(0).toInt
  val b = s(1).toInt

  var solved: Boolean = false
  if (a > 8 || b > 8) {
    solved = false
  } else {
    solved = true
  }
  val result = if (solved) {
    "Yay!"
  } else {
    ":("
  }
  println(result)
}

Measured memory_bytes: 25544
import java.util.Scanner;

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

		int pt = 0;
		int ph = 0;
		for (int i = 0; i < n; i++) {
			String[] strs = in.nextLine().split(" ");
			String strTaro = strs[0];
			String strHanako = strs[1];
			int diff = strTaro.compareTo(strHanako);
			if (diff == 0) {
				pt++;
				ph++;
			} else if (diff > 0) {
				// win taro
				pt += 3;
			} else {
				ph += 3;
			}
		}
		System.out.printf(String.format("%d %d\n", pt, ph));
	}
}

Measured memory_bytes: 31300
#include<iostream>
//#include<cstring>
#include<cmath>
//#include<cstdio>
//#include<algorithm>
using namespace std;

long x,y; 

int main(){
	cin>>x>>y;
	if(x%y!=0){
		cout<<x<<endl;
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}  

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

int main() {
int N;
  double ansud;
  cin >> N;
  vector<double> a(N);
  ansud = 0;
    rep(i,N){
      cin >> a.at(i);
      ansud += 1/a.at(i);
    }
  printf("%.20lf\n", 1/ansud);
}

Measured memory_bytes: 256
using System;

namespace AOJ
{
  class Program
  {
    static void Main()
    {
      char[] str = Console.ReadLine().ToCharArray();
      char[] str2;

      int q = int.Parse(Console.ReadLine());
      string[] data;
      string order;
      int a, b, i, j, n, m;
      char w;

      for (i = 0; i < q; i++)
      {
        data = Console.ReadLine().Split(' ');
        order = data[0];
        a = int.Parse(data[1]);
        b = int.Parse(data[2]);

        if (order == "print")
        {
          for (j = a; j <= b; j++) Console.Write(str[j]);
          Console.WriteLine();
        }
        else if (order == "reverse")
        {
          for (n = a, m = b; n < m; n++, m--)
          {
            w = str[n];
            str[n] = str[m];
            str[m] = w;
          }
        }
        else if (order == "replace")
        {
          str2 = data[3].ToCharArray();
          for (j = 0; j < b - a + 1; j++) str[a + j] = str2[j];
        }
      }
    }
  }
}

Measured memory_bytes: 8948
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    double mean = accumulate(all(a), 0.0) / n;
    double mn = 1e18;
    int ans = -1;
    rep(i, n) {
        if (chmin(mn, abs(a[i] - mean))) ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

ll k,s;

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

  cin >> k >>s ;
  ll sum=0;
  ll max,min;
  REP(i,k+1){
    if(s-i>=0&&s-i<=2*k) {
      min =0;
      if((s-i-k)>=0) min=s-i-k;
      max=s-i;
      if(s-i>=k) max=k;
      sum += max-min+1;
    }
  }




  cout <<sum <<endl;
  return 0;
}

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

namespace bla
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string s = Console.ReadLine();
            int w = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if(s[i] == 'W')
                {
                    w++;
                }
            }
            int min = w;
            int wchange = 0;
            int echange = s.Length - w;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'E')
                {
                    echange--;
                }
                min = Math.Min(min, wchange + echange);
                if(s[i] == 'W')
                {
                    wchange++;
                }
            }
            Console.WriteLine(min);
        }
    }
}


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

using ll=long long;



void solve(){
    int d;
    cin>>d;
    if(d==25)cout<<"Christmas"<<endl;
    if(d==24)cout<<"Christmas Eve"<<endl;
    if(d==23)cout<<"Christmas Eve Eve"<<endl;
    if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10 ** 9 + 7

s = [0 for i in range(k+1)]

ret = 0
for i in range(k,0,-1):
	a = int(k/i)
	c = pow(a,n,mod)
	for j in range(2,k+1):
#		print("aaa",i,j,k)
		if i*j <= k:
			c -= s[i*j]
		else :
			break
	s[i] = c%mod
#	print(i,a,c%mod,(c*i)%mod)
	ret = (ret+(c%mod)*i)%mod
print(ret)

Measured memory_bytes: 79456
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];
        var seqH = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        Console.WriteLine(seqH.Count(x => x >= k));
    }
}


Measured memory_bytes: 19296
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll D;
string K;
ll n;
ll dp[MAXN][105][2];
ll pw[MAXN];
bool done[MAXN][105][2];

ll d(ll ind, ll md, bool cnt){
    if(ind == n){
        if(md == 0) return 1;
        else return 0;
    }
    if(done[ind][md][cnt]){
        return dp[ind][md][cnt];
    }else{
        done[ind][md][cnt] = 1;
        if(cnt){
            ll mx = (int)(K[ind] - '0');
            for(int i = 0; i < mx; i++){
                dp[ind][md][cnt] += d(ind + 1, (md + i)%D, 0);
                dp[ind][md][cnt] %= mod;
            }
            dp[ind][md][cnt] += d(ind + 1, (md + mx)%D, 1);
            dp[ind][md][cnt] %= mod;
        }else{
            for(int i = 0; i < 10; i++){
                dp[ind][md][cnt] += d(ind + 1, (md + i)%D, 0);
                dp[ind][md][cnt] %= mod;
            }
        }
        return dp[ind][md][cnt];
    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>K>>D;
    n = K.length();
    cout<<(d(0, 0, 1) - 1 + mod)%mod;
    

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

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

int main(void) {
   int A,B;
   cin>>A>>B;
   int val;
   if (A<=9 && B<=9) val = A*B;
   else val=-1;

   cout<<val<<endl;

   return 0;
}

Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        n: usize,
        s: String
    }

    let mut ans = vec![0; n];
    let mut r0 = 0;
    let x: Vec<i64> = s.chars().map(|e| e.to_digit(2).unwrap() as i64).collect();
    let pc: i64 = x.iter().sum();
    for b in 0..=1 {
        let mut pc = pc;
        if b == 0 {
            pc += 1;
        } else {
            if pc == 1 {
                continue;
            }
            pc -= 1;
        }

        let mut r0: i64 = 0;
        for &e in &x {
            r0 = (r0 << 1).rem_euclid(pc);
            r0 += e;
        }

        let mut k: i64 = 1;
        for (i, &e) in x.iter().enumerate().rev() {
            if e == b {
                if b == 0 {
                    ans[i] = f((r0 + k).rem_euclid(pc)) + 1;
                } else {
                    ans[i] = f((r0 - k).rem_euclid(pc)) + 1;
                }
            }
            k = (k << 1).rem_euclid(pc);
        }
    }

    for e in &ans {
        println!("{}", e);
    }
}

fn f(n: i64) -> i64 {
    if n == 0 {
        return 0;
    }

    1 + f(n.rem_euclid(n.count_ones() as i64))
}


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

int main() {
    int n;
    cin >> n;
    string ans = "No";
    for (int i=0; i<=25; i++) {
        for (int j=0; j<=10; j++) {
            if (4*i + 7*j == n) ans = "Yes";
        }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
        int n,*p;
        unsigned long sum_time,inclusive_sum;
	int i,j,temp;
	while (1) {
		scanf("%d",&n);
		if (n == 0)break;
		int wait_time[n];
		inclusive_sum = 0;
		sum_time = 0;
		p = wait_time;
		for (i = 0; i < n; i++)
			scanf("%d",&wait_time[i]);
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				if (wait_time[i] > wait_time[j]) {
				  temp = *(p+i);
				  *(p+i) = *(p+j);
				  *(p+j) = temp;
				}
			}
		}
		for (i = 0; i < n-1; i++) {
		  inclusive_sum = 0;
			for (j = 0; j <=i; j++) {
			  inclusive_sum += *(p+j);    
			}
			sum_time += inclusive_sum;
		}
		printf("%lu\n",sum_time);
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    string s;
    cin >> s;
    cout << (s[0] =='9' || s[1] == '9' ? "Yes" : "No") << endl;
    return 0;
}


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

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

cnt = 0
min_abs = 10 ** 15
for a in A:
    if a < 0:
        cnt += 1
    min_abs = min(min_abs, abs(a))
        
if cnt % 2 == 0:
    print(sum(map(abs, A)))
else:
    print(sum(map(abs, A)) - min_abs * 2)

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

int main() {
	// your code goes here
	long long n;
	cin>>n;
	vector<int> a;
	for(long long i=2;i*i<=n;i++) {
		if(n%i==0) {
			int cnt = 0;
			while(n%i==0) {
				n /= i;
				cnt ++;
			}
			a.push_back(cnt);
		}
	}
	if(n!=1)
		a.push_back(1);
	int cnt = 0;
	for(int i=0;i<a.size();i++) {
		double d = (sqrt(8.0*a[i] + 1.0) -1.0 )/2.0;
		cnt += d;
		// cout<<a[i]<<" "<<cnt<<"\n";
	}
	cout<<cnt;
	return 0;
}

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

int main(){
  int a=-1e9,b=1e9+7,n,x;
  cin>>n;
  while(n--){
    cin>>x;
    b=min(b,x);
    a=max(a,x);
  }
  cout<<a-b<<endl;
}


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

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result = true;
            for (int i = 0; i < n - 1; i++)
            {
                var right = n - i - 1;
                var left = right - 1;
                var diff = h[right] - h[left];
                if(diff >= 0)
                {
                    continue;
                }else if (diff == -1)
                {
                    h[left] -= 1;
                }
                else
                {
                    result = false;
                    break;
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 30044
import java.io.IOException;
import java.util.Scanner;

/**
 * Created on 2017/09/30 21:01.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            String s = sc.next().replaceAll("0", "");
            System.out.println(s.length());
        }
    }
}

Measured memory_bytes: 24276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max = Math.max(a, b);
		int min = Math.min(a, b);

		if (max >= min && max <= min + w) {
			System.out.println("0");
		} else {
			System.out.println(max - (min + w));
		}
	}
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string s;cin>>s;
  vector<ll> a(27);
  for(i=0;i<s.size();i++){
    a[s[i]-'a']++;
  }
  for(i=0;i<27;i++){
    if(a[i]==0){
      if(i==26)cout<<"None"<<endl;
      else cout<<char(i+'a')<<endl;
      break;
    }

  }


  return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

pub 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")
}

use std::cmp::max;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let x = a * 10 + b + c;
    let y = a + b * 10 + c;
    let z = a + b + c * 10;
    println!("{}", max(x, max(y, z)));
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>

using namespace std;

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

  vector<pair<long long, int>> sack = {{0, 0}};

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

    vector<pair<long long, int>> new_sack;
    for (int j = 0; j < sack.size(); j++) {
      long long sack_v = sack[j].first;
      int sack_w = sack[j].second;

      new_sack.push_back({sack_v, sack_w});
      if (sack_w + w <= W) {
        new_sack.push_back({sack_v + v, sack_w + w});
      }
    }

    sort(new_sack.begin(), new_sack.end());

    vector<pair<long long, int>> filtered_sack;

    for (int j = 0; j < new_sack.size(); j++) {
      bool filtered = false;
      for (int t = j + 1; t < new_sack.size(); t++) {
        if (new_sack[j].first <= new_sack[t].first &&
            new_sack[j].second >= new_sack[t].second) {
          filtered = true;
        }
      }

      if (!filtered) {
        filtered_sack.push_back(new_sack[j]);
      }
    }

    sack = filtered_sack;

    // for (int j = 0; j < new_sack.size(); j++) {
      // cout << new_sack[j].first << " " << new_sack[j].second << " ; ";
    // }
    // cout << endl;
  }

  long long result = 0;
  for (int i = 0; i < sack.size(); i++) {
    result = max(result, sack[i].first);
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 556
n = input().split(' ')
third = 100000
second = 200000
first = 300000
sum = 0
for i in n:
    if int(i) == 3:
        sum = sum + third
    elif  int(i) == 2:
        sum = sum + second
    elif  int(i) == 1:
        sum = sum + first

if int(n[0]) == 1 and int(n[1]) == 1:
    sum = sum + 400000

print(sum)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
using namespace std;

int rec(int a, int b){
	if(b == 0) return a;
	return rec(b, a%b);
}

int LCM(int a, int b){
	int gcm = rec(a, b);
	return a * b / gcm;
}

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

	int ans = 0;
	for(int i = 0; i < N; i++) ans += a[i] - 1;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>

typedef long long ll;
#define fi first
#define se second

char S[101];

using namespace std;

int main(){
  
  fill( S, S+101, '\0' );
  
  scanf("%s", S);
  
  
  int i = 0;
  int C = 1;
  int F = 1;
  
  while( S[i] != '\0' ){
    
    if( C ){
      if( S[i] == 'C' ) C = 0;
    }
    else{
      if( S[i] == 'F' ) F = 0;
    }
    i++;
    if( C == 0 && F == 0 ){
      puts("Yes");
      break;
    }
  }
  
  if( C || F ) puts("No");
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 1e18LL

const ll MAX = 1000000000000000000; //1e18

int main(){
    ll ans = 0;
    ll cnt = 0;
    ll n; cin >> n;
    vector<ll> h(n);
    rep(i, n){
        cin >> h[i];
    }
    rep(i, n-1){
        ll left = h[i];
        ll right = h[i+1];
        if(left >= right) {
            cnt++;
            ans = max(ans, cnt);
        }
        else cnt = 0;
    }
    cout << ans << endl;
}


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

//#define DBG

ll N;
string S;

void strswap(string& s, int i, int j){
    char t = s[j];
    s[j] = s[i];
    s[i] = t;
}

int main(){
    cin >> N;
    cin.ignore();
    cin >> S;
    cin.ignore();

    int wptr = 0;
    int rptr = S.size() - 1;
    int state = 0; // 0: swap 1: change
    ll scnt = 0;
    ll ccnt = 0;
    for(int i = 0; i < S.size(); i++){
        wptr = i;
        if(S[wptr] == 'W' && state == 0){
            bool rfound = false;
            while(rptr > wptr){
                if(S[rptr] == 'R'){
                    rfound = true;
                    ++scnt;
                    #ifdef DBG
                    cout << "SWP" << endl;
                    cout << "wptr " << wptr << endl;
                    cout << "rptr " << rptr << endl;
                    #endif
                    S[wptr] = 'R';
                    S[rptr] = 'W';
                    --rptr;
                    break;
                }
                --rptr;
            }
            if(!rfound){
                break;
            }
        } else if(S[wptr] == 'W' && state == 1){
            S[wptr] = 'R';
                    #ifdef DBG
                    cout << "iniCNT" << endl;
                    cout << "wptr " << wptr << endl;
                    cout << "rptr " << rptr << endl;
                    #endif
            ++ccnt;
        }
    }
    #ifdef DBG
    cout << scnt << endl;
    cout << ccnt << endl;
    #endif
    cout << scnt + ccnt << endl;

    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
 
#define DEBUG
 
typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define insert ins
#define ers erase
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

ld dist(pii a, pii b) {
    ll x1 = a.F;
    ll y1 = a.S;
    ll x2 = b.F;
    ll y2 = b.S;

    ll x = abs(x2 - x1);
    ll y = abs(y2 - y1);

    return sqrt(x*x + y*y);
}

int main() {
	
	fastio;
	
    vc(pii, d);
    rd1(ll, n);

    FOR(i, 0, n) {
        rd2(ll, x, y)
        d.pb(mp(x, y));
    }

    ld s = 0;
    FOR(i, 0, n - 1) {
        FOR(j, i + 1, n) {
            s += dist(d[i], d[j]);
        }
    }
	
    cout << setprecision(10) << (s * 2) / n;

	return 0;
}


Measured memory_bytes: 256
#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 = 333;
const ll inf = 1e18;

int n;
ll dist[maxn][maxn];
ll fuel[maxn][maxn];
ll cap;
int m;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m>>cap;
    for (int i=1; i<=n; i++) {
	for (int j=1; j<=n; j++) {
	    dist[i][j] = inf;
	    fuel[i][j] = inf;
	    if (i==j) {
		dist[i][j] = 0;
		fuel[i][j] = 0;
	    }
	}
    }
    for (int i=0; i<m; i++) {
	ll a,b,c; cin>>a>>b>>c;
	dist[a][b] = min(dist[a][b], c);
	dist[b][a] = min(dist[b][a], c);
    }


    for (int k=1; k<=n; k++) {
	for (int i=1; i<=n; i++) {
	    for (int j=1; j<=n; j++) {
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	    }
	}
    }

    for (int i=1; i<=n; i++) {
	for (int j=1; j<=n; j++) {
	    if (i==j) continue;
	    if (dist[i][j]<=cap) {
		fuel[i][j] = min(fuel[i][j], 1LL);
	    }
	}
    }

    for (int k=1; k<=n; k++) {
	for (int i=1; i<=n; i++) {
	    for (int j=1; j<=n; j++) {
		fuel[i][j] = min(fuel[i][j], fuel[i][k]+fuel[k][j]);
	    }
	}
    }

    int q; cin>>q;

    while (q--) {
	int s,t; cin>>s>>t;
	if (fuel[s][t] == inf) {
	    cout<<"-1\n"; continue;
	}
	ll ans = fuel[s][t] - 1;
	cout<<ans<<"\n";
    }
  

    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    int ans=0;
    string s,t,temp;
    cin>>s>>t;
    int len=s.size();
    for(int i = 0;i<len;i++)
    {
        if(s.at(i)!=t.at(i))
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3628
/*
Volume0-0009
*/
//#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 1000000
#define TRUE (int)(0==0)
#define FALSE !TRUE
#define BUFLEN 1024
//using std;

int syserr(char *str)
{
  fputs(str, stderr);
  exit(-1);
}
int main(int argc, char *argv[]){
  int f[N];
  int i;
  int j;
  int n;
  int m;
  char buf[BUFLEN];

  //  memset(f, TRUE, N);
  f[0]=FALSE;
  f[1]=FALSE;
  for (i=2; i<N; i++)
    f[i] = TRUE;

  for (i=2; i<N; i++){
    if (f[i] == TRUE ) {
      for (j=i+i; j<N; j+=i){
	f[j] = FALSE;
      }
    }
  }

  while (fgets(buf, BUFLEN, stdin) != NULL){
    n = atoi(buf);

    m = 0;
    for (i=1; i<=n; i++){
      if (f[i]){
	m++;
      }
    }
    printf("%d\n", m);
  }
 
  exit(0);
}

Measured memory_bytes: 4436
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (5006)
ll n, a, b, dp[MAXN][MAXN][3], mod=1e9+7, ans=1, sum[MAXN];
int main(){
	FAST
	cin>>n>>a>>b;
	if(a>b)swap(a,b);
	dp[0][0][2]=1, sum[0]=1;
	FOR(i,1,n){
		FOR(j,0,b-1){
			if(j==0) {
				FOR(k,1,min(a-1,i)) dp[i][j][0] += sum[i-k], dp[i][j][0] %= mod;
			} else{
				dp[i][j][1] += dp[i-1][j-1][1] + (j-a >= 0 && i-a >= 0 ? dp[i-a][j-a][2] : 0), dp[i][j][1] %= mod;
				dp[i][j][2] += dp[i-1][j-1][2] + dp[i-1][j-1][1] + dp[i-1][j-1][0], dp[i][j][2] %= mod;
			}
			sum[i] += dp[i][j][2], sum[i] %= mod;
		}
	}
	FOR(i,1,n) ans*=2,ans%=mod;
	FOR(j,0,b-1)ans-=dp[n][j][0]+dp[n][j][1]+dp[n][j][2],ans+=mod*3,ans%=mod;
	cout<<ans<<'\n';
}


Measured memory_bytes: 590336
a = int(input())
b = [int(input()) for i in range(5)]
c = min(b)
if a > c:
    if a%c == 0:
        d = int(a/c) + 4
        print(d)
    else:
        d = int(a/c) + 5
        print(d)
else :
    print(5)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[300][300];
	rep(i, N) rep(j, N) A[i][j] = getint();
	rep(i, N) A[i][i] = 1e9;

	ll kotae = 0;
	rep(i, N) {
		auto b = A[i];
		rep(j, i) {
			int a = A[i][j];
			auto c = A[j];
			bool B = 1;
			rep(k, N) {
				if (a > b[k] + c[k]) {
					printf("-1");
					return 0;
				}
				if (a == b[k] + c[k]) B = 0;
			}
			if (B) kotae += a;
		}
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        int ans = n*a;
        if ( ans < b){
            System.out.println(ans);
        } else {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {
	public int[] CountingSort(int[] A, int n, int k) {
		int[] B = new int[n], C = new int[k + 1];
		for (int i = 0; i < n; i++) {
			C[A[i]]++;
		}
		for (int i = 1; i < k + 1; i++) {
			C[i] += C[i - 1];
		}
		for (int i = n - 1; i >= 0; i--) {
			B[C[A[i]] - 1] = A[i];
			C[A[i]]--;
		}
		return B;
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = 10000;
		int[] A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}
		int[] B = CountingSort(A, n, k);
		StringBuilder sb = new StringBuilder();
		sb.append(B[0]);
		for (int i = 1; i < n; i++) {
			sb.append(" " + B[i]);
		}
		System.out.println(sb.toString());
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 547700
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i=0; i < n/r + 2;i++){
        for(int j=0; j< (n-r*i)/g + 2; j++){
            if((r*i + g*j) <= n && (n-r*i-g*j) % b == 0){
                ans ++ ;
            }
        }
    }
    cout << ans << endl;
    
}


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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			x = in.readLine();
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		int n = Integer.parseInt(x);
		
		for (int i = 0; i < n; i++) {
			int num = i + 1;
			if (((num % 3) == 0) || ((num % 10) == 3)) {
				System.out.print(" " + (i + 1));
			} else {
				while (num != 0) {
					num = num / 10;
					if ((num % 10) == 3) {
						System.out.print(" " + (i + 1));
						break;
					}
				}
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 26372
N, K, *H = [*gets.split, *gets.split].map(&:to_i)

dp = [0]
1.step(N-1) do |i|
  dp[i] = Float::INFINITY
  1.step(K) do |j|
    break if i-j < 0
    cost = dp[i-j] + (H[i]-H[i-j]).abs
    dp[i] = cost if cost < dp[i]
  end
end
puts dp.last


Measured memory_bytes: 12932
#include <queue>
#include <cstdio>
int main() {
	register int u, cur; register char c, cz[13];
	std::priority_queue<int> que;
	while (true) {
		c = getchar_unlocked();
		c = getchar_unlocked();
		c = getchar_unlocked();
		if (c == 'd') break;
		if (c == 't') {
			getchar_unlocked();
			getchar_unlocked();
			getchar_unlocked();
			getchar_unlocked();
			getchar_unlocked();
			u = que.top(), cur = 0; que.pop();
			if (u == 0) cz[cur++] = 48;
			while (u) cz[cur++] = u % 10 + 48, u /= 10;
			while (cur) putchar_unlocked(cz[--cur]);
			putchar_unlocked('\n');
		}
		else {
			getchar_unlocked();
			getchar_unlocked();
			getchar_unlocked();
			getchar_unlocked();
			c = getchar_unlocked();
			cur = 0;
			while (48 <= c && c <= 57) cur = cur * 10 + c - 48, c = getchar_unlocked();
			que.push(cur);
		}
	}
	return 0;
}

Measured memory_bytes: 6404
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 154-d
int main() {
    int n, k, h;
    cin >> n >> k;

    vector<int> hitpnt(n);
    rep(i, 0, n) {
        cin >> h;
        hitpnt[i] = h;
    }

    sort(hitpnt.begin(), hitpnt.end());

    ll atkcnt = 0;
    rep(i, 0, n - k) { atkcnt += hitpnt[i]; }

    cout << atkcnt << endl;

    return 0;
}



Measured memory_bytes: 1024
MOD=10**9+7
def modpow(a, p, mod=MOD):
    # return a**p (mod MOD) O(log p)
    if p==0: return 1
    if p%2==0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod

class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
def comb(x,n):
    divd=1
    for i in range(n):
        divd*=ModInt(x-i)
    for i in range(n):
        divd/=ModInt(i+1)
    return divd
ans = ModInt(0)
s = int(input())
for i in range(1,1+s//3):
    su = s-i*3
    ans += comb(su+i-1,i-1)
print(ans)

Measured memory_bytes: 67976
import sys
n, k = list(map(int, sys.stdin.readline().split()))
arr = list(map(int, sys.stdin.readline().split()))
 
dp = [100000000000] * n
 
dp[0] = 0
dp[1] = dp[0] + abs(arr[1] - arr[0])
 
for i in range(2, len(arr)):
	for j in range(1, k + 1):
		if (i - j < 0): continue
		dp[i] = min(dp[i - j] + abs(arr[i - j] - arr[i]), dp[i])
 
print(dp[len(arr) - 1])


Measured memory_bytes: 54420
import java.util.*;

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

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int money = 0;

    if (A + B < 2 * C) {
      money = A * X + B * Y;
    } else {
      if (X > Y) {
        money = Math.min(C * Y * 2 + A * (X - Y), C * X * 2);
      } else {
        money = Math.min(C * X * 2 + B * (Y - X), C * Y * 2);
      }
    }

    System.out.println(money);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> ansv(100002, 0);

    int ans = 0;

    rep(i, 0, N){
        int a;
        cin >> a;
        ansv[a]++;
        ansv[a+1]++;
        ansv[a+2]++;
    }
    rep(i, 0, 100002) ans = max(ans, ansv[i]);

    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define long long long
#define INF 1LL << 30
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

long H, N;

//vector<vector<long>> dp(pow(10, 5) , vector<long>(INF));
vector<long> dp(pow(10,5), INF);

int main(){
	cin >> H >> N;
	vector<long> A(N);
	vector<long> B(N);
	rep(i,N) cin >> A.at(i) >> B.at(i);

	// Extract min value of A
	vector<long>::iterator iter = min_element(A.begin(), A.end());
	size_t min_index =  distance(A.begin(), iter);
	//printf("min A: %lld\n", A.at(min_index));
	//rep(i, A.at(min_index)) dp.at(i) = 0;
	dp.at(0) = 0;
	long damage;
	rep(i, H+1){
		rep(j, N){

			if(A[j] > i){
				damage = i;
			}else {
				damage = A[j];
			}	
			chmin(dp.at(i),  dp.at(i - damage) + B[j]);
		}
	}
	cout << dp.at(H) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, nxt;
	scanf("%d", &N);
	int occ[N];
	fill_n(occ, N, 0);
	long long int ans = 1;
	for (int i = 0; i < N; ++i) {
		scanf("%d", &nxt);
		if (nxt == 0) ans = ans * (3 - occ[0]);
		else ans = ans * (occ[nxt - 1] - occ[nxt]);
		++occ[nxt];
		ans %= 1000000007;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int R,C,N;
	cin >> R >> C >> N;
	vector<int> X(N), Y(N);
	vector<cat> A(N);
	for(int i =0; i < N; i++) cin >> X[i] >> Y[i] >> A[i];
	cat a0 =A[0];
	for(int i =N-1; i >= 0; i--) A[i] +=a0;
	
	vector< vector< pair<int,cat> > > G(R+C);
	for(int i =0; i < N; i++) {
		G[X[i]-1].push_back(make_pair(Y[i]-1+R,A[i]));
		G[Y[i]-1+R].push_back(make_pair(X[i]-1,A[i]));
	}
	vector<bool> vis(R+C,0);
	vector<cat> val(R+C);
	
	for(int i =0; i < R+C; i++) if(!vis[i]) {
		queue<int> q;
		q.push(i);
		vis[i] =1;
		val[i] =0;
		vector<int> comp;
		while(!q.empty()) {
			comp.push_back(q.front());
			ALL_THE(G[q.front()],it) if(!vis[it->ff]) {
				vis[it->ff] =1;
				val[it->ff] =it->ss-val[q.front()];
				q.push(it->ff);
			}
			q.pop();
		}
		cat minvx =OVER9000, minvy =OVER9000;
		ALL_THE(comp,it) {
			ALL_THE(G[*it],jt) if(jt->ss != val[*it]+val[jt->ff]) {
				cout << "No\n";
				return 0;
			}
			if(*it < R) minvx =min(minvx,val[*it]);
			else minvy =min(minvy,val[*it]);
		}
		if(minvx < a0-minvy) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 14336