akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

const int MOD = 1000000007;

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int K, T ;
    cin >> K >> T;
    int iMax = 0;

    REP(i,T)
    {
        int a;
        cin >> a;
        iMax = max(iMax, a);
    }

    int res = max(0, iMax - (K - iMax + 1));

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  private void run() {

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

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      int[] mHeap = new int[heapSize+1];
      mHeap[0] = heapSize;
      for(int i=1; i<=heapSize; i++)
        mHeap[i] = Integer.parseInt( keys[i-1] );

      buildMaxHeap(mHeap);

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<mHeap.length; i++) 
        buf.append(" ").append(mHeap[i]);

      System.out.println(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
  private void buildMaxHeap(int[] heap) {
    for(int i= heap[0]/2; i>0; i--)
      maxHeapify(heap, i);
  }
  private void maxHeapify(int[] heap, int node) {
    int t,left,right,largest;
    left  = nodeLeft(node);
    right = nodeRight(node);

    if( (left <= heap[0]) && (heap[left] > heap[node]) )
      largest = left;
    else
      largest = node;
    if( (right <= heap[0]) && (heap[right] > heap[largest]) )
      largest = right;

    if( largest != node ) {
      t = heap[node]; heap[node] = heap[largest]; heap[largest] = t;

      maxHeapify(heap, largest);
    }
  }
  private int nodeLeft(int node) {
    return node*2;
  }
  private int nodeRight(int node) {
    return node*2+1;
  }
}


Measured memory_bytes: 75216
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int N=404404;
int fac[N],ifac[N];
int n,m,p=1e9+7;
ll ans=0;
ll power(int a,int b){
	int sum=1;
	for (; b; b>>=1){
		if (b&1)	sum=1ll*sum*a%p;
		a=1ll*a*a%p;
	}
	return sum;
}
ll C(int n,int m){
	return 1ll*fac[n]*ifac[m]%p*ifac[n-m]%p;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	ifac[0]=fac[0]=1;
	for (int i=1; i<=n; i++)	fac[i]=1ll*fac[i-1]*i%p;
	ifac[n]=power(fac[n],p-2);
	for (int i=n-1; i>=1; i--)	ifac[i]=1ll*ifac[i+1]*(i+1)%p;
	ll ans=1;
	if (k>=n-1)	k=n-1;
	for (int i=1; i<=k; i++)
		ans=(ans+C(n,i)*C(n-1,i)%p)%p;
	printf("%lld\n",ans);
	return 0;
}

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

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

    vector<ll> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    int ans = 0;
    int count = 0;
    int c = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (h[i] >= h[i+1]) {
            ++count;
        } else {
            c = count;
            count = 0;
        }
        ans = max({ans, c, count});
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
N,M = map(int,input().split(' '))
sections = [list(map(int,input().split(' '))) for _ in range(M) ]

'''
tmp_list = [sections[0]]
for i in range(1,len(sections)):
    for j in range(i):
        if sections[i] < tmp_list[j]:
            tmp_list.insert(j,sections[i])
            break
        if j == i -1:
            tmp_list.append(sections[i])
'''
min_end = 10000000000000000
sorted_list = sorted(sections)
cnt = 0
for section in sorted_list:
    if min_end <= section[0]:
        cnt += 1
        min_end = min_end = 10000000000000000
    min_end = min(min_end,section[1])
cnt += 1
print(cnt)


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

const int N = 1e5 + 10;

map< pair<int, int>, int > ans;
int k = 0;

vector<int> G[N];
set<int> colors[N];

void dfs(int v, int p) {
    int c = 1;
    for(int u : G[v]) {
        if(u == p) continue;
        while(colors[u].find(c) != colors[u].end() or colors[v].find(c) != colors[v].end()) c++;
        ans[{u,v}] = c;
        ans[{v,u}] = c;
        colors[u].insert(c);
        colors[v].insert(c);
        k = max(k, c);
        dfs(u, v);
    }

}

int main() {
    ios::sync_with_stdio(false);

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

    dfs(1, -1);
    cout << k << '\n';
    for(auto p : edges) {
        cout << ans[p] << '\n';
    }


    return 0;
}

Measured memory_bytes: 33400
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;

