akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> cnt(3, 0);
  rep(i, n) {
    cnt[s[i] - 'a']++;
  }
  int mn, mx;
  mn = min(cnt[0], min(cnt[1], cnt[2]));
  mx = max(cnt[0], max(cnt[1], cnt[2]));
  if (mx >= mn+2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


R = ni()
print(float(R)*3.141592653 * 2 )



Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

inline void InitRand()
{
    srand((unsigned int)time(NULL));
}

int main() {
    InitRand();
    int D; cin >> D;
    veci C(26);
    vecveci S(D,veci(26));
    veci T(D);
    REP(i,26) cin >> C[i];
    REP(i,D) REP(j,26) cin >> S[i][j];
    REP(i,D) {
        T[i] = rand()%26;
    }
    int M; M = 2*1e5;
    veci B(M),Q(M);
    REP(i,M) {
        B[i] = rand()%D;
        Q[i] = rand()%26;
    }

    veci last_d(26);
    ll old_ans = 0;
    REP(i,D) {
        int d = i+1;
        last_d[T[i]] = d;
        old_ans += S[i][T[i]];
        REP(j,26) {
            old_ans -= C[j]*(d-last_d[j]);
        }
    }

    REP(i,M) {
        int old_p = T[B[i]];
        T[B[i]] = Q[i];
        ll score = 0;
        veci last(26);
        REP(j,D) {
            int d = j+1;
            last[T[j]] = d;
            score += S[j][T[j]];
            REP(k,26) {
                score -= C[k]*(d-last[k]);
            }
        }
        if(old_ans < score) {
            old_ans = score;
        }
        else {
            T[B[i]] = old_p;
        }
    }
    REP(i,D) cout << T[i]+1 << endl;
}

Measured memory_bytes: 4768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.io.IOException;

public class Main {

    public static void main(String[] args) {

        try(var br = new BufferedReader(new InputStreamReader(System.in))) {

            var nk = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

            System.out.println(IntStream.of(Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray()).sorted().limit(nk[1]).sum());

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 34900
s=str(input())
ans=0
for i in range(1<<(len(s)-1)):
  st=s[0]
  for j in range(len(s)-1):
    if i & (1<<j):
      st+="+"+s[j+1]
    else:
      st+=s[j+1]
  ans+=eval(st)
print(ans)

Measured memory_bytes: 3060
<?php

$n = explode(' ',fgets(STDIN));
$left = $n[0]+$n[1];
$right = $n[2]+$n[3];
if ($left > $right){
  echo 'Left';
} else if ($right > $left){
  echo 'Right';
} else {
  echo 'Balanced';
}

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> S;
	vector<vector<ll>> dp(S.size() + 1, vector<ll>(4, 0));
	dp[0][0] = 1;
	for (int i = 1; i <= S.size(); i++) {
		if (S[i - 1] == 'A') {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][2] = dp[i - 1][2];
			dp[i][3] = dp[i - 1][3];
		}
		else if (S[i - 1] == 'B') {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = dp[i - 1][1] + dp[i - 1][2];
			dp[i][3] = dp[i - 1][3];
		}
		else if (S[i - 1] == 'C') {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = dp[i - 1][2];
			dp[i][3] = dp[i - 1][2] + dp[i - 1][3];
		}
		else {
			dp[i][0] = 3*dp[i - 1][0];
			dp[i][1] = dp[i - 1][0] + (3 * dp[i - 1][1]) % MOD;
			dp[i][2] = dp[i - 1][1] + (3 * dp[i - 1][2]) % MOD;
			dp[i][3] = dp[i - 1][2] + (3 * dp[i - 1][3]) % MOD;
		}
		for (int j = 0; j < 4; j++)dp[i][j] %= MOD;
	}
	cout << (dp[S.size()][3] % MOD) << endl;
}

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

using namespace std;

int main(){
    long long h,w,a,b;
    cin>>h>>w>>a>>b;
    map<long long,pair<long long,bool>> tate,yoko;
    for(long long i=0;i<max(h,w);i++){
        tate[i]=make_pair(0,false);
        yoko[i]=make_pair(0,false);
    }
    
    vector<vector<long long>> grid(h,vector<long long>(w,0));
    
    for(long long i=0;i<h;i++){
        for(long long j=0;j<w;j++){
            if(j<a && i<b) cout<<0;
            if(j<a && i>=b) cout<<1;
            if(j>=a && i<b) cout<<1;
            if(j>=a && i>=b) cout<<0;
        }
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 11184
n,m=map(int,input().split())
A=[[0]*m for i in range(0,n)]
for i in range(0,n):
    A[i]=list(map(int,input().split()))
x=[0]*m
for i in range(0,m):
    x[i]=int(input())
y=[0]*n
for i in range(0,n):
    for j in range(0,m):
        y[i]+=A[i][j]*x[j]
for i in range(0,n):
    print(y[i])


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


namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {

            //var str1 = Console.ReadLine();
            var str2 = Console.ReadLine()
                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => int.Parse(x))
                .ToArray();
            if (str2[0] > str2[1])
                Console.WriteLine(str2[0] - 1);
            else
                Console.WriteLine(str2[0]);
            Console.ReadLine();
        }
    }

}

Measured memory_bytes: 13268
n=int(input())
a=list(map(int,input().split()))
cnt2=0
cnt4=0
for x in a:
    if x%4==0:
        cnt4+=1
    elif x%2==0:
        cnt2+=1
if cnt2!=0:
    if n-cnt2-cnt4+1<=cnt4+1:
        print("Yes")
    else:
        print("No")
else:
    if n-cnt2-cnt4<=cnt4+1:
        print("Yes")
    else:
        print("No")


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

#define LL long long
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1; char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}

