akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main () {
    string s;
    int count = 0;
    cin >> s;
    set<char> first;
    set<char>::iterator it;
    for (int i = 0; i < s.length(); i++) {
        char c = s[i];
        it = first.find(c);
        if (it != first.end()) {
            //cout << "Found" << endl;
            count++;
        }
        else {
            //cout << "Inserting" << endl;
            first.insert(c);
        }
    }
    if (count > 0) cout << "no" << endl;
    else cout << "yes" << endl;
}
        

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



int main()
{
    long long int a,b,x;
    cin >> a >> b >> x;
    if (a % x == 0)
    cout << (b/x)-(a/x)+1 << endl;
    else
    cout << (b/x)-(a/x) << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
	int N,M,i,j,max=0,kk;
	int A[1001]={0},B,P[1001]={0};
	scanf("%d%d",&N,&M);
	for(i=1;i<=N;i++)scanf("%d",&A[i]);
	for(j=1;j<=M;j++){
		scanf("%d",&B);
		for(i=1;i<=N;i++){
			if(A[i]<=B){
				P[i]++;
				break;
			}
		}
	}
	for(i=1;i<=N;i++){
		if(max<P[i]){
		max=P[i];
		kk=i;
		}
	}
	printf("%d\n",kk);
	return 0;
}



Measured memory_bytes: 2112
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  ll dp[s.size()][13];
  rep(i,s.size()) rep(j,13) dp[i][j]=0;
  if(s[0]=='?') rep(i,10) dp[0][i]=1;
  else dp[0][s[0]-'0']=1;
  rep(i,s.size()-1){
    if(s[i+1]=='?'){
      rep(j,13){
        rep(k,10){
          dp[i+1][(j*10+k)%13]+=dp[i][j];
          dp[i+1][(j*10+k)%13]%=MOD;
        }
      }
    }else{
      rep(j,13){
        dp[i+1][(j*10+(s[i+1]-'0'))%13]+=dp[i][j];
        dp[i+1][(j*10+(s[i+1]-'0'))%13]%=MOD;
      }
    }
  }
  cout<<dp[s.size()-1][5]<<endl;
}

Measured memory_bytes: 10704
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (H, W) = parse_line!(usize, usize);
    let (h, w) = parse_line!(usize, usize);
    let ans = (H - h) * (W - w);
    println!("{}", ans);
}


Measured memory_bytes: 4352
/*
ID: htc9811
LANG: C++
TASK: 
*/

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<queue>
#include<deque>
#include<stack>
#include<ctime>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<cctype>
#include<bitset>
#include<list>
using namespace std;

int a,b,c;
long long k;

int main(){
	cin>>a>>b>>c>>k;
	if(k%2==0) cout<<a-b<<endl;
	else cout<<b-a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int v,i,n;
   scanf("%d",&n);
  v=0; 
  for(i=0;n>0;i++)
   {
      if(n%10==7)
      { 
        v++;
        printf("Yes");
        break;
       
       }
      n=n/10;
   }
  if(v==0)
  {
     printf("No\n");
  }
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    int ans = 0;
    REP(i, N) if(i%2 == 0 && a[i]%2 == 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3616
// ------------------------------------
// Date:2018/ 3/ 8
// Problem:AGC 010 Addition a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#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 ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N;
  cin >> N;
  int cnt = 0;
  int tmp;
  REP(i, N) {
    cin >> tmp;
    if (tmp % 2 == 1) {
      ++cnt;
    }
  }

  cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

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

  bool turn = true;
  while (A > 0 && C > 0) {
    if (turn) {
      C -= B;
    } else {
      A -= D;
    }
    turn = !turn;
  }

  if (A > 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3636
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto L = new long[](N);
    auto R = new long[](N);
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!long);
        L[i] = s[0];
        R[i] = s[1];
    }

    L.sort();
    R.sort();
    long ans = -1;
    long tmp = 0;

    foreach (i; 0..N) {
        tmp += L[$-i-1] * 2;
        ans = max(ans, tmp);
        tmp -= R[i] * 2;
        ans = max(ans, tmp);
    }

    tmp = 0;

    foreach (i; 0..N) {
        tmp -= R[i] * 2;
        ans = max(ans, tmp);
        tmp += L[$-i-1] * 2;
        ans = max(ans, tmp);
    }

    ans.writeln;
}