int main() {
  string s, t;
  int ans = 1e9;
  cin >> s >> t;
  REP(i, s.size()) {
    if (i + t.size() > s.size())
      break;
    int cnt = 0;
    REP(j, t.size()) {
      if (s[i + j] != t[j])
        cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int num_ppl, num_inv;
    scanf("%d%d", &num_ppl, &num_inv);
    char status[num_ppl+1];
    scanf("%s", status);
    int cmltv_sum_stnd[num_ppl];
    int cmltv_sum_hstnd[num_ppl];
    cmltv_sum_stnd[0] = 0 ; cmltv_sum_stnd[1] = 0;
    cmltv_sum_hstnd[0] = 0; cmltv_sum_hstnd[1] = 0;
    int x=1;
    char pre_status = '1';
    for(int i=0; i<strlen(status); i++){
        if(pre_status == '1' && status[i] == '0'){
            x++;
            cmltv_sum_stnd[x] = cmltv_sum_stnd[x-1];
            cmltv_sum_hstnd[x] = cmltv_sum_hstnd[x-1];
        }
        if(status[i] == '0'){
            cmltv_sum_stnd[x]++;
        }else{
            cmltv_sum_hstnd[x]++;
        }
        pre_status = status[i];
    }
    /*for(int i=0; i<=x; i++){
        printf("%d ", cmltv_sum_stnd[i]);
    }
    printf("\n");
    for(int i=0; i<=x; i++){
        printf("%d ", cmltv_sum_hstnd[i]);
    }
    printf("\n");*/
    int first = 1, last = x < num_inv+1?x:num_inv+1;
    int max = 0;
    while(last <= x){
        if(max < cmltv_sum_hstnd[last]-cmltv_sum_hstnd[first-1] + cmltv_sum_stnd[last]-cmltv_sum_stnd[first]){
            max = cmltv_sum_hstnd[last]-cmltv_sum_hstnd[first-1] + cmltv_sum_stnd[last]-cmltv_sum_stnd[first];
            //printf("%d %d\n", first, last);
        }
        first++;
        last++;
    }
    printf("%d", max);

    return 0;
}

Measured memory_bytes: 640
///***Bismillahir Rahmanir Rahim***///

///*********************************///
///******Ashraful Haque Toni********///
///********Dept. of CSE,JnU*********///
///email:ashrafulhaquetoni@gmail.com///
///*******contact:01640690531*******///
///*********************************///


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb push_back
#define         mp make_pair
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d%d",&m,&n);
#define         sc2l(m,n) scanf("%I64d%I64d",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

const int mod =1e9+7;
const int N =5e6+5;
typedef long long ll;



int main()
{

    ash;
    ll a,b,c=1,cnt=0;
    cin>>a>>b;
    for(int i=1;i<=a;i++)
    {
        int k,m=0;
        cin>>k;
        cnt+=k;
        //if(m==0)c++;
        if(cnt<=b){
            c++;
        }

    }
    cout<<c<<endl;



    return 0;
}




Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		while(true){
			int N = scn.nextInt();
			if(N==0) break;
			int W = scn.nextInt();
			int H = scn.nextInt();
			int[][] map = new int[W+1][H+1];
			while(N-->0){
				map[scn.nextInt()][scn.nextInt()]++;
			}
			int S = scn.nextInt();
			int T = scn.nextInt();
			int max=0;
			for(int s=1;s<=W-S+1;s++){
				for(int t=1;t<=H-T+1;t++){
					int count=0;
					for(int a=s;a<s+S;a++){
						for(int b=t;b<t+T;b++){
							count+=map[a][b];
						}
					}
					if(max<count){
						max = count;
					}
				}
			}
			pr.println(max);
		}
		pr.flush();
		scn.close();
	}

}

Measured memory_bytes: 49940
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

const int N = 100005;
const int LG = 19;
const int MOD = 1e9 + 7;
const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;

int a[N];
ll dp[N][2];
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[1][0] = a[1];
    dp[1][1] = -INFLL;
    for (int i = 2; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
        dp[i][1] = max(dp[i - 1][0] - 2 * a[i - 1] - a[i], dp[i - 1][1] + 2 * a[i - 1] - a[i]);
    }
    cout << max(dp[n][0], dp[n][1]) << endl;
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  long long N,M;
  cin>>N>>M;
  if(N==1&&M==1){
    cout<<1<<endl;
  }else if(N==1){
    cout<<M-2<<endl;
  }else if(M==1){
    cout<<N-2<<endl;
  }else{
    cout<<(M-2)*(N-2)<<endl;
  }
  

  
}


  
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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; }