int main(){
	string s; int ans;
	cin>>s;
	if (s=="SUN") ans=7;
	if (s=="MON") ans=6;
	if (s=="TUE") ans=5;
	if (s=="WED") ans=4;
	if (s=="THU") ans=3;
	if (s=="FRI") ans=2;
	if (s=="SAT") ans=1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))



(let ((a (read)) (b (read)) (c (read)))
  (princ (if (zerop (mod c (gcd a b)))
		   "YES"
		   "NO")))


Measured memory_bytes: 7992
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())
a,b,c = [int(n) for n in input().split()]

if(b <= c and a <= c):
    print(10*c + a + b)
elif(a <= b and c <= b):
    print(10*b + c + a)
elif(c <= a and b <= a):
    print(10*a + c + b)


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int start = -1;
    int res = -1;
    int i = 0;
    while(start) {
        start = (a * i + b * i);
        int end = (a * (i + 1) + b * i);
        int c_ = c + (start / 60) * 60;

        if(start <= c_ && c_ <= end) {
            res = c_;
            break;
        }

        i++;
        start = (a * i + b * i) % 60;
    }

    cout << (res < 0 ? -1 : res) << endl;

    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;


int main() {
    int N, sum = 0;
    cin >> N;

    vector<int> a1(N);
    vector<int> a2(N);

    REP(i, N){
        cin >> a1[i];
        sum += a1[i];
    }
    REP(i, N){
        cin >> a2[i];
        sum += a2[i];
    }

    int res = INF, num = 0, res_temp = 0;
    REP(i, N){
        res_temp = 0;
        FOR(j, i+1,N-1){
            res_temp += a1[j];
        }

        FORD(j, i-1, 0){
            res_temp += a2[j];
        }

        if (res_temp < res){
            res = res_temp;
            num = i;
        }
    }

    cout << sum - res << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

int sum(vector<int> , int start, int end);

int main(int argc,char **argv)
{
  int N;
  cin >> N;
  vector<int> line1;
  vector<int> line2;

  for(int i=0;i<N;i++)
  {
    int c;
    cin >> c;
    line1.push_back(c);
  }

  for(int i=0;i<N;i++)
  {
    int c;
    cin >> c;
    line2.push_back(c);
  }

  int maxval=0;
  for(int i=0;i<N;i++)
  {
    int sum1 = accumulate(line1.begin(), line1.end()-(N-i-1),0);
    int sum2 = accumulate(line2.begin()+i, line2.end() , 0);
    int sum = sum1 + sum2;
    maxval = max(sum, maxval);
  }
  cout << maxval << endl;
  return 0;
}





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

int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>= 13)ans += b;
    else if(a <= 5) ans = 0;
    else ans += b / 2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const long long mod = 1e9+7;

