akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	
	int j=1, cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]==j){
			j++;
			cnt++;
		}
	}
	if(cnt==0) cout<<-1<<endl;
	else
		cout<<n-cnt<<endl;
		
	return 0;
} 

Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
k = inp()
now = 1
for i in range(n):
    now = min(now+k, now*2)
print(now)

Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int main() {
	int N, M, C, A[20][20], B[20], res = 0;
	cin >> N >> M >> C;
	for (int i = 0; i < M; ++i)
		cin >> B[i];
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < M; ++j)
			cin >> A[i][j];
	for (int i = 0; i < N; ++i){
		long long sum = 0;
		for (int j = 0; j < M; ++j)
			sum += A[i][j] * B[j];
		if (sum > -C)
			++res;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)

x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
import heapq
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

def readlines(n):
    for _ in range(n):
        b, c = map(int, input().split())
        yield b, c

def main():
    _, M = map(int, input().split())
    A = list(map(int, input().split()))
    total = sum(A)
    heapq.heapify(A)

    for b, c in sorted(readlines(M), key=itemgetter(1), reverse=True):
        for _ in range(b):
            o = heapq.heappushpop(A, c)
            if o < c:
                total += c - o
            else:
                break
            
    print(total)

main()

Measured memory_bytes: 22844
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000010

char S[SIZE];
vector<pair<int, int>> pos, neg;

int main() {
  int N;

  scanf("%d", &N);

  int sum = 0;

  for (int i = 0; i < N; i++) {
    scanf("%s", S);
    int M = strlen(S);

    int counter = 0, minC = 0;

    for (int j = 0; j < M; j++) {
      if (S[j] == '(')
        counter++;
      else
        counter--;
      minC = min(minC, counter);
    }
    sum += counter;

    if (counter >= 0)
      pos.push_back({minC, counter});
    else
      neg.push_back({minC, counter});
  }

  sort(pos.begin(), pos.end(), greater<pair<int, int>>());
  sort(neg.begin(), neg.end(), [](auto a, auto b) {
    return a.first - a.second < b.first - b.second;
  });

  if (sum != 0) {
    puts("No");
    return 0;
  }

  int now = 0;

  pos.insert(pos.end(), neg.begin(), neg.end());

  for (auto p : pos) {
    if (now + p.first < 0) {
      puts("No");
      return 0;
    }
    now += p.second;

    debug(p);
  }

  puts("Yes");

  return 0;
}

Measured memory_bytes: 18844
n=input()
a=int(n[0])
b=int(n[1])
c=int(n[2])
d=int(n[3])

if a+b+c+d==7:
    print("%d+%d+%d+%d=7"%(a,b,c,d))
elif a+b+c-d==7:
    print("%d+%d+%d-%d=7"%(a,b,c,d))
elif a+b-c+d==7:
    print("%d+%d-%d+%d=7"%(a,b,c,d))
elif a+b-c-d==7:
    print("%d+%d-%d-%d=7"%(a,b,c,d))
elif a-b+c+d==7:
    print("%d-%d+%d+%d=7"%(a,b,c,d))
elif a-b+c-d==7:
    print("%d-%d+%d-%d=7"%(a,b,c,d))
elif a-b-c+d==7:
    print("%d-%d-%d+%d=7"%(a,b,c,d))
else:
    print("%d-%d-%d-%d=7"%(a,b,c,d))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n;i>s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll t[100001];