int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n),b;
	for(int i=0;i<n;++i){
		cin >> a[i];
	}
	for(int i=n-1;i>=0;i-=2){
		cout << a[i] <<" ";
	}
	if(n%2==0){
		for(int i=0;i<n;i+=2){
			cout << a[i] <<" ";
		}
	}else{
		for(int i=1;i<n;i+=2){
			cout << a[i] <<" ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
intInput = int(input())
a, b, c, d, e, f = 500, 100, 50, 10, 5, 1
sumResult = 0

num500 = intInput // 500
mod500 = intInput % 500
sumResult += num500 * 1000
num5 = mod500 // 5
sumResult += num5 * 5
print(sumResult)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll MOD;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

const int N = 3020;
int n;
ll C[N][N];
ll D[N][N];
ll p2[N * N];
ll pp2[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%lld", &n, &MOD);

	for (int i = 0; i < N; i++)
		C[i][0] = C[i][i] = 1;
	for (int i = 1; i < N; i++)
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
	p2[0] = 1;
	for (int i = 1; i < N * N; i++)
		p2[i] = add(p2[i - 1], p2[i - 1]);
	pp2[0] = 2;
	for (int i = 1; i < N; i++)
		pp2[i] = mult(pp2[i - 1], pp2[i - 1]);

	D[0][0] = 1;
	for (int i = 0; i < N - 2; i++)
		for (int j = 0; j <= i; j++) {
			D[i + 1][j] = add(D[i + 1][j], mult(D[i][j], j));
			D[i + 1][j + 1] = add(D[i + 1][j + 1], D[i][j]);
		}

	ll ans = 0;
	for (int k = 0; k <= n; k++) {
		ll res = 0;
		for (int p = 0; p <= k; p++) {
			ll cur = add(D[k][p], mult(D[k][p + 1], p + 1));
			res = add(res, mult(cur, p2[p * (n - k)]));
		}
		res = mult(res, pp2[n - k]);
		res = mult(res, C[n][k]);
		if (k & 1)
			ans = sub(ans, res);
		else
			ans = add(ans, res);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 214144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, C, K;
  cin >> N >> C >> K;
  int ans = 0;
  long long buss_time = 0, buss_count = 0;
  vector<int> T(N);
  rep(i, N)
  {
    cin >> T[i];
  }
  SORT(T);
  rep(i, N)
  {
    if (buss_time < T[i] || buss_count >= C)
    {
      ans++;
      buss_time = T[i] + K;
      buss_count = 1;
    }
    else
      buss_count++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int a[1000];
    for(int i=0; i<m; i++){
        cin >> a[i];
    }
    int lCost=0, rCost=0;
    for(int i=x; i<=n; i++){
        for(int j=0; j<m; j++){
            if(i==a[j]) rCost++;
        }
    }
    for(int i=x; i>=0; i--){
        for(int j=0; j<m; j++){
            if(i==a[j]) lCost++;
        }
    }
    cout << min(lCost, rCost) << endl;
    return 0;
}

Measured memory_bytes: 256
# ABC 135

N = int(input())
A = [int(i) for i in (input().split())]
B = [int(i) for i in (input().split())]
cnt = 0 
for i in range(len(A)-1):

    cnt += min(A[i]+A[i+1],B[i])
    if A[i] < B[i]:
        A[i+1] = max(A[i+1] - (B[i] - A[i]),0)
print(cnt)

Measured memory_bytes: 19648
n = int(input())
d = [[int(e) for e in input().split()] for i in range(n)]
f = [None for i in range(n)]
f[0] = d[0]
for i in range(1, n):
  f[i] = [max(f[i - 1][1] + d[i][0], f[i - 1][2] + d[i][0]), max(f[i - 1][0] + d[i][1], f[i - 1][2] + d[i][1]), max(f[i - 1][0] + d[i][2], f[i - 1][1] + d[i][2])]
print(max(f[n - 1]))


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  if (S.size() <= K){
    cout << S << endl;
  }
  else {
    for (int i=0; i<K; i++){
      cout << S[i];
    }
    cout << "..." << endl;
  }
  
 
}


Measured memory_bytes: 3632
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
L=[0];ct=0
for i in range(n-1):
  if s[i:i+2]=='AC':
    ct+=1
  L.append(ct)
for j in range(q):
  print(L[l[j][1]-1]-L[l[j][0]-1])

Measured memory_bytes: 30704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if (op.equals("?"))
				break;
			if (op.equals("+")) {
				System.out.println(a + b);
			} else if (op.equals("-")) {
				System.out.println(a - b);
			} else if (op.equals("*")) {
				System.out.println(a * b);
			} else if (op.equals("/")) {
				System.out.println(a / b);
			}

		}
	}

}



Measured memory_bytes: 26356
#include <cstdio>
#include <cctype>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

