akhauriyash/Code-Regression huggingface dataset:
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
 
#include <iostream>
#include<stdio.h>
#include<cmath>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<string.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<string.h>
#include<stack>
#include<queue>
#include<deque>
 
#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 100000007
 
using namespace std;
 
ll a[305][305],n,k;
 
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    ll n;
    sfl(n);
    vll a(n);
    for(ll i=0;i<n;i++)
    {
    	sfl(a[i]);
    }
    sort(all(a),greater<int>());
    ll ans=0;
    ans+=a[0];
    ll cnt=(n-2)/2;
    for(ll i=1;i<=cnt;i++)
    {
    	
    	ans+=a[i]*2;
    }
    if((n-2)%2!=0) ans+=a[cnt+1];
    cout<<ans;
    return 0;
}

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

int main() {
  char S[4];
  cin >> S[0] >> S[1] >> S[2] >> S[3];
  
  int res = 0;
  for(int i=0 ; i < 4 ; ++i){
  	if(S[i]=='+') ++res;
  	else --res;
  }
  
  cout << res << endl;
}


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

const ll mod=1e9+7;
const ll ma=210000;

vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while(n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n,1LL));
    return res;
}

ll fac[ma],finv[ma],inv[ma];

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2; i < ma; i++){
	    fac[i] = fac[i-1] * i % mod;
	    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
	    finv[i] = finv[i-1] * inv[i] % mod;
	}
}