long long mod_pow(long long x, long long k){
  long long ret = 1;
  while(k){
    if(k&1) ret *= x, ret %= mod;
    x *= x, x %= mod;
    k >>= 1;
  }
  return ret;
}

int main(){
  int b, w;
  cin >> b >> w;
  int N = b+w;
  vector<long long> B(N,0), W(N,0), F(N+1,1), F_(N+1,1);
  for(int i = 1; i <= N; ++i) F[i] = F[i-1]*i%mod;
  F_[N] = mod_pow(F[N],mod-2);
  for(int i = N-1; i > 0; --i) F_[i] = F_[i+1]*(i+1)%mod;
  auto comb = [&F,&F_](int n, int m){
                if(m > n) return 0LL;
                return F[n]*F_[m]%mod*F_[n-m]%mod;
              };
  long long t = 1, inv2 = mod_pow(2,mod-2);
  for(int i = 1; i < N; ++i){
    t *= inv2, t %= mod;
    B[i] = (B[i-1] + comb(i-1,w-1)*t%mod)%mod;
    W[i] = (W[i-1] + comb(i-1,b-1)*t%mod)%mod;
  }
  for(int i = 0; i < N; ++i){
    cout << ((1+B[i]-W[i])%mod+mod)%mod*inv2%mod << endl;
  }
}


Measured memory_bytes: 8448
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
    int K,A,B;

    cin >> K;
    cin >> A >> B;

    int i;
    bool judge = false;
    for(i = A; i <= B; i++){
        if( (i%K) == 0){
            judge = true;
            break;
        }
    }

    if(judge == true){
        cout << "OK";
    } else {
        cout << "NG";
    }

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	int x, y; cin >> x >> y;
	for (int i = y - x + 1; i <= y + x - 1; i++)cout << i << " ";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    double z = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        if (i >= k) z++;
        else {
            double y = 1;
            int x = i;
            while (x < k) x += x, y /= 2;
            z += y;
        }
    }
    cout << setprecision(13) << z / n;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

typedef unsigned long long ull;
const ull B = 1000000007;

string t, p;

void solve() {
	int al = (int)p.size(), bl = (int)t.size();
	if (al > bl)return;
	ull x = 1;
	for (int i = 0; i < al; i++)x *= B;
	ull ah = 0, bh = 0;
	for (int i = 0; i < al; i++) {
		ah = ah * B + p[i];
		bh = bh * B + t[i];
	}
	for (int i = 0; i + al <= bl; i++) {
		if (ah == bh)cout << i << endl;
		if (i + al < bl)bh = bh * B + t[i + al] - t[i] * x;
	}
}

signed main() {
	cin >> t >> p;
	solve();
}


Measured memory_bytes: 3904
#include<stdio.h>

long long int re[100001];

