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

using namespace std;

int cnt[100005];

int main(){
  int n;
  cin >> n;
  int k;
  int ans = 0;
  for(int i = 0;i<n;i++){
    cin >> k;
    if(k>n)ans++;
    else cnt[k]++;
  }
  for(int i = 1;i<=n;i++){
    if(cnt[i]<i)ans+=cnt[i];
    else ans+=cnt[i]-i;
  }
  cout << ans << "\n";
  return 0;
}


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

bool solve(vector<int> a) {
    int n = a.size();
    for (int i = 0; i < n; i++) {
        a[i] %= 4;
        if (a[i] == 3) a[i] = 1;
    }

    vector<int> cnt(3);
    for (int i = 0; i < n; i++) {
        cnt[a[i]]++;
    }

    if (cnt[1] > cnt[0] + 1) return false;
    if (cnt[0] == 0 && cnt[1] > 0) return false;
    if (cnt[2] >= 1 && cnt[1] + 1 > cnt[0] + 1) return false;
    return true;
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);

        string s = solve(a) ? "Yes" : "No";
        printf("%s\n", s.c_str());
    }

    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=500;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	sort(A.begin(),A.end(),greater<int>());
	int a=0,b=0;
	for(int i=0;i<N;i++){
		if(i%2==0)
			a+=A[i];
		else
			b+=A[i];
	}
	cout<<a-b<<endl;
	return 0;
}

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

int main(){
    ll n;
    cin>>n;
    vector<ll> num;
    for (ll i=0; i<n; i++){
        ll p;
        cin>>p;
        num.push_back(p);
    }
    bool ans=true;
    sort(num.begin(),num.end());
    for (ll i=1; i<n; i++){
        if (num[i]==num[i-1]){
            ans=false;
            break;
        }
    }
    if (ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
}

Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N, X;
ll l[60], b[60], p[60];


ll f(ll n, ll x) {
    if(n==0) {
        if(x<=0) return 0;
        else return 1;
    }
    
    if(x<=l[n]/2) {
        return f(n-1, x-1);
    }else {
        return f(n-1, x-2-l[n-1])+p[n-1]+1;
    }
    
    
}


int main(void) {
    cin >> N >> X;
    ll i;
    l[0]=1;
    b[0]=0;
    p[0]=1;
    for(i=1; i<=50; i++) {
        l[i]=2*l[i-1]+3;
        b[i]=2*b[i-1]+2;
        p[i]=2*p[i-1]+1;
    }
    
    
    pr(f(N, X));
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 1; i < 300_000; i++) {
            boolean[] check = new boolean[4];
            int m = i;
            int num = 0;
            while (m > 0) {
                int r = m % 4;
                check[r] = true;
                if (r != 0) num = num * 10 + (2 * r + 1);
                m /= 4;
            }
            if (!check[0] && check[1] && check[2] && check[3] && num <= n) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 30676
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
		}
		Arrays.sort(A);
		if (A[N - M] >= sum / (4 * (double) M)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22996
class Dice:	
	def __init__( self, nums ):
		self.face = nums
	
	def rolltoTopIndex( self, faceindex ):	
		if faceindex == 1:
			self.roll( "N" )
		elif faceindex == 2:
			self.roll( "W" )
		elif faceindex == 3:
			self.roll( "E" )
		elif faceindex == 4:
			self.roll( "S" )
		elif faceindex == 5:
			self.roll( "NN" )
	
	def roll( self, actions ):
		for act in actions:
			t = 0
			if act == "E":
				t =   self.face[0]
				self.face[0] =   self.face[3]
				self.face[3] =   self.face[5]
				self.face[5] =   self.face[2]
				self.face[2] = t
			elif  act == "N":
				t =   self.face[0]
				self.face[0] =   self.face[1]
				self.face[1] =   self.face[5]
				self.face[5] =   self.face[4]
				self.face[4] = t
			elif  act == "S":
				t =  self.face[ 0]
				self.face[0] =  self.face[4]
				self.face[4] =  self.face[5]
				self.face[5] =  self.face[1]
				self.face[1] = t	
			elif  act == "W":
				t =  self.face[0]
				self.face[0] =  self.face[2]
				self.face[2] =  self.face[5]
				self.face[5] =  self.face[3]
				self.face[3] = t	
			elif  act == "M":
				t =  self.face[1]
				self.face[1] =  self.face[2]
				self.face[2] =  self.face[4]
				self.face[4] =  self.face[3]
				self.face[3] = t

def isDiffDice( dice1, dice2 ):
	diceface = dice2.face
	cnt = 0
	for i in range( 6 ):
		if dice1.face[0] == dice2.face[i]:
			dice2.rolltoTopIndex( i )
			for j in range( 1, 5 ):
				if dice1.face[1] == dice2.face[1]:
					cnt = 0
					for k in range( 6 ):
						if dice1.face[k] == dice2.face[k]:
							cnt += 1
					if cnt == 6:
						break
				dice2.roll( "M" )
		if cnt == 6:
			break
		dice2.face = diceface
			
	if cnt == 6:
		return False
	else:
		return True


n = int( raw_input( ) )
dices = [ Dice( [ int( val ) for val in raw_input( ).split( " " ) ] ) for i in range( n ) ]

isdiff = True
for i in range( 0, n-1 ):
	for j in range( i+1, n ):
		if not isDiffDice( dices[i], dices[j] ):
			print( "No" )
			isdiff = False
			break
	if not isdiff:
		break

if isdiff:
	print( "Yes" )

Measured memory_bytes: 4416
#include <stdio.h>
#include <string.h>
int main(){
int n;
scanf("%d",&n);
char chara[n];
scanf("%s",chara);
int len=strlen(chara);
if(len%2){
	printf("No");
	return 0;
}
else{
	for (int i=0;i<len/2;i++){
		if(chara[i]!=chara[i+(len/2)]){
			printf("No");
			return 0;
		}
		else{
			continue;
		}
	}
}
printf("Yes");
return 0;
}

Measured memory_bytes: 1732
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=1,length(a);while l<=r;m=l+div(r-l,2);if a[m]<x;l=m+1;else;r=m-1;end;end;return(l-1);end

function main()
	n,a,b = readline() |> split |> parseMap
	h = Array{Int}(n)
	for i in 1:n
		h[i] = readline() |> parseInt
	end
	h = sort(h)
	l = 1
	r = cld(h[n],b)
	while l<=r
		m = l+div(r-l,2)
		k = 0
		s = bsearch(h,m*b)
		for i in s+1:n
			k += cld(h[i]-m*b,a-b)
		end
		if m<k
			l = m+1
		else
			r=m-1
		end
	end
	println(l)
end

main()

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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = double.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(double.Parse).ToArray();

            var m = a.Sum() / n;
            var distance = 1000.0;
            var minFrame = 0;

            for(int i = 0; i < n; i++)
            {
                if(Math.Abs(a[i] - m) < distance)
                {
                    distance = Math.Abs(a[i] - m);
                    minFrame = i;
                }
            }
            Console.WriteLine(minFrame);
        }
    }
}