ll a[100001];
ll maxV[100001];
ll minV[100001];
bool ok[100001];

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

	repe(i, 1, n) cin >> t[i];
	repe(i, 1, n) cin >> a[i];

	if (t[n] != a[1]) {
		cout << 0 << endl;
		return 0;
	}
	//t
	repe(i, 1, n) {
		ll T = t[i];
		if (t[i - 1] < t[i]) {
			maxV[i] = T;
			ok[i] = true;
		}
		else {
			maxV[i] = T;
		}
	}

	//a
	rep_r(i, 0, n) {
		ll A = a[i];

		if (a[i] > a[i + 1]) {
			if (ok[i]) {
				if (A != maxV[i]) {
					cout << 0 << endl;
					return 0;
				}
				else {
					continue;
				}
			}
			ok[i] = true;
			maxV[i] = A;
		}
		else {
			if (ok[i]) {
				if (maxV[i] > A) {
					cout << 0 << endl;
					return 0;
				}
				else {
					continue;
				}
			}
			maxV[i] = min(A, maxV[i]);
		}
	}

	ll ans = 1;
	repe(i, 1, n) {
		if (!ok[i]) {
		ans = ans * maxV[i] % MOD;

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

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(N);
  for(ll i(0);i<N;i++) cin>>A[i];
  vector<ll> r(N+1,0);
  
  for(ll i(0);i<N;i++){
    r[i+1] = r[i] + A[i];
  }

  map<ll,ll> cnt;
  for(ll i(0);i<N+1;i++){
    r[i] %= M;
    cnt[r[i]]++;
  }
  ll ans(0);
  for(auto mi:cnt) {
    ans += mi.second*(mi.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 5760
import math
import sys

n, k = map(int, sys.stdin.readline().rstrip().split())
r, s, p = map(int, sys.stdin.readline().rstrip().split())
t = sys.stdin.readline().rstrip()
ans = 0
sim = []
for i, ti in enumerate(t):
    if ti == 'r':
        if i >= k and sim[i - k] == 'p':
            sim.append('x')
        else:
            ans += p
            sim.append('p')
    elif ti == 's':
        if i >= k and sim[i - k] == 'r':
            sim.append('x')
        else:
            ans += r
            sim.append('r')
    else:
        if i >= k and sim[i - k] == 's':
            sim.append('x')
        else:
            ans += s
            sim.append('s')
# print(sim)
print(ans)


Measured memory_bytes: 4212
#include <map>
#include <iostream>
 
using namespace std;
 
int main() {
    int N,a;
    cin >> N ;
	int sum = 0;
	int X = N;
	for (int i = 0;i < 8; i++){
	a = X%10;
	X = X/10;
	sum = sum + a;
}
	if(N % sum == 0){
           cout << "Yes" << endl;
}	else{
           cout << "No" << endl;
}
return 0;
} 


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {


	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int Q = fs.nextInt();
		int query[][] = new int[Q][2]; 
		for(int i=0;i<Q;i++) {
			int a = fs.nextInt(), b = fs.nextInt();
			if(a > b) {
				int t = a;
				a = b;
				b = t;
			}
			query[i][0] = a;
			query[i][1] = b;
		}
		long ans = 0;
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<Q;i++) {
			long a = query[i][0];
			long b = query[i][1];
			//a <= b
			if(a == b) {
				ans = 2 * (a - 1);
			}else {
				long l = -1;
				long r = a * b + 100;
				while(l+1<r) {
					long c = (l + r)/2;//cは人数　//lがok, rがout
					if(check(c, a, b)) l = c;
					else r = c;
				}
				ans = l;
			}
			sb.append(ans + "\n");
		}
		System.out.println(sb.toString());
	}
	// 構築できるならtrueを返す。
	static boolean check(long c, double x, double y) {
		// x <= yで考えて良い
		double max = 0;
		long n = c+1;
		if(n%2==0) {
			if(n/2<=x-1 || y+1 <= n/2) {
				double lrmax = n*n/4;
				double center_max = Math.max((x+1)*(n-x), y*(n-(y-1))); 
				max = Math.max(lrmax, center_max);
			}else {
				double lrmax = Math.max((x-1)*(n-(x-1)), (y+1)*(n-(y+1)));
				double center_max = Math.max(((n-1)/2 + 1)*(n-(n-1)/2), ((n-1)/2 + 2)*((n-(n-1)+1)/2));
				max = Math.max(lrmax, center_max);
			}
		}
		else {
			if((n-1)/2<=x-1 || y+1 <= (n+1)/2) {
				double lrmax = (n-1)*(n+1)/4;
				double center_max = Math.max((x+1)*(n-x), y*(n-(y-1))); 
				max = Math.max(lrmax, center_max);
			}else {
				double lrmax = Math.max((x-1)*(n-(x-1)), (y+1)*(n-(y+1)));
				double center_max = (n-1)*(n-1)/4 + n;
				max = Math.max(lrmax, center_max);
			}
			
		}
		return max < x * y;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21204
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, l, n, q;
  scanf("%lld", &n);
  ll dp[n][3], cnt[n];
  char s[n + 10];
  scanf("%s%lld", s, &q);
  cnt[0] = s[0] == 'M' ? 1 : 0;
  for(i = 1; i < n; ++i) cnt[i] = cnt[i - 1] + (s[i] == 'M' ? 1 : 0); 
  for(l = 0; l < q; ++l) {
    scanf("%lld", &k);
    for(i = 0; i < n; ++i) for(j = 0; j < 3; ++j) dp[i][j] = 0;
    if(s[0] == 'D') dp[0][0] = 1;
    for(i = 1; i < n; ++i) {
      if(i >= k && s[i - k] == 'D') dp[i][0]--, dp[i - 1][1] -= cnt[i] - cnt[i - k];
      for(j = 0; j < 3; ++j) dp[i][j] += dp[i - 1][j];
      if(s[i] == 'D') dp[i][0]++;
      if(s[i] == 'M') dp[i][1] += dp[i - 1][0];
      if(s[i] == 'C') dp[i][2] += dp[i - 1][1];
    }
    printf("%lld\n", dp[n - 1][2]);
  }
  return 0;
}

Measured memory_bytes: 32384
ss = input()
ue = int(ss[:2])
sita = int(ss[2:])

uem = False
sitam = False

if 1 <= ue and ue <= 12:
  uem = True
  
if 1 <= sita and sita <= 12:
  sitam = True
  
if uem and sitam:
  print('AMBIGUOUS')
elif uem:
  print('MMYY')
elif sitam:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3064
# frozen_string_literal: true

n = gets.to_i
p = gets.split.map(&:to_i)
q = gets.split.map(&:to_i)

a = (1..n).to_a.permutation(n).to_a.sort

pi = -1
qi = -1
a.each_index do |i|
  pi = i if a[i] == p
  qi = i if a[i] == q

  break if pi >= 0 && qi >= 0
end

puts (qi - pi).abs


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

namespace ConsoleApplication1 {
     class Program {
          static void Main(string[] args) {
               string s = Console.ReadLine();
               int a = s.IndexOf("A");
               int b = -1;
 
               
               for(int x = s.Length - 1; x > 0; x--) {
                   if(s.Substring(x,1) == "Z") {
                         b = x;
                         break;
                    }     
               }
               Console.WriteLine(b - a + 1);
              

         }
     }
}



Measured memory_bytes: 14176
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    if(n%2){
        cout<<0<<"\n";
        return 0;
    }
    lli q = n/2;
    lli ans = 0;
    lli r = q / 5;
    ans += r;
    r = 5;
    while(q/r > 0){
        r *= 5;
        ans += q / r;
    }
    cout<<ans<<"\n";
}
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n,k;
    cin >> n >> k;
    int ans=1;
    rep(i,n)
    {
        ans = min(ans+k,ans*2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    ll x;
    cin >> x;
    int ans=0;
    ll money=100;
    while(true){
        if(money >= x){
            break;
        }
        else{
            money +=  money/100;
            ans ++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main(void) {
	int a, b, c,flag;
	cin >> a >> b >> c;
	
	if(a>b){
		if (a > c)  cout << b + c;
		else cout << b + a;
	}
	else {
		if (b > c)  cout << a + c;
		else cout << a + b;
	
	}

	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll D;
    cin >> D;
    vector<ll> vec(26);
    rep(i,26){
        cin >> vec[i];
    }
    vector<vector<ll> > happiness(D, vector<ll>(26));
    rep(i,D){
        rep(j,26){
            cin >> happiness[i][j];
        }
    }
    vector<ll> sad(26,0);
    rep(j,26){
        sad[j] += vec[j];
    }
    ll normal_sadistic_per_day = 0;
    rep(i,26){
        normal_sadistic_per_day += vec[i];
    }
    rep(i,363){
        ll sadistic_per_day = 0;
        rep(j,26){
            sadistic_per_day += sad[j];
        }
        ll minus_point = 0;
        ll t = 0;
        minus_point -= sadistic_per_day;
        ll max_point = minus_point;
        rep(j,26){
            if (max_point <= minus_point + sad[j] + happiness[i][j]){
                t = j + 1;
                max_point = minus_point + sad[j] + happiness[i][j];
            }
        }
        rep(j,26){
            sad[j] += vec[j];
        }
        sad[t - 1] = 0;
        cout << t << endl;
    }
    rep(i,1){
        ll sadistic_per_day = 0;
        rep(j,26){
            sadistic_per_day += sad[j];
        }
        ll minus_point = 0;
        ll t1 = 0;
        ll t2 = 0;
        minus_point -= sadistic_per_day;
        ll max_point = -100000000000;
        rep(j,26){
            minus_point += sad[j] + happiness[363 + i][j];
            ll sadistic_per_day2 = 0;
            rep(k,26){
                sad[k] += vec[k];
                sadistic_per_day2 += sad[k];
            }
            ll save_sad = sad[j];
            sad[j] = 0;
            minus_point -= (sadistic_per_day2 - save_sad);
            rep(k,26){
                if (max_point <= minus_point + sad[k] + happiness[364 + i][j]){
                    t1 = j + 1;
                    t2 = k + 1;
                    max_point = minus_point + sad[k] + happiness[364 + i][j];
                }
            }
            sad[j] = save_sad;
            rep(k,26){
                sad[k] -= vec[k];
            }
        }
        rep(j,26){
            sad[j] += vec[j];
        }
        sad[t1 - 1] = 0;
        rep(j,26){
            sad[j] += vec[j];
        }
        sad[t2 - 1] = 0;
        cout << t1 << endl;
        cout << t2 << endl;
    }
}


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

using namespace std;
#define INF (int)1e8


int sol(vector<int> &dp, vector<int> h, int k, int n)
{
	dp[0] = 0;
	for (int i = 0 ; i < n ; i++) 
	{
		for (int j = i + 1 ; j <= i + k ; j++)
		{
			if (j < n) dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
		}
	}
	return dp[n-1];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	vector<int> dp(n,INT_MAX);
	for (int i = 0 ; i < n ; i++) cin >> h[i];
	cout << sol(dp,h,k,n) << "\n";
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(void){
    int r;
    scanf("%d", &r);
    if ( r < 1200 ) {
        printf("ABC\n");
    } else if ( r < 2800 ) {
        printf("ARC\n");
    } else {
        printf("AGC\n");
    }
    return 0;
}

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

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    rep(i, n)
    {
        if (v[i] - c[i] > 0)
            ans += v[i] - c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N = int(readline())

P = np.array(readline().split(), np.int32)
Q = np.minimum.accumulate(P)
ans = np.count_nonzero(P <= Q)
print(ans)


Measured memory_bytes: 23124
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var c = 0
    for (i in 1..n) {
        if (i.toString().length % 2 == 0) {
            continue
        }
        ++c
    }
    println(c)
}

Measured memory_bytes: 36228
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(3 * n);
  for (int i = 0; i < 3 * n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long sum = 0;
  for (int i = n; i < 3 * n; i += 2) {
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main(){
	int a,b,c; cin >> a >> b >> c;
	if(a+b<c) cout << "No" << endl;
	else cout << "Yes" << endl;
}


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

using namespace std;

int main()
{
	string s;

	cin >> s;
	sort(s.begin(), s.end());
	
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

s64 N, X;
s64 rec(s64 n, s64 x)
{
    if (n == 0 && x == 1) return 1;

    s64 len = ((s64)1 << (n + 1)) - (s64)3;
    s64 num = ((s64)1 << n) - (s64)1;
    s64 ret = 0;
    if (x == 0) return 0;
    else if (x <= 1 + len)
    {
        ret = rec(n - 1, x - 1);
    }
    else if (x == 2 + len)
    {
        ret = rec(n - 1, x - 1) + 1;
    }
    else if (x <= 2 + 2 * len)
    {
        ret = num + 1 + rec(n - 1, x - 2 - len);
    }
    else
    {
        ret = 2 * num + 1;
    }

    return ret;
}

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

    cin >> N >> X;
    cout << rec(N, X) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
char a[10005][10005];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
void solve() {
    int r, c;
    cin >> r >> c;
    int ans[r][c];
    for(int i=0;i<r;i++) {
        for(int j=0;j<c;j++) {
            ans[i][j] = -1;
        }
    }
    queue<pair<int, int> > q;
    for(int i=0;i<r;i++) {
        for(int j=0;j<c;j++) {
            cin >> a[r][c];
            if(a[r][c] == '#') {
                q.push({i, j});
                ans[i][j] = 0;
            }
        }
    }
    while(!q.empty()) {
        pair <int, int> p = q.front();
        q.pop();
        for(int i=0;i<4;i++) {
            int x = p.first + dx[i];
            if(x >= r || x < 0)
                continue;
            int y = p.second + dy[i];
            if(y >= c || y < 0)
                continue;
            if(ans[x][y] >= 0)
                continue;
            ans[x][y] = ans[p.first][p.second]+1;
            q.push(make_pair(x, y));
        }
    }
    int mx = 0;
    for(int i=0;i<r;i++) {
        for(int j=0;j<c;j++) {
            //cout << ans[i][j] << " ";
            mx = max(mx, ans[i][j]);
        }
        //cout << '\n';
    }
    cout << mx << '\n';
    return ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 26420
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

char x[]={'A','C','G','T'};
char y[]={'T','G','C','A'};

char b;
cin>>b;

for(int i=0;i<4;i++){
    if(b==x[i]){
        cout<<y[i]<<endl;
        return 0;
    }
}



return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var (
		S, retS string
		s []string
		sum int
	)
	fmt.Scan(&S)
	s = strings.Split(S, "")
	for bit := 0; bit < (1 << (len(S)-1)); bit++ {
		num, _ := strconv.Atoi(s[0])
		sum = num
		retS = s[0]
		for i := 0; i < len(S)-1; i++ {
			num, _ = strconv.Atoi(s[i+1])
			if (bit >> i) & 1 == 1{
				sum += num
				retS += "+" + s[i+1]
			} else {
				sum -= num
				retS += "-" + s[i+1]
			}
		}
		if sum == 7 {
			retS += "=7"
			break
		}
	}
	fmt.Println(retS)
}


Measured memory_bytes: 1836
#include <iostream>

using namespace std;

int main(void)
{
    string result;
    int defeat_count = 0;

    cin >> result;

    for(int i = 0; i < result.size(); i++){
        if(result[i] == 'x'){
            defeat_count += 1;
        }
    }

    if(defeat_count >= 8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import itertools

N = int(input())
H = list(map(int, input().rstrip().split()))

cnt = 0
prev_max_height = 0

for h in H:
    if prev_max_height <= h:
        prev_max_height = h
        cnt += 1

out = cnt

print(out)

Measured memory_bytes: 3060
h,w = map(int, input().split())
s = [input() for i in range(h)]
ans = [["#"]*w for i in range(h)]
dx = [-1,0,1,-1,1,-1,0,1]
dy = [-1,-1,-1,0,0,1,1,1]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        else:
            num = 0
            for k in range(8):
                ni = i + dy[k]
                nj = j + dx[k]
                if ni < 0 or h <= ni:
                    continue
                if nj < 0 or w <= nj:
                    continue
                if s[ni][nj] == "#":
                    num += 1
            ans[i][j] = str(num)
for l in ans:
    print(''.join(l))

Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[]h = new int[n];
        
    int high = 0;
    int cou = 0;
    for(int i=0; i<n; i++) {
    	h[i] = sc.nextInt();
    	if(h[i] >= high) {
    		high = h[i];
    		cou++;
    }
    }     	
    	System.out.println(cou);
    }
}




Measured memory_bytes: 35696
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1e9+7;
ll fac[100001];
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
bool comp(PI a,PI b){
    return b.F<a.F;
}

int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(m==n)forn(i,m)cout<<m;
    else if(m<n)forn(i,n)cout<<m;
    else if(m>n)forn(i,m)cout<<n;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int dp[41][401][401] = {};
int exist[41][401][401] = {};

int main(){
   
    int n,ma,mb;
    cin >> n >> ma >> mb;
    int a,b,c;
    for (int i=0;i<=40;i++) {
        exist[i][0][0] = 1;
    }
    for (int i=1;i<=n;i++){
        cin >> a >> b >> c;

        for(int j=0;j<=400;j++){
            for (int k=0;k<=400;k++){
                if(j-a >= 0 and k-b >= 0) {
                    if(exist[i-1][j][k] == 1) {
                        dp[i][j][k] = dp[i - 1][j][k];
                        if(exist[i-1][j-a][k-b] == 1){
                            dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - a][k - b] + c);
                        }
                        exist[i][j][k] = 1;
                    }else if(exist[i-1][j-a][k-b] == 1){
                        dp[i][j][k] = dp[i - 1][j - a][k - b] + c;
                        exist[i][j][k] = 1;
                    }
                }else if(exist[i-1][j][k] == 1){
                    dp[i][j][k] = dp[i - 1][j][k];
                    exist[i][j][k] = 1;
                }
            }
        }
    }

    int ans = INT16_MAX;
    int idx = 1;
    int tmp = 0;
    while(max(ma,mb) * idx <= 400){
        if(exist[n][idx*ma][idx*mb] == 1) {
            tmp = dp[n][idx * ma][idx * mb];
            if (ans > tmp){
                ans = tmp;
            }
        }
        idx++;
    }
    if(ans == INT16_MAX){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    



}

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

int main(){
    int n,count=3;
    char s;
    
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=='Y'){
            count=4;
            break;
        }
    }
    
    if(count==3)
        cout<<"Three"<<endl;
    else if(count==4)
        cout<<"Four"<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;


int main() {
	int n;
	cin >> n;
	vi a(n,0);

	rep(i, n-1) {
		int k;
		cin >> k;
		k--;
		a[k]++;
	}

	rep(i, n) {
		cout << a[i] << endl;
	}

}

Measured memory_bytes: 4052
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
   



int main(){
   IOS

   int n; cin>>n;
   vi a(n);
   for(int & x : a)cin>>x;

   for(int i :a){
      if(i & 1)continue;
      else{
         if(i % 3 != 0 and i % 5 != 0){
            cout<<"DENIED";
            return 0;
         }
      }
   }

   cout<<"APPROVED\n";


   





}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
   if(b&1)
       res = res * a % mod;
        a = a * a % mod;
   b >>= 1;
    }

    return res;
}



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  string S;
  cin >> S;
  if(S.find("7") != string::npos) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 3656
// https://github.com/atcoder-live/library
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	rp(i,0,s)v.push_back(init);
	rp(i,s,e){x=in<T>();v.push_back(x);}
	return v;
}
// vi P = inarr<int>(1,N+1,INT_MAX);
// vi P = inarr<int>(0,N);

// #define NMAX 1000000000
int H,N;
vi A;

string solve(){
	// string ans="";
	ll s = 0;
	rp(i,0,N){
		s+=A[i];
	}
	if(s>=H){
		return "Yes";
	}
	else{
		return "No";
	}
	// return ans;
}

int main(){
	cin>>H;
	cin>>N;
	A = inarr<int>(0,N);
	cout<< solve() <<endl;
}


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

int main(){
  int N;
  bool flag = 0;
  string s;
  cin >> N;
  
  for(int i=0;i<N;i++){
     cin >> s;
     if(s == "Y"){
       cout << "Four" << endl;
       break;
     }
     if(i == N-1){
       cout << "Three" << endl;
       break;
     }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	bool dp[110][110][10] = { false };
	REP(i, N) {
		cin >> A[i];
		dp[i][i][A[i]] = true;
	}
	eFOR(l, 2, N) {
		eREP(i, N - l) {
			int j = i + l - 1;
			eFOR(k, i, j - 1) {
				//cout << i << " " << j << endl;
				eREP(c, 9) {
					if (dp[i][k][0] && dp[k + 1][j][0] ||
						dp[i][k][c] && dp[k + 1][j][c]) dp[i][j][0] = true;

					if (c) {
						if (dp[i][k][0] && dp[k + 1][j][c] ||
							dp[i][k][c] && dp[k + 1][j][0] ||
							dp[i][k][c] && dp[k + 1][j][c]) dp[i][j][c] = true;
					}
				}
			}
		}
	}
	cout << (dp[0][N-1][0] ? "yes" : "no") << endl;
	
	return 0;
}




Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define INF 2e9+7
using namespace std;
using pii=pair<int,int>;
using ll=long long int;

int gcd(int a,int b,int c) {
    return __gcd(__gcd(a,b),c);
}
int sum;

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            for(int k=1;k<=n;k++) {
                sum+=gcd(i,j,k);
            }
        }
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#define rep(i,k,n)for(ll i=k;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int gcd(ll a, ll b) {

	if (b == 0) {

		return a;
	}
	else {
		a = a%b;
		gcd(b, a);
	}
}
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
vector<double> tmp(5);

char num[3] = { 's','p','r' };
vector<bool>key;
int main() {
	ll N, K;
	cin >> N >> K;
	ll R[3];
	cin >> R[0] >> R[1] >> R[2];
	string T;
	cin >> T;
	ll ans=0;
	rep(i, 0, K) {

		rep(j, 0, 3) {

			if (num[j] == T[i]) {
				ans += R[j];
				key.push_back(1);
			}
		}
	}
	rep(i, K,N) {

		rep(j, 0, 3) {

			if (num[j] == T[i]) {
				if (T[i] != T[i - K] || key[i - K] != 1) {
					ans += R[j];
					key.push_back(1);
				}
				else {
					key.push_back(0);
				}
			}
		}
	}
	cout << ans;
}
	/*
	ll N;
	cin >> N;
	vector<ll>A(N), B(N);
	vector<pair<ll,ll>>X;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	for (int i = 0; i < N; i++) {

		X.push_back(make_pair(B[i],A[i]));
	}
	sort(X.begin(), X.end());
	ll sum=0;
	for (int i = 0; i < N; i++) {
		sum += X[i].second;
		if (sum > X[i].first) {
			cout << "No";
			return 0;
		}

	}
	cout << "Yes";
}*/
//	ll N;
//	cin >> N;
//	vector<ll>A(N);
//	for (int i = 0; i < N; i++) {
//		cin>>A[i];
//	}
//	cout << GCD(A);
//}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum, N_t;
  sum = 0;
  N_t = N;
  
  while(N_t != 0) {
    sum += N_t % 10;
    N_t /= 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,k,ar[200005],i,sum=0;
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>ar[i];
    sort(ar,ar+n,greater<int>());
    for(i=k;i<n;i++)
        sum+=ar[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
  long long h, w;
  cin >> h >> w;

  if (w == 1 || h == 1) {
    cout << 1 << "\n";
    return 0;
  }
  
  long long cnt =  h / 2 * w + h % 2 * ((w + 1) / 2);
  cout << cnt << "\n";
  
  return 0;
}

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut ans = vec![];
    let offset = n % 2;
    for f in 0..n - offset {
        let ban = n - f - 1 - offset;
        for t in f + 1..n {
            if t == ban {
                continue;
            }
            ans.push((f, t));
        }
    }
    println!("{}", ans.len());
    for &e in ans.iter() {
        println!("{} {}", e.0 + 1, e.1 + 1);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

inline vi Accumulate(vi input) {
	vi v(input.size());
	v[0] = input[0];
	for (unsigned int i = 1; i < input.size(); i++) {
		v[i] = v[i - 1] + input[i];
	}

	return v;
}
inline vi rAccumulate(vi input) {
	unsigned int l = input.size();
	vi v(l);
	v[l - 1] = input[l - 1];
	for (int i = l - 2; i >= 0; i--) {
		v[i] = v[i + 1] + input[i];
	}

	return v;
}

inline int ctoi(char c, char key) {
	if (c == key) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	vi East(N);
	vi West(N);

	vi nEast(N);
	vi nWest(N);
	rep(i, N) {
		nEast[i] = ctoi(S[i], 'W');
		nWest[i] = ctoi(S[i], 'E');
	}

	East = Accumulate(nEast);
	West = rAccumulate(nWest);

	int ans = int_INF;
	rep(i, N) {
		int temp;
		if (i == 0) {
			temp = West[1];
		}
		else if (i == N - 1) {
			temp = East[N - 2];
		}
		else {
			temp = East[i - 1] + West[i + 1];
		}

		temp < ans ? ans = temp : 1;
	}

	cout << ans << endl;;
}


Measured memory_bytes: 7684
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int ans, k, i, j, t;
    vector< int > T(5);
    vector< int > T2(5);

    cin >> T[0] >> T[1] >> T[2] >> T[3] >> T[4];

    t = 0;
    for (i=0; i<5; i++){
        T2[i] = T[i] % 10;
        if (T2[i] != 0) T2[i] = 10 - T2[i];
        t += T2[i];
    }

    int max = *std::max_element(T2.begin(), T2.end());
    ans = T[0] + T[1] + T[2] + T[3] + T[4] + t - max;

    cout << ans << "\n";
}

   

Measured memory_bytes: 256
L=list()
s=input()
K=int(input())
if len(s)<10:
  for i in range(len(s)):
    for j in range(i+1,len(s)+1):
      L.append(str(s[i:j]))
  L=sorted(list(set(L)))
  print(L[K-1])
else:
  A=sorted(list(s))
  B=[A[0],A[1],A[2],A[3],A[4]]
  for i in range(len(s)):
    if s[i] in B:
      for j in range(i+1,min(i+6,len(s)+1)):
        L.append(str(s[i:j]))
      L=sorted(list(set(L)))
      if len(L)>K:
        L=list(L[:K])
  print(L[K-1])

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

int main(){
int N; cin >> N;
vector<char> S(N);
bool yellow = false;
for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == 'Y') {
        yellow = true;
    }
}
if (yellow) {
    cout << "Four" << endl;
} else {
    cout << "Three" << endl;
}

}



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

int main()
{
    long N, M;
    cin >> N >> M;
    vector<pair<int, int>> job(N);
    rep(i, N)
    {
        cin >> job[i].first >> job[i].second;
    }
    sort(job.begin(), job.end());
    priority_queue<int> max_job;
    long long ans = 0;
    int index = 0;
    for (int d = 1; d <= M; d++)
    {
        while (index < N && job[index].first == d)
        {
            max_job.push(job[index].second);
            index++;
        }
        if (max_job.size() != 0)
        {
            ans += max_job.top();
            max_job.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int N,M,Q;
vector<vector<int> > G(101010);
int color[101010];
int memo[15][101010];
int V[101010],D[101010],C[101010];

void func(int d,int v,int c){
  if(memo[d][v]!=0) return;
  if(color[v]==0) color[v]=c;
  if(d==0){
    memo[0][v]=1;
    return;
  }
  rep(i,G[v].size()){
    func(d-1,G[v][i],c);
  }
  func(d-1,v,c);
  memo[d][v]=1;
  return;
}

int main(){
  cin>>N>>M;
  rep(i,M){
    int a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cin>>Q;
  rep(i,Q){
    cin>>V[i]>>D[i]>>C[i];
    V[i]--;
  }
  for(int i=Q-1;i>=0;i--) func(D[i],V[i],C[i]);
  rep(i,N) cout<<color[i]<<endl;
  return 0;
}


Measured memory_bytes: 13048