int main(){
	int n,k,i;
	long long c;
	re[0]=0;
	while(0<=scanf("%d%d",&n,&k)){
		if(n==0 && k==0)break;
		
		for(i=1;i<=n;i++){
			scanf("%lld",&c);
			re[i]=re[i-1]+c;
		}
		c=re[k];
		for(i=1;i+k-1<=n;i++){
			if(c<re[i+k-1]-re[i-1])c=re[i+k-1]-re[i-1];
		}
		printf("%lld\n",c);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<vector>
#define ll long long
#define N 201000
#define ls (now<<1)
#define rs ((now<<1)|1)
#define RG register
using namespace std;

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

ll n,m;
char s[N],t[N];
inline int Gcd(int x,int y) { while(y^=x^=y^=x%=y); return x; }

int main(){
	n=read(),m=read(),scanf("%s\n%s",s+1,t+1);
	ll len=n/Gcd(n,m)*m,l1=len/n,l2=len/m;
	ll sum=l1/Gcd(l1,l2)*l2,t1=sum/l1,t2=sum/l2;
	for(RG ll i=0,l=1,r=1;i*sum<len&&l<=n&&r<=m;++i,l+=t1,r+=t2)
		if(s[l]!=t[r]) return puts("-1"),0;
	printf("%lld\n",len); return 0;
}


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int id[1005][1005];
int toP(int i, int j)
{
  if (j < i) swap(i, j);
  return id[i][j];
}

void solve()
{
  int N;
  cin >> N;
  vector<vector<int>> a(N);
  rep(i, N) rep(j, N - 1) {
    int k;
    cin >> k;
    k--;
    a[i].push_back(k);
  }
  dumpv(a, N);
  int idx = 0;
  rep(i, N) rep(j, N) {
    if (i < j) {
      id[i][j] = idx++;
    }
  }
  int V = idx; // 試合数 (==N*(N-1)/2)
  vector<vector<int>> to(V);
  rep(i, N) rep(j, N - 2) {
    to[toP(i, a[i][j])].push_back(toP(i, a[i][j + 1]));
  }
  dump(idx, to);
  // トポロジカルソート
  vector<int> used(V); // 1: visited, 2: completed
  vector<int> res;
  int loop = false;
  function<void(int)> dfs = [&](int u) {
    if (used[u] == 1) {
      loop = true;
      return;
    }
    else if (!used[u]) {
      used[u] = 1;
      for (auto& v : to[u]) dfs(v);
      used[u] = 2;
      res.push_back(u); // 帰りがけ順で追加
    }
  };
  rep(i, V) {
    if (!used[i]) dfs(i);
    if (loop) break;
  }
  if (loop) { //閉路が存在
    cout << -1 << endl;
    return;
  }
  reverse(res.begin(), res.end());
  dump(res);
  vector<int> dp(V);
  used.assign(V, 0);
  function<int(int)> dfs2 = [&](int u) {
    if (used[u]) return dp[u];
    used[u] = 1;
    dp[u] = 1;
    for (auto& v : to[u]) {
      dp[u] = max(dp[u], dfs2(v) + 1);
    }
    return dp[u];
  };
  int ans = 0;
  rep(i, V) {
    ans = max(ans, dfs2(i));
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 41584
import java.util.*;

public class Main {

    static int mod = 998244353;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int S = sc.nextInt();
        int[] A = new int[N];
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt();
        }

        long[][] dp = new long[N+1][3100];
        dp[0][0] = 1;
        for (int i=0;i<N;i++) {
            for (int j=0;j<3100;j++) {
                dp[i+1][j] += 2*dp[i][j];
                if (j-A[i] >= 0) dp[i+1][j] += dp[i][j-A[i]];
                dp[i+1][j] %= mod;
            }
        }
        System.out.println(dp[N][S]);
    }
}

Measured memory_bytes: 136828
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int[] values;
	static int n;
	static int k;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		values = new int[n];
		for(int i = 0; i < n; i++){
			values[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i <= k; i++){
			for(int i2 = 0; i2 <= k - i; i2++){
				if(i + i2 > n){
					break;
				}
				for(int i3 = 0; i3 <= k - i - i2; i3++){
					if(i + i2 < i3){
						break;
					}
					int val = operate(i, i2, i3);
					ans = Math.max(ans, val);
				}
			}
		}
		System.out.println(ans);
	}
	
	static int operate(int a, int b, int c){
		ArrayList<Integer> ary = new ArrayList<>();
		for(int i = 0; i < a; i++){
			ary.add(values[i]);
		}
		
		for(int i = 0; i < b; i++){
			ary.add(values[n - i - 1]);
		}
		ary.sort(Integer::compareTo);
		for(int i = 0; i < c; i++){
			int n = ary.get(i);
			if(n < 0){
				ary.set(i, 0);
			}
		}
		int sum = 0;
		for(int n : ary){
			sum += n;
		}
		return sum;
	}
}



Measured memory_bytes: 59804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    
    int n;
    long long int sum1 = 0, sum2 = 0;

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

    long long int minDiff = -1;
    
    for(int i = 0; i < n - 1; i++){
        sum1 -= a[i];
        sum2 += a[i];
        long long int diff = abs(sum1 - sum2);
        if(diff < minDiff || minDiff == -1){
            minDiff = diff;
        }
    }
    printf("%lld\n", minDiff);

    return 0;
}

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

