akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> H(n);
    for (int i = 0; i < n; ++i) {
        cin >> H[i];
    }
    sort(H.begin(), H.end());
    long long res = 0;
    for (int i = 0; i + (k + 1) <= n; ++i) {
        res += H[i];
    }
    cout << res << "\n";


    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sca=new Scanner(System.in);
		int x = sca.nextInt();
		int y = sca.nextInt();
		System.out.println(gcd(x,y));
	}
	public static int gcd(int x, int y){
	    if(x<y){
			int r = x;
			x = y;
			y = r;
		}
		while(x%y != 0){
			int r = x%y;
			x=y;
			y=r;
		}
		return y;
	}
}


Measured memory_bytes: 26360
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  input.shift();
  var p = input[0].split(" ").map(i => Number(i));
  var map=new Array(N+1);
  for(var i=0;i<N+1;i++){
    var tmp=new Array(N+1).fill(0);
    map[i]=tmp;
  }
  map[0][0]=1;
  for(var i=1;i<N+1;i++){
    for(var j=0;j<=i;j++){
      if(j==0){
        map[i][j]=map[i-1][j]*(1-p[i-1]);
      }else{
        map[i][j]=map[i-1][j]*(1-p[i-1])+map[i-1][j-1]*p[i-1];
      }

    }
  }
  var ans=0;
  for(var i=Math.ceil(N/2);i<N+1;i++){
    ans+=map[N][i];
  }
  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 180784
#include <bits/stdc++.h>
#define Return(x) { printf("%d\n",x); return ; }

typedef long long LL;

const int N=1e5+10,Mod=1e9+7;

int n,a[N],In[N],len[N],ccir[N],dp[N];

void Init() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]),In[a[i]]++;; 
}

int vis[N];
bool cir[N];

int pd(int x,int y) {
	if (y<x) return 0;
	if (y==x) return 1;
	return 2;
}

void Solve() {
	for (int i=1;i<=n;++i) {
		if (vis[i]) continue;
		int x=i;
		while (!vis[x]) vis[x]=i,x=a[x];
		if (vis[x]!=i) continue;
		while (!cir[x]) cir[x]=1,x=a[x]; 
	}
	for (int i=1;i<=n;++i) {
		if (cir[i] && In[i]>2) Return(0);
		if (!cir[i] && In[i]>1) Return(0);
	}
	for (int i=1;i<=n;++i) {
		if (In[i]) continue;
		int x=i,cnt=0; while (!cir[x]) x=a[x],cnt++;
		len[x]=cnt;
	}	
	int ans=1;
	for (int i=1;i<=n;++i) if (cir[i]) {
		int first=0,last=0,rk=0,x=i,flen;
		while (cir[x]) {
			++rk; cir[x]=0;
			if (len[x]) {
				if (!first) { first=rk; last=rk; flen=len[x]; }
				else {
					ans=1ll*ans*pd(len[x],rk-last)%Mod;
					last=rk;
				}
			}
			x=a[x];
		}
		if (!first) ccir[rk]++;else ans=1ll*ans*pd(flen,first+rk-last)%Mod;
	}
	for (int i=1;i<=n;++i) if (ccir[i]) {
		dp[0]=1; int tp=(i&1)+(i>1);
		for (int j=1;j<=ccir[i];++j) {
			dp[j]=dp[j-1]*tp%Mod;
			if (j>1) dp[j]=(dp[j]+1ll*(j-1)*i%Mod*dp[j-2])%Mod;
		}
		ans=1ll*ans*dp[ccir[i]]%Mod;
	}
	Return(ans);
}

int main() {
	Init();
	Solve();
	return 0;
} 

Measured memory_bytes: 1920
#include <stdio.h>
#include <algorithm>

long long int N, T[1123], A[1123];
long long int n;

int my_ceil(long long int i, long long int j) {
	if (i%j == 0) { return 0; }
	else { return 1; }
}