#define m(a, b, c) make_tuple(a, b, c)

int main() {
	vector<tuple<string, double, double>> r =
	{m("AAA", 35.5, 71), m("AA", 37.5, 77), m("A", 40, 83), m("B", 43, 89),
	m("C", 50, 105), m("D", 55, 116), m("E", 70, 148), m("NA", 361, 361)};
	for (double a, b; scanf("%lf %lf", &a, &b) != EOF;)
		for (auto t: r)
			if (a < get<1>(t) && b < get<2>(t)) {
				outl(get<0>(t));
				break;
			}
}


Measured memory_bytes: 2644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,temp,sum=0;
    cin>>n>>k;
    temp=k;
    if(n>=k)
    {
        if(k==1)
            cout<<"0"<<endl;
        else
        cout<<"1"<<endl;
    }
    else
    {
       int flag=1, num=n-1;
       while(temp>n)
       {
           sum=sum+num;
           temp=k-sum;
           flag++;
       }
    cout<<flag<<endl;
    }
}


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

int main(){
    int N,K,num=1;
    cin >> N >> K;

    for(int i = 0; i < N; i++){
        if(num*2 <= num + K){
            num *= 2;
        }
        else{
            num += K;
        }       
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
typedef long long ll;
int main() {
    ll n, d;
    cin >> n >> d;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d) cnt++;
    }
    printf("%d\n", cnt);
}


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

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string []Ni = Console.ReadLine().Split(' ');
            int N = Convert.ToInt32(Ni[0]);
            int i = Convert.ToInt32(Ni[1]);
            Console.WriteLine(N - i + 1);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27536
#include<stdio.h>

#define MAX 101
#define INFTY -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[MAX][MAX],colar[MAX],d[MAX],Q[MAX];
int head,tail,n;

void enqueue(int x){
  Q[tail]=x;
  tail++;
}

int dequeue(){
  head++;
  return Q[head-1];
}

void bfs(int s){
  int i,u,v;

  d[s]=0;
  colar[s]=GRAY;
  enqueue(s);

  while(head!=tail){
    u=dequeue();
    for(v=1;v<=n;v++){
      if((M[u][v]==1)&&(colar[v]==WHITE)){
	colar[v]=GRAY;
	d[v]=d[u]+1;
	enqueue(v);
      }
    }

    colar[u]=BLACK;
  }
}

int main(){
  int i,j,k,u,v,max=0,count=0;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    d[i]=INFTY;
    colar[i]=WHITE;
    for(j=1;j<=n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      M[u][v]=1;
    }
  }

  bfs(1);

  for(i=1;i<=n;i++){
  printf("%d %d\n",i,d[i]);
  }

  return 0;
}



Measured memory_bytes: 2064
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut m: usize = 0;
    for i in 1..=k {
        m = m * 10 + 7;
        m %= k;
        if m == 0 {
            return i.to_string();
        }
    }
    "-1".to_string()
}


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

unsigned long long N,A,B,pc[10000007],a[10000007],ans,dp;

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

    cin >> N >> A >> B;

    for(int i=0;i<N;i++){
        cin >> a[i];
        if(i==0) continue;
        else pc[i] = a[i] - a[i-1];
    }

    for(int i=1;i<N;i++){
        dp = min(pc[i]*A,B);
        ans += dp;
    }

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