using namespace std;

int main(void)
{
	for (int i = 0; i < 5; i++) {
		int x;
		cin >> x;
		if (x == 0) {
			cout << i+1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3580
while 1:
    m, nmin, nmax = map(int, input().split())
    if m == 0:
        break

    score = []
    for _ in range(m):
        score.append(int(input()))
    score.sort(reverse=True)

    ans = 0
    num = 0
    for i in range(nmin, nmax+1):
        gap = score[i-1] - score[i]
        if gap >= ans:
            ans = gap
            num = i

    print(num)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std; 
int n,m;
vector<int>v[100010];
int low[100010];
int pa[100010];
int dp[100010];
bool vis[100010];
int ans;
void dfs(int pos,int dep){
	low[pos]=dp[pos]=dep;
	vis[pos]=1;
	for(int i=0;i<v[pos].size();i++){
		int to=v[pos][i];
		if(to==pa[pos])continue;
		if(vis[to])low[pos]=min(low[pos],low[to]);
		else{
			pa[to]=pos;
			dfs(to,dep+1);
			low[pos]=min(low[pos],low[to]);
		}
	}
}
set<int>s;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0,0);
	for(int i=0;i<n;i++){
		if(low[i]==dp[i])ans++;
		//else s.insert(low[i]);
	}
	cout<<ans-1<<endl;
    return 0; 
}/*
7 7
1 3
2 7
3 4
4 5
4 6
5 6
6 7
*/

Measured memory_bytes: 6012
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2])puts("Yes");
	else if(s[1]==s[2]&&s[2]==s[3])puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();

		if(n >= 10) {
			System.out.println(r);
		}
		else {
			r = r + (100 * (10 - n));
			System.out.println(r);
		}

		sc.close();

	}

}


Measured memory_bytes: 35624
#include<bits/stdc++.h>
#define F(a,b,c,d) for (register int a=b;a<=c;a+=d)
#define FD(a,b,c,d) for (register int a=b;a>=c;a-=d)
using namespace std;
int main(){
	int n,ans=0;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int k;
		cin>>k;
		ans+=k-1;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
using vi = vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int di[] = {0, 0, -1, 1, -1, 1, -1, 1}; //右、左、マイナス、プラス
int dj[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
//manip
template<class T> bool chmax(T &a, T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, T &b) {if (a > b) {a = b; return 1;} return 0;}
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0

int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    int w, h;
    while (cin >> w >> h && w) {
        int table[2 * h - 1][2 * (w - 1) + 1];
        rep(i, 2 * h - 1) rep(j, 2 * (w - 1) + 1) table[i][j] = 0;
        rep(i, 2 * h - 1) {
            rep(j, w - 1) {
                if (i % 2 == 0) {
                    cin >> table[i][j * 2 + 1];
                } else {
                    cin >> table[i][j * 2];
                }
            }
            if (i % 2 != 0) cin >> table[i][2 * (w - 1)];
        }
        //rep(i, 2 * h - 1) {rep(j, 2 * (w - 1) + 1) cout << table[i][j] << " "; cout << endl;}
        queue<pii> q;
        q.push(pii(0, 0));
        table[0][0] = 1;
        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            rep(k, 4) {
                int ny = i + di[k] * 2;
                int nx = j + dj[k] * 2;
                if (ny < 0 || ny >= 2 * h - 1 || nx < 0 || nx >= 2 * (w - 1) + 1) continue;
                if (table[ny][nx]) continue;
                if (table[(ny + i) / 2][(nx + j) / 2]) continue;
                table[ny][nx] = table[i][j] + 1;
                q.push(pii(ny, nx));
            }
        }
        //cout << endl; rep(i, 2 * h - 1) {rep(j, 2 * (w - 1) + 1) cout << table[i][j] << " "; cout << endl;}
        cout << table[2 * h - 1 - 1][2 * (w - 1) + 1 - 1] << endl;
        
    }
    
}
//cast caution