int main(void) {
	scanf("%lld", &N);
	for (int i = 0; i < N; ++i) { scanf("%lld%lld", &T[i], &A[i]); }

	for (int i = 1; i < N; ++i) {
		if (T[i] < T[i - 1] || A[i] < A[i - 1]) {
			n = std::max(T[i - 1] / T[i] + my_ceil(T[i - 1], T[i]), A[i - 1] / A[i] + my_ceil(A[i - 1], A[i]));
			T[i] *= n, A[i] *= n;
		}
	}

	printf("%lld\n", T[N - 1] + A[N - 1]);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	for (int a, b, c; a = in(), b = in(), c = in(), a || b || c;) {
		int d = min(a, b), e = (d == a) ? min(b, c) : min(a, c);
		double o = sqrt(d * d + e * e) / 2;
		for (int n = in(); n--;)
			out(in() > o ? "OK" : "NA", '\n');
	}
}


Measured memory_bytes: 2476
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define ll long long
#define ld long double
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);

#define int ll

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

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

int n, a[N], l[N], r[N], ans;
main() {
    file("rmq");
    ios;
    cin >> n;
    fo(i, 1, n, 1) cin >> a[i];
    stack <int> st;
    fo(i, 1, n, 1) {
        l[i] = 1;
        while (!st.empty() and a[st.top()] >= a[i]) st.pop();
        if (!st.empty()) l[i] = st.top() + 1;
        st.push(i);
    }
    while (!st.empty()) st.pop();
    foo(i, n, 1, 1) {
        r[i] = n;
        while (!st.empty() and a[st.top()] >= a[i]) st.pop();
        if (!st.empty()) r[i] = st.top() - 1;
        st.push(i);
    }
    fo(i, 1, n, 1) ans += (i - l[i] + 1) * (r[i] - i + 1) * a[i];
    cout << ans;
    return 0;
}
/**

*/


Measured memory_bytes: 6656
#多分累積和?
n,q = list(map(int, input().split()))
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

sss = [0]
before = None
for i in s:
    if before=='A' and i=='C':
        sss.append(sss[-1] + 1)
    else: sss.append(sss[-1])
    before = i

for i in lr:
    print(sss[i[1]] - sss[i[0]] )


Measured memory_bytes: 30756
#include <bits/stdc++.h>
using namespace std ;
typedef long double ld ;
const double delta = 0.9993 ;
ld x[ 60 ] , y[ 60 ] ;
int n ;
ld ans = 100000 , Ans = 100000 ;
ld sumx , sumy ;
ld t ;
inline ld dis ( ld x1 , ld y1 , ld x2 , ld y2 ) {
	return sqrt ( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) ;
}
inline ld dist ( ld sumx , ld sumy ) {
	ld mindist = 0 ;
	for ( int i = 1 ; i <= n ; i ++ ) {
		mindist = max ( mindist , dis ( x[ i ] , y[ i ] , sumx , sumy ) ) ;
	}
	return mindist ;
}
inline void SA () {
	t = 200000000 ;
	while ( t > 1e-14 ) {
		ld a = ( rand () * 2 - RAND_MAX ) * t , b = ( rand () * 2 - RAND_MAX ) * t ;
		ld tmp = dist ( sumx + a , sumy + b ) ;
		/*if ( t <= 1000 ) */
		if ( ans - tmp > 0 ) {
			sumx += a ;
			sumy += b ;
			ans = tmp ;
			Ans = min ( ans , Ans ) ;
		}
		else if ( exp ( ( tmp - ans ) / t ) < ( ld ) rand () / RAND_MAX ) {
			sumx += a ;
			sumy += b ;
			ans = tmp ;
		}
		//printf ( "%.18Lf %.18Lf %.18Lf %.18Lf \n " , sumx , sumy , tmp , Ans ) ;
		t *= delta ;
	}
}
signed main () {
	srand ( time ( 0 ) ) ;
	cin >> n ;
	for ( int i = 1 ; i <= n ; i ++ ) {
		cin >> x[ i ] >> y[ i ] ;
		sumx += x[ i ] ; sumy += y[ i ] ;
	}
	sumx /= n ; sumy /= n ;
	for ( int i = 1 ; i <= 20 ; i ++ ) SA () ;
	printf ( "%.18Lf" , Ans ) ;
	return 0 ;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);

const int MAXN = 2e5;
vi v;
int arr[MAXN];

vi path;