Measured memory_bytes: 28324
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int a, b;
	cin >> a >> b;
	cout << max(0, a-2*b) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
  
    
    for (int i = 0; i*4 <= N; i++) {
        if((N-i*4)%7==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
     
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  ll ans = 0;
  vb done(n, false);
  rep(i, n) {
    if(i >= k && t[i - k] == t[i] && done[i - k]) continue;
    if(t[i] == 'r')
      ans += p;
    else if(t[i] == 's')
      ans += r;
    else
      ans += s;
    done[i] = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
N,M,X,Y = map(int,input().split())
ans = 0
x = list(map(int,input().split()))
y = list(map(int,input().split()))
for i in range(X+1,Y):
  k = i
  if i>max(x):
    if i<=min(y):
      ans += 1
      break
if ans == 1:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<VI>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

void update(vector<int> &v, int x, int h)
{
    v.clear();
    v.push_back(0);
    int idx = 1;
    while (x)
    {
        if ((x & 1) != 0)
        {
            v.push_back(idx);
        }
        x >>= 1;
        ++idx;
    }
    v.push_back(h);
}

int main()
{
    // IOS;
    int h, w, k;
    cin >> h >> w >> k;
    VVI sum(h + 1, VI(w + 1, 0));
    FOR(i, 1, h + 1)
    {
        string s;
        cin >> s;
        FOR(j, 1, w + 1)
        {
            sum[i][j] = (int)(s[j - 1] - '0');
            sum[i][j] =
                sum[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
        }
    }
    int ans = h * w;
    vector<int> hs;
    FOR(state, 0, (1 << (h - 1)))
    {
        int cur = __builtin_popcount(state);
        bool ok = true;
        int j2 = 0;
        update(hs, state, h);
        FOR(j, 1, w + 1)
        {
            int wmax = 0;
            FOR(i, 1, hs.size())
            {
                wmax = max(wmax, sum[hs[i]][j] - sum[hs[i]][j2] -
                                     sum[hs[i - 1]][j] + sum[hs[i - 1]][j2]);
            }
            // cout << j << ' ' << wmax << '\n';
            if (wmax > k)
            {
                if (j == 1)
                {
                    ok = false;
                    break;
                }
                ++cur;
                j2 = j - 1;
            }
        }
        if (ok)
        {
            // cout << state << ' ' << cur << '\n';
            ans = min(ans, cur);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int n, k; cin >> n >> k;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	int time = 1, cur = 1;
	unordered_map<int, int> vis;
	int st = 0, ed = 0;
	while (!(vis.count(cur))) {
		vis[cur] = time++;
		cur = a[cur];
	}
	ed = time; st = vis[cur];
	if (k <= st - 1) {
		int ans = 1;
		while (k > 0) {
			ans = a[ans];
			k--;
		}
		cout << ans << endl;
	}
	else {
		k -= (st - 1);
		k %= (ed - st);
		int ans = cur;
		while (k > 0) {
			ans = a[ans];
			k--;
		}
		cout << ans << endl;
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 12936
import itertools
n = int(input())
p = [int(i)-1 for i in input().split()]
q = [int(i)-1 for i in input().split()]
m = sorted(p)
a = 0
b = 0
cnt = 1
for i in itertools.permutations(m,n):
  if list(i) == p:
    a += cnt
  if list(i) == q:
    b += cnt
  if a!=0 and b!=0:
    break
  else:
    cnt += 1
print(abs(a-b))

Measured memory_bytes: 73620
from sys import exit

N, M = map(int, input().split())
lst = [None] * N
for _ in range(M):
    s, c = map(int, input().split())
    if lst[s - 1] != c and lst[s - 1] is not None:
        print(-1)
        exit()
    else:
        lst[s - 1] = c
if lst[0] is None:
    if N == 1:
        lst[0] = 0
    else:
        lst[0] = 1
elif lst[0] == 0 and N != 1:
    print(-1)
    exit()

lst = [0 if i is None else i for i in lst]
print(''.join(map(str, lst)))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 

int main()
{
    int cnt[26]={0};
    string s;
    cin >> s;

    cnt[s[0]-'A']++;
    cnt[s[1]-'A']++;
    cnt[s[2]-'A']++;
    cnt[s[3]-'A']++;

    int ans = 0;

    for(int i=0;i<26;i++)
    {
        if(cnt[i] == 2) ans++;
    }

    if(ans == 2) cout << "Yes\n";
    else cout << "No\n";
}




Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
class modint{
public:
  long long x;
  constexpr modint(long long x=0):x((x%MOD+MOD)%MOD){}
  constexpr modint operator-() const{return modint(-x);}
  constexpr modint& operator+=(const modint& a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator-=(const modint& a){
    if((x+=MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator*=(const modint& a){
    (x*=a.x)%=MOD;
    return *this;
  }
  constexpr modint operator+(const modint& a) const{return modint(*this)+=a;}
  constexpr modint operator-(const modint& a) const{return modint(*this)-=a;}
  constexpr modint operator*(const modint& a) const{return modint(*this)*=a;}
  constexpr bool operator==(const modint& a) const{return this->x==a.x;}
  constexpr bool operator!=(const modint& a) const{return this->x!=a.x;}
  constexpr modint pow(long long expo) const{
    if(expo==0)  return 1;
    modint a=pow(expo>>1);
    a*=a;
    if(expo&1)  a*=(*this);
    return a;
  }
  //for prime MOD
  constexpr modint inv() const{return pow(MOD-2);}
  constexpr modint& operator/=(const modint& a){return (*this)*=a.inv();}
  constexpr modint operator/(const modint& a) const{return modint(*this)/=a;}
};
istream& operator>>(istream& is,const modint& a){return is >> a.x;}
ostream& operator<<(ostream& os,const modint& a){return os << a.x;}

//for binomial coefficients
const int MAX=2200000;
vector<modint> fac(MAX,0);
vector<modint> finv(MAX,0);
vector<modint> inv(MAX,0);
void COMinit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(int i=2;i<MAX;i++){
    fac.at(i)=fac.at(i-1)*i;
    inv.at(i)=-inv.at(MOD%i)*(MOD/i);
    finv.at(i)=finv.at(i-1)*inv.at(i);
  }
}
modint COM(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0)  return 0;
  return fac.at(n)*finv.at(k)*finv.at(n-k);
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int K;
  string S;
  cin >> K >> S;

  COMinit();

  int N=sz(S);
  modint ans=0;
  for(int i=0;i<=K;i++){
    modint tmp=COM(N-1+K-i,N-1)*((modint)25).pow(K-i)*((modint)26).pow(i);
    ans+=tmp;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 55832
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  vector<long> list;
  long N, K;
  cin >> N >> K;
  if (N < K) {
    cout << "0";
    return 0;
  }
  for (int index = 0; index < N; index++) {
    long H = 0;
    cin >> H;
    list.push_back(H);
  }
  sort(list.begin(), list.end(), greater<int>());
  long all = 0;
  for (int index = K; index < N; index++) {
    all += list[index];
  }
  cout << all;
}

Measured memory_bytes: 2420
from collections import deque
while 1:
    n, k, s = map(int, raw_input().split())
    if n==0:break
    ps = [map(int, raw_input().split()) for i in xrange(n)]

    G = [[] for i in xrange(n)]
    for i in xrange(n):
        xi, yi, zi = ps[i]
        for j in xrange(i+1, n):
            if i==j: continue
            xj, yj, zj = ps[j]

            dx = abs(xi-xj)
            dy = abs(yi-yj)
            dz = abs(zi-zj)

            if dx < s and dy < s and dz < s:
                cost = 2*((s-dx)*(s-dy)+(s-dy)*(s-dz)+(s-dz)*(s-dx))
                G[i].append((j, cost))
                G[j].append((i, cost))
    if k == 1:
        print 6*s*s
        continue

    ans = -1
    leaf = set()
    used = [0]*n
    for i in xrange(n):
        if len(G[i]) == 0:
            used[i] = 1
        elif len(G[i]) == 1:
            leaf.add(i)
    for v in leaf:
        if used[v]:
            continue
        used[v] = 1
        prev = t = None
        deq = deque()
        su = 0
        while 1:
            if prev is not None and len(G[v]) == 1:
                break
            for t, cost in G[v]:
                if t == prev:
                    continue
                used[t] = 1
                if len(deq) < k-1:
                    deq.append(cost)
                    su += cost
                else:
                    su -= deq.popleft()
                    deq.append(cost)
                    su += cost
                break
            if len(deq) == k-1:
                ans = max(ans, su)
            v, prev = t, v
    for v in xrange(n):
        if used[v]:
            continue
        prev = t = None
        used[v] = 1
        u = set([v])
        while v is not None and used[v] < 3:
            for t, cost in G[v]:
                if t == prev:
                    continue
                used[t] += 1
                u.add(t)
                break
            v, prev = t, v
        cont = k if len(u) == k else k-1
        prev = t = None
        deq = deque(); su = 0
        for i in xrange(2*len(u)):
            for t, cost in G[v]:
                if t == prev:
                    continue
                if len(deq) < cont:
                    deq.append(cost)
                    su += cost
                else:
                    su -= deq.popleft()
                    su += cost
                    deq.append(cost)
                break
            if len(deq) == cont:
                ans = max(ans, su)
            v, prev = t, v

    if ans == -1:
        print -1
    else:
        print 6*k*s*s - ans

Measured memory_bytes: 7036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main()
{
    int N, L;
    std::cin >> N >> L;

    std::vector<std::string> S(N);
    for (auto& s : S) {
        std::cin >> s;
    }

    std::sort(std::begin(S), std::end(S));

    for (const auto& s : S) {
        std::cout << s;
    }
    std::cout << '\n';
}

Measured memory_bytes: 3616
#include "stdio.h"

int team_score[100];
int N;

int main(){
  scanf("%d",&N);
  
  for(int i=1;i<=N*(N-1)/2;i++){
    int A_i,B_i,C_i,D_i;
    scanf("%d%d%d%d",&A_i,&B_i,&C_i,&D_i);
    if (C_i>D_i)
      team_score[A_i-1]+=3;
    else if (C_i<D_i)
      team_score[B_i-1]+=3;
    else{
      team_score[A_i-1]++;
      team_score[B_i-1]++;
    }
  }
  
  for(int i=0;i<N;i++){
    int score=team_score[i];
    int rank=1;
    for (int j=0;j<N;j++)
      if(team_score[j]>score)
	rank++;

    printf("%d\n",rank);
  }

  
  return 0;
}



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

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;



int main(void) {
   ll N;
   cin>>N;
   vector<ll> s(N);
   rep(i,0,N) cin>>s[i];

   ll ans = 0;
   rep(C,1,N-1) {
      ll cad = 0;
      rep(n,0,(int)(N-1)/C) {
         ll A = N-1 - C*n;
         cad += s[A] + s[C*n];
         if (A <= C*n && A%C == 0) continue;
         chmax(ans,cad);
      }
   }
   cout<<ans<<endl;




   return 0;
}

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

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

const Int INF = 1e15;
const Int MAX = 303;
Int p[MAX][MAX];
Int sm[MAX][MAX];

Int query(Int u,Int d,Int j){
  return sm[d+1][j]-sm[u][j]; 
}

signed main(){
  Int n;
  cin>>n;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      cin>>p[i][j];

  Int ans=-INF;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      chmax(ans,p[i][j]);

  // 1 * w, 2 * w
  for(Int i=0;i<n;i++){
    for(Int l=0;l<n;l++){
      Int sum=0,sum2=0;
      for(Int r=l;r<n;r++){
        sum+=p[i][r];
        if(i+1<n) sum2+=p[i+1][r];
        chmax(ans,sum);
        chmax(ans,sum+sum2);
      }
    }    
  }

  // h * 1, h * 2
  for(Int j=0;j<n;j++){
    for(Int u=0;u<n;u++){
      Int sum=0,sum2=0;
      for(Int d=u;d<n;d++){
        sum+=p[d][j];
        if(j+1<n) sum2+=p[d][j+1];
        chmax(ans,sum);
        chmax(ans,sum+sum2);
      }
    }
  }

  memset(sm,0,sizeof(sm));
  for(Int j=0;j<n;j++)
    for(Int i=0;i<n;i++)
      sm[i+1][j]=sm[i][j]+p[i][j];
  
  // larger than 3 * 3
  for(Int u=0;u<n;u++){
    for(Int d=u+2;d<n;d++){
      Int sum=query(u,d,n-1);
      for(Int j=n-3;j>=0;j--){
        chmax(sum,query(u,d,j+2));
        sum+=p[u][j+1]+p[d][j+1];	
        chmax(ans,query(u,d,j)+sum);
      }
    }
  }
    
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4524
#pragma GCC optimize(2) 
#include<bits/stdc++.h>
using namespace std;
char s[1000001];
char t;
int	ans;
int a[1000001];
bool check(int x)
{
	int n=strlen(s+1),kum=0;
	for(int i=1;i<=n;i++) a[i]=(s[i]-'0')*9;
	a[1]+=9*x;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>9)
		{
			if(i==n) a[++n]=0;
			a[i+1]+=a[i]/10;
			a[i]%=10;
		}
	}
	for(int i=1;i<=n;i++) kum+=a[i];
	return kum<=x*9;
}
int main()
{
	scanf("%s",s+1); 
	int l=1,r=strlen(s+1);
	reverse(s+1,s+r+1);
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)==1)
			ans=mid,r=mid-1;
		else
			l=mid+1;
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 4608
import java.util.*;
import java .io.*;
public class Main {
    static int size;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int array[] = new int[n + 1];
        st = new StringTokenizer(br.readLine());
        for (int i = 1; i <= n; i++) {
            array[i] = Integer.parseInt(st.nextToken());
        }
        st = new StringTokenizer(br.readLine());
        int cnt[] = new int[n + 2];
        for(int i = 1;i <= n;i++){
            cnt[i] = Integer.parseInt(st.nextToken());
        }
        boolean mark[] = new boolean[n + 1];
        for(int i = 1;i <= n;i++)
            if(array[i] > array[i - 1])mark[i] = true;

        for(int i = n;i >= 1;i--) {
            //System.out.println(i + " " + mark[i] + " " + cnt[i] + " " + array[i]);
            if(mark[i]){
                if(cnt[i] < array[i]){
                    System.out.print("0");
                    return;
                }
            }
            if (cnt[i] > cnt[i + 1]) {
                //System.out.println("1");
                mark[i] = true;
                if(array[i] < cnt[i]){
                    System.out.print("0");
                    return;
                }
            }
        }
        long ans = 1;
        int mod = 1000_000_000 + 7;
        for(int i = 1;i <= n;i++){
            if(mark[i])continue;
            ans *= Math.min(cnt[i],array[i]);
            ans %= mod;
        }
        System.out.print(ans);
    }
    }


Measured memory_bytes: 31456
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;

int main(){
  ll n,k,ans=0;cin>>n>>k;
  rep(i,k+1,n+1){//b
    ll tmp1=n/i,tmp2=n%i;
    ans+=(i-k)*tmp1;
    if(tmp2>=k){
      ans+=tmp2-k+1;
    }
    if(k==0){ans--;}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<chrono>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
#define sz(x) (int(x.size()))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef vector<string> vs;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int res = 0;
	for(int k = 1; k <= n; k ++){
		int cnt = 0, e = 1;
		while(e <= k){
			e *= 10;
			cnt ++;
		}
		if(cnt & 1){
			res ++;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = S()

hon = {2,4,5,7,9}
pon = {0,1,6,8}

if int(N[-1]) in hon:
  print("hon")
elif int(N[-1]) in pon:
  print("pon")
else:
  print("bon")
  


Measured memory_bytes: 27212
n, c, k = map(int, input().split())
T = sorted([int(input()) for i in range(n)])
ans = 0
last = 0
jokyaku = 0
for t in T:
    jokyaku += 1
    if jokyaku == c or t > last:
        jokyaku = 0
        last = t + k
        ans += 1
print(ans)

Measured memory_bytes: 8280
#include <stdio.h>

#define A 0
#define B 1
#define C 2
#define D 3
#define X 0
#define Y 1


int main()
{
	double xy[4][2];
	int n,
		i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf"
		,&xy[A][X],&xy[A][Y] , &xy[B][X],&xy[B][Y] , &xy[C][X],&xy[C][Y],&xy[D][X],&xy[D][Y]);
		
		if( (xy[B][Y]-xy[A][Y])/(xy[B][X]-xy[A][X]) == (xy[D][Y]-xy[C][Y])/(xy[D][X]-xy[C][X]) ){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

struct circ {
        ll x, y, r;
} p[1100];

long double dis (circ a, circ b) {
        ll d = (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
        if (d <= (a.r+b.r)*(a.r+b.r)) return 0.0;
        long double x = sqrt((long double) d);
        return x - ((long double) a.r+b.r);
}

int N;
bool seen[1100];
long double res[1100];

int main () {
        scanf("%lld %lld %lld %lld %d", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &N);
        p[0].r=p[1].r=0ll;
        fo(i, 2, N+2) scanf("%lld %lld %lld", &p[i].x, &p[i].y, &p[i].r);

        fo(i, 1, N+2) res[i] = 8e18;
        fo(i, 0, N+2) {
                int mni = -1; fo(j, 0, N+2) if (!seen[j] && (mni==-1 || res[j]<res[mni])) mni = j;
                seen[mni] = 1;
                fo(j, 0, N+2) res[j] = min(res[j], res[mni] + dis(p[mni], p[j]));
        }
        printf("%.10Lf\n", res[1]);
        return 0;
}


Measured memory_bytes: 256
#include <unistd.h>
#include <cstdint>
#include <algorithm>
#include <vector>
using namespace std;

using i64 = long long;

#define REP(i, n) for (int i = 0, i##_len = n; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)

namespace io {
  using i64 = std::int64_t;
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
      if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
      return *ip++;
  }
  inline i64 scan() {
      i64 r = 0;
      if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
      else while ((it = *ip++) & 16) r = r * 10 + it - '0';
      return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
      *op++ = c;
      if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  // x shoud be greater than or equal to zero
  inline void print(i64 x) {
      char d[20];
      int i = 0;
      while (true) {
          d[i] = x % 10 + 48;
          x /= 10;
          ++i;
          if (x <= 0) break;
      }
      while (i--) {
          putc(d[i]);
      }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  i64 n = io::scan();
  i64 k = io::scan();
  i64 r = io::scan();
  i64 s = io::scan();
  i64 p = io::scan();
  char *t = io::ip;
  i64 ans = 0;
  REP(i, n) {
    if (i >= k && t[i] == t[i - k]) t[i] = 0;
    ans += t[i] == 'r' ? p
         : t[i] == 's' ? r
         : t[i] == 'p' ? s
         : 0;
  }
  io::print(ans);
  io::flush();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,ll> P;

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

int main(void){
    ll a,b;
    cin>>a>>b;
    ll g=gcd(a,b);
    ll x=a/g;
    ll y=b/g;
    cout<<g*x*y<<endl;
    return 0;
}

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

using namespace std;
#define endl "\n"
#define FILEIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
typedef vector<LL> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<LL ,LL > mii;
//typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second





vi vect_2pow;
void pow_of_2(){
    vect_2pow.assign(32,0);
      for(int i=0;i<=32;i++){
           LL y = 1<<i;
           vect_2pow[i]=y;
      }
}
bool Ispalindrome(string str){
        LL len = str.size();
		bool flag;
		for(int i=0;i<len/2;i++){
				if(str[i]==str[len-i-1])
				     {
						 flag=0;
						 continue;
					 }
					 else 
					    {
							flag=1;
							break;
						}
			}
		if (flag==1)
		  return false;
		else return true;  
		
}
vector<LL> prime_check;
mii get_high_prime;
int high_prime_factor(){
	//cout<<"ecd";
	LL max_prime=0;
	for(int i=2;i<100000;i++)
	{
		LL n=i;
		
		while(n%2==0)
		{
			max_prime=2;
			n>>=1;
		}
		for(int j=3;j<=sqrt(n);j++)
		{
			while(n%j==0){
				max_prime=j;
				n/=j;
			}
		}
		if(n>2)
		  max_prime=n;
		  
		//prime_check.pb(max_prime);
		get_high_prime[i]=max_prime;
	}
	
			
}

const LL inf = 10e+9;

int main()
{
   fast;
   LL n;
   cin>>n;
   vi vect(n);
   for(LL &x:vect)
        cin>>x;

   vector<LL> dp(n,inf);
   dp[0]=0;
   for(LL i=0;i<n;i++)
   {
	   for(LL j:{i+1,i+2}){
		   if(j<n)
		   {
			   dp[j]=min(dp[j],dp[i]+abs(vect[i]-vect[j]));
		   }
            // cout<<j<<endl;
	   }
   }
   cout<<dp[n-1];


}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll C;
ll x[100100];
ll v[100100];

ll sum[2][100100];
ll best[2][100100];

ll solve() {
    ll res = 0;
    ll val = 0;
    ll best0 = -1e18;
    for (int i = 1; i <= n; i++) {
        val += v[i];
        val -= (x[i] - x[i-1]);
        sum[0][i] = val;
        best0 = max(best0, val);
        res = max(res, val);
    }
    val = 0;
    ll best1 = -1e18;
    for (int i = n; i >= 1; i--) {
        val += v[i];
        val -= (x[i+1] - x[i]);
        sum[1][i] = val;
        best1 = max(best1, val);
        res = max(res, val);
    }

    for (int i = 1; i <= n; i++) {
        if (best[0][i-1] < sum[0][i]) {
            best[0][i] = sum[0][i];
        } else {
            best[0][i] = best[0][i-1];
        }
    }
    for (int i = n; i >= 1; i--) {
        if (best[1][i+1] < sum[1][i]) {
            best[1][i] = sum[1][i];
        } else {
            best[1][i] = best[1][i+1];
        }
    }
    
    for (int i = 1; i <= n; i++) {
        res = max(res, sum[0][i] - x[i] + best[1][i+1]);
    }
    for (int i = n; i >= 1; i--) {
        res = max(res, sum[1][i] - (C-x[i]) + best[0][i-1]);
    }
    return res;
}

void input() {
    cin >> n >> C;
    x[0] = v[0] = 0;
    for (int i = 0; i < n; i++) cin >> x[i+1] >> v[i+1];
    x[n+1] = C;
    v[n+1] = 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 4992
n, m, l = gets.split.map(&:to_i)

a = []
i = 0

for i in 0..(n-1)
    a[i] = gets.split.map(&:to_i)
end

b = []
j = 0

for j in 0..(m-1)
    b[j] = gets.split.map(&:to_i)
end

ans = Array.new(n)

ans.each_with_index do |n, i|
    ans[i] = Array.new(l, 0)
end

b.each_with_index do | k , i_1|
    k.each_with_index do | v, i_2|
        for c in 0..(n-1)
           ans[c][i_2]  += a[c][i_1] * v
        end
    end 
end

ans.each do |n|
    str = ""
    n. each do |l|
        str << "#{l} "
    end
    puts str.strip
end


Measured memory_bytes: 7304
import java.util.*;

public class Main {
	static int N;
	static long A, B;
	static long[] S;
	static BinaryIndexedTree bitA;
	static BinaryIndexedTree bitB;
	static final long MOD = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextLong();
		B = sc.nextLong();
		S = new long[N];
		bitA = new BinaryIndexedTree(N);
		bitB = new BinaryIndexedTree(N);
		Stack<Query> stackA = new Stack<>();
		Stack<Query> stackB = new Stack<>();
		for (int i = 0; i < N; ++i) {
			S[i] = sc.nextLong();
		}
		Arrays.sort(S);

		bitA.addVal(0 + 1, 1);
		bitB.addVal(0 + 1, 1);
		stackA.push(new Query(0 + 1, 1));
		stackB.push(new Query(0 + 1, 1));
		int leftA = -1;
		int leftB = -1;
		for (int i = 0; i + 1 < N; ++i) {
			long sA = 0;
			long sB = 0;
			while (S[i + 1] - S[leftA + 1] >= A)
				++leftA;
			while (S[i + 1] - S[leftB + 1] >= B)
				++leftB;
			sB = bitA.getVal((leftB + 1) + 1);
			sA = bitB.getVal((leftA + 1) + 1);
			if (S[i + 1] - S[i] < A) {
				while (!stackA.isEmpty()) {
					Query q = stackA.pop();
					bitA.addVal(q.pos, -q.val);
				}
			}
			if (S[i + 1] - S[i] < B) {
				while (!stackB.isEmpty()) {
					Query q = stackB.pop();
					bitB.addVal(q.pos, -q.val);
				}
			}
			bitA.addVal((i + 1) + 1, sA);
			bitB.addVal((i + 1) + 1, sB);
			stackA.add(new Query((i + 1) + 1, sA));
			stackB.add(new Query((i + 1) + 1, sB));
		}
		System.out.println((bitA.getVal(N) + bitB.getVal(N)) % MOD);
	}

	static class BinaryIndexedTree {
		int n;
		long[] val;

		public BinaryIndexedTree(int n) {
			this.n = n;
			val = new long[n + 1];
		}

		void addVal(int k, long v) {
			while (k <= n) {
				val[k] += v;
				val[k] = (val[k] + MOD) % MOD;
				k += k & -k;
			}
		}

		long getVal(int k) {
			long s = 0;
			while (k > 0) {
				s += val[k];
				s = (s + MOD) % MOD;
				k -= k & -k;
			}
			return s;
		}

		void clear() {
			val = new long[n + 1];
		}
	}

	static class Query {
		int pos;
		long val;

		public Query(int pos, long val) {
			this.pos = pos;
			this.val = val;
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 52072
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

L, R, d = LI()

ans = R // d - (L - 1) // d
print(ans)

Measured memory_bytes: 10840
n,m=map(int,input().split())

hoge=[]
hoge.append(["."]*(m+2))
for i in range(n):
  hoge.append(["."]+list(input())+["."])
hoge.append(["."]*(m+2))

for i in range(n):
  for j in range(m):
    a=i+1
    b=j+1
    if(hoge[a][b]=="#"):
      print("#",end="")
    else:
      ans=0
      if(hoge[a-1][b-1]=="#"):
        ans+=1
      if(hoge[a-1][b]=="#"):
        ans+=1
      if(hoge[a-1][b+1]=="#"):
        ans+=1
      if(hoge[a][b-1]=="#"):
        ans+=1
      if(hoge[a][b+1]=="#"):
        ans+=1
      if(hoge[a+1][b-1]=="#"):
        ans+=1
      if(hoge[a+1][b]=="#"):
        ans+=1
      if(hoge[a+1][b+1]=="#"):
        ans+=1
      print(ans,end="")
  print("")

Measured memory_bytes: 3572
n = int(input())
ls = [input() for _ in range(n)]

nac = 0
nwa = 0
ntle = 0
nre = 0

for s in ls:
    if s == "AC":
        nac += 1
    elif s == "WA":
        nwa += 1
    elif s == "TLE":
        ntle += 1
    else:
        nre += 1

print(f"AC x {nac}\n\
WA x {nwa}\n\
TLE x {ntle}\n\
RE x {nre}")


Measured memory_bytes: 16184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str="";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}

int main() {
	int n, k; cin >> n >> k;
	int sum = 0, num = 1;

	for (int i = 0; i < n; i++) {
		//sum += min(num * 2, num + k);
		num = min(num * 2, num + k);;
		//cout << num << endl;
	}
	cout << num;

	cout << endl;
	return 0;
}

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

int main(void) {

    char str[1000];

    fgets(str,sizeof(str),stdin);

    sscanf(str,"%s",str);

    if (strcmp(str, "ABC") == 0) {

        printf("%s\n","ARC");

    }
    else
    {
        printf("%s\n", "ABC");
    }

    return 0;
}

Measured memory_bytes: 1708
#include <cstdio>
#include <stack>
#include <set>
using namespace std;

const int MAXN = 100005;

int N, M, Q;
int a[MAXN];
stack <int> occ[MAXN], pos[MAXN];
set <int> S;

void load() {
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 0; i < Q; i++)
		scanf("%d", a + i);
}

bool solve() {
	for (int i = 0; i < Q; i++)
		occ[a[i]].push(i);
	
	for (int i = 1; i <= M; i++)
		S.insert(i);
	
	for (int i = 0; i < N; i++)
		pos[i].push(Q);
	
	bool ok = true;
	for (int i = Q - 1; i >= 0; i--) {
		if (!S.count(a[i])) continue;
		for (int j = 0; j < N; j++) {
			while (!occ[a[i]].empty() && occ[a[i]].top() >= pos[j].top())
				occ[a[i]].pop();
			if (occ[a[i]].empty()) {
				ok = false;
				break;
			}
			pos[j].push(occ[a[i]].top());
			occ[a[i]].pop();
		}
		if (!ok && a[i] != *S.begin()) 
			return false;
		S.erase(a[i]);
	}
	
	return true;
}

int main() {
	load();
	puts(solve() ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 140160
MOD = int(1e9+7)

N = int(input())
S1 = input()
S2 = input()

pattern = []

i = 0
while i < N:
    if i != N-1 and S1[i] == S1[i+1]:
        pattern.append(2)
        i += 2
    else:
        pattern.append(1)
        i += 1

if pattern[0] == 1:
    ans = 3
else:
    ans = 6

for i in range(1, len(pattern)):
    if pattern[i] == 1:
        if pattern[i-1] == 1:
            ans = ans * 2
        else:
            ans *= 1
    else:
        if pattern[i-1] == 1:
            ans *= 2
        else:
            ans *= 3
    ans %= MOD

print(ans)



Measured memory_bytes: 3064
import Glibc
extension String: CollectionType {}

//var inp = readLine()!.split(" ").map { Int($0)! }
var n = readLine()!.characters.map { String($0) }
if n[0] == n[1] || n[1] == n[2] || n[2] == n[0] {
  print("No")
} else {
  print("Yes")
}

Measured memory_bytes: 768