Measured memory_bytes: 4860
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int t,x,y,z;
    cin>> x >> y >> z;
    if (x > y){
        t = y;
        y = x;
        x = t;
        t = 0;
    }
    if (y > z){
        t = z;
        z = y;
        y = t;
        t = 0;
    }
    if (x > y){
        t = y;
        y = x;
        x = t;
        t = 0;
    }
    cout<< x << " " << y << " " << z << endl;
}



Measured memory_bytes: 3088
#include <iostream>

int main(void) {
  	const int N = []() {
      	int tmp; std::cin >> tmp;
      	return tmp;
    }();
  
    for(int n = N; n >= 0; n -= 7) {
        if(n % 4 == 0) {
            std::cout << "Yes\n";
            return 0;
        }
    }
  
    std::cout << "No\n";
}


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

int main(){
  string S;
  cin >> S;
  
  char end = S.at(S.size() - 1);
  string ans = S;
  if (end == 's'){
    ans += "es";
  }
  else{
    ans += "s";
  }
  
  cout << ans << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b;
    cin >> a >> b;
    ANS(a*b);
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1e5 + 55, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vi a(n);
	for(auto &i : a) cin >> i;
	sort(all(a));
	cout << a[n/2] - a[n/2 - 1];
}


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

int main() {
	int n;
	cin >> n;
	int a[n][3];
	for(int i=0; i<n; i++){
	    for(int j=0; j<3; j++){
	        cin >> a[i][j];
	    }
	}
	int dp[n][3];
	for(int i=0; i<3; i++){
	    dp[0][i]=a[0][i];
	}
	for(int i=1; i<n; i++){
	    for(int j=0; j<3; j++){
	        if(j==0) dp[i][j]=max(dp[i-1][j+1],dp[i-1][j+2])+a[i][j];
	        if(j==1) dp[i][j]=max(dp[i-1][j+1],dp[i-1][j-1])+a[i][j];
	        if(j==2) dp[i][j]=max(dp[i-1][j-1],dp[i-1][j-2])+a[i][j];
	    }
	}
	int ans=0;
	for(int i=0; i<3; i++){
	    if(dp[n-1][i]>ans) ans=dp[n-1][i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()


int main(){
  int n,ans=0;
  cin >> n;
  vi l(n);
  rep(i,n)  cin >> l[i];
  sort(all(l));
  
  REP(i,0,n){
    REP(j,i+1,n){
      REP(k,j+1,n){
        if(l[k]<l[i]+l[j]){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char str[100005];
int main()
{
    while (scanf("%s",str)!=EOF)
    {
        int len=strlen(str);
        int res;
        if (str[0]==str[len-1])
            res=len-3;
        else
            res=len-2;
        if (res%2==1)
            printf("First\n");
        else printf("Second\n");
    }
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,K;
    cin >> N >> K;

    cout << N-K+1 << endl;
}

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


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

namespace ConsoleApplication3
{
class Program
{
    static void Main(string[] args)
    {
          
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int tate = int.Parse(str[0]);
            int yoko = int.Parse(str[1]);

            if ((tate == 0) && (yoko == 0))
            {
                break;
            }
            for (int i = 1; i <= tate; ++i)
            {
                for (int j = 1; j <= yoko; ++j)
                {
                   
                    if ((i+j) % 2 == 0)
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                    Console.WriteLine();
            }
                Console.WriteLine(); 
            } 
        }
    }
}

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

int main(){

  string s,t;
  cin >> s >> t;

  sort(s.begin(),s.end());
  
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());

  if(s<t) cout << "Yes";
  else cout << "No";
  
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    ll ans=0;
    ll min_=MOD;
    int flag=1;
    for(int i=0; i<N; i++){
        ll A, B;
        cin >> A >> B;
        ans+=A;
        if(A>B){
            min_=min(min_, B);
        }
        if(A!=B){
            flag=0;
        }
    }
    if(flag==1){
        cout << 0 << endl;
        return 0;
    }
    cout << ans-min_ << endl;
}

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

#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

#define rep(i,n)      for(int i=0; i < (n); ++i)
#define fr            first
#define sc            second
#define int           long long
#define uint          unsigned long long
#define pb            push_back
#define mp            make_pair
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define sz(x)         (x).size()

const double PI=3.1415926535897932384626433832795;
const int mod=1e9+7;
const int mod1=998244353;
int n,ans; string str;

int solve(){
    cin>>n; int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    a[0]-=1;
    for (int i = 1; i < n; ++i)
    {
        if(a[i]>a[i-1]) a[i]--;
    }
    for (int i = 1; i < n; ++i)
    {
        if(a[i]<a[i-1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int tests=1;
    //cin>>tests;
    while(tests--) solve();
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int A[202020];

ll mo=998244353;
template<class V, int ME> class BIT_mod {
public:
	V bit[1<<ME];
	BIT_mod(){ZERO(bit);};
	V operator()(int e) {ll s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s%mo;}
	void add(int e,V v) { e++; while(e<=1<<ME) { bit[e-1]+=v; bit[e-1] -= (bit[e-1]>=mo)?mo:0; e+=e&-e;}}
};
BIT_mod<ll,20> bt,num;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	
	ll r2=(mo+1)/2;
	ll ret=0;
	FOR(i,K) {
		bt.add(A[i],1);
		num.add(A[i],1);
	}
	
	ret=1LL*K*(K-1)%mo*r2%mo*r2%mo;
	
	ll p=(K-1)*modpow(K)%mo;
	ll rp=1;
	ll c=1;
	for(i=K;i<N;i++) {
		c=c*p%mo;
		// less
		(ret+=bt(A[i])*(c*r2%mo))%=mo;
		// more
		(ret+=(mo+bt(N)-bt(A[i]))*(mo-c*r2%mo))%=mo;
		(ret+=(mo+num(N)-num(A[i])))%=mo;
		bt.add(A[i],modpow(c));
		num.add(A[i],1);
	}
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 20788
s = input()
if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
 print(3)
elif s == 'FRI':
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int n;
int a[maxn];
ll f[maxn][5];

template<typename T>
inline void read(T &k)
{
	int f = 1; k = 0; char c = getchar();
	while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
	while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
	k *= f;
}

int main()
{
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);

	memset(f, 0x3f, sizeof(f));
	f[0][0] = 0;
	for (int i = 1; i <= n; i++)
	{
		f[i][0] = f[i - 1][0] + a[i];
		f[i][1] = min(f[i - 1][0], f[i - 1][1]) + (a[i] == 0 ? 2 : (a[i] & 1));
		f[i][2] = min(min(f[i - 1][0], f[i - 1][1]), f[i - 1][2]) + (!(a[i] & 1));
		f[i][3] = min(min(f[i - 1][0], f[i - 1][1]), min(f[i - 1][2], f[i - 1][3])) + (a[i] == 0 ? 2 : (a[i] & 1));
		f[i][4] = min(min(min(f[i - 1][0], f[i - 1][1]), min(f[i - 1][2], f[i - 1][3])), f[i - 1][4]) + a[i];
		// printf("i:%d f0:%lld f1:%lld f2:%lld f3:%lld f4:%lld\n", i, f[i][0], f[i][1], f[i][2], f[i][3], f[i][4]);
	}

	printf("%lld\n", min(min(min(f[n][0], f[n][1]), min(f[n][2], f[n][3])), f[n][4]));
}

Measured memory_bytes: 20736
fun main(args: Array<String>) {
    val (n, m, x) = readLine()!!.split(' ').map(String::toLong)
    val input = mutableListOf<List<Long>>()
    (1..n).forEach {
        input.add(readLine()!!.split(' ').map(String::toLong))
    }
    val pattern = IntArray(n.toInt()) { 0 }

    fun addP(i: Int = 0): Boolean {
        if (i == n.toInt() - 1 && pattern[i] == 1) {
            return false
        }
        if (pattern[i] == 0) {
            pattern[i] = 1
            return true
        } else {
            for (j in 0..i) pattern[j] = 0
            return addP(i + 1)
        }
    }

    var minCost = Long.MAX_VALUE
    fun calcCost(): Long {
        var cost = 0L
        val aL = LongArray(m.toInt()) { 0L }
        for (i in 0 until n.toInt()) {
            if (pattern[i] == 1) {
                cost += input[i][0]
                for (mi in 0 until m.toInt()) {
                    aL[mi] += input[i][mi + 1]
                }
            }
        }
        if(aL.all { it>=x })return cost
        else return Long.MAX_VALUE
    }

    while (addP()) {
//        println(pattern.joinToString(","))
        minCost = Math.min(minCost, calcCost())
    }
    if(minCost==Long.MAX_VALUE) println(-1)
    else println(minCost)
}


Measured memory_bytes: 39332
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int main(){
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> A(Q); REP(i, Q) cin >> A[i];
  // 各人が正解した個数
  vector<int> Right(N, 0); 
  REP(i, Q) Right[A[i] - 1] += 1;
  REP(i, N){
    if(Q - Right[i] >= K )cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1408
#include <iostream>
#define rep(i, n) for(int i =0; i<n; i++)

using namespace std;

int main(void){
  int N;
  cin >> N;
  int a[N];
  rep(i, N)
    cin >> a[i];
  //入力終了

  //rating3200以上の人のことを「自由人」と呼ぶことにする
  
  //各色の人数を記録
  //colors[8]には自由人の人数を記録
  int colors[9] = {0};

  rep(i, N){
    if(1<=a[i] && a[i]<=399)
      colors[0]++;
    else if(400<=a[i] && a[i]<=799)
      colors[1]++;
    else if(800<=a[i] && a[i]<=1199)
      colors[2]++;
    else if(1200<=a[i] && a[i]<=1599)
      colors[3]++;
    else if(1600<=a[i] && a[i]<=1999)
      colors[4]++;
    else if(2000<=a[i] && a[i]<=2399)
      colors[5]++;
    else if(2400<=a[i] && a[i]<=2799)
      colors[6]++;
    else if(2800<=a[i] && a[i]<=3199)
      colors[7]++;
    else
      colors[8]++;
  }

  int ans = 0;
  rep(i, 8){
    //各色の人が一人でもいればカウント
    if(colors[i]>0)
      ans++;
  }

  //最小の時の解答
  //自由人しかいない時
  if(ans == 0)
    cout << 1 << " ";
  //自由人は既にある色のみを選ぶ
  else
    cout << ans << " ";

  //最大の時の解答
  //自由人はできるだけ多くの色が出るように選ぶ
  cout << ans+colors[8] << endl;
  
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int maxn=110;
string a[maxn];
int n,m;
int main() {
    cin>>n>>m;
    for (int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    string ans;
    for (int i=0;i<n;i++) ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second

LL dp[1010][1010];
LL f[1010], iv[1010];
const LL mod = 1000000007;
LL inv(LL a, LL n = mod) {
  return a < 2 ? a : ((1 - n * 1LL * inv(n % a, a)) / a % n + n) % n;
}
LL pow_mod(LL a, LL p, const LL m) {
  LL ret = 1;
  for (; p; p >>= 1, a = a*a%m)
    if (p & 1)
      ret = ret*a%m;
  return ret % m;
}
int main() {
  f[0] = iv[0] = 1;
  REPE(i, 1, 1000) {
    f[i] = f[i-1] * i % mod;
    iv[i] = inv(f[i]);
  }
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  REP(i, 1010) dp[0][i] = 1;
  REPE(i, 1, n) {
    for (int j = a; j <= b; ++j) {
      dp[i][j] = dp[i][j-1];
      int ub = min(d, i / j);
      LL bot = pow_mod(iv[j], c, mod);
      for (int k = c; k <= ub; ++k) {
        dp[i][j] += dp[i-j*k][j-1] * (((f[i] * bot % mod) * iv[i - j * k] % mod) * iv[k] % mod);
        dp[i][j] %= mod;
        bot = bot * iv[j] % mod;
      }
    }
  }
  cout << dp[n][b] << endl;
  return 0;
}



Measured memory_bytes: 8192
import Control.Applicative( (<$>))

main = do
    _n <- getLine
    s_ <- getLine
    let
	proc1 v diff []	= (v,diff)
	proc1 v diff (c:cs)
	  | c==')'	    = if diff==0
				then proc1 ('(':v) diff cs
				else proc1 v (diff-1) cs
	  | otherwise	    = proc1 v (diff+1) cs

	(v,d) = proc1 [] 0 s_
	post = take d $ repeat ')'

    putStr $ v++s_++post

Measured memory_bytes: 508
inputs = gets.split(" ").map!(&:to_i)
n = inputs[0]
timeLimit = inputs[1]

flag = false
mincost = 1001
n.times do |i|
  route = gets.split(" ").map!(&:to_i)
  if route[1] <= timeLimit && route[0] < mincost then
    mincost = route[0]
    flag = true
  end
end 
if flag == true then
  p mincost
else 
  puts "TLE"
end

Measured memory_bytes: 1788
wrapper::Int->Int->[[Char]]->[[Char]]
wrapper x y pic = let sharps = take (y+2) (repeat '#') in
                  sharps:( (map (\z -> '#':(z++"#")) pic)++[sharps])

get_n::Int->IO [[Char]]
get_n 0 =return []
get_n n = do
  this<-getLine
  rest<-get_n (n-1)
  return (this:rest)

out_pic::[[Char]]->IO()
out_pic [] = return()
out_pic (x:xs) = do
    putStr x
    putStr "\n"
    out_pic xs

main::IO()
main=do
  hwc<-getLine
  let h:w:[] = map read (words hwc)
  pic<-get_n h
  out_pic (wrapper h w pic)


Measured memory_bytes: 1404
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

struct edge {
	int to,  cost;
};
vector<int> G[100010];
int color[100010];

bool visited[100010];

void dfs(int n) {
	for (auto x : G[n]) {
		if (!visited[x]) {
			visited[x] = true;
			dfs(x);
		}
	}
}
long long power(long long a, long long n) {//aのn乗を計算します。
	long long x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}
vector<int>ans;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int M, K; cin >> M >> K;
	if (K == 0) {
		REP(i, power(2, M)) {
			pe(i)pe(i);
		}cout << endl;
	}
	else if (M == 1 && K == 1) {
		print(-1); return 0;
	}
	else if (power(2, M) <= K) {
		print(-1); return 0;
	}
	else {
		ans.pb(K);
		for (int i = 0; i < power(2, M); i++) {
			if (i == K)continue;
			ans.pb(i);
		}
		ans.pb(K);
		for (int i = power(2, M) - 1; i >= 0; i--) {
			if (i == K)continue;
			ans.pb(i);
		}
		REP(i, ans.size()) {
			pe(ans[i]);
		}cout << endl;
	}
	
}

Measured memory_bytes: 6384
#0407
N = int(input())
x = list(map(int,input().split()))
x.sort()
a = int(x[0])
b = int(x[N-1])
if a%2 == 0 and b%2 == 0:
    print((b - a)//2)
else:
    print((b - a + 1)//2)


Measured memory_bytes: 5616
#include<stdio.h>
int main(void)
{
	int n,k,x,y,i,ans;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	ans=0;
	for(i=1;i<=n;i++){
		if(k<i){
			ans+=y;
		}
		else{
			ans+=x;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi =vector<vi>;

int main(){
  string s;
  cin >>s;
  vector<char>A(s.size());
  vector<char>B(s.size());
  bool ans = 1;
  
  for(int i=0 ;i<s.size() ;i++) A[i]=s[i],B[i]=s[i];
  reverse(B.begin(),B.end());
  for(int i=0 ;i<s.size() ;i++) if(A[i]!=B[i]) ans = 0;
  
  vector<char>C((s.size()-1)/2);
  vector<char>D((s.size()-1)/2);
  
  for(int i=0 ;i<C.size() ;i++) C[i]=s[i],D[i]=s[i];
  reverse(D.begin(),D.end());
  for(int i=0 ;i<C.size() ;i++) if(C[i]!=D[i]) ans = 0;
  
  vector<char>E(s.size()-(s.size()+3)/2+1);
  vector<char>F(s.size()-(s.size()+3)/2+1);
  
  for(int i=0 ;i<E.size() ;i++) E[i]=s[i],F[i]=s[i];
  reverse(F.begin(),F.end());
  for(int i=0 ;i<E.size() ;i++) if(E[i]!=F[i]) ans = 0;
  
  if(ans) cout <<"Yes"<< endl;
  else cout <<"No"<<endl;
}
  
  
  
  
  

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

const int N = (int)1e5+5;

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

    int n,m,t=0;
    cin>>n>>m;
    vector<int> a(n);
    for(int i=0;i<n;i++) {
        cin>>a[i];
        t+=a[i];
    }
    sort(a.begin(),a.end());
    int cnt = 0, lim = t/(4*m);
    if(t%(4*m)==0) lim--;
    for(int i=n-1;i>=0;i--) {
        if(a[i]<=lim) break;
        cnt++;
    }
    if(cnt>=m) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    int a[100+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(a[i]<a[j]){
                int temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    
    int alice=0, bob=0;
    for(int i=0; i<n; i++){
        if(i%2==0)alice+=a[i];
        else bob+=a[i];
    }
    printf("%d\n", alice-bob);
    return 0;
}


Measured memory_bytes: 1728
N, K = map(int, input().split())
nlist = list(map(int, input().split()))
Ktot = sum(i for i in nlist[:K])
maximum = Ktot
for l in range(N-K):
  Ktot = Ktot - nlist[l] + nlist[l+K]
  maximum = max(maximum, Ktot)
print((maximum+K)/2)


Measured memory_bytes: 24804
from collections import deque


def main():
    N, M = map(int, input().split())
    adj = [set() for _ in range(N*3)]
    dp = [[[] for _ in range(N)] for _ in range(3)]
    for _ in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        adj[u].add(N*1+v)
        adj[N*1+u].add(N*2+v)
        adj[N*2+u].add(v)
    S, T = map(int, input().split())
    searchq = deque()
    visited = set()
    searchq.append((S-1, 0))
    visited.add(S-1)
    while len(searchq):
        p, cost = searchq.popleft()
        if p == T-1:
            print(cost//3)
            return
        for nxt in adj[p]:
            if nxt not in visited:
                searchq.append((nxt, cost+1))
                visited.add(nxt)
    print(-1)


if __name__ == "__main__":
    main()


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

int main()
{
  int n, k;
  cin >> n >> k;
  int i, ans;
  ans = k;
  for(i = 0; i < n - 1; i++)
  {
    ans *= (k-1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int w,h;
  int i,j;
  
  while(1){
    
    scanf("%d %d",&h,&w);
    
    if(w == 0 && h == 0){      
      break;
    }
    
    for(i = 1;i <= h;i++){
      for(j = 1;j <= w;j++){
	if((i+j) % 2 == 1){
	  printf(".");
	}
	if((i+j) % 2 == 0){
	  printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return(0);
}



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

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

    string ps;
    cout << n - 1 << '\n';
    cin >> ps;

    if (ps == "Vacant")
        return 0;

    string s = ps;
    int hi = n - 1, lo = 0, prev = n - 1, mid;
    while (true) {
        mid = (hi + lo) / 2;
        cout << mid << '\n';
        cin >> s;
        if (s == "Vacant")
            return 0;
        else if (s == ps) {
            // not between prev and mid
            if (abs(mid - prev) % 2 == 0) {
                if (mid > prev)
                    lo = mid + 1;
                else
                    hi = mid - 1;
            }
            // between prev and mid
            else {
                if (mid > prev)
                    hi = mid - 1;
                else
                    lo = mid + 1;
            }
        } else {
            // between prev and mid
            if (abs(mid - prev) % 2 == 0) {
                if (mid > prev)
                    hi = mid - 1;
                else
                    lo = mid + 1;
            }
            // not between prev and mid
            else {
                if (mid > prev)
                    lo = mid + 1;
                else
                    hi = mid - 1;
            }
        }
        ps = s;
        prev = mid;
    }
}


Measured memory_bytes: 852
#include<iostream>
#include<string>
using namespace std;
 
int main(){
	int n;
	string s;
	cin>>n>>s;
	int x=0;
	int res=0;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			res++;
		}
		else{
			res--;
		}
		if(res>x){
			x=res;
		}
	}
	cout<<x<<endl;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
if H == 1 || W == 1
  result = 1
elsif W.even? || H.even?
  result = (H * W)  / 2
else
  result = H * ((W - 1)/ 2)
  result += (H + 1) / 2
end

puts result

Measured memory_bytes: 1788
n=int(input())
h=[]
xy=[[] for i in range(n)]
for i in range(n):
  a=int(input())
  h.append(a)
  xy[i]=[list(map(int,input().split())) for i in range(a)]
ans=0
for i in range(2**n):
  check=[0]*n
  for j in range(n):
    if (i>>j)&1:
      check[j]=1
  for j in range(n):
    if check[j]==1:
      for k in range(h[j]):
        if check[xy[j][k][0]-1]!=xy[j][k][1]:
          break
      else:
        continue
      break
  else:
    ans=max(ans,sum(check))
print(ans)

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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





int main() {
  ll N, M, K;
  cin >> N >> M >> K;

  vector<ll> A(N+1), B(M+1);
  A[0] = 0;
  B[0] = 0;

  for(ll i = 1; i <= N; i++){
    ll Ai;
    cin >> Ai;
    A[i] = Ai + A[i-1];
  }
  for(ll i = 1; i <= M; i++){
    ll Bi;
    cin >> Bi;
    B[i] = Bi + B[i-1];
  }
  
  ll ia = 0;
  for(ll i = 1; i <= N; i++){
    if(A[i] <= K){
      ia = i;
    }else{
      break;
    }
  }
  ll ib = 0;
  for(ll i = 1; i <= M; i++){
    if(A[ia] + B[i] <= K){
      ib = i;
    }else{
      break;
    }
  }

  ll ans = ia + ib;

  for(ll i = ia; i >= 0; i--){
    for(ll j = ib; j <= M; j++){
      if(A[i] + B[j] <= K){
        ans = max(ans, i+j);
      }else{
        ib = j;
        break;
      }
      if(j == M){
        cout << ans << endl;
        return 0;
      }
    }
  }

  cout << ans << endl;


  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 6440
//package  com.company;


import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int n=s.length();
        int sum=0;
        for(int i=0;i<n;++i)sum+=(s.charAt(i)-'0');
        if(sum%9==0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 30948
#include<bits/stdc++.h>
#define ll long long
#define dl cout<<"LINE"<<__LINE__<<endl;
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
char que[999999];
int head=500000,tail=500001;int k=0; 
inline void output() {
	if(!k){
		for(int i=head+1; i<tail; i++)cout<<que[i];
	}
	else{
		for(int i=tail-1; i>head; i--)cout<<que[i];
	}
	cout<<endl; 
}
int main() {
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++) {
		que[tail++]=s[i];
	} 
	int t;
	cin>>t;
	for(int i=1; i<=t; i++) { 
		int a,b;
		char c;
		cin>>a;
		if(a==1) {
			k=!k; 
		} else {
			cin>>b>>c;
			if(b==1) {
				if(!k)que[head--]=c;
				else que[tail++]=c;
			} else {
				if(!k)que[tail++]=c;
				else que[head--]=c;
			}
		}
	}
	output();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    
    ll mn=0, mx=0;
    for(int i=0; i<k; i++) {
        mn += i;
        mx += (n-i);
    }
    
    ll res = 0;
    while(k <= n+1) {
        res = (res + (mx - mn + 1)) % mod;
        mn += k;
        mx += (n-k);
        ++k;
    }
    
    cout << res << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <limits>

int main()
{
    int n;
    std::cin >> n;

    int min;
    std::cin >> min;
    int max = std::numeric_limits<int>::min();
    for (int i = 1; i < n; ++i) {
        int val;
        std::cin >> val;
        int tmp = val - min;
        if (tmp > max) {
            max = tmp;
        }
        if (val < min) {
            min = val;
        }
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 1164
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const H = parseInt(arg[0].split(" ")[0]);
    const W = parseInt(arg[0].split(" ")[1]);
    
    const N = parseInt(arg[1]);
    const A = arg[2].split(" ").map(n=>parseInt(n));
    
    let temp = [];
    
    if(H * W === 1) {
        console.log(1);
        return;
    }
    
    for(let i=1; i<=N; i++) {
        for(let j=0; j<A[i-1]; j++) {
            temp.push(i);
        }
    }

    let answer = [];
    let list = [];
    let currentH = 0;

    for(let i=0; i<temp.length; i++) {
        list.push(temp[i]);
        
        if(i !== 0 && (parseInt(i) + 1) % W === 0) {
            if(currentH % 2 !== 0) list.reverse()

            answer.push(list.join(" "));
            list = [];
            currentH++;
        }
    }
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8384
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var limit = long.Parse(Console.ReadLine());
            Console.WriteLine(Dfs("", limit));
        }

        static int Dfs(string n, long limit)
        {
            if (!string.IsNullOrEmpty(n) && long.Parse(n) > limit) return 0;
            var count = "753".Count(x => n.Contains(x)) == 3 ? 1 : 0;
            count += Dfs(n + '7', limit);
            count += Dfs(n + '5', limit);
            count += Dfs(n + '3', limit);
            return count;
        }
    }
}


Measured memory_bytes: 17360
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int N, ans=0;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++){
    cin >> B[i];
  }  
  vector<int> MaxA(N);
  MaxA[0]=B[0];
  for(int i=0;i<N-2;i++){
    MaxA[i+1] = min(B[i],B[i+1]);
  }
  MaxA[N-1]=B[N-2];
  
  for(int j=0;j<N;j++){
      ans = ans + MaxA[j];
  }  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(string, s);
    int c = count(all(s), '0');
    print(min<i64>(c, s.length() - c) * 2);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
#define PI 3.141592653589793
using namespace std;

int main()
{
    FAST
    string s,t;cin>>s>>t;
    int n=s.length();
    int ans=0;
    f(i,0,n)
    {
        if(s[i]!=t[i]) ans++;

    }
    cout<<ans;
}


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

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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x % 2 == 0)
        {
            if (x % 5 != 0 && x % 3 != 0)
            {
                cout << "DENIED\n";
                exit(0);
            }
        }
    }
    cout << "APPROVED\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int max = 3000001;
	static boolean[] gdosu= new boolean[max];
	static boolean[] gdsosu = new boolean[max];
	public static void main(String[] args) {
		for(int i=0;i<max;i++){
			gdosu[i]=false;
			if(i<=1)continue;
			if(i%7==1||i%7==6){
				gdosu[i]=true;
			}
		}
		for(int i=0;i<max;i++)gdsosu[i]=true;
		for(int i=0;i<max;i++){
			if(!gdosu[i]){
				gdsosu[i]=false;
				continue;//もし月曜土曜数ではなかったらやり直し
			}
			for(int s=i+i;s<max;s+=i){
				gdsosu[s]=false;
			}
		}
		Scanner in = new Scanner(System.in);
		while(true){
			int input = in.nextInt();
			if(input == 1)break;
			System.out.print(input+":");
			for(int i=0;i<=input;i++){
				if(!gdsosu[i])continue;
				if(input%i==0){
					System.out.print(" "+i);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 30484
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

int n,q;
int a[3005],x[3005],y[3005];
int nxt[3005][3005];
int dp[2][2][3005][3005];
int cur[3005];
int p2[3005];

int rec(int i,int l,int r,int z,int k)
{
	if(i>q)
		return (l>r);
	int j;
	int cc=(z?x[i]:y[i]);
	if(cc==l)
		j=r;
	else
		j=l;
	if(dp[k][z][i][j]!=-1)
		return dp[k][z][i][j];
	int nt=min(nxt[l][i],nxt[r][i]);
	int an=(p2[nt-i-1]*1ll*rec(nt,l,r,(x[nt]==l||x[nt]==r),(x[nt]==l||y[nt]==l)))%MOD;
	if(x[i]==l)
		l=y[i];
	else if(y[i]==l)
		l=x[i];
	if(x[i]==r)
		r=y[i];
	else if(y[i]==r)
		r=x[i];
	nt=min(nxt[l][i],nxt[r][i]);
	an=(an+p2[nt-i-1]*1ll*rec(nt,l,r,(x[nt]==l||x[nt]==r),(x[nt]==l||y[nt]==l)))%MOD;
	return dp[k][z][i][j]=an;
}

int main()
{
	SPEED;	
	memset(dp,-1,sizeof dp);
	p2[0]=1;
	for(int i=1;i<=3000;i++)
		p2[i]=(p2[i-1]*2ll)%MOD;
	cin>>n>>q;
	for(int i=1;i<=n;i++)
		cin>>a[i],cur[i]=q+1;
	for(int i=1;i<=q;i++)
		cin>>x[i]>>y[i];
	for(int i=q;i>=0;i--)
	{
		for(int j=1;j<=n;j++)
			nxt[j][i]=cur[j];
		cur[x[i]]=i;
		cur[y[i]]=i;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{	
			int nt=min(nxt[i][0],nxt[j][0]);
			if(a[i]<a[j])
				ans=(ans+p2[nt-1]*1ll*rec(nt,i,j,(x[nt]==j||x[nt]==i),(x[nt]==i||y[nt]==i)))%MOD;
			else if(a[i]>a[j])
				ans=(ans+p2[nt-1]*1ll*rec(nt,j,i,(x[nt]==j||x[nt]==i),(x[nt]==j||y[nt]==j)))%MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 176896
#include <stdio.h>
int main(void)
{
	int l, a, b, c, d, jw, mw;
	scanf("%d", &l);
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	if(a % c == 0){
		jw = a / c;
	}
	else {
		jw = a / c + 1;
	}
	if(b % d == 0){
		mw = b / d;
	}
	else {
		mw = b / d + 1;
	}
	if(jw < mw){
		printf("%d\n", l - mw);
	}
	else {
		printf("%d\n", l - jw);
	}
	return 0;
}

		



Measured memory_bytes: 2140
from collections import defaultdict


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1
    ans = 0
    for k, v in d.items():
        ans += v - k if v >= k else v
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 18676