akhauriyash/Code-Regression huggingface dataset:
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var road = new int[n];
        for (int i = 0; i < n; i++)
            road[i] = int.Parse(Console.ReadLine().Trim());
        var tenki = new int[m];
        for (int i = 0; i < m; i++)
            tenki[i] = int.Parse(Console.ReadLine().Trim());
        var dp = new int[n + 1, m + 1];
        for (int i = 1; i < n + 1; i++)
            for (int j = 0; j < m+1; j++) dp[i, j] = 999999999;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
            {
                var t1 = dp[i - 1, j - 1] + road[i-1] * tenki[j-1];
                dp[i, j] = Math.Min(t1, dp[i, j - 1]);
            }
        Console.WriteLine(dp[n, m]);
    }
}

Measured memory_bytes: 12268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    int keta = (int)(log10(n));

    ll sita = (ll)(pow(10,keta))-1;
    ll ue = (n-sita)/(sita+1);
    cout << ue + keta*9 << endl;

    
    
}




Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n,i,cnt=0;
	long long h,w,a,b;
	scanf("%d %lld %lld",&n,&h,&w);
	for(i=0;i<n;i++)
	{
		scanf("%lld %lld",&a,&b);
		if(a>=h&&b>=w)
		{
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
count = 0
for i in range(1, n - 1):
    if max(p[i - 1], p[i], p[i + 1]) != p[i] and min(p[i - 1], p[i], p[i + 1]) != p[i]:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#define int long long
using namespace std;

int32_t main() {
	long long n, p, ans = 1;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	if (n > 50) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 2; i * i <= p; i++) {
		int x = 0;
		while (p % i == 0) {
			p /= i;
			x++;
		}
		for (int j = 0; j < 1ll * x / n; j++) {
			ans *= i;
		}
	}
	if (n == 1) {
		ans *= p;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
 
input = sys.stdin.readline
tree = [[] for _ in range(200001)]
scores = [0 for _ in range(200001)]

def dfs(pre, p):
    for child in tree[p]:
        if child == pre: continue
        scores[child] += scores[p]
        dfs(p, child)

def main():
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        scores[p] += x
    dfs(0, 1)
    print(' '.join(map(str, scores[1:N+1])))

if __name__ == '__main__':
    main()

Measured memory_bytes: 232216
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cstring>
#include <stdio.h>
#include <string.h>
using namespace std;
#define ll long long



int main() {

    ll n;
    cin>>n;

    ll b[n - 1];
    for(ll i = 0; i < n - 1; i++) {
        cin>>b[i];
    }


    ll sum = b[n - 2];
    for(ll i = n - 2; i >= 1; i--) {
        sum += min(b[i], b[i - 1]);
    }

    cout<<sum + b[0]<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int fibonacci(int n){
  int F[45];
  int i;

  F[0] = 1;
  F[1] = 1;
  for(i=2;i<=n;i++) F[i] = F[i-2] + F[i-1];
 
  return F[i-1];
}

int main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

double ans[100001];
double keisu[100001];

int main() {

  for ( int i = 1; i <= 100000; i++ ) {

    keisu[i] = ( pow( 2, i ) - 1 ) / pow( 2, i * ( i + 1 ) / 2 );

  }

  ans[1] = 1.00;
  ans[2] = 1.50;

  for( int i = 3; i <= 100000; i++ ) {

    ans[i] = 0.00;

    for ( int j = 1; j <= 100; j++ ) {

      if ( i-j-1 == 0 ) break;

      ans[i] += ( ans[i-j-1] + j ) * keisu[j];

    }

    if ( i > 100 ) continue;

    ans[i] += keisu[i-1] * ( i - 1 );

    ans[i] += 1.00 * i / pow( 2, i * ( i - 1 ) / 2 );

  }

  while( true ) {

    long long int n;

    cin >> n;

    if ( n == 0 ) break;

    cout << fixed << setprecision(8) << ans[n] << endl;

  }

  return 0;

}

Measured memory_bytes: 2852
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
using Data = deque<pair<char,int> >;

char conv(char c, int change) {
    if (change & 1) return (c == 'A' ? 'B' : 'A');
    else return c;
}

string recon(const Data &v, int change) {
    string res = "";
    int sum = 0;
    for (auto p : v) {
        sum += p.second;
        for (int i = 0; i < p.second; ++i) res += conv(p.first, change);
    }
    return res;
}

int main() {
    int N, K; string S;
    cin >> N >> K >> S;
    Data v;
    for (int i = 0; i < S.size();) {
        int j = i+1;
        while (j < S.size() && S[j] == S[i]) ++j;
        v.push_back({S[i], j-i});
        i = j;
    }
    int LIMIT = (int)S.size() * 10;
    if ((K - LIMIT) & 1) ++LIMIT;
    if (K > LIMIT) K = LIMIT;
    int change = 0;
    for (int i = 0; i < K; ++i) {
        char c = conv(v[0].first, change);
        if (c == 'A') {
            auto p = v[0];
            v.pop_front();
            if (p.second > 1) v.push_front({conv('A', change), p.second - 1});
            v.push_front({conv('B', change), 1});
        }
        else {
            ++change;
            v[0].second--;
            if (v[0].second == 0) v.pop_front();
            v.push_back({conv('A', change), 1});
        }
    }
    cout << recon(v, change) << endl;
}


Measured memory_bytes: 2724
#include<stdio.h>
int main(void)
{
  int high, wide, i;
  scanf("%d%d", &high,&wide);
  char mark[wide];
  for(i=0; i<=wide+1; i++){printf("#");}
  printf("\n");
  
  for(i=0; i<high; i++)
  {
    printf("#");    
      scanf("%s", mark);
      printf("%s", mark);
    printf("#\n");
  }
  for(i=0; i<=wide+1; i++){printf("#");}
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m, x; cin>>n>>m>>x;
	int a=0, b=0;
	for(int i=0; i<m; i++) {
		int l; cin>>l;
		if(l<x) a++;
		else b++;
	}
	cout<<min(a, b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> x(n, 0);
    for (int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
    }
    long long ans = 1, mod = 1e9 + 7, acum = 1;
    for (int i = 1; i < n; i++) {
        if (x[i] >= acum * 2 + 1) {
            acum++;
        } else {
            acum++;
            ans = ans * acum % mod;
            acum -= 2;
            i--;
        }
    }
    while (acum > 1) {
        ans = ans * acum % mod;
        acum--;
    }
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	k,a,b = readline() |> split |> parseMap
	if a>=b
		println(k+1)
	else
		total = a
		r = k-a+1
		x = div(r,2)
		for i in 1:x
			total += b-a
		end
		if r%2 == 1
			total += 1
		end
		println(max(total,k+1))
	end
end

main()

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

int main () {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A+B) < (C+D)) {
    cout << "Right" << endl;
  }
  
  else if  ((A+B) > (C+D)) {
    cout << "Left" << endl;
  }
  
  else {
    cout << "Balanced" << endl;
  }
}

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

using namespace std;
int main(void){
    int n, i, buf1, h;
    cin >> n;
    
    cin >> buf1;
    buf1--; //最初は必ず減らしておく
    
    for (int i = 1; i < n; i++){
        cin >> h;
        
        if (buf1 < h) h--; //減らせる場合は必ず減らす
        else if (buf1 > h){
            cout << "No" << endl; //すでに直前の値は減らしているため buf1 > hの場合NG
            return 0;
        }
        buf1 = h; //次に比較するための値をbuf1へ保持する
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
String.prototype.repAll = function (a, b) {
  return this.split(a).join(b);

}

var words = [];

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
    var arr = input.repAll(".", " ").repAll(",", " ").split(" ");
    for (var i  in arr) {
      if(arr[i].length > 2 && arr[i].length < 7) words.push(arr[i]);
    }
});
process.stdin.on('end', function() {
  console.log(words.join(" "));
});

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

int main() {
    init_io();
    ll N, M;
    cin >> N >> M;
    V<PLL> v(N);
    for(PLL &p : v) cin >> p.first >> p.second;
    sort(ALL(v));
    ll ans = 0;
    ll rest = M;
    for(ll i = 0; i < N && rest; i++) {
        ll buy = min(rest, v[i].second);
        ans += v[i].first * buy;
        rest -= buy;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int answer = 0;
  for (int i = 0; i <= N; ++i) {
    int sum = 0;
    for (char s : to_string(i)) {
      sum += s - '0';
    }
    if (A <= sum && sum <= B) {
      answer += i;
    }
  }
  cout << answer << endl;
}

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

int main()
{
  string s;
  cin>>s;
  int ans=0;
  int g=0,p=0;
  bool state=false;
  for (int i = 0; i < s.size(); ++i)
  {
    if(state){
      p++;
      if(s[i]=='g') ans++;
    }
    else {
      g++;
      if(s[i]=='p') ans--;
    }
    if(g==p) state=false;
    else state=true;
  }
  cout<<ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        int a[n];
        for (auto &ai:a) {
            cin >> ai;
        }
        sort(a, a+n);
        int prev = -1000000, ans = 1000000;
        for (auto &ai:a) {
            ans = min(ans, ai - prev);
            prev = ai;
        }
        cout << ans << '\n';
    }
    return 0;
}


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

int dp[404][404],A[444];
int n,a[404];

int dfs(int l,int r){
  if(l==r)return 0;
  if(dp[l][r]!=-1)return dp[l][r];
  int res=1e15;
  for(int i=l;i<r;i++){
    res=min(res,dfs(l,i)+dfs(i+1,r)+A[i+1]-A[l]+A[r+1]-A[i+1]);
  }
  return dp[l][r]=res;
}

signed main(){
  memset(dp,-1,sizeof(dp));
  cin>>n;
  r(i,n)cin>>a[i],A[i+1]=a[i];
  r(i,n)A[i+2]+=A[i+1];
  cout<<dfs(0,n-1)<<endl;
}

Measured memory_bytes: 1536
program atcoder
    implicit none
    integer :: N, A, B, i, s
    integer :: counter = 0

    read *, N, A, B
    do i = 1, N
        s = KetaSum(i)
        if((s .ge. A) .and. (s .le. B)) then
            counter = counter + i
        endif
    enddo
    print '(i0)', counter

    stop
    contains
        function KetaSum(x) result(y)
            implicit none
            integer, intent(in) :: x
            integer, allocatable :: array(:)
            integer :: s, c1, i, y

            s = int(log10(real(x)))+1
            allocate(array(s))
            do i = 1, s
                c1 = i - 1
                array(i) = int(x/(10**c1)) - int(x/(10**i)) * 10
            enddo
            y = sum(array)
            deallocate(array)

            return
        endfunction

endprogram atcoder


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int a,b;
  cin >> a >> b;
  int k = b-a;
  ll res = 0;
  REP(i,k){
    res += i;
  }
  cout << res - a << endl;

  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main(String [] args)
    {
        Map<String,Integer> map =new HashMap<>();
        Scanner  sc =new Scanner(System.in);
        map.put("400-599",8);
        map.put("600-799",7);
        map.put("800-999",6);
        map.put("1000-1199",5);
        map.put("1200-1399",4);
        map.put("1400-1599",3);
        map.put("1600-1799",2);
        map.put("1800-1999",1);
        int n = sc.nextInt();
        for(Map.Entry<String,Integer> map1:map.entrySet())
        {
            String str = map1.getKey();
            String chr[] = str.split("-");
            int start = Integer.parseInt(chr[0]);
            int end = Integer.parseInt(chr[1]);
            if(n>=start && n<=end)
            {
                System.out.println(map1.getValue());
                break;
            }
        }
    }
}

Measured memory_bytes: 35856
#include <iostream>

int main(){

    int n, k, x, y;
    std::cin >> n >> k >> x >> y;

    int sum = 0;
    
    if(n >= k){
        sum = k * x + (n - k) * y;
    }else{
        sum = n * x;
    }

    std::cout << sum << std::endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int N;
            string S, T, U;
        cin >> N;
            cin >> S >> T;
                for(int i = 0; i < N; i++){
                    //U.at(2 * i) = S.at(i);
                        //U.at(2 * i + 1) = T.at(i);
                            //cout << i;
                    U = U + S.at(i) + T.at(i);
                }
                    cout << U << endl;
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 1000000007ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
ModInt pow(ModInt a,ll x){
	ModInt res = ModInt(1ll);
	while(x){
		if(x&1)res *= a;
		x >>= 1;
		a = a*a;
	}
	return res;
}
const int SIZE = 100100;
ModInt inv[SIZE+10],fac[SIZE+10],facinv[SIZE+10];
// notice: 0C0 = 1 
ModInt nCr(int n,int r){
	assert(!(n<r));
	assert(!(n<0||r<0));
	return fac[n]*facinv[r]*facinv[n-r];
}
void init(){
	fac[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)fac[i]=fac[i-1]*ModInt(i);
	inv[1]=ModInt(1ll);
	for(int i=2;i<=SIZE;i++)inv[i]=ModInt(0ll)-ModInt(MOD/i)*inv[MOD%i];
	facinv[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)facinv[i]=facinv[i-1]*inv[i];
	return;
}
int N;
int K;
int a[105];
ModInt dp[105][100100];
int main(){
	init();
	cin >> N >> K;
	for(int i=0;i<N;i++)cin >> a[i];
	dp[0][0]=ModInt(1ll);
	for(int i=0;i<N;i++){
		for(int j=1;j<=K;j++){
			dp[i][j]+=dp[i][j-1];
		}
		for(int j=0;j<=K;j++){
			int l = max(0,j-a[i]);
			if(l>0)dp[i+1][j]+=(dp[i][j]-dp[i][l-1]);
			else dp[i+1][j]+=dp[i][j];
		}
	}
	cout << dp[N][K] << endl;
    return 0;
}


Measured memory_bytes: 84736
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  ll k,n;cin>>k>>n;
  vector<ll>a(n);
  rep(i,n)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  ll r=0;
  for(ll i=0;i<n-1;i++){
    r=max(r,a.at(i+1)-a.at(i));
  }
  r=max(r,k-a.at(n-1)+a.at(0));
  ll ans=k;
  cout<<ans-r;
}
  
    
    
    

Measured memory_bytes: 1792
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

graph G;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;
	vector<int> heights(n); fore(e, heights) cin >> e;
	forl(i, 0, m) { int a, b; cin >> a >> b; G[a].insert(b); G[b].insert(a); }
	int ans = 0;
	forl(i, 0, n) {
		bool good = true;
		fore(e, G[i+1]) {
			if(heights[i] > heights[e-1]) continue;
			good = false;
			break;
		}
		if(good) ans++;
	}
	println(ans);
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=1;i<n;i++){
    int cnt=0;
    map<char,int> mpx;
    map<char,int> mpy;
    for(int j=0;j<i;j++){
      mpx[s[j]]++;
    }
    for(int j=i;j<n;j++){
      mpy[s[j]]++;
    }
    for(auto x:mpx){
      for(auto y:mpy){
        if(x.first==y.first&&x.second>0&&y.second>0){
          cnt++;
        }
      }
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int exist[1000005];
int max1;
int min1=0x3f3f3f3f;
int end1;
bool flag[1000005];
void sieve()
{
    for(int i=min1;i<=max1;i++)
    {
    	if(exist[i]==1)
        {
            for(int j=2*i;j<=max1;j+=i)
            {
                if(exist[j]&&flag[j]==0)
                {
                    exist[j]--;
                    end1--;
                }
            }
        }
    }
}
int x;
int main() 
{
    int n;cin>>n;
	for(int i=1;i<=n;i++)
    {
        cin>>x;
        exist[x]++;
        max1=max(max1,x);
        min1=min(min1,x);
    }
    for(int i=min1;i<=max1;i++)
    {
    	if(exist[i]==1)
    	{
    		end1++;
		}
		else if(exist[i]>1)
		{
			exist[i]=1;
			flag[i]=1;
		}
	}
    sieve();
    cout<<end1;
}




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

int prime_number(int n) {
  if(n == 2 || n == 3) {
    return 1;
  }
  for(int i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      return 0;
    }
  }
  return 1;
}

int main() {
  int n;
  cin >> n;
  for(int i = n; 1; i++) {
    int a = prime_number(i);
    if(a == 1) {
      cout << i;
      return 0;
    }
  }
}
  


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0, cnt = 1;
  cin >> n;
  vector<ll> a(n * 3);
  rep(i, n * 3) cin >> a[i];

  sort(a.rbegin(), a.rend());

  for (int i = i + 1; i < 2 * n; i += 2) ans += a[i];

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

Measured memory_bytes: 5544
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T>> &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n, k;
string s;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  
  cin >> n >> k >> s;
  transform(s.begin() + k - 1, s.begin() + k, s.begin() + k - 1, ::tolower); 
  cout << s << endl;
  return 0;
}




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

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

// void p() {
//     cout << "\n";
// }
// template<class Head, class... Body>
// void p(Head head, Body... body) {
//     cout << head << ",";
//     p(body...);
// }

int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
    }
    vector<int> c(M), d(M);
    for (int j = 0; j < M; ++j) {
        cin >> c[j] >> d[j];
    }

    for (int i = 0; i < N; ++i) {
        int dist_min;
        int dest = -1;
        for (int j = 0; j < M; ++j) {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dest == -1 || dist < dist_min) {
                dist_min = dist;
                dest = j;
            }
        }
        cout << dest + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <deque>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define mp make_pair
#define fname ""
#define fi first
#define se second
#define sz(a) (int)a.size()
#define pb push_back
#define fo(i,k,n) for(int i=k; (int)i<n; ++i)
#define rep(i,n,k) for(int i=n; (int)i>=k; --i)
#define all(v) v.begin(), v.end()
#define it ::iterator
#define forit(it,v) for(__typeof(v.begin()) it = v.begin(); it != v.end(); ++it)


const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int N = 100100;

int a,b;

int main(){
    
    //freopen(fname"in", "r", stdin);
    //freopen(fname"out", "w", stdout);
    
    scanf("%d%d", &a,&b);
    ll ans = 1;
    
    if(a == b || abs(a - b) == 1){
        if(a == b){
            fo(i,1,a+1){
                ans*=i;
                ans%=(inf + 7);
            }
            ans*=ans;
            ans%=(inf + 7);
            ans*=2;
            ans%=(inf + 7);
            
        }else{
            fo(i,1,a+1){
                ans*=i;
                ans%=(inf + 7);
            }
            ll ans2 = 1;
            fo(i,1,b+1){
                ans2*=i;
                ans2%=(inf + 7);
            }
            ans*=ans2;
            ans%=(inf + 7);
        }
    }else{
        ans = 0;
    }

    cout<<ans;
    
    return 0;
}









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

// 2DTree

class Node {
    public:
        int location;
        int p, l, r;
        Node() {}
};

class Point {
    public:
        int id, x, y;
        Point() {}
        Point(int id, int x, int y): id(id), x(x), y(y) {};
        bool operator < (const Point &p) const {
            return id < p.id;
        }

        void print(){
            printf("%d\n", id);
        }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x;}
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y;}