/*
 o 1 o
 0   1
 o 0 o
 1   0
 o 1 o
 
 oのとこがマスに対応
 
 
 
 
 */





Measured memory_bytes: 3116
#include<stdio.h>

int main(void){
  int apple = 0;
  int applepiece = 0;
  int applepie = 0;
  
  scanf("%d %d", &apple, &applepiece);
  
  applepie = (apple * 3 + applepiece) / 2;
  
  printf("%d\n", applepie);
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var M = sc.nextInt();
        var arr = new long[N, 3];
        for (int i = 0; i < N; i++) {
            arr[i, 0] = sc.nextLong();
            arr[i, 1] = sc.nextLong();
            arr[i, 2] = sc.nextLong();
        }

        var D = 3;
        var ans = new long[8];
        for (int i = 0; i < (1 << D); i++) {
            var hoge = new long[N];
            for (int k = 0; k < N; k++) {
                long sum = 0;
                for (int j = 0; j < D; j++) {
                    if ((1 & i >> j) == 1) {
                        sum += arr[k, j];
                    } else {
                        sum -= arr[k, j];
                    }
                }
                hoge[k] = sum;
            }
            ans[i] = hoge.OrderByDescending(l => l).Take(M).Sum();
        }
        WriteLine(ans.Max());
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {


        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

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

string divide[4] = { "dream", "dreamer", "erase", "eraser"};
int main() {
    string S; cin >> S;
  
  reverse(S.begin(), S.end());
  
  for(int i = 0; i< 4;i++) reverse(divide[i].begin(), divide[i].end());
  
  bool can = true;
  
  for(int i = 0; i<S.size();){
    bool can2 = false;
    for(int j = 0;j<4;j++){
      string d = divide[j];
      if(S.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

const long X=10000000000;

int main(){
	while(1){
		int n;
		scanf(" %d", &n);
		if(n==0) break;
		
		long sig[1000]={0}; //signals
		
		for(int i=0; i<n; ++i){
			string s;
			cin >> s;
			if(s=="x") sig[i]=X;
			else{
				istringstream iss(s);
				iss >> sig[i];	
			}
		}
		
		//for(int i=0; i<n; ++i) printf("sig[%d]= %d\n", i, sig[i]);
		
		//small????????§?????????big???????°??????????????????°????????????
		long big=2000000000, small=-2000000000;
		bool noans=false;
		
		for(int i=0; i<n-1; ++i){
			if(sig[i]==X && sig[i+1]==X) noans=true;	
		}
		
		if(noans) printf("none\n");
		else{
			for(int i=0; i<n; ++i){	
				if(sig[i]==X){
					if(i%2==0){ //?\???°???????????????, big?????´??°
						long tmp=2000000000;
						
						if(i-1>=0) tmp=min(tmp, sig[i-1]);
						if(i+1<n) tmp=min(tmp, sig[i+1]);
						
						big=min(big,tmp);
					}
					else{ //??¶??°??????????????????small?????´??°
						long tmp=-2000000000;
						
						if(i-1>=0) tmp=max(tmp, sig[i-1]);
						if(i+1<n) tmp=max(tmp, sig[i+1]);
						
						small=max(small,tmp);
					}	
				}
				else{
					if(i%2==0){ //?\???°???????????????, ?¢????
						if(i-1>=0 && sig[i-1]!=X && sig[i-1]<sig[i]) noans=true;	
						if(i+1<n && sig[i+1]!=X && sig[i+1]<sig[i]) noans=true;
					}
					else{ //??¶??°???????????????????¢????
						if(i-1>=0 && sig[i-1]!=X && sig[i-1]>sig[i]) noans=true;	
						if(i+1<n && sig[i+1]!=X && sig[i+1]>sig[i]) noans=true;
					}						
				}
				
				if(noans) break;
			}
			
			//printf("big=%d, small=%d\n", big, small);
			
			if(noans || big-small<=1) printf("none\n");
			else if(big-small==2) printf("%d\n", big-1);
			else printf("ambiguous\n");
		}		
	}
}

Measured memory_bytes: 1288
S = list(input())
odd_easy_steps = ["R", "U", "D"]
event_easy_steps = ["L", "U", "D"]
is_easy_step = True
for i, s in enumerate(S):
    index = i + 1
    if index % 2 == 0 and s not in event_easy_steps:
        is_easy_step = False
        break
    elif index % 2 != 0 and s not in odd_easy_steps:
        is_easy_step = False
        break
print("Yes" if is_easy_step else "No")


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

pub 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")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let s: i64 = read();
    println!("{}",  (s / 500) * 1000 + ((s % 500) / 5) * 5);
}


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

int main(){
  int n; cin>>n;
  vector<long long> a(n);
  
  for(int i=0;i<n;i++)cin>>a[i];
  
  sort(a.rbegin(),a.rend());
  
  long long l=-1,m=-1;
  for(int i=0;i<n-1;i++){
    if(l==-1){
      if(a[i]==a[i+1]){
        l=a[i];
        i++;
      }
    }else{
      if(a[i]==a[i+1]){
        m=a[i];
        break;
      }
    }
  }
  if(m==-1){
    cout<<0<<endl;
  }else{
    cout<<l*m<<endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  map<int, int> x;
  for (int i = 0; i < n; i++) x[a[i]] += 1;
  int ans = 0;
  for (int i = 0; i < 100001; i++) {
    ans = max(ans, x[i - 1] + x[i] + x[i + 1]);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
	return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
	return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
	int n, a[21], b[21], c[21];
	scanf("%d", &n);

	int i, j, k;
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (i = 0; i < n - 1; i++)
		scanf("%d", &c[i]);
	c[19] = 0;

	int prev, now, sum = 0;
	prev = -2;
	for (i = 0; i < n; i++)
	{
		now = a[i] - 1;
		if (now == prev + 1)
			sum += c[prev];
		sum += b[now];
		prev = now;
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
import collections

n = int(input())
A = list(map(int, input().split()))
S = sorted(list(set(A)), reverse=True)
c = collections.Counter(A)

L = []
for s in S:
    if c[s] > 3:
        L.append(s)
        L.append(s)
    elif c[s] > 1:
        L.append(s)
    if len(L) > 1:
        print(L[0]*L[1])
        break
else:
    print(0)


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


int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v(n,0);
  lp(i,m){
    string s;
    cin>>s;
    lp(j,n){
      if(s[j]=='W'){
        v[j]--;
      }
      else{
        v[j]++;
      }
    }
  }
  int sum=0,mini=0,ans=-1;
  lp(i,n){
    sum+=v[i];
    if(mini>sum){
      mini=sum;
      ans=i;
    }
  }
  cout<<ans+1<<" "<<ans+2<<endl;
}



Measured memory_bytes: 3220
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 30;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector< vector<int> > G(N);
    for(int i=0; i+1<N; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    vector<int> lis(N+1, INF), ans(N);
    auto dfs = [&](auto &&self, int cur, int par) -> void {
        int k = lower_bound(lis.begin(), lis.end(), A[cur]) - lis.begin();
        int rec_v = lis[k];
        lis[k] = A[cur];
        ans[cur] = lower_bound(lis.begin(), lis.end(), INF) - lis.begin();
        for(auto to : G[cur]) {
            if(to == par) continue;
            self(self, to, cur);
        }
        lis[k] = rec_v;
    };
    dfs(dfs, 0, -1);

    for(int i=0; i<N; i++) cout << ans[i] << endl;
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long

void add(int &a,int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}

int32_t main()
{
    //sbs();
    // int t;cin>>t;
    // while(t--) {
        
    //     cout<<'\n';
    // }
    string s,t;cin>>s>>t;
    int n=s.length(),m=t.length();
    std::vector<vi> dp(n+1,vi(m+1));
    for(int i=0;i<=n;i++)dp[i][0]=0;
    for(int i=0;i<=m;i++)dp[0][i]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }else {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    if(dp[n][m]==0){
        cout<<""<<endl;return 0;
    }
    string ans;
    int i=n,j=m;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
            ans=s[i-1]+ans;
            i--;j--;
        }else {
            if(dp[i][j-1]>dp[i-1][j]){
                j--;
            }else i--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70784
import kotlin.random.Random
fun main(args: Array<String>) {
    var D = readLine()!!.toInt()
    var c = readLine()!!.split(" ").map{it.toInt()}

    val s = mutableListOf<List<Int>>()
    for(i in 0 until D) {
        s.add(readLine()!!.split(" ").map{it.toInt()})
    }

    for(i in 0 until D) {
        val randomInt = Random.nextInt(26)
        println(randomInt + 1)
    }
}

Measured memory_bytes: 39936
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}

# 一桁で0のときの対応
if sc == [] and N == 1:
    print(0)
    exit()
if sc == [[1, 0]] and N == 1:
    print(0)
    exit()

# 文字を組み立てます。
for k in sc:
    if k[0] in dic:
        if dic[k[0]] != k[1]:  # 重なったら即アウト
            print(-1)
            exit()
    else:
        dic[k[0]] = k[1]
ans = 0

if 1 in dic and dic[1] == 0:  # 一桁めが存在するかどうか判定している。
    print(-1)
    exit()
for k in dic:
    ans += 10**(N - k) * dic[k]
if ans < 10**(N - 1):
    ans += 10**(N - 1)
print(ans)


Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AColorfulSubsequence solver = new AColorfulSubsequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class AColorfulSubsequence {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();

            long[] chars = new long['z' - 'a' + 1];
            for (int i = 0; i < n; i++) {
                chars[s.charAt(i) - 'a']++;
            }
            long ans = 1;
            long MOD = (long) 1e9 + 7;
            for (int i = 0; i < 'z' - 'a' + 1; i++) {
                ans = (ans * (chars[i] + 1)) % MOD;
            }

            out.println((ans + MOD - 1) % MOD);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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



Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	ll n,m;
	cin >> n >> m;
	vector<pair<int,int> > arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i].first >> arr[i].second;
	}
	sort(arr.begin(),arr.end());

	int cursor = 0;
	ll ans = 0;
	while(m>0&&cursor<arr.size()) {
		pair<int,int> p = arr[cursor];
		ll num = p.first;
		ll amt = p.second;
		ans += num * min(amt,m);
		m -= amt;
		cursor++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    if((a and b) or c) cout << "Open" << endl;
    else cout << "Close" << endl;
    return 0;
}




Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    string str;
    cin>>str;
    string ans;
    for(int i=0;i<str.size();i++){
        if(str[i]=='0') ans+='0';
        else if(str[i]=='1') ans+='1';
        else if(!ans.empty()) ans.pop_back();
        
    }
    cout<<ans;
    
    return 0;
}

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

int main(){
string a,b;
  cin>>a>>b;
  if(a.size()>b.size()){
    cout<<"GREATER"<<endl;
  }
  else   if(a.size()<b.size()){
    cout<<"LESS"<<endl;
  }
  else{
  for(int i=0;i<a.size();i++){
    if(a[i]==b[i]){
      if(i!=a.size()-1){
      continue;
    }
    else{
      cout<<"EQUAL"<<endl;
    }
    }
    else if(a[i]>b[i]){
         cout<<"GREATER"<<endl;
      break;
  }
  else{
    cout<<"LESS"<<endl;
    break;
  }
  }
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << (s[0] == s[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0;
    int r=n-1;
    int cnt=0;
    int min1=1e9;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            cnt++;
    }
    min1=min(cnt,n-cnt);
    int sum=0;
    while(l<r)
    {
        while(s[r]!='R'&&l<r)
        {
            r--;
        }
        if(l>=r)
            break;
        while(s[l]!='W'&&l<r)
        {
            l++;
        }
        if(l>=r)
            break;
        sum++;
        r--;
        l++;
    }
    min1=min(min1,sum);
    cout<<min1<<'\n';



}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);CIN(B);
    COUT(N-1+(N<=B?+1:+0));
    return 0;
}


Measured memory_bytes: 256