void solve(ll k, ll n){
    clr(arr);
    path.clear();
    if (k <=n){
        ll t = 1; 
        while(k--){
            t = v[t-1];
        }
        cout << t << endl;
        return;
    }
    ll i = 0, tar;
    while(true){
       if(arr[i]){
            tar = i;
            break;
       } else{
          path.pb(i);
          arr[i]++;
          i = v[i] -1;
       }
    }
    bool ok = 1;
    ll sub = 0;
    vi ans;
    FOR(i, 0, path.size()){
        if(ok && path[i]!=tar){
            sub++;
        }else{
            ok = 0;
            ans.pb(path[i]+1);
        }
    }

    ll v = k-sub;
    v %= ans.size();
    cout << ans[v] << endl;

}

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

        
    ll t, n;
    cin >> n >> t;
    v.clear();
    v.assign(n, 0);
    repc(i,n){
        cin >> v[i];
    }
    solve(t, n);
    return 0;
}
 
  




Measured memory_bytes: 6232
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
ll N, M, K, ans, mi, A;
string s;
int main() {
	cin >> N>>M;
	M += 3 * N;

	
	cout << M/2<< endl;
						return 0;

}



Measured memory_bytes: 764
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int target = int.Parse(Reader.ReadLine());

        bool canBuy = false;
        for (int i =0; i <= 100; i++) {
            int sub = target - (4 * i);
            if(sub < 0) {
                break;
            }
            if(sub % 7 == 0) {
                canBuy = true;
                break;
            }
        }
        string ans = "Yes";
        if(!canBuy) {
            ans = "No";
        }
        Console.WriteLine(ans);
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