ll COM(ll n,ll k){
	if(n<k)return 0;
	if(n<0||k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
	ll n,m;
	COMinit();
	cin>>n>>m;
	auto vec = prime_factorize(m);
	ll res=1;
	for(auto pa:vec){
		ll num = pa.second;
		ll tmp=COM(num+n-1,n-1);
		res= (res*tmp)%mod;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 5120
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
const int MaxN = 1e5 + 5;

int main () {
	int n;
	scanf("%d", &n);
	printf("%d\n", n / 3);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
typedef struct
{
  double x;
  double y;
} point;
void func(point,point,int);
void printPoint(point);
int main(void)
{
  int n;//input
  point p1,p2;
  p1.x=0.0;
  p1.y=0.0;
  p2.x=100.0;
  p2.y=0.0;
  scanf("%d",&n);
  printPoint(p1);
  func(p1,p2,n);
  return 0;
}
void func(point p1,point p2,int n)
{
  point p3,p4,p5;
  if(n==0) printPoint(p2);
  else
    {
      p3.x=p1.x+(p2.x-p1.x)/3.0;
      p3.y=p1.y+(p2.y-p1.y)/3.0;
      p5.x=p1.x+(p2.x-p1.x)*2.0/3.0;
      p5.y=p1.y+(p2.y-p1.y)*2.0/3.0;
      p4.x=p3.x+(p5.x-p3.x)*1.0/2.0-(p5.y-p3.y)*sqrt(3.0)/2.0;
      p4.y=p3.y+(p5.x-p3.x)*sqrt(3.0)/2.0+(p5.y-p3.y)*1.0/2.0;
      func(p1,p3,n-1);
      func(p3,p4,n-1);
      func(p4,p5,n-1);
      func(p5,p2,n-1);
    }
}
void printPoint(point p)
{
  printf("%f %f\n",p.x,p.y);
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int N;
vi A;
ll ans = 0;

ll rec(int n, ll s, ll t, ll u){
    
    //cout << n csp s csp t csp u << endl;
    
    if(n==0){
        
        if(s + u > 1){
            ans = -1;
            return -1;
        }else{
            ans += 1;
            return 1;
        }
        
    }
    
    ll a = rec(n-1,(s+u+1)/2,t+u,A[n-1]);
    if(a == -1) return -1;
    ll b = a*2 - u;
    if(b < s) return -1;
    chmin(b,t);
    ans += b+u;
    return b;
}



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

    cin >> N;
    A.resize(N+1);
    in(N+1,A);
    
    rec(N,0,0,(ll)A[N]);
    
    cout << ans << endl;
    
    
    

    return 0;
}


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

int main() {
    int N, K, X, Y;
    std::cin >> N >> K >> X >> Y;

    if (N <= K) {
        std::cout << X * N << std::endl;
    } else {
        std::cout << K * X + (N - K) * Y << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, T = list(map(int,input().split()))
c = []
t = []

for x in range(N):
	ci, ti = list(map(int, input().split()))
	if ti <= T:
		c.append(ci)
		t.append(ti)

if c == []:
	print('TLE')
else:
	print(min(c))

Measured memory_bytes: 3060
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::collections::BTreeSet;

fn main() {
    let (a, b, c, d, e, f): (usize, usize, usize, usize, usize, usize);
    input!(a, b, c, d, e, f);
    let mut x = BTreeSet::new();
    let mut y = BTreeSet::new();

    for aa in 0..f / 100 + 1 {
        for bb in 0..f / 100 + 1 {
            if 100 * aa * a + 100 * bb * b <= f {
                x.insert(100 * aa * a + 100 * bb * b);
            } else {
                break;
            }
        }
    }
    for aa in 0..f + 1 {
        for bb in 0..f + 1 {
            if aa * c + bb * d <= f {
                y.insert(aa * c + bb * d);
            } else {
                break;
            }
        }
    }

    let mut maxx = 0;
    let mut maxy = 0;
    for xx in &x {
        for yy in &y {
            let buf = *xx + *yy;
            if buf > f {
                break;
            }
            if *yy as f64 / (*xx as f64 + *yy as f64) > e as f64 / (100.0 + e as f64) {
                break;
            }

            if maxx + maxy == 0
                || maxy as f64 / (maxx as f64 + maxy as f64) < *yy as f64 / (*xx as f64 + *yy as f64)
            {
                maxx = *xx;
                maxy = *yy;
            }
        }
    }
    println!("{} {}", maxx + maxy, maxy);
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = (1 << 19) + 10;

int n, q;
pii ar[N];

vector<pii> va[N];

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

    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> ar[i].fi >> ar[i].se; // val, weight
    }
    va[0].pb(mp(0, 0));
    int pre = min((1 << 10), n);
    for (int i=1;i<=pre;i++){
        int p = i / 2;
        pii temp = ar[i];
        for (auto x : va[p]){
            va[i].pb(x);
            va[i].pb(mp(x.fi + temp.se, x.se + temp.fi));
        }
        sort(va[i].begin(), va[i].end());
        for (int j=1;j<va[i].size();j++){
            va[i][j].se = max(va[i][j].se, va[i][j - 1].se);
        }
    }

    cin >> q;
    while (q--){
        int node, mx;
        cin >> node >> mx;
        if (node <= pre){
            int ans = 0;
            for (auto x : va[node]){
                if (x.fi <= mx) ans = max(ans, x.se);
            }
            cout << ans << el;
            continue;
        }
        vector<int> path;
        while (node > pre){
            path.pb(node);
            node >>= 1;
        }
        int len = path.size();
        vector<pii> vb; // weight, val
        vb.pb(mp(0, 0));
        for (int i=0;i<len;i++){
            vector<pii> temp;
            pii isi = ar[path[i]];
            for (auto x : vb){
                temp.pb(mp(x.fi + isi.se, x.se + isi.fi));
            }
            for (auto x : temp){
                vb.pb(x);
            }
        }
        int ans = 0;
        int valen = va[node].size();
        for (auto x : vb){
            int low = 0, high = valen - 1;
            while (low < high){
                int mid = (low + high + 1) / 2;
                if (x.fi + va[node][mid].fi <= mx){
                    low = mid;
                } else{
                    high = mid - 1;
                }
            }
            if (x.fi + va[node][low].fi <= mx) ans = max(ans, x.se + va[node][low].se);
        }
        cout << ans << el;
    }

    return 0;
}

Measured memory_bytes: 23276
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e3+7;
const int INF = 0x3f3f3f3f;
vector<int> G[MAXN];
int n,m,dfn[MAXN],low[MAXN],sccID[MAXN],sccnum,k;
bool instk[MAXN];
vector<int> scc[MAXN];
stack<int> stk;
void tarjan(int u){
    stk.push(u); instk[u] = true;
    low[u] = dfn[u] = ++k;
    for(int v : G[u]){
        if(!dfn[v]){
            tarjan(v);
            low[u] = min(low[u],low[v]);
        }
        else if(instk[v]) low[u] = min(low[u],dfn[v]);
    }
    if(dfn[u]==low[u]){
        ++sccnum;
        while(true){
            int tp = stk.top();
            sccID[tp] = sccnum;
            scc[sccnum].push_back(tp);
            stk.pop();
            instk[tp] = false;
            if(tp==u) break;
        }
    }
}
vector<int> GG[MAXN];
void rebuild(int k){
    for(int i = 0; i < MAXN; i++) GG[i].clear();
    for(int u : scc[k]){
        for(int v : G[u]){
            if(sccID[u]!=sccID[v]) continue;
            else GG[u].push_back(v);
        }
    }
}
int dist[MAXN],pre[MAXN];

void SPFA(int s,int t){
    memset(dfn,0,sizeof(dfn));
    memset(dist,INF,sizeof(dist));
    dist[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int u = que.front();
        que.pop();
        dfn[u] = 0;
        for(int v : GG[u]){
            if(dist[u]+1>=dist[v]) continue;
            dist[v] = dist[u] + 1;
            pre[v] = u;
            if(!dfn[v]){
                dfn[v] = 1;
                que.push(v);
            }
        }
    }
}
void gao(int k,vector<int> &vec){
    rebuild(k);
    for(int t:scc[k]) for(int s:GG[t]){
        SPFA(s,t);
        if(!vec.empty()&&dist[t]+1>=vec.size()) continue;
        vec.clear();
        int rt = t;
        while(true){
            vec.push_back(rt);
            if(rt==s) break;
            rt = pre[rt];
        } 
    }
}
int main(){
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
    }
    for(int i = 1; i <= n; i++) if(!dfn[i]) tarjan(i);
    bool ok = false;
    for(int i = 1; i <= sccnum; i++){
        if(scc[i].size()>1){
            ok = true;
            //for(int u : scc[i]) cout << u << ' '; cout << endl;
            vector<int> vec;
            gao(i,vec);
            cout << vec.size() << endl;
            for(int u : vec) cout << u << endl;
            break;
        }
    }
    if(!ok) cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main() {
    int K;
    cin >> K;
    ll sum = 0;
    repX(a,K+1,1){
        repX(b, K+1,1){
            repX(c, K+1,1){
                sum += gcd(a,gcd(b,c));
            }
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

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 K = sc.nextInt();
 	int count=0;
   
   	if(A>=K){
    count=K;
    }
   	else if(A<K&&A+B>=K){
    count=A;}
    else if(A+B<K){
    count=A-(K-A-B);}
 
  System.out.println(count);
 }
}


Measured memory_bytes: 35768
#include <iostream>

using namespace std;

const int MOD = 1000000007;
const int MAX = 550000;

long long fac[MAX], finv[MAX], inv[MAX];

void init() {
	fac[0] = fac[1] = inv[1] = finv[0] = finv[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;
	}
}

long long nPr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * finv[n - r] % MOD;
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

int main() {
	init();
	int n, m; cin >> n >> m;
	long long ans = 0;
	for (int i = 0; i <= n; ++i)
		ans = (ans + (i & 1 ? -1 : 1) * nCr(n, i) * nPr(m - i, n - i) % MOD + MOD) % MOD;
	ans = ans * nPr(m, n) % MOD;
	cout << ans << endl;

	return 0;
}

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

int main() {
    int N, K;
    int answer = 1;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        if (answer*2 < answer+K) {
            answer *= 2;
        } else {
            answer += K;
        }
    }
    cout << answer << endl;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  bool flg = true;
  rep(i, N){
    ll a;
    cin >> a;
    flg = flg and a%2==0;
  }
  if(flg)cout << "second";
  else cout << "first";
  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  REP(i, N) { cin >> h[i]; }

  constexpr ll INF = numeric_limits<ll>::max() / 3;
  vector<ll> dp(N, INF);
  dp[0] = 0;
  dp[1] = dp[0] + abs(h[0] - h[1]);
  REP(i, N) {
    REP1(j, K) {
      if (i + j < N) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      }
    }
  }
  cout << dp[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
import numpy as np
a,b,h,m=map(int,input().split())
pi = np.pi
x = 2*pi*(h*60+m)/720
y = 2*pi*m/60
theta=abs(x-y)
cos = np.cos(theta)
ans = (a**2+b**2-2*a*b*cos)**0.5
print(ans)

Measured memory_bytes: 27252
import sys
sys.setrecursionlimit(1000000)
# input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        # 親の番号 根なら要素数(負の数)

    def find(self, x):
        """木の根を求める"""
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        """xとyの属する集合を併合"""
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """xとyが同じ集合に属するか否か"""
        return self.find(x) == self.find(y)

    def size(self, x):
        """グループのサイズを返す"""
        return -self.parents[self.find(x)]

N, M, K = map(int, input().split())

uf = UnionFind(N)
ans = [0] * N
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    uf.unite(A, B)
    ans[A] -= 1
    ans[B] -= 1

for i in range(N):
    ans[i] += uf.size(i) - 1

for _ in range(K):
    C, D = map(int, input().split())
    C -= 1
    D -= 1
    if uf.same(C, D):
        ans[C] -= 1
        ans[D] -= 1

print(*ans)


Measured memory_bytes: 13380
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random

# List of ints
def LI(): return list(map(int, sys.stdin.readline().split()))

# Single int
def I(): return int(sys.stdin.readline())

# List, which contains Lists of chars (not strings)
def LS():return list(map(list, sys.stdin.readline().split()))

# Single List of chars (not strings)
def S(): return list(sys.stdin.readline())[:-1]

# List of "n" integers from "n" lines.
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
# List of "n" Lists of integers
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l


# Runtime Complexity: O(?)
# Space Complexity: O(?)
# Solution
s = S()

if 'A' in s and 'B' in s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5608
def bubble_sort(a, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if a[j][1] < a[j-1][1]:
                a[j], a[j-1] = a[j-1], a[j]
        

def selection_sort(a, n):
    for i in range(n):
        min = i
        for j in range(i, n):
            if a[j][1] < a[min][1]:
                min = j
        if min != i:
            a[min], a[i] = a[i], a[min]
            

N = int(input())
O_A = input().split()

B_A = O_A[:]
S_A = O_A[:]

bubble_sort(B_A, N)
selection_sort(S_A, N)
print(*B_A)
print('Stable')
print(*S_A)
for i in range(N):
    if B_A[i] != S_A[i]:
        print('Not stable')
        break
else:
    print('Stable')

    


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> a(n);
  vector<int> b(n);
  REP (i, n) {
    cin >> a[i] >> b[i];
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  auto it = lower_bound(b.begin(), b.end(), a[n - 1]);

  int ans = 0;
  for (auto itr = b.end() - 1; itr >= it; itr--) {
    h -= *itr;
    ans++;
    if (h <= 0) break;
  }

  if (h > 0) {
    ans += h / a[n - 1];
    if (h % a[n - 1] != 0) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
	int a,b,c,x;
	cin >> a >> b >> c >> x;
	int res=0;
	for(int i=0; i<=a; ++i){
	    for(int j=0; j<=b; ++j){
		    for(int k=0; k<=c; ++k){
			    int total = 500*i+100*j+50*k;
				if(total==x) ++res;
			}
		}
	}
	cout << res <<endl;
	return 0;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素
const ll MX=1e18;

int main(){
    int n; 
    cin>>n;
    ll ans=1;
    bool ng=false;
    rep(i,n){
        ll a;
        cin>>a;
        if(a==0){
            cout<<"0"<<endl;
            return 0;
        }
        if(ng || (MX+1)/ans<a || ans*a>MX){
            ng=true;
        }
        ans*=a;
    }
    if(ng) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int k;
    cin>>k;
    string s,t;
    cin>>s;
    int len=s.size();
    if(len>k)
    {
        s=s.substr(0,k);
        t="...";
        s+=t;
        cout<<s<<endl;
    }
    else cout<<s<<endl;
    return 0;
}


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

typedef long long ll;

#define reg register 
#define rep(a,b,c) for(reg int a=b,a##end=c;a<=a##end;++a)
#define drep(a,b,c) for(reg int a=b,a##end=c;a>=a##end;--a)

char IO;
int rd(){
	int s=0,f=0;
	while(IO=getchar(),IO<'0'||IO>'9')if(IO=='-')f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(IO=getchar(),IO>='0'&&IO<='9');
	return f?-s:s;
}

const int N=2e5+10;

int n,m;
int cnt;


vector <int> G[N],R[N];

int fa[N];
int Find(int x) { return fa[x]==x?x:fa[x]=Find(fa[x]); }

int sz[N];

void merge(int x,int y){
	int fx=Find(x),fy=Find(y);
	//cout<<"M"<<x<<' '<<y<<' '<<fx<<' '<<fy<<endl;
	if(fx!=fy) {
		if(G[fx].size()<G[fy].size()) swap(fx,fy);
		sz[fx]+=sz[fy];
		fa[fy]=fx;
		rep(i,0,G[fy].size()-1) G[fx].push_back(G[fy][i]);
	}
}


int main(){
	n=rd();
	rep(i,1,2e5) fa[i]=i,sz[i]=1;
	rep(i,1,n){
		int x=rd(),y=rd();
		R[y].push_back(x);
		G[x].push_back(y);
	}
	rep(i,1,1e5) rep(j,1,R[i].size()-1) merge(R[i][0],R[i][j]);
	rep(i,1,1e5) rep(j,1,G[i].size()-1) merge(1e5+G[i][0],1e5+G[i][j]);
	ll ans=0;
	rep(i,1,1e5) if(Find(i)==i) { 
		if(!G[i].size())continue;
		int f=Find(G[i][0]+1e5);
		ans+=1ll*sz[i]*sz[f];
		//cout<<sz[i]<<' '<<sz[f]<<endl;
	}
	ans-=n;
	cout<<ans<<endl;
}







Measured memory_bytes: 18044
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define debug(x)			{ cerr << #x << " = " << x << endl; }
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define vi					vector<int>
#define vii					vector<vi>
#define max(x,y)			(x>y)?x:y
#define min(x,y)			(x<y)?x:y
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	ll a,b,k;
	cin>>a>>b>>k;
	if(k<=a) 
		cout<<a-k<<" "<<b;
	else if(k <= a+b) 
		cout<< 0 << " "<< b - (k-a);
	else 
		cout<< 0 << " " << 0;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B, C;

int main()
{
  std::cin >> A >> B >> C;

  puts( A+B >= C ? "Yes" : "No" );

  return 0;
}

Measured memory_bytes: 3532
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        ArrayList<Integer> ls = new ArrayList<>();

        for (int i = 0; i < n; i++) ls.add(scan.nextInt());

        Collections.reverse(ls);
        for (int i = 0; i < ls.size(); i++) {
            System.out.print(i == ls.size() -1? ls.get(i) : ls.get(i) + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 26176
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int p=1000000007;
const int N=600005;

ll f[N],inv[N],finv[N];

void init()
{
	inv[1]=1;
	for(int i=2;i<N;++i)
	{
		inv[i]=(p-p/i)*1ll*inv[p % i] %p;
	}
	f[0]=1;finv[0]=1;
	for(int i=1;i<N;++i)
	{
		f[i]=f[i-1]*1ll*i%p;
		finv[i]=finv[i-1]*1ll*inv[i]%p;
	}
}


int C(int n,int m)
{
	if(m<0||m>n) return 0;
	return f[n]*1ll*finv[m]%p*finv[n-m]%p;
}

int main()
{
	init();
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	ans=C(m,n)*f[n]%p;
	for(int i=1;i<=n;++i)
	{
		ll k=(i%2)?-1:1;
		ll tmp=C(n,i);
		tmp=tmp*C(m-i,n-i)%p;
		tmp=tmp*f[n-i]%p;
		ans=(ans+k*tmp+2*p)%p;
	}
	cout<<ans*C(m,n)%p*f[n]%p<<endl;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int N;
int bottom=114514;
int top=0;
typedef vector<int> V;
bool isunique(V a){
    return top==bottom&&top==N-1;
}
#define YES {cout<<"Yes"<<endl;return 0;}
#define NO {cout<<"No"<<endl;return 0;}

int main(){
    cin>>N;
    V a(N);
    cin>>a;
    for(auto &it:a){
        chmin(bottom,it);
        chmax(top,it);
    }
    if(isunique(a))YES;
    if(top-bottom>1)NO;
    int x=0,y=0;
    for(auto &it:a){
        if(it==bottom)x++;
        else y++;
    }
    int z=top-x;
    if(top-bottom==1){
        if(z>0){
            if(z<=y/2){YES;}
            else {NO;}
        }
        else if(z==0&&y==0){YES;}
        else {NO;}
    }
    else if(top-bottom==0){
        if(top<=x/2){YES;}
        else NO;

    }
}


Measured memory_bytes: 1024
H,W,K = map(int,input().split())
S = [[int(i) for i in input()] for l in range(H)]
posibility = set()

for i in range(1<<H-1):
    SW = []
    tmp = S[0]
    counter = 0
    
    for k in range(H-1):
        if i>>k & 1:
            SW.append(tmp)
            tmp = S[k+1]
        else:
            tmp = [tmp[l]+S[k+1][l] for l in range(W)]
    SW.append(tmp)
    counter += len(SW)-1
    max_counter = 0

    for k in range(len(SW)):
        max_counter = max(max(SW[k]),max_counter)
    if max_counter >K:
        continue

    tmp_w = [SW[row][0] for row in range(len(SW))]
    
    for w in range(W-1):
        test = [tmp_w[row]+SW[row][w+1] for row in range(len(SW))]
        if max(test)>K:
            tmp_w = [SW[row][w+1] for row in range(len(SW))]
            counter += 1
        else:
            tmp_w = test

    posibility.add(counter)
print(min(posibility))

Measured memory_bytes: 48348
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i=a; i<(int)(b); i++)

using namespace std;

typedef vector<int> vi;

int main(void){
    long n; cin >> n;
    string s; cin >> s;
    
    vi lv(26,0);
    vi rv(26,0);
    rep(i,0,n) rv[s[i]-'a']++;
    
    int biggest = 0;
    
    rep(i,0,n){
        rv[s[i]-'a']--;
        lv[s[i]-'a']++;
        int cnt = 0;
        rep(j,0,26){
          if(lv[j]!=0 && rv[j]!=0) cnt++;
        }
        biggest = max(biggest, cnt);
    }
    cout << biggest;
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] an = new int[5];
        an[0] = sc.nextInt();
        an[1] = sc.nextInt();
        an[2] = sc.nextInt();
        an[3] = sc.nextInt();
        an[4] = sc.nextInt();

        int last = -1;
        int min = 10;
        for(int i = 0;i < 5;i++){
            int d = an[i] % 10;
            if(d != 0 && d < min){
                min = d;
                last = i;
            }
        }

        int ans = 0;
        for(int i = 0;i < 5;i++){
            if(last == i){
                ans += an[i];
            } else {
                ans += an[i];
                int d = an[i] % 10;
                if(d != 0){
                    ans += 10 - d;
                }
            }
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define pow(x,y) round(pow(x,y))
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}
float dnum(int N) {return floor(log10(N))+1;}
int fibnth(int N) {
    int p = (pow(1+sqrt(5),N)) - (pow(1-sqrt(5),N)); //first part (upper part)
    int p2 = pow(2,N)*(sqrt(5)); //second part (lower part)
    return p/p2;
}

int main() {
int g,b;
cin>>g>>g>>b;
cout<<(((g*10)+b)%4==0 ? "YES" : "NO")<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N;cin>>N;
  string s; cin>>s;
  vector<ll> v(N);
  ll ans = 0;
  // 変換
  rep(i,N){
    if(s[i] =='R') v[i] = 0;
    else if(s[i] =='G') v[i] = 1;
    else v[i] = 2;
  }
// まずはcount
  ll a=0,b=0,c=0;
  rep(i,N){
    if(v[i]==0) a++;
    else if(v[i]==1) b++;
    else c++;
  }
  ans += a*b*c;

  rep(i,N){
    //空間
    rep(j,N){
      //始まり
      if(j+2*i >= N) continue;
      if(v[j] != v[j+i] and v[j+i] != v[j+2*i] and v[j] != v[j+2*i]){
        ans--;
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std ;
int main()
{
   string str1 , str2 ;
   cin >> str1 >> str2 ;
   int cnt = 0 ;
   for(int i = 0 ; i < str1.size() ; i++)
   {
       if(str1[i] != str2[i]) cnt ++ ;
   }
   cout <<cnt << endl ;
   return 0 ;
}


Measured memory_bytes: 3924
n = int(input())
arr = list(map(int, input().split()))
counter = 0
for i in range(1, len(arr)-1):
    if (arr[i] > arr[i-1] and arr[i] < arr[i+1]) or (arr[i] < arr[i-1] and arr[i] > arr[i+1]):
        counter += 1
print(counter)

Measured memory_bytes: 3060
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet};

// Main
fn main(){
    input!{
        n: u32,
    }
    println!("{}", ((n-1)/111 +1) *111);
}


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

int main(){

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

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

int main() {
  long k;
  string s;
  cin >> s >> k;
  for(int i=0;true;i++) {
    if(s.at(i)!='1') {
      cout << s.at(i) << endl;
      break;
    } else if(i+1==k) {
      cout << 1 << endl;
      break;
    };
  };
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,i,j,b,k,r,g[],p,f[]={1,20,-20,-1};(i=r=n=s.nextInt())>0;System.out.println(r>0?"No":"Yes")){for(g=new int[n],p=210;i-->0;)g[i]=s.nextInt()+20*s.nextInt();for(i=s.nextInt();i-->0;)for(k=f["ENSW".indexOf(s.next().charAt(0))],b=s.nextInt();b-->0;)for(p+=k,j=n;j-->0;)if(p==g[j])r+=g[j]=-1;}}}

Measured memory_bytes: 32332
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete()
    c = N[-1]
    if c in ['2', '4', '5', '7', '9']:
        print('hon')
    elif c in ['0', '1', '6', '8']:
        print('pon')
    else:
        print('bon')


if __name__ == "__main__":
    main()

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

int main(){
    int n;
    cin >> n;
    int a[200];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int min_ans = 0;
    int max_ans = 0;
    bool color[8];
    int rainbow = 0;
    for(int i=0; i<8; i++){
        color[i] = false;
    }
    for(int i=0; i<n; i++){
        if(a[i]<3200){
            color[a[i]/400] = true;
        }else{
            rainbow++;
        }
    }
    for(int i=0; i<8; i++){
        if(color[i]){
            min_ans++;
            max_ans++;
        }
    }
    if(min_ans==0){
        min_ans = 1;
    }
    max_ans += rainbow;
    cout << min_ans << " " << max_ans << endl;
    return 0;
}

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

int main() {
  int ali = 0 ,bob =0 ; 
  
  int n ;
  cin >> n ;
  vector<int> vec(n) ; 
  for ( int i = 0 ; i < n ; i++ ) 
  	cin >> vec.at(i) ;
  
  sort(vec.begin() , vec.end()) ; 
  reverse(vec.begin() , vec.end()) ;
  
  for ( int i = 0 ; i < vec.size() ; i++) {
      if ( i % 2 == 0 )
        ali += vec.at(i);
      else
        bob += vec.at(i);
  }
  
  cout << ali - bob << '\n' ; 
  
  
}





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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll n, m;
ll a[101010];
ll sum[101010];

int main() {
    cin >> n >> m;
    rep(i, n) {
        cin >> a[i];
        sum[i+1] += (sum[i]+a[i])%m;
    }
    map<int, ll> mp;
    ll ans=0;
    for (int l=0; l<=n; ++l) {
        ans += mp[sum[l]];
        mp[sum[l]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N,A,B;
  cin >> N;
  if(N==1) cout << "Hello World" << endl;
  if(N==2) {
      cin >> A >> B;
      cout << A+B << endl;
  }
}


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

string S;
int a = 1, b = 1, c = 1;

int main() {
	cin >> S;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'a') a--;
		if (S[i] == 'b') b--;
		if (S[i] == 'c') c--;
	}

	if (a == 0 && b == 0 && c == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N = int(input())

graph = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append((b,i))
    graph[b-1].append((a,i))
    
ans = [0]*(N-1)

def dfs(past,now,edge_col):
    new_col = 1
    for (future,i) in graph[now-1]:
        if future == past:
            pass
        else:
            if new_col == edge_col:
                new_col += 1
            ans[i] = new_col
            dfs(now,future,new_col)
            new_col += 1
            
dfs(-1,1,-1)

print(max(ans))
for i in ans:
    print(i)

Measured memory_bytes: 74736
import kotlin.math.abs

fun main() {
    val (x, n) = readLine()!!.split(' ').map { it.toInt() }
    val p = readLine()!!
            .let {
                if (it.isEmpty()) emptySet()
                else it.split(' ').map { s -> s.toInt() }.toSet()
            }
    var ans = 0
    for (i in 1..101) {
        if (p.contains(i)) continue
        if (abs(x - i) < abs(x - ans)) {
            ans = i
        }
    }
    println(ans)
}

Measured memory_bytes: 36776
wds = ['dream', 'dreamer', 'erase', 'eraser']
s = gets.strip

until s.empty? do
  isr = false
  wds.map do |w|
    if s[-w.size, w.size]==w
      s = s[0..-w.size-1]
      isr = true
      break
    end
  end
  
  unless isr
    puts 'NO'
    exit 0
  end
end

puts 'YES'

Measured memory_bytes: 56296
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let (n,m) = {
        let xs = read_vec_i64();
        (xs[0] as usize, xs[1] as usize)
    };
    let mut first: BinaryHeap<(i64,usize)> = BinaryHeap::new();
    let mut first_del: BinaryHeap<(i64,usize)> = BinaryHeap::new();
    let mut second: BinaryHeap<(i64,usize)> = BinaryHeap::new();
    let mut second_del: BinaryHeap<(i64,usize)> = BinaryHeap::new();
    let mut xs = vec![];
    for i in 0..m {
        let ts = read_vec_i64();
        let (a,b) = (ts[0] - 1, ts[1] - 1);
        xs.push((a,b));
        first.push((-a,i));
        second.push((-b,i));
    }
    let mut res = 0;
    loop {
        //eprintln!("aa");
        while ! second.is_empty() && !second_del.is_empty() && second.peek().unwrap() == second_del.peek().unwrap() {
            second.pop();
            second_del.pop();
        }
        if second.is_empty() {
            break;
        }
        let (b,i) = second.pop().unwrap();
        first_del.push((-xs[i].0,i));
        res += 1;
        loop {
            //eprintln!("bb");
            while ! first.is_empty() && ! first_del.is_empty() && first.peek().unwrap() == first_del.peek().unwrap() {
                first.pop();
                first_del.pop();
            }
            if first.is_empty() {
                break;
            }
            if -first.peek().unwrap().0 < -b {
                let (a,k) = first.pop().unwrap();
                second_del.push((-xs[k].1,k));
            }
            else {
                break;
            }
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 12468
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n(),ans=0;
  for(let i=0;i<n;i++){
    let a=t.n(),s=t.s()
    if(s=='JPY')ans+=a
    else ans+=380000*a
  }
  t.o(ans)
}
main()

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

using namespace std;

string S;
long long int K;

int main(void) {

	cin >> S;
	cin >> K;

	int N = S.size();

	int num1 = 0;

	int M;

	for (int i = 0; i < N; i++) {
		if (S[i] == '1') { num1++; }
		else { M = S[i] - '0'; break; }
	}

	if (K <= num1) { cout << 1 << endl; }
	else { cout << M << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 256