Measured memory_bytes: 1792
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int M = sc.nextInt();
        long[] sum = new long[N+1];
        sum[0] = 0;
        for(int i = 1;i <= N;i++){
            sum[i] = sc.nextInt()+sum[i-1];
        }
        Map<Integer, Integer> modN = new HashMap<>();
        for(int i = 0;i <= N;i++){
            int r = (int)(sum[i]%M);
            if(!modN.containsKey(r)) modN.put(r, 1);
            else    modN.put(r, modN.get(r)+1);
        }
        long ans = 0;
        for(Integer key : modN.keySet()){
            long value = modN.get(key);
            ans += value*(value-1)/2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 59384
//Pradeep_7
//double tt = clock();
//if((clock()-tt)/CLOCKS_PER_SEC > 1) break;
#include<bits/stdc++.h>
#define mp make_pair 
#define pb push_back
#define fi first
#define se second 
#define IO ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define ll long long int
#define nn cout<<"\n"
#define tcc int tc;	cin>>tc; while(tc--)
#define arr(a,n)	for(int i=0;i<n;i++)		cin>>a[i]
#define all(a)	a.begin(),a.end()
#define rall(a)	a.rbegin(),a.rend()
using namespace std;
bool vis[10];
bool fun(int n)
{
	while(n!=0)
	{
		if(vis[n%10])
		{
			return false;
		}
		n=n/10;
	}
	return true;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		int p;
		cin>>p;
		vis[p]=true;
	}
	while(!fun(n))
	{
		n++;
	}
	cout<<n;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < 2; ++i) {
    if (n[i] == '9') {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


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

int main() {
  string str;
  cin >> str;
  int K=0;
  for(int i=0; i<str.size(); i++){
      if(i==0){
          cout << str.at(i);
      }
      else if(i==str.size()-1){
          cout << K-1 << str.at(i) << endl;
      }
      K++;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		if(a < b) System.out.println("a < b");
		if(a == b) System.out.println("a == b");
		if(a > b) System.out.println("a > b");

		scan.close();
	}

}



Measured memory_bytes: 25964
#include<cstdio>
#include<map>
#include<cassert>
#include<functional>
#include<string>
#include<cassert>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD(1e9+7);


int n, c, a[444], b[444], d[444][444], p[444][444];

int go(int idx, int c)
{
 if (idx > n) return (c == 0);
 int &ret = d[idx][c];
 if (~ret) return ret;
 ret = 0;

 for (int j = 0; j <= c; j++) {
  ret = (ret + go(idx + 1, c - j)*1LL*
      ((p[b[idx]][j]-p[a[idx]-1][j]+MOD)%MOD) % MOD) % MOD;
 }

 return ret;
}

int main()
{
 scanf("%d%d", &n, &c);
 for (int i = 1; i <= n; i++) scanf("%d", a+i);
 for (int i = 1; i <= n; i++) scanf("%d", b+i);

 for (int i = 1; i <= 400; i++) {
  p[i][0] = 1;
  for (int j = 1; j <= 400; j++)
   p[i][j] = p[i][j-1] *1LL* i % MOD;
  for (int j = 0; j <= 400; j++)
   p[i][j] = (p[i][j] + p[i-1][j]) % MOD;
 }

 memset(d, -1, sizeof d);
 printf("%d\n", go(1, c));
 return 0;
}


Measured memory_bytes: 1664
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	string str;
	while(getline(cin,str)){
		if(str[0]=='0')break;
		stringstream ss;
		ss <<str;
		int x;
		int sum = 0;
		int cnt = 0;
		while(ss>>x){
			if(x==1){
				cnt++;
			}
			if(x >=11){
				x = 10;
			}
			sum +=x;
		}
		for(int i =0;i < cnt;i++){
			if(sum+10<=21){
				sum +=10;
			}else{
				break;
			}
		}
		if(sum >21)sum = 0;
		cout <<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	string board[50];
	for (int i = 0; i < h; i++) {
		cin >> board[i];
	}
	bool can = true;
	const int dx[4] = { -1,1,0,0 };
	const int dy[4] = { 0,0,-1,1 };
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (board[i][j] == '.')continue;
			bool flag = true;
			for (int d = 0; d < 4; d++) {
				int ni = i + dx[d];
				int nj = j + dy[d];
				if (ni < 0 || h <= ni)continue;
				if (nj < 0 || w <= nj)continue;
				if (board[ni][nj] == '#') flag = false;
			}
			if (flag) can = false;
		}
	}
	if (can) cout << "Yes" << endl;
	else { cout << "No" << endl; }
}

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

struct node{
	int x;int y;
}aa[456];