40


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    string s;cin>>s;
    int half =s.size()/2;
    int cnt=0;

    rep(i,half){
        if(s[i]!=s[s.size()-1-i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

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

	char c;
	cin >> c;
	char x = c + 1;
	cout << x;

}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

const int N = (int)1e4 + 150;

int can[N];
bool dig[10];
int c[10] = {0,2,5,5,4,5,6,3,7,6};
int pv[N];

int main(){
  fastIO;
  for(int i = 0 ; i < N ; i++ ) can[i] = -1;
  int n, m;
  cin >> n >> m;
  int d;
  for(int i = 1; i <= m ; i ++ ){
    cin >> d;
    dig[d] = true;
  }
  can[0] = 0;
  for(int i = 0 ; i <= n; i ++ ){
    if(can[i] == -1) continue;
    for(int j = 1; j < 10 ; j ++ ){
      if(dig[j]){
        if(can[i + c[j]] < can[i] + 1){
          can[i + c[j]] = can[i] + 1;
          pv[i + c[j]] = j;
        }
        else if(can[i + c[j]] == can[i] + 1){
          pv[i + c[j]] = max(pv[i + c[j]], j);
        }
      }
    }
  }
  while(n > 0){
    cout << pv[n];
    n -= c[pv[n]];
  }
  return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    S=input()
    f=0
    if S[0]==S[1]==S[2]:
        f=1
    elif S[1]==S[2]==S[3]:
        f=1
    
    if f==1:
        print("Yes")
    else:
        print("No")
        
    
main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);} int dummmmmmmmy

using namespace std;

int main(){

    int n,k;
    cin >> n >> k;
    
    cout << 1 + (n - 2) / (k - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      h: usize,
      w: usize,
      d: usize,
      a: [[Usize1; w]; h],
      q: usize,
      lr: [(Usize1, Usize1); q]
   }
   let mut map = std::collections::BTreeMap::new();
   for i in 0..h {
      for j in 0..w {
         map.insert(a[i][j], (i as i32, j as i32));
      }
   }
   let mut mag = vec![vec![]; d];
   let mag_dif = |(x1, y1): (i32, i32), (x2, y2): (i32, i32)| (x1 - x2).abs() + (y1 - y2).abs();
   for i in 0..d {
      mag[i].push(0);
      let mut j = 1;
      while i + d * j < h * w {
         let x = mag[i][j - 1] + mag_dif(map[&(i + d * (j - 1))], map[&(i + d * j)]);
         mag[i].push(x);
         j += 1;
      }
   }
   for (l, r) in lr {
      let i = l % d;
      println!("{}", mag[i][r / d] - mag[i][l / d]);
   }
}


Measured memory_bytes: 13276
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fs first
#define se second
#define M 1000000007
ll exp(ll a,ll p)
{
	if(p==1)
		return a;
	if(p==0)
		return 1;
	ll st=exp(a,p/2);
	st=(st*st)%M;
	if(p%2 != 0)
		st=(st*a)%M;
	return st;
} 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll d;
	if(n%2 == 0)
	{
		ll ans=0,p1=0,p2=0;
		ll d=10;
		while(d<=n)
		{
			ans+=n/d;
			d*=5;
		}
		// d=50;
		// while(d<=n)
		// {
		// 	ans+=(n/d);
		// 	d*=5;
		// }
		cout<<ans<<endl;
	}
	else
		cout<<0<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int a, int b)
{
	int r = a % b;
	while (r > 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	int gr[100005], gl[100005];
	gl[0] = a[0];
	for (i = 1; i < n; i++)
		gl[i] = gcd(gl[i - 1], a[i]);
	gr[n - 1] = a[n - 1];
	for (i = n - 2; i >= 0; i--)
		gr[i] = gcd(gr[i + 1], a[i]);
	int max = gr[1];
	int g;
	for (i = 1; i < n - 1; i++)
	{
		g = gcd(gl[i - 1], gr[i + 1]);
		if (g > max)
			max = g;
	}
	if (max < gl[n - 2])
		max = gl[n - 2];
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1664
import sys
n, k, q = map(int, sys.stdin.readline().split())
L = [k-q for i in range(n)]

for _ in range(q):
    a = int(sys.stdin.readline())
    L[a-1] +=1

for l in L:
    if l>0:
        print('Yes')
    else:
        print('No')

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

int main() {
  char C;
  cin >> C;
  //アルファベット小文字
  vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  for (int i=0; i<25; i++) {
    if (C==alphabet.at(i)) {
      cout << alphabet.at(i+1) << endl;
      break;
    }
  }
}

Measured memory_bytes: 384
#include <cstdio>

const int MAX_N = 3;
char S[MAX_N];

int main()
{
	scanf("%s", &S);

	if(S[0] == '7' || S[1] == '7' || S[2] == '7') {
		printf("Yes");
	} else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 1732
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B_Robot_Arms.exe B_Robot_Arms.cpp 
Execute: ./B_Robot_Arms
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
#include<bits/stdc++.h> 
using namespace std;

bool sortbysec(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second < b.second; 
} 

int main() { 	
	/* Input */ 
	int N;
	cin >> N;
	int X[N], L[N];
	for(int i = 0; i < N; i++) cin >> X[i] >> L[i]; 
	
	// Vector of robots. Ordered pairs represent intervals of each robot's reach. 
	vector< pair <int,int> > robots; 
	for(int i = 0; i < N; i++) 
		robots.push_back(make_pair(X[i]-L[i], X[i]+L[i])); 
	sort(robots.begin(), robots.end(), sortbysec); 
	
	int num_trees = 1, cum_intsctn_min, cum_intsctn_max;  
	cum_intsctn_min = robots[0].first; 
	cum_intsctn_max = robots[0].second; 
	
	for(int i = 1; i < N; i++) {
		if(robots[i].first < cum_intsctn_max) {
			// Update cumulative intersection if a robot's range overlaps with cumulative intersection. 
			// Overlap of two intervals I & J is: [max(I1, J1), min(I2, J2)] 
			cum_intsctn_min = (cum_intsctn_min > robots[i].first)? cum_intsctn_min : robots[i].first; 
			cum_intsctn_max = (cum_intsctn_max < robots[i].second)? cum_intsctn_max : robots[i].second; 
		} else { 
			num_trees++; 
			cum_intsctn_min = robots[i].first; 
			cum_intsctn_max = robots[i].second; 
		} 
	}
	
	/* Output */ 
	cout << num_trees << endl;
	
	return 0; 
} 


Measured memory_bytes: 2168
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+1;

int main(){
    ll n,a;
    cin >> n >> a;
    if(n%500<=a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 256
inf=10**9+7
n=int(input())
h=list(map(int,input().split()))

dp=[inf]*n
dp[0]=0
for i in range(n):
  for j in range(i+1,i+3):
    if j<n:
      dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
      
print(dp[-1])

Measured memory_bytes: 20448
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    string s;
    cin >> s;
    string t = "keyence";
    int i = 0;
    while(i < t.size() and s[i]==t[i])i++;
    reverse(t.begin(),t.end());
    reverse(s.begin(),s.end());
    int j = 0;
    while(j < t.size() and s[j]==t[j])j++;
    if(i+j>=t.size()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    vector<ll> a(3*n);
    for(int i=0;i<3*n;i++) cin>>a[i];
    sort(a.rbegin(),a.rend());
    ll res=0;
    for(int i=0;i<n;i++){
        res+=a[i*2+1];
    }
    cout<<res<<endl;
}


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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a)a, rreps(i,  0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;


void solve(long long A, long long B, long long C) {
	int t = A - B;
	C -= min(t, C);
	cout << C << endl;
}

signed main() {
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	long long C;
	scanf("%lld",&C);
	solve(A, B, C);
	return 0;
}


Measured memory_bytes: 256
function main(lines) {
    const input = lines.split('\n')
    const searchWord = input[0].toLowerCase()
    const context = input.slice(1, input.length-1) 
    const contextArray = context.join(' ').split(' ')
    
    let count = 0
    contextArray.map(function(element){
        if(element.toLowerCase() === searchWord){
            count++
        }
    })

    console.log(count)
}

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



Measured memory_bytes: 15384
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2100000;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

const int MOD = 1000000007;

int n, t;
VI A;

int main()
{
  cin >> n >> t;
  FOR (i,0,n)
  {
    int x;
    cin >> x;
    A.PB(x);
  }

  int mx = 0, md = 0, cnt = 0;
  RFOR (i,n,0)
  {
    if (mx > A[i])
    {
      int d = mx - A[i];
      if (d > md)
      {
        cnt = 1;
        md = d;
      }
      else
      if (md == d) ++ cnt;
    }

    mx = max(mx, A[i]);
  }


  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 892
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String s = br.readLine();
    
    String s1 = s.substring(0, (s.length()-1)/2);
    String s2 = s.substring((s.length()+2)/2);
    
    for (int i=0; i<s.length(); i++){
      if (s.charAt(i) != s.charAt(s.length()-i-1)){
        System.out.println("No");
        return;
      }
    }
    
    for (int i=0; i<s1.length(); i++){
      if (s1.charAt(i) != s1.charAt(s1.length()-i-1)){
        System.out.println("No");
        return;
      }
    }
    for (int i=0; i<s2.length(); i++){
      if (s2.charAt(i) != s2.charAt(s2.length()-i-1)) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 23124
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
map<int, int>wow;
int main() {
	int n;
	cin >> n;
	int large = 0;
	REP(i, n) {
		int a;
		cin >> a;
		large = max(large, a);
		wow[a]++;
	}
	large++;
	if (large % 2 == 1) {
		for (int i = 0;i <= large / 2;++i) {
			if (i != large / 2) {
				wow[large-i-1] -= 2;
			}
			else wow[large - i-1]--;
			if (wow[large - i-1] < 0) {
				cout << "Impossible" << endl;
				return 0;
			}
		}
		for (int q = 0;q <= large / 2;++q) {
			if (wow[q] != 0) {
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	else {
		for (int i = 0;i < large / 2;++i) {
			wow[large - i-1] -= 2;
			if (wow[large - i-1] < 0) {
				cout << "Impossible" << endl;
				return 0;
			}
		}
		for (int q = 0;q <= large / 2;++q) {
			if (wow[q] != 0) {
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	cout << "Possible" << endl;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

char s[123];

int main(){
    scanf("%s", s);
    int len = strlen(s);
    for(int i = 0; i < len - 8; i++){
        printf("%c", s[i]);
    }
    puts("");
}


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

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

const ll MOD = 1e9+7;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const ll MAX = 200010;
ll l[MAX]={};
ll dp[MAX]={};

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> C(N); REP(i, N) cin >> C[i];
	REP(i, MAX) l[i] = -1;

	dp[0] = 1;
	REP(i, N)
	{
		(dp[i+1] += dp[i]) %= MOD;
		ll c = C[i];
		if (l[c] >= 0 && l[c] < i-1)
			(dp[i+1] += dp[l[c]+1]) %= MOD;
		l[c] = i;
	}

	std::cout << dp[N] << std::endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  int N; cin >> N;
  string S; cin >> S;
  
  string T = S;
  int ans = 0;
  for (int k = 1; k < N; k++) {
    int count = 0;
    for (int i = k; i < N; i++) {
      if (S[i] != T[i-k] || count == k) {
        chmax(ans,count);
        count = 0;
      } else count++;
    }
    chmax(ans,count);
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <limits.h>

#define MAX 100

int main(){

  int i, j, k, l, n, a[MAX+1], b[MAX+1][MAX+1], temp;

  scanf("%d",&n);

  for(i = 1; i <= n; i++) scanf("%d%d",&a[i-1],&a[i]);

  for(i = 1; i <= n; i++) b[i][i] = 0;

  for(j = 2; j <= n; j++){
    for(i = 1; i <= n - j + 1; i++){
      k = i + j - 1;
      b[i][k] = INT_MAX;

      for(l = i; l <= k - 1; l++){
	temp = b[i][l] + b[l+1][k] + a[i-1] * a[l] * a[k];
	if(b[i][k] > temp) b[i][k] = temp;
	else b[i][k] =  b[i][k];
      }
    }
  }

  printf("%d\n",b[1][n]);

  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        string s = to_string(i);
        if(s.size() % 2 == 1){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp;

fn main(){
  loop {
    let n: usize = read();
    if n == 0 {break;}
    
    let mut cv: Vec<Vec<char>> = vec![vec!['.'; n]; n];
    let mut lv: Vec<Vec<u32>> = vec![vec![0; n+1]; n+1];
    let mut mxl: u32 = 0;
    
    for i in 0 .. n {
      cv[i] = read_charvec();
    }
  
    for i in 0..n {
      for j in 0..n {
        if cv[i][j] == '*' {
          lv[i+1][j+1] = 0;
        } else {
          let x: u32 = cmp::min(lv[i][j], cmp::min(lv[i][j+1], lv[i+1][j]));
          lv[i+1][j+1] = x+1;
          mxl = cmp::max(mxl, x+1);
        }
      }
    }
    println!("{}", mxl);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_charvec() -> Vec<char>
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().chars().collect()
}



Measured memory_bytes: 13200
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
#define int long long
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	auto getid = [](int u, int w) {
		return 2501 * u + w;
	};
	int n, m, s; cin >> n >> m >> s; s = min(s, 2500LL);
	vector<vector<array<int, 2>>> g(4e5);
	for (int i = 0; i < m; ++i) {
		int u, v, x, y; cin >> u >> v >> x >> y;
		for (int i = x; i <= 2500; ++i) {
			int a = getid(u, i), b = getid(v, i-x);
			g[a].pb({b, y});
			a = getid(u, i-x), b = getid(v, i);
			g[b].pb({a, y});
		}
	}
	vector<array<int, 2>> ex(n);
	for (int i = 0; i < n; ++i) {
		cin >> ex[i][0] >> ex[i][1];
		ex[i][0] = min(ex[i][0], 2500LL);
		for (int s = 0; s+ex[i][0] <= 2500; ++s) {
			int u = getid(i+1, s), v = getid(i+1, s+ex[i][0]);
			g[u].pb({v, ex[i][1]});
		}
	}
	set<array<int, 2>> active;
	vector<int> dist((int)4e5, -1);
	dist[getid(1, s)] = 0;
	active.insert({0, getid(1, s)});
	while (!active.empty()) {
		auto [y, x] = *active.begin();
		active.erase(active.begin());
		for (auto [u, d] : g[x]) {
			int newdist = y + d;
			if (dist[u] == -1 or dist[u] > newdist) {
				active.erase({dist[u], u});
				dist[u] = newdist;
				active.insert({newdist, u});
			}
		}
	}
	vector<int> ans(n+1, -1);
	for (int i = 0; i < dist.size(); ++i) {
		int node = i / 2501;
		if (node < 1 or node > n) continue;
		if (dist[i] == -1) continue;
		if (ans[node] == -1) ans[node] = dist[i];
		else ans[node] = min(ans[node], dist[i]);
	}
	for (int i = 2; i <= n; ++i)
		cout << ans[i] << ' ';
	// dp[i][j] -> minimum time to reach city i having at least j coins
}

// Graph of (node, x)
// Edge of weight 0 between (node, x) and node(x+1)
// 50 * 50 * 50 nodes = 10^5
// If (u, v, w, t) exists in the original graph, add edge (u, x) -> (v, x-w) with weight t for every x >= w

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

using namespace std;

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


int main(){
	
	
	int a,b;
	int sum=0,c=0;
	int sumb=0;
	
	while(scanf("%d,%d",&a,&b)!=EOF){
		sum += a*b;
		sumb += b;
		c++;
	}
	
	printf("%d\n%d\n",sum,int(sumb/(double)c+0.5));
	
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define int long long
using namespace std;

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

  int ans = 1e9;
  for (int i = -300; i <= 300; i++) {
    int temp = 0;
    for (int j = 0; j < N; j++) {
      temp += (x[j] - i) * (x[j] - i);
    }
    ans = min(ans, temp);
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  bool used[26] = {};
  string s;
  cin >> s;
  REP(i, s.length())
  {
    used[s[i] - 'a'] = true;
  }

  if (s.length() != 26)
  {
    REP(i, 26)
    {
      if (!used[i])
      {
        char a = 'a' + i;
        cout << s << a << endl;
        return 0;
      }
    }
  }
  else
  {
    for (int i = 25; i >= 1; i--)
    {
      used[s[i] - 'a'] = false;
      if (s[i] > s[i - 1])
      {
        string ans = s.substr(0, i - 1);
        char a;
        REP(j, 26)
        {
          if (!used[j] && s[i - 1] < 'a' + j)
          {
            a = 'a' + j;
            break;
          }
        }
        cout << ans << a << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        s: String
    }
    let v = vec! ["SUN","MON","TUE","WED","THU","FRI","SAT"];
    let p = v.iter().position(|t| **t == s);
    println!("{}", v.len() - p.unwrap());
}
/* vim:set foldmethod=marker: */


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

int main(void){

  int N,K;
  cin >> N >> K;

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


  if(N<K){
    cout<<"0"<<endl;
    return 0;
  }
  
  sort(H.begin(),H.end());
  for(int i=0;i<K;i++)
    H.pop_back();
 long long int count=0;
  for(int i=0;i<H.size();i++){
    count+=H[i];
  } 
  cout << count <<endl;






  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	char name[31];
};

struct Ans{
	char left[31],right[31];
};

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

int strCmp2(char* left,char* right){
	int i;

	if(strCmp(left,right))return 3;

	for(i=0;left[i] != '\0' && right[i] != '\0'; i++){
		if(left[i] != right[i]){
			if(left[i] < right[i])return 1;
			else{
				return 2;
			}
		}
	}
	if(left[i] == '\0')return 1;
	else{
		return 2;
	}
}



int main(){

	int F,N,index,base;
	scanf("%d %d",&N,&F);
	int num_of_data[N];
	char*** data = new char**[N];
	for(int i = 0; i < N; i++){
		data[i] = new char*[10];
		for(int k = 0; k < 10; k++){
			data[i][k] = new char[31];
		}
	}
	int** checkTable = new int*[1000];
	for(int i = 0; i < 1000; i++){
		checkTable[i] = new int[1000];
		for(int k = 0; k < 1000; k++)checkTable[i][k] = 0;
	}

	Info info[10*N];
	index = 0;

	char buf[31];
	bool FLG;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&num_of_data[loop]);

		for(int i = 0; i < num_of_data[loop];i++){
			scanf("%s",buf);
			strcpy(data[loop][i],buf);
			FLG = false;
			for(int k = 0; k < index; k++){
				if(strCmp(info[k].name,buf)){
					FLG = true;
					break;
				}
			}
			if(!FLG){
				strcpy(info[index].name,buf);
				index++;
			}
		}
	}

	for(int loop = 0; loop < N; loop++){
		for(int i = 0; i < num_of_data[loop];i++){

			for(int k = 0; k < index; k++){
				if(strCmp(data[loop][i],info[k].name)){
					base = k;
					break;
				}
			}

			for(int k = 0; k < num_of_data[loop];k++){
				if(k != i){
					for(int p = 0; p < index; p++){
						if(strCmp(data[loop][k],info[p].name)){
							checkTable[base][p]++;
							break;
						}
					}
				}
			}
		}
	}

	Ans* ans = (Ans*)malloc(sizeof(Ans)*(index*index));
	int ans_index = 0;

	for(int i = 0; i < index-1; i++){
		for(int k = i+1; k < index; k++){
			if(checkTable[i][k] >= F){
				if(strCmp2(info[i].name,info[k].name) == 1){
					strcpy(ans[ans_index].left,info[i].name);
					strcpy(ans[ans_index].right,info[k].name);
					ans_index++;
				}else{
					strcpy(ans[ans_index].left,info[k].name);
					strcpy(ans[ans_index].right,info[i].name);
					ans_index++;
				}
			}
		}
	}

	for(int i = 1; i <= ans_index-1; i++){
		for(int k = ans_index-1; k >= i;k--){
			if(strCmp2(ans[k].left,ans[k-1].left) == 1)swap(ans[k],ans[k-1]);
			else if(strCmp2(ans[k].left,ans[k-1].left) == 3 && strCmp2(ans[k].right,ans[k-1].right) == 1)swap(ans[k],ans[k-1]);
		}
	}

	printf("%d\n",ans_index);

	for(int i = 0; i < ans_index; i++){
		printf("%s %s\n",ans[i].left,ans[i].right);
	}

    return 0;
}

Measured memory_bytes: 6988
w[100000],c,n,k,g,i,l,m,r=1e9;
f(p){for(c=1,g=0,i=0;i<n;){if(g+w[i]<=p){g+=w[i++];}else{if(g>0)c++;else return k+1;g=0;}}return c;}
main(){for(scanf("%d%d",&n,&k);i<n;scanf("%d",w+i++));
while(l<r){m=(l+r)/2;if(f(m)>k)l=m+1;else r=m;}for(m--;;m++){if(f(m)<=k)break;}printf("%d\n",m);exit(0);}

Measured memory_bytes: 2216
import collections
n = int(input())
v = list(map(int,input().split()))
even = [] 
odd = []
for i in range(n//2):
  even.append(v[2*i])
  odd.append(v[2*i+1])
e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

ans = float("inf")
for i in range(2):
  for j in range(2):
    if i < len(e) and j < len(o):
      if e[i][0] == o[j][0]:
        continue
      else:
        ans = min(ans,n-(e[i][1]+o[j][1]))
if ans ==  float("inf"):
  ans = n//2       
print(ans)      

Measured memory_bytes: 21084
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int main()
{
    int a, b, c, k;
    scanf("%d%d%d%d\n", &a, &b, &c, &k);
    int cnt = 0;
    while(!(a<b)) b*=2, ++cnt;
    while(!(b<c)) c*=2, ++cnt;
    puts(cnt <= k ? "Yes" : "No");
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int startIdx, endIdx;
    for (int i = 0; i < (int)s.size(); i++) {
        if ('A' == s[i]) {
            startIdx = i;
            break;
        }
    }
    for (int i = 0; i < (int)s.size(); i++) {
        int idx = s.size() - i;
        if ('Z' == s[idx]) {
            endIdx = idx;
            break;
        }
    }

    int ret = endIdx - startIdx + 1;
    cout << ret << endl;
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A) {
    map<long long, bool> map;
    for (long long i = 0; i < N; i++) {
        if (map.count(A[i]) == 0) {
            map.insert(make_pair(A[i], true));
        } else {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}


int main() {
    ll N, K, ans;
    cin >> N >> K;
    vi A(N+1);
    vector<bool> ch(N+1, false);
    rep1(i, N) cin >> A[i];
    queue<int> que;

    int n_i = 1;
    que.push(n_i);
    do{
        ch[n_i] = true;
        n_i = A[n_i];
        que.push(n_i);
    }while(que.size()-1 < K && (!ch[n_i]));

    if(que.size()-1 == K)
        ans = n_i;
    else{
        int tmp=que.front(); que.pop();
        int cnt = 0;
        while(tmp != n_i) {
            tmp = que.front(); que.pop();
            cnt++;
        }

        ll r = (K-cnt)%(que.size());
        ll pc = (r-1 >= 0 ? r-1 : que.size()-1);
        rep(i,pc) que.pop();
        ans = que.front();
    }
    

    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    cout << ans;
    cout << "\n";
    return 0;
}


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

int main(){
    ll k,a,b;
    ll ans=0;
    cin>>k>>a>>b;
    if(b-a<=2){
        ans+=k+1;
    }else if((k-a+1)%2==0){
        ans+=a;
        ll s=(k-a+1)/2;
        s*=b-a;
        ans+=s;
    }else{
        ans+=a+1;
        ll s=(k-a)/2;
        s*=b-a;
        ans+=s;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256