int makeKDTree(int l, int r, int depth) {
    if ( !(l < r) ) return NIL;
    int mid = (l+r) / 2;
    int t = np++;
    if( depth % 2 == 0) {
        sort (P+l, P+r, lessX);
    } else {
        sort( P+l, P+r, lessY);
    }
    T[t].location = mid;
    T[t].l = makeKDTree(l, mid, depth+1);
    T[t].r = makeKDTree(mid+1, r, depth+1);

    return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
    int x = P[T[v].location].x;
    int y = P[T[v].location].y;
    if ( sx <= x && x <= tx && sy <= y && y <= ty ) {
        ans.push_back(P[T[v].location]);
    }
    if (depth % 2 == 0) {
        if(T[v].l != NIL) {
            if ( sx <= x ) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if(T[v].r != NIL) {
            if ( x <= tx ) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    } else {
        if(T[v].l != NIL) {
            if ( sy <= y ) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
        }
        if(T[v].r != NIL) {
            if ( y <= ty ) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
        }
    }
}

int main(){
    int x, y;
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].l = T[i].r = T[i].p = NIL;
    }
    np = 0;
    int root = makeKDTree(0, N, 0);

    int q;
    scanf("%d", &q);
    int sx, tx, sy, ty;
    vector<Point> ans;
    for(int i = 0; i < q; i++ ) {
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for (int j = 0; j < ans.size(); j++) {
            ans[j].print();
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 16464
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 k, x;
    cin >> k >> x;
    cout << (500 * k >= x ? "Yes" : "No") << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b; cin>>a>>b;
    cout << max(0, a-2*b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s,t;
const char *s1,*t1;
int ctr=0;
cin >> s >> t;
s1=s.c_str();
t1=t.c_str();
for(int i=0;i<min(s.size(),t.size());i++){
if(s1[i]==t1[i]) ctr++;
}
cout << ctr;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;

int dp[405][405][41];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	sort(l.rbegin(), l.rend());
	int ans = 0;
	rep(i,k) ans += l[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair <int,int> P;


int main(){
    int a,b,c,d,e,f,k;
    cin >> a >> b >> c >> d >> e >> k;

    if(e - a > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    ll l;
    cin >> n >> l;

    vector<ll> a(n);

    rep(i, n){
        cin >> a[i];
    }

    bool able = false;
    int last;

    rep(i, n - 1){

        if(a[i] + a[i + 1] >= l){
            able = true;
            last = i + 1;
            break;
        }
    }

    if(able){
        cout << "Possible" << endl;

        for(int i = 1; i < last; i++){
            cout << i << endl;
        }

        for(int i = n - 1; i >= last; i--){
            cout << i << endl;
        }

        
    }else{
        cout << "Impossible" << endl;
    }



    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=105;
const int NN=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll n, w, arr[N][2],dp[N][NN], ret;

ll solve(ll i, ll j)
{
    if(i==n+1)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=min(solve(i+1, j), solve(i+1, j+arr[i][1])+arr[i][0]);
    if(dp[i][j]<=w)
        ret=max(ret, j);
    return dp[i][j];
}

int main() 
{
    inlld2(n, w);
    for(ll a=1; a<=n; a++)
        inlld2(arr[a][0], arr[a][1]);
    // memset(dp, -1, sizeof(dp));
    // ll x=solve(1, 0);
    // printf("%lld\n", ret);
    for(ll a=0; a<N; a++)
        for(ll b=1; b<NN; b++)
            dp[a][b]=1e15;
    ll ans=0;
    for(ll a=1; a<=n; a++)
    {
        for(ll b=0; b<NN; b++)
        {
            dp[a][b]=min(dp[a][b], dp[a-1][b]);
            if(b-arr[a][1]<0)
            {
                if(dp[a][b]<=w)
                    ans=max(ans, b);
                continue;
            }
            dp[a][b]=min(dp[a][b], dp[a-1][b-arr[a][1]]+arr[a][0]);
            if(dp[a][b]<=w)
                ans=max(ans, b);
        }
    }
    // for(ll a=1; a<=n; a++)
    //     printf("%lld %lld %lld %lld\n", dp[a][30], dp[a][80], dp[a][90]);
    printf("%lld\n", ans);
    return 0;
}



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

using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  return b ? gcd(b, a % b) : a;
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  ll lcm = C * D / gcd(C, D);
  ll c1 = A - A / C - A / D + A / lcm, c2 = B - B / C - B / D + B / lcm;
  cout << c2 - c1 << endl;
  return 0;
}

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) b[i] = a[i];

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

  rep(i,n){
    if(b[0] == a[i]) cout << b[1] << endl;
    else cout << b[0] << endl;
  }
}


/*





















*/


Measured memory_bytes: 3200
N = int(input())
S1 = input()
S2 = input()
count = 1

if(S1[0] == S2[0]):
  ans= 3
else:
  ans= 6
  count+= 1

while count < N:
  if(S1[count] == S2[count]):
    if(S1[count- 1] == S2[count- 1]):
      ans*= 2
      count+= 1
    else:
      count+= 1
  else:
    if(S1[count- 1] == S2[count- 1]):
      ans*= 2
      count+= 2
    else:
      ans*= 3
      count+= 2
      
print(ans% (10** 9+ 7))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <iomanip>
#include <math.h>
#include <time.h>
#include <chrono>
#include <sstream>
#include <sys/stat.h>
#include <string>
#include <algorithm>
#include <numeric>

 int calcNumOfCombination(int n, int r){
        int num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

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

	int div=0;
	int count=0;

	int ansn,ansm;

	ansn=calcNumOfCombination(n,2);
	ansm=calcNumOfCombination(m,2);

	std::cout << ansn+ansm;	
}

Measured memory_bytes: 256
#coding:utf-8

a, b = map(int, input().split())

#1は13より強いので、比較のために14に置き換え
if a == 1:
  a = 14

if b == 1:
  b = 14
  
if a > b:
  print('Alice')
elif a < b:
  print('Bob')
else:
  print('Draw')


Measured memory_bytes: 2940
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-3 11:49:10
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
string S;

int main()
{
  cin >> N >> S;
  int ans = 0;
  for (auto i = 0; i < N; i++)
  {
    string X[2] = {S.substr(0, i), S.substr(i, N - i)};
    bool A[2][26];
    fill(&A[0][0], &A[0][0] + 26 * 2, false);
    for (auto k = 0; k < 2; k++)
    {
      for (auto x : X[k])
      {
        A[k][x - 'a'] = true;
      }
    }
    int t_ans = 0;
    for (auto i = 0; i < 26; i++)
    {
      if (A[0][i] && A[1][i])
      {
        t_ans++;
      }
    }
    ans = max(ans, t_ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B, K;
  cin >> A >> B >> K;
  for(int i = 0; i < K; i++){
    if(i % 2 == 0){
      A /= 2;
      B += A;
    } else {
      B /= 2;
      A += B;
    }
  }
  cout << A << ' ' << B << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n);
  Vi B(n);
  REP(i,n){
    IN2(A[i],B[i]);
  }
  Vi diff(n);
  REP(i,n){
    diff[i] = B[n-i-1] - (A[n-i-1]%B[n-i-1]);
  }
  int rec = 0;
  REP(i,n){
    if(B[n-i-1] != 1 && A[n-i-1] != 0 && A[i] != B[i]){
      if(diff[i] >= rec){
        rec = diff[i];
      } else {
        int modE = diff[i] % B[n-i-1];
        int modRec = rec % B[n-i-1];
        int modDiff;
        if(modE - modRec >= 0){
          modDiff = modE - modRec;
        } else {
          modDiff = modE + B[n-i-1] - modRec;
        }
        diff[i] = rec + modDiff;
        rec = diff[i];
      }
    }
  }
  OUT(rec);
}

Measured memory_bytes: 2688
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int a = n / x;
	if (n % x > 0) {
		++a;
	}
	cout << a * t << endl;
	return 0;
}


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

int main() {
  int A,B,C,K;
  cin >>A>>B>>C>>K;
  int ans=0;
  if(K<=A)
    ans=K;
  else{
    if(K<=A+B)
      ans=A;
    else
      ans=A-(K-A-B);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3640
while 1 do
  a,op,b=gets.split
  a=a.to_i
  b=b.to_i
  if op=='?' then
    break
  else
    c=a+b if op=='+'
    c=a-b if op=='-'
    c=a*b if op=='*'
    c=a/b if op=='/'
  end
  puts c
end



Measured memory_bytes: 6872
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct edge{ll from, to, weight;};

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

int main(){
  ll n,X;
  cin >> n >> X;
  ll x[n];
  REP(i,n){
    cin >> x[i];
    x[i]-=X;
    x[i]=abs(x[i]);
  }
  ll ans = x[0];
  REP(i,n-1){
    ans = gcd(ans,x[i+1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
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;}

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

    int ans = 0;
    for(int a=1; a<=N-1; a++){
        int count = (N-1)/a;
        ans += count;
    }

    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 3632
import sys
import numpy as np
input = sys.stdin.readline
N, W = map(int, input().split())
def knapsack():
  dp = np.zeros((N+1, W+1), dtype=int)
  c = np.arange(1, N+1)
  for i in c:
    w, v = map(int, input().split())
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)
    dp[i][:] = np.maximum(dp[i][:], dp[i-1][:])
  return dp[-1][-1]
print(knapsack())

Measured memory_bytes: 92700
def main():
    import sys
    input = sys.stdin.readline

    N, X, Y = map(int, input().split())
    L = Y-X+1
    ans = [0] * N
    for i in range(1, N):
        for j in range(i, N+1):
            d = min(j - i, abs(i-X) + abs(j-Y) + 1, abs(i-Y) + abs(j-X) + 1)
            ans[d] += 1
    for i in range(1, N):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 45916