bool cmp(node a,node b)
{
	return atan2(a.x,a.y)<atan2(b.x,b.y);
}
int main()
{
	long long n,x,y;
	long long ans=0;
	cin>>n;
	for(int i=0;i<n;i++)	cin>>aa[i].x>>aa[i].y;
	sort(aa,aa+n,cmp);
	for(int i=0;i<n;i++)
	{
		x=aa[i].x;y=aa[i].y;
		ans=max(ans,x*x+y*y);
		for(int j=(i+1)%n;j!=i;j=(j+1)%n)
		{
			x+=aa[j].x;y+=aa[j].y;
			ans=max(ans,x*x+y*y);
		}
	}
	double res=sqrt(ans);
	printf("%.13lf\n",res);
	return 0;
}

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

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    cin >> n;
    string str;
    cin >> str;

    ll ans = 0;
    i = 0;
    while (i < n) {
        char ch = str[i];
        j = i;
        ans++;
        while (j < n && str[j] == str[i]) {
            j++;
        }
        i = j;
    }

    cout << ans << "\n";

    return 0;
}




Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
long n,r,l=-1,m,c,s,i,j,a[1<<17];
main(){
	for(cin>>n;cin>>m;r=r<m?m:r)a[j++]=m;
	for(;r-l>1;(c>n*(n+1)/4?r:l)=m){
		int b[2*n]={};
		m=l+r>>1;
		for(j=n;j<=2*n;j+=j&-j)b[j]++;
		for(c=s=i=0;i<n;){
			s+=a[i++]>m?-1:1;
			for(j=s+n-1;j>0;j-=j&-j)c+=b[j];
			for(j=s+n;j>0&&j<=2*n;j+=j&-j)b[j]++;
		}
	}
	cout<<r;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
int N;
char mat[510][510];
int ans = inf;
int ok = 0;
bool flag = false;
int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            cin >> mat[i][j];
            if(mat[i][j] == '#') flag = true;
        }
    }
    for(int i = 1; i <= N; i++){
        int cnt1 = 0;
        int cnt2 = 0;
        for(int j = 1; j <= N; j++){
            if(mat[i][j] == '.') cnt1++;
            if(mat[j][i] == '#') cnt2++;
        }
        
        if(cnt2 != 0) chmin(ans, cnt1);
        else chmin(ans, cnt1 + 1);
        if(cnt2 == N) ok++;
    }
    cout << (flag ? ans + N - ok : -1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9'){ x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
	return x*f;
}
const int N=1e5+7;
int n,m,ans;
struct Node{
	int a,b;
	bool operator < (const Node &x)const {
		return a < x.a;
	}
}t[N];
priority_queue<int>q;
int main()
{
	n=read() ,m=read();
	for(int i=1;i<=n;++i) {
		t[i].a=read(),t[i].b=read();
	}
	sort(t+1,t+1+n);
	for(int i=1,j=1;i<=m;++i) {
		for(;j<=n;++j) {
			if(i<t[j].a) break;
			q.push(t[j].b);
	    }
		if(!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main() {
	cout << fixed << setprecision(10);
	while (true) {
		double n;
		cin >> n;
		if (n == 0)break;
		vector<int> score(n);
		double total = 0;
		for (int i = 0; i < n; i++) {
			cin >> score.at(i);
			total += score.at(i);
		}
		double average = total / n;
		double sigma;
		double zan = 0;
		for (int i = 0; i < n; i++) {
			zan += (score.at(i) - average) * (score.at(i) - average);
		}
		sigma = zan / n;
		cout << sqrt(sigma) << endl;
	}
}


Measured memory_bytes: 3212
#include<stdio.h>
int main(void){
  
  int i;
  char c[3];
  int ct=0;
  
  
  for(i=0;i<3;i++){
    scanf("%c",&c[i]);
  }
  
  for(i=0;i<3;i++){
    if(c[i]=='o')ct++;
  }
  
  printf("%d\n",700+100*ct);
  
  return 0;
}

Measured memory_bytes: 1596
#include <iostream>
using namespace std;
long long pow26(int n) {
    long long result = 1;
    for (int i=0; i<n; i++) {
        result *= 26;
    }
    return result;
}
long long sumofpow26(int n) {
    long long result = 0;
    for (int i=0; i<n; i++) {
        result += pow26(i+1);
    }
    return result;
}
int main() {
    long long n;
    cin >> n;
    int keta = 1;
    while (n > sumofpow26(keta)) {
        keta++;
    }
    //n=0のとき'aaa...a', n=(26^m)-1のとき'zzz...z'となるようにする
    n -= sumofpow26(keta-1) + 1;
    int num[keta];
    string s(keta, 'a');
    for (int i=0; i<keta; i++) {
        num[i] = (n/pow26(i))%26;
        s[keta-i-1] = (char)(num[i]+97);
    }
    cout << s << endl;
}

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

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1)
    {
      c -= b;
      if (c <= 0)
      {
        cout << "Yes" << endl;
        return (0);
      }
      a -= d;
      if (a <= 0)
      {
        cout << "No" << endl;
        return (0);
      }
    }
    return (0);
}

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

int main()
{
  int N;
  cin >> N;
  
  int max = 1;
  int count = 0,maxcount = 0;
  for(int i = 1; i <= N; i++){
      int j = i;
      while( (j % 2) == 0){
        count++;
        j /= 2;
      }
      if(count > maxcount){
        maxcount = count;
        max = i;
      }
      count = 0;
  }
  cout << max << endl;
}


Measured memory_bytes: 3672
a, b = [int(_) for _ in input().split(' ')]

def f0(n):
    l = len(bin(n)) - 2
    v = 0
    for i in range(l):
        if i >= 1:
            m = n % (1 << i + 1)
            if m >= (1 << i):
                v += ((m + 1) % 2 << i)
        else:
            v += ((n + 1) % 4) // 2
    return v

print(f0(b) ^ f0(a - 1))


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

using namespace std;

void hawawa()
{
  int n;
  cin >> n;
  if (n < 1200) {
    cout << "ABC\n";
  } else {
    cout << "ARC\n";
  }
}

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

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

ll dp[110000];

main()
{
        int n,m; cin>>n>>m;
        set<int> s;
        int a;
        rep(i,m)
        {
          cin>>a;
          s.insert(a);
        }

        dp[0]=1;
        rep(i,n+1)
        {
          if(s.find(i)!=s.end())continue;
          dp[i+1]+=dp[i];
          dp[i+1]%=mod;
          dp[i+2]+=dp[i];
          dp[i+2]%=mod;
        }
        cout<<dp[n]<<endl;
}


Measured memory_bytes: 4992
def nears_impl(x, dis, is_minus):
    def cal(x, dis):
        if is_minus:
            r = x - dis
            return r
        else:
            r = x + dis
            return r

    res = cal(x, dis)
    return res


def nears(start_x):
    yield start_x
    i = 1
    while True:
        yield nears_impl(start_x, i, True)
        yield nears_impl(start_x, i, False)
        i += 1


x, n = [int(x) for x in input().split(" ")]
    
if n == 0:
    print(x)
    exit()

p = [int(x) for x in input().split(" ")]

for near in nears(x):
    if near not in p:
        print(near)
        break


Measured memory_bytes: 9212
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int l;
    while(1){
        cin >> l;
        if(l==0) break;

        int cnt =0;
        bool flag = false;
        rep(i,12){
            int a, b;
            cin >>a >> b;
            if(flag) continue;
            cnt += a-b;
            if(cnt >= l){
                cout << i+1 << endl;
                flag = true;
            }
        }
        
        if(cnt<l) cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 2988
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
int main(){
    int N;
    cin >> N;
    int sum = 0;
    int A = N;
    while(A!=0){
        sum =  sum + (A % 10);
        A = A / 10;
    }
    string ans = (N%sum==0)? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
d=[0]*26
mod=10**9+7
for i in range(len(s)):
	d[ord(s[i])-ord("a")]+=1
ans=1
for i in range(26):
	ans*=d[i]+1
	ans%=mod
print((ans+mod-1)%mod)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    vi l(n); rep(i, n) cin >> l[i];
    sort(all(l));
    
    int cnt = 0;
    rep3(i, 0, n - 3){
        rep3(j, i + 1, n - 2){
            rep3(k, j + 1, n - 1){
                if(l[i] == l[j] || l[j] == l[k]) continue;
                if(l[i] + l[j] > l[k]) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3664
n,m=map(int,input().split())
L=[10]*n
for i in range(m):
	s,c=map(int,input().split())
	if L[s-1]==10 or L[s-1]==c:
		L[s-1]=c
	else:
		print(-1)
		exit()
if n==1:
	if L[0]==10:
		print(0)
		exit()
	else:
		print(L[0])
		exit()
else:
	if L[0]==10:
		L[0]=1
	elif L[0]==0:
		print(-1)
		exit()
	for i in range(1,n):
	    if L[i]==10:
	        L[i]=0
	print(''.join(map(str,L)))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int N, M, C;
int A[21][21];
int B[21];

int main()
{
    int ans = 0;

    cin >> N;
    cin >> M;
    cin >> C;

    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j < M; j++) {
            int x;
            cin >> x;
            tmp += x * B[j];
        }
        tmp += C;

        if (tmp > 0) ans++;
    }
    
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,a;
    cin>>n>>a;
    
    if(n==0){
        cout<<"Yes"<<endl;
    }

    else if(n%500<=a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    int n,a,s4=0,s2=0,s1=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%4==0)s4++;
        else if(a%2==0)s2++;
        else if(a%2==1)s1++;
    }
    if(s2==1&&n==1)cout<<"No"<<endl;
    else if(s2==0&&s4+1<s1)cout<<"No"<<endl;
    else if(s2==1&&s4<s1)cout<<"No"<<endl;
    else if(s2!=0&&s4<s1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://apc001.contest.atcoder.jp/tasks/apc001_d>
問題文============================================================
 N 頂点 M 辺の森が与えられます。頂点には 0 から N−1 の番号がついています。
 辺は (xi,yi) の形で与えられます。これは頂点 xi と yi が辺でつながっていることを意味します。
 
 各頂点 i には ai という値が定まっています。 あなたは与えられた森に辺を追加して連結にしたいです。
 辺を追加するときには、まず異なる頂点二つを選択し( i , j とする)、 i と j の間に辺を張ります。
 この時コストが ai+aj かかります。そしてこれ以降，頂点 i と j は永遠に選択できなくなります。
 
 森を連結にする最小コストを求めてください。 連結にするのが不可能な場合はImpossibleと出力してください。
=================================================================

解説=============================================================

================================================================
*/

void dfs(ll n,vector<int>& color,vector<vector<ll>>& G,int color_idx){
    color[n] = color_idx;
    for(auto next:G[n]){
        if(color[next]==-1)dfs(next,color,G,color_idx);
    }
}

ll solve(){
    ll res = 0;
    ll N,M; cin >> N >> M;
    vector<ll> a(N); for(auto &in:a) cin >> in;
    vector<ll> x(M),y(M);
    for(int i = 0; i < M;i++) cin >> x[i] >> y[i];
    if(M == N-1)return res;
    if(N < 2*(N-1-M)) return -1;
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }
    vector<int> color(N,-1);
    int color_idx = 0;
    for(int i = 0;i < N;i++){
        if(color[i]==-1) dfs(i,color,G,color_idx++);
    }
    
    vector<vector<ll>> color_cost(color_idx);
    for(int i = 0; i < N;i++){
        color_cost[color[i]].push_back(a[i]);
    }
    for(auto& array:color_cost)sort(array.begin(),array.end());
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    ll cnt = 2*(N-M-1);
    for(auto& array:color_cost){
        res += array[0]; cnt--;
        for(int i = 1; i < array.size();i++){
            pq.push(array[i]);
        }
    }
    while(cnt--){
        res += pq.top();pq.pop();
    }
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll ans = solve();
    if(ans == -1) cout << "Impossible" << endl;
    else cout << ans << endl;
	return 0;
}


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

vector<long long> divisor (const long long &x) {
    vector<long long> ret;
    for (long long i = 1; i * i <= x; i++) {
        if (x % i == 0) {
            const long long j = x / i;
            ret.push_back(i);
            if (i != j) {
                ret.push_back(j);
            }
        }
    }
    return ret;
}

int main() {
    long long n;
    cin >> n;
    vector<long long> div = divisor(n);
    
    auto f = [](long long x) { return (to_string(x).length()); };
    
    int ans = numeric_limits<int>::max();
    for (const auto &d : div) {
        ans = min(ans, (int)max(f(d), f(n / d)));
    }
    
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int count = 0;

		for (int i=1; i<=k; i++) {
			boolean odd = false;
			if (i%2 == 1) {
				odd = true;
			}
			for (int j=i; j<=k; j++) {
				if ((j%2 == 1) != odd) {
					count++;
				}
			}
		}

		System.out.println(count);

		sc.close();
	}

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pf push_front
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, m;

ll faktorial(ll n){
		ll x=n;
		ll ans=1;
		while(x){
			ans=(ans*x)%mod;
			x--;
		}
		return ans;
	}
	
int main(){
	IOS
	cin >> n >> m;
	if(abs(n-m)>=2){
		cout << 0 << '\n';
	}
	else if(n==m){
		cout << (2*faktorial(n)*faktorial(m))%mod << '\n';
	}
	else{
		cout << (faktorial(n)*faktorial(m))%mod << '\n';
	}
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int n; cin>>n;
  n%=10;
  if(n==3) cout<<"bon"<<endl;
  else if(n==0 || n==1 || n==6 || n==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
  return 0;
}

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

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

int N;
ll A,B;
int pos[5050];

ll from[10101];
ll to[10101];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	FOR(i,N) {
		cin>>x;
		pos[x]=i*2+1;
	}
	
	for(i=1;i<=N;i++) {
		ll mi=1LL<<60;
		FOR(j,2*N+1) {
			mi=min(mi,from[j]);
			if(j%2==0) {
				if(j<pos[i]) to[j]=mi+B;
				if(j>pos[i]) to[j]=mi+A;
			}
			else if(j==pos[i]) to[j]=mi;
			else to[j]=1LL<<60;
		}
		
		swap(to,from);
	}
	
	
	cout<<*min_element(from,from+2*N+1)<<endl;
	
	
}


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


Measured memory_bytes: 384