akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    vector<P> ab(n), cd(n);
    for(int i = 0; i < n; ++i)  cin >> ab[i].first >> ab[i].second;
    for(int i = 0; i < n; ++i)  cin >> cd[i].first >> cd[i].second;
    sort(ab.begin(), ab.end());
    sort(cd.begin(), cd.end());
    ab.emplace_back(n * 2, n * 2);
    int ans = 0;
    vector<bool> used(n, false);
    for(int i = n - 1; i >= 0; --i){
        int bound = ab[i - 1].first;
        int idx = -1, mine = n * 2;
        for(int j = 0; j < n; ++j){
            if(used[j]) continue;
            if(cd[j].first <= ab[i].first)  continue;
            if(cd[j].second <= ab[i].second)    continue;
            if(cd[j].second < mine){
                mine = cd[j].second;
                idx = j;
            }
        }
        if(idx != -1){
            ++ans;
            used[idx] = true;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
 
#define MAX 500001
 
int maxHeapify(int*,int);
int n;
 
int main(){
 
  int i,A[MAX];
 
  scanf("%d",&n);
  for(i=1; i<=n; i++)
    scanf("%d",&A[i]);
 
  for(i=n/2; i>=1; i--){
    maxHeapify(A,i);
  }
 
  for(i=1; i<=n; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
 
  return 0;
}
 
int maxHeapify(int *A,int i){
 
  int l,r,largest,temp;
 
  l = 2*i;
  r = 2*i+1;
 
  if(l <= n && A[l] > A[i]){
    largest = l;
  }else largest = i;
 
  if(r <= n && A[r] > A[largest]){
    largest = r;
  }
 
  if(largest != i){ 
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
   
  maxHeapify(A,largest);
  }
}

Measured memory_bytes: 2552
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;



public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		Integer[] arr = new Integer[n];
		long sum =0;
		for (int i=0; i<n; i++) {
			arr[i]=sc.nextInt();
			sum+=arr[i];
		}
		Arrays.sort(arr);
		int mtaken = 0;
//		System.out.println(sum);
//		System.out.println((1.0/4*m));
//		System.out.println(sum*(1.0/(4*m)));
		double mustbegreaterthanoreq = sum*(1.0/(4*m));
//		System.out.println(mustbegreaterthanoreq);
		for(int i=n-1; i>=0 ;i--) {
			if(arr[i]>=mustbegreaterthanoreq) {
				mtaken++;
//				System.out.println(mtaken);
				if(mtaken==m)
					break;
			}
			else
				break;
		}
		if(mtaken==m)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	


	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 22996
#include<iostream>

using namespace std;

int n,x;
int main(){
    while(true){
        cin>>n>>x;
        if(n==0&&x==0){
            break;
        }
        int num=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        num++;
                    }
                }
            }
        }
        cout<<num<<endl;
    }
}

Measured memory_bytes: 1160
def solve():
    N, M = map(int, input().split())
    A = [list(map(int, input().split())) for i in range(N)]
    dp = [[0] * (M+1) for i in range(N+1)]
    
    for i in range(N):
        for s in range(M+1):
            a, b = A[i]
            if s-a >= 0:
                dp[i+1][s] = max(dp[i+1][s], dp[i][s-a] + b)
            dp[i+1][s] = max(dp[i+1][s], dp[i][s])
    return dp[N][M]

print(solve())

Measured memory_bytes: 120428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define rcin(a,n) rep(i,n)cin >> a[i];
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    int x[n],y[m];
    rcin(x, n);
    rcin(y, m);
    qsort(x, n, sizeof(int), desc);
    qsort(y, m, sizeof(int), asc);
    nfor(i, X + 1, Y + 1){
        if (x[0] < i && y[0] >= i) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N, Y = map(int, input().split())
    Y /= 1000
    for a in range(N + 1):
        for b in range(N + 1 - a):
            c = N - a - b
            # print(a, b, c)
            if 10 * a + 5 * b + 1 * c == Y:
                print(a, b, c)
                return
    print(-1, -1, -1)
if __name__ == '__main__':
    main()


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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }

    bool ans = true;
    int count = 0;
    int wrong = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] != i + 1) {
            if (count == 0) {
                wrong = i;
                count++;
            } else {
                if (i + 1 != P[wrong]) {
                    ans = false;
                }
            }
        }
    }

    if (ans && (count ==  1 || count == 0)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n]={0};
    while(k--){
        int m;
        cin>>m;
        while(m--){
            int x;
            cin>>x;
            x--;
            a[x]++;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++)if(a[i]==0)ans++;
        cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <set>
using namespace std;
int main()
{
    long long b,n;
    set<int>a;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin >> b;
        a.insert(b);
    }
    if(a.size()==n)
        cout << "YES"<<endl;
    else
        cout << "NO"<<endl;
}


Measured memory_bytes: 9600
k = int(input())
lists = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lists[k-1])

Measured memory_bytes: 38256
def examA():
    N = LI()
    N.sort()
    if N==[1,4,7,9]:
        print("YES")
    else:
        print("NO")
    return

def examB():
    S = SI()
    K = "keyence"
    for i in range(7):
        if S[:i]+S[-7+i:]==K:
            print("YES")
            return
    if S[:7]==K:
        print("YES")
        return
    print("NO")
    return

def examC():
    N = I()
    A = LI()
    B = LI()
    if sum(A)<sum(B):
        print(-1)
        return
    dis = [A[i]-B[i] for i in range(N)]
    dis.sort()
#    print(dis)
    cur = 0
    ans = bisect.bisect_left(dis,0)
    need = -sum(dis[:bisect.bisect_left(dis,0)])
    for i in range(N):
        if need<=cur:
            break
        cur += dis[-i-1]
        ans += 1
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 20004
#include <iostream>

using namespace std;

int main()
{
	int a[100000];
	int n, k;
	int ans = 0;
	int cnt = 0;
	
	cin >> n >> k;
	
	for (int i = 0; i < n; i++) cin >> a[i];
	
	while (n > 0) {
		n -= k;
		ans++;
		if (cnt == 0) {
			k--;
			cnt++;
		}
	}
	
	cout << ans << endl;
	
	return (0);
}

Measured memory_bytes: 640
import itertools
H, W, K = map(int, input().split())
grid = []
for _ in range(H):
    line = list(input())
    grid.append(line)
# 横に割る方法は(H-1)**2通り、高々81通り
# これを決め打ちして、縦の割り方はGreedyに

ans = 10**9

# 割る場合を1, 割らない場合を0で表すことにする
for ptn in itertools.product([0, 1], repeat=H - 1):

    # 不可能な場合、そのパターンはスキップする############################
    able = True
    for w in range(W):
        # それぞれのブロックにおける白の数
        lines = [0] * (sum(ptn) + 1)
        # 今、上から何ブロック目か
        line_num = 0
        for h in range(H):
            # 白の場合
            if grid[h][w] == "1":
                lines[line_num] += 1

            # 境界を引く場合
            # h=H-1の時、indexが範囲外になるのでminを使って調整
            if ptn[min(h, H - 2)] == 1:
                line_num += 1
        # 1列でK個を超えるブロックがある場合、その割り方は不適。
        if max(lines) > K:
            able = False
            break
    if able == False:
        continue
    # 以下、実現が可能なものとして考える################################

    # それぞれのブロックにおける白の数
    lines = [0] * (sum(ptn) + 1)
    # 横に割った回数
    cnt = sum(ptn)
    # ダメだったら1個前に戻る、という処理をしたいのでwhileで書く
    # for内でデクリメントしてもループにならない(自戒)
    w = 0
    while w < W:
        line_num = 0
        for h in range(H):
            # 白の場合
            if grid[h][w] == "1":
                lines[line_num] += 1
            # 境界を引く場合
            # h=H-1の時、indexが範囲外になるのでminを使って調整
            if ptn[min(h, H - 2)] == 1:
                line_num += 1
        # Kを超えるブロックができてしまう場合
        # 一つ前の列で切って、今の列からlinesを数え直す
        if max(lines) > K:
            cnt += 1
            lines = [0] * (sum(ptn) + 1)
            w -= 1
        w += 1
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 75496
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }

    map<ll,ll> mp;

    for(ll i = 0; i < n; i++){
        mp[-a[i] + i]++;
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(mp.find(a[i] + i) != mp.end()){
            ans += mp[a[i] + i];
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 16360
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
//0の場合のアレンジに注意
template<class T>
T gcd(T a,T b){
    if(a == 0)return b;
    else if(b == 0)return a;
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}
template<class T = ll>
T in(){T x;cin >> x;return x;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll X =in();
    if(X >= 30)cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 26604
Q, H, S, D = map(int, input().split())
N = int(input())
SL = [S, 2 * H, 4 * Q]
DL = [D, 2 * S, 4 * H, 8 * Q]
print((N // 2) * min(DL) + (N % 2) * min(SL))

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

int main() {
  int A,B;
  cin >> A >> B;
  int a[5];
  int cnt = 0;
  int calci;
  for(int i=A; i<=B; i++){
    calci = i;
    for(int j=0; j<=5; j++){
      a[j] = calci%10;
      calci /= 10;
    }
    if(a[0]==a[4] && a[1]==a[3]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w, n; cin >> h >> w >> n;
    vector<int> allnum;
    REP(i,1,n+1) {
        int a; cin >> a;
        rep(j,a) {
            allnum.push_back(i);
        }
    }
    int ans[105][105];

    int cnt = 0;
    rep(i,h) {
        rep(j,w) {
            if(i%2==0) {
                ans[i][j] = allnum[cnt];
            }else {
                ans[i][w-j-1] = allnum[cnt];
            }
            cnt++;
        }
    }

    rep(i,h) {
        rep(j,w) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
def main():
    t = input().split(" ")
    dx = int(t[2]) - int(t[0])
    dy = int(t[3]) - int(t[1])

    s = 'R' * dx + 'U' * (dy+1) + 'L' * (dx+1) + 'D' * (dy+1) + 'R' + 'U' * dy + 'R' * (dx+1) + 'D' * (dy+1) + 'L' * (dx+1) + 'U'
    print(s)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    int h,w;
    cin >> h >> w;
    int k;
    cin >> k;
    char s[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
        }
    }
    int ans = 0;
    for(int bith = 0; bith < (1<<h); bith++){
        map<int,bool> mh;
        for(int i = 0; i < h; i++){
            if(bith & (1<<i)) mh[i] = true;
        }
        for(int bitw = 0; bitw < (1<<w); bitw++){
            map<int,bool> mw;
            for(int i = 0; i < w; i++){
                if(bitw & (1<<i)) mw[i] = true;
            }
            int can = 0;
            for(int i = 0; i < h; i++){
                if(mh[i]) continue;
                for(int j = 0; j < w; j++){
                    if(mw[j]) continue;
                    if(s[i][j] == '#') can++;
                    //cout << "OK" << endl;
                }
            }
            if(can == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int X;
   cin >> X;
   if (X == 7 || X == 5|| X ==3) cout << "YES" << endl;
   else cout << "NO" << endl;
   return 0;
}


Measured memory_bytes: 256
n = int(input())
xyh = [[int(i) for i in input().split()] for i in range(n)]
xyh.sort(reverse=True, key=lambda x:x[2])

for i in range(101):
    for j in range(101):
        px, py, ph = xyh[0]
        H = ph + abs(px - i) + abs(py - j)
        if all(h == max(H - abs(x - i) - abs(y - j), 0) for x, y, h in xyh):
            print(i, j, H)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  static int n,a[100010],b[100010];
  cin>>n;
  for(int t=0;t<n;t++){
    cin>>a[t];
    b[t]=a[t];
  }

  sort(a,a+n);
  int max=-1;
  for(int t=0;t<n-1;t++){
    if(min(a[t],a[n-1]-a[t])>max){
      max=a[t];
    }
  }
  cout<<a[n-1]<<" "<<max<<endl;
  return 0;
}


Measured memory_bytes: 1024
import java.lang.Math.*

operator fun Int.not() = if (this != 0) false else true
operator fun Int.plus(other: Boolean) = this + if (other) 1 else 0

data class Point(val x: Int, val y: Int)

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val ps = Array<Point>(n) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    Point(x, y)
  }
  val odd = (abs(ps.first().x) + abs(ps.first().y)) % 2
  if (ps.any { (abs(it.x) + abs(it.y)) % 2 != odd }) {
    println(-1)
    return
  }
  println(31 + !odd)
  if (!odd) print("1 ")
  for (i in 30 downTo 0) {
    print(1 shl i)
    print(if (i == 0) "\n" else " ")
  }
  for (p in ps) {
    var (x, y) = p
    if (!odd) {
      x -= 1
      print("R")
    }
    for (i in 30 downTo 0) {
      val t = 1 shl i
      if (abs(x) < abs(y)) {
        if (y > 0) {
          y -= t
          print("U")
        } else {
          y += t
          print("D")
        }
      } else {
        if (x > 0) {
          x -= t
          print("R")
        } else {
          x += t
          print("L")
        }
      }
    }
    println("")
  }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll popcount(ll x){
  ll res=0;
  for(ll i=0; i<=40; i++){
    if(x>>i&1) res++;
  }
  return res;
}

ll f(ll x){
  if(x==0) return 0;
  ll cnt=popcount(x);
  return 1+f(x%cnt);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  string s; cin>>s;
  
  ll cnt=0;
  rep(i,n) if(s[i]=='1') cnt++;
  
  vll t1(n+1,1), t2(n+1,1);
  for(ll i=1; i<n; i++){
    t1[i]=t1[i-1]*2%(cnt+1);
    if(cnt>1) t2[i]=t2[i-1]*2%(cnt-1);
  }
  
  ll f1=0, f2=0;
  for(ll i=0; i<n; i++){
    f1=f1*2+(s[i]=='1');
    f1%=(cnt+1);
    if(cnt>1){
      f2=f2*2+(s[i]=='1');
      f2%=(cnt-1);
    }
  }
  
  // 1度cntのmodを取ってしまえば、その桁数は20未満なので、2回目以降modを取る計算量は定数と見て良い
  // 各iについて、1回目の操作がO(n)となるので、これを高速化する
  // 元のpopcountをcntとするとbit反転後のpopcountはcnt+1かcnt-1のいずれかになる
  // これを利用して、s mod (cnt+1), s mod (cnt-1) を予め求めておき、反転して立つ or 消えるbitを足し引きすることでO(1)で計算する
  // 例えばi bit目が立つならmod cnt+1となるので、(s+1<<i)%(cnt+1) つまり s%(mod+1)+(1<<i)%(cnt+1) が計算できれば良い
  // s%(mod+1)は上で求めたf1である
  // (1<<i)%(mod+1)は上で求めたt1[n-1-i]である
  // NOTE: t1について
  // iは最大2*10^5になるので、これを単にbitシフトするとオーバーフローする
  // そのため各桁ごとにmod cnt+1を求めていく
  // 2進数において今見ている桁の値は前の桁の値*2で求まるので、これに対してmod cnt+1を計算してt1に格納していく
  // t1はt[0]がs[n-1]の値、t[n-1]がs[0]の値に対応している
  
  for(ll i=0; i<n; i++){
    if(s[i]=='1'){
      if(cnt==1) cout<<0<<endl;
      else{
        ll tmp=f2-t2[n-1-i];
        tmp%=(cnt-1);
        if(tmp<0) tmp+=cnt-1;
        ll ans=f(tmp)+1;
        cout<<ans<<endl;
      }
    }else{
      ll tmp=f1+t1[n-1-i];
      tmp%=(cnt+1);
      ll ans=f(tmp)+1;
      cout<<ans<<endl;
    }
  }
  
}

Measured memory_bytes: 6732
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace std;
    using namespace __gnu_pbds; 
    #define lli long long int
    #define fr(i,a,b) for(lli i=a;i<b;i++)
    #define bfr(i,a,b) for(lli i=a;i>=b;i--)
    #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
    #define tc int t;cin>>t;while(t--)
    #define mod 1000000007LL
    #define mod2 998244353LL
    #define all(vec) vec.begin(),vec.end()  
    #define ld long double
    #define pb push_back

    #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 




     bool check(string s)
     {
        fr(i,0,s.length()-1)if(abs((lli)(s[i]-s[i+1]))>1)return false;
        return true;
     }
    int main()
    {
                           
             

           
              fio

             
              vector<lli> ans;
              vector<string> temp,temp2;
              fr(i,1,10)ans.push_back(i);
              fr(i,0,10)temp.push_back(to_string(i));

              lli n;
              cin>>n;


              fr(l,0,10)
              {
                  if(l%2==0)temp2.clear(); else temp.clear();
                  fr(i,0,10)
                  {

                     if(l%2==0)
                     { 
                     fr(j,0,temp.size())
                     {
                        string s=to_string(i)+temp[j];
                        if(check(s) && i!=0){lli o=stoll(s);ans.pb(o);}
                        if(check(s))temp2.push_back(s);
                        if(ans.size()>n)break;

                     }
                     }
                     else 
                     {
                        
                        fr(j,0,temp2.size())
                     {
                        string s=to_string(i)+temp2[j];
                        if(check(s) && i!=0){lli o=stoll(s);ans.pb(o);}
                        if(check(s))temp.push_back(s);
                        if(ans.size()>n)break;

                     }

                     }
                     if(ans.size()>n)break;

                  }
                    if(ans.size()>n)break;
                    //cout<<ans.size()<<'\n';

              }

              cout<<ans[n-1];




              
              
return 0;}

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

int main()
{
    int w, h, n, minx, maxx, miny, maxy;
    cin >> w >> h >> n;
    maxx = w;
    maxy = h;
    for (int i = 0; i < n; i++)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1)
            minx = max(x, minx);
        else if (a == 2)
            maxx = min(x, maxx);
        else if (a == 3)
            miny = max(y, miny);
        else if (a == 4)
            maxy = min(y, maxy);
    }

    if (maxx >= minx)
    {
        w = maxx - minx;
    } else
    {
        w = 0;
    }
    

    if (maxy >= miny)
    {
        h = maxy - miny;
    } else
    {
        h = 0;
    }
    
    cout << w * h << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] NW = ReadLineParseIntArray();
        int N = NW[0];
        int W = NW[1];
        long[] dp = new long[W + 1];
        for(int i = 0; i  < N; i++)
        {
            int[] wv = ReadLineParseIntArray();
            for(int w = W; w >= 0; w--)
            {
                if (w >= wv[0])
                    dp[w] = Max(dp[w - wv[0]] + wv[1], dp[w]);
            }
        }
        WriteLine(dp[W]);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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

int main(){
    int N;
    vector<int> P;
    cin >> N;
    int ans = 0;
    int min = N+1;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        if (x<min) {
            ans += 1;
            min = x;
        }
    }
    
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
if len(a)%2 != 0:
    a.append(0)
    N += 1
alice = []
bob = []
for i in range(int(N/2)):
    alice.append(a.pop(a.index(max(a))))
    bob.append(a.pop(a.index(max(a))))
print(sum(alice)-sum(bob))

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;
const int MAXN=1e5+5;

ll n,m,k;
ll a[MAXN],ans[MAXN],id[MAXN];
ll sta[MAXN],top;
bool vis[MAXN];

int main(){

	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),id[i]=i;
	for(int i=n;i>=1;i--) a[i]-=a[i-1];
	scanf("%lld%lld",&m,&k);
	for(int i=1;i<=m;i++){
	    int x;
        scanf("%d",&x);
        swap(id[x],id[x+1]);
	}
	for(int i=1;i<=n;i++){
	    if(vis[i]) continue;
	    top=0;
	    for(int j=i;j<=n&&!vis[j];j=id[j]) sta[++top]=j,vis[j]=1;
	    for(int j=1;j<=top;j++) ans[sta[j]]=a[sta[(j+k-1)%top+1]];
	}
	for(int i=1;i<=n;i++)
		ans[i]+=ans[i-1],printf("%lld\n",ans[i]);

	fclose(stdin);
	fclose(stdout);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    /*
    LL L,R;cin >> L >> R;
    LL h = R - L;
    if(673 < h){
        cout<<0<<endl;
    }else if()
    */
    LL N;cin >> N;
    vector<LL> vec;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        vec.push_back(b);
    }
    LL w = vec.back();
    for(int i = N-2;i >= 0;i--){
        w = vec.at(i) - w;
    }
    vector<LL> ans;
    ans.push_back(w);
    for(int i = 0;i < N-1;i++){
        ans.push_back((vec.at(i) - ans.back()/2)*2);
    }
    for(int i = 0;i < N;i++){
        cout<<ans.at(i)<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 105
#define MOD 1000000007
#define MAX_BIT 35
bool rev(int a,int b)
{
    return a>b;
}
int main()
{
    long long int N,K;
    scanf("%lld %lld",&N,&K);
    long long int first=N%K,second=(K-N%K)%K;
    first=min(first,second);
    printf("%lld",first);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
using namespace std;

#define all(c) c.begin(),c.end()
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i,0,n)
#define MAX(x, y)  ((x > y)? x : y);
#define MIN(x, y)  ((x < y)? x : y);
#define dump(x)  cout << #x" = " << x << endl;
#define debug(x) cout << #x" = " << x << " (" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
typedef vector<int> vi;

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

	int t, ans = 0;
	REP(i, n) {
		cin >> t;
		if (t < a || t >= b) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
from numba import njit, i8, jitclass

spec = [
    ("size", i8),
    ("tree", i8[:])
]


@jitclass(spec)
class Bit:
    def __init__(self, n, arr):
        self.size = n
        self.tree = np.array([0] + arr, np.int64)
        for i in range(1, n+1):
            if i + (i & -i) < n + 1:
                self.tree[i + (i & -i)] += self.tree[i]

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def range_sum(self, l, r):
        return self.sum(r) - self.sum(l)


def main():
    n, q = map(int, sys.stdin.buffer.readline().split())
    bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
    for x in sys.stdin.buffer.readlines():
        q, p, x = map(int, x.split())
        if q:
            print(bit.range_sum(p, x))
        else:
            bit.add(p+1, x)


if __name__ == "__main__":
    main()


Measured memory_bytes: 160856
#include <cstdio>
using namespace std;

typedef long long LL;
const LL maxn=2e5+5;
LL n, a[maxn], l, r, xorsum, sum, ans;

int main(){
    scanf("%lld", &n); r=0;
    for (LL i=1; i<=n; ++i) scanf("%lld", &a[i]);
    for (LL i=1; i<=n; ++i){  //[i, r]
        xorsum^=a[i-1]; sum-=a[i-1];
        while (r<=n&&xorsum==sum){ ++r; xorsum^=a[r]; sum+=a[r]; }
        xorsum^=a[r]; sum-=a[r]; --r;
        ans+=r-i+1;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	bing := make(map[int][]int)
	var num int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&num)
			bing[num] = []int{i, j}
		}
	}
	var n int
	fmt.Scan(&n)
	isOk := make([]bool, 9)
	for i := 0; i < n; i++ {
		fmt.Scan(&num)
		if pos, ok := bing[num]; ok {
			isOk[pos[0]*3+pos[1]] = true
		}
	}
	if isOk[0] && isOk[1] && isOk[2] ||
		isOk[3] && isOk[4] && isOk[5] ||
		isOk[6] && isOk[7] && isOk[8] ||
		isOk[0] && isOk[3] && isOk[6] ||
		isOk[1] && isOk[4] && isOk[7] ||
		isOk[2] && isOk[5] && isOk[8] ||
		isOk[0] && isOk[4] && isOk[8] ||
		isOk[2] && isOk[4] && isOk[6] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int x,ans;
	REP(i,5){
		cin >> x;
		if(x==0) ans = i+1;
	}
	cout << ans << endl;
	
	return 0;
	
}

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

#define rep(i, first, to) for(int i = first; i < to; ++i)

using namespace std;
typedef long long ll;

vector<char> cs;
int n;
stack<char> s;

int receive(char c, int i) {
	int r = 0;
	if (c == '(') {
		s.push('(');
	} else if(c == ')') {
		if (!s.empty() && s.top() == '(') {
			s.pop();
		} else {
			cs.insert(cs.begin(), '(');
			r++;
		}
	}
	return r;
}

void solve() {
	cin >> n;
	rep(i, 0, n) {
		char c;
		cin >> c;
		cs.push_back(c);
	}
	rep(i, 0, cs.size()){
		i += receive(cs[i], i);
	}

	while(!s.empty()) {
		s.pop();
		cs.insert(cs.end(), ')');
	}
	rep(i, 0, cs.size()) {
		cout << cs[i];
	}
	cout << endl;
}

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

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string L;
    cin >> L;
    ll dp0 = 0;
    ll dp1 = 1;
    for(int i=0; i<L.size(); i++){
        ll dp0n = 0;
        ll dp1n = 0;
        if(L[i] == '1'){
            dp0n = 1 * dp1;
            dp1n = 2 * dp1;
        }else{
            dp1n = 1 * dp1;
        }
        dp0n += 3 * dp0;
        swap(dp0, dp0n);
        swap(dp1, dp1n);
        dp0 %= 1000000007;
        dp1 %= 1000000007;
    }
    auto res = dp0 + dp1;
    res %= 1000000007;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m,x;
  vector<int> a(1000);
  cin >> n >> m >> x;
  int i;
  int left = 0;
  int right = 0;
  for(i=0;i<m;i++) cin >> a[i];
  for(i=0;i<m;i++){
    if(a[i]<x){
      left++;
    }
  }
  for(i=0;i<m;i++){
    if(a[i]>x){
      right++;
    }
  }
  cout << ((right<left) ? right:left) << "\n";
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ')
puts ((0..((n - 1) / 2)).map { |m| n - m * 2 - 1 } + (1..(n / 2)).map { |m| m * 2 - 1 - (n + 1) % 2 }).map { |i|
  a[i]
}.join(' ')


Measured memory_bytes: 25020
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;


const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    REP(i,n){
        cin >> p[i];
        p[i]--;
    }
    UnionFind uf(n);
    uf.init(n);
    REP(i,m){
        int x,y;
        cin >> x >> y;
        uf.merge(x-1,y-1);
    }
    int ans=0;
    REP(i,n){
        if(uf.issame(i,p[i])){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  string s;
  cin >> n>>s;
  long mod=1000000007;
  
  
  vector<int>c(26);
  rep(i,n){
    c.at(s.at(i)-'a')++;
  }
  long ans=1;
  rep(i,26){  
    ans=ans*(1+c.at(i))%mod;
  }
  cout<<ans-1<<endl; 
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

const int inf = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n, inf));
  vector<vector<int>> d(n, vector<int>(n, inf));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = c;
    g[b][a] = c;
    d[a][b] = c;
    d[b][a] = c;
  }
  
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] == inf) {
        continue;
      }
      if (d[i][j] != g[i][j]) {
        cnt++;
      }
    }
  }
  cout << cnt / 2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() {
	
	int Blood_sum[4] = {};
	int n;
	char ch;
	string Blood;
	
	while(cin >> n >> ch >> Blood)	{
		
		if(Blood == "A")
			Blood_sum[0]++;
		
		if(Blood == "B")
			Blood_sum[1]++;
			
		if(Blood == "AB")
			Blood_sum[2]++;
			
		if(Blood == "O")
			Blood_sum[3]++;
		
	}
	
	for(int i=0;i<4;i++)
		cout << Blood_sum[i] << "\n";
		
	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, x, t;
	cin >> n >> x >> t;
	int ans = ((n + x - 1) / x) * t;
	cout << ans;

	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

const long long MOD = 1000000007;

ll extgcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

//* calculate a^-1 mod m
ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, x, y);
    return(m + x%m) % m;
}

//* calculate C(n, 0), C(n, 1), ... C(n, n) mod p in O(n) 
vll mod_comb_list(ll n, ll p){
    vll res(n+1, 1);
    for(ll k=1; k <= n; k++){
        res[k] = (res[k-1] * (n - k + 1)) % p;
        res[k] = (res[k] * mod_inverse(k, p)) % p;
    }
    return res;
}

void solve(long long n, std::vector<long long> a){
    //* decide replicate position
    map<ll, vll> rec_a;
    REP(i, n+1) {
        if(!rec_a.count(a[i])){
            rec_a[a[i]] = vll(1, i);
        }
        else{
            rec_a[a[i]].push_back(i);
        }
    }
    ll L, R;
    for(auto x: rec_a){
        if(x.second.size()>1){
            L = x.second[0]; R=x.second[1]; break;
        }
    }
    if(L > R) swap(L, R);
    ll m = n - (R - L);
    vll ctotal= mod_comb_list(n+1, MOD), csub = mod_comb_list(m, MOD);
    for(ll k = 1; k <= n+1; k++){
        ll res = ctotal[k];
        if(k-1 <= m) res = (res - csub[k-1]) % MOD;
        if(res < 0) res += MOD;
        cout<< res<<endl;
    }
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n+1);
    for(int i = 0 ; i < n+1 ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 14464
A, B, K = map(int, input().split())
if B - A <= 100:
    s = [0 for i in range(B - A + 1)]
    if K > len(s):
        K = len(s)
    
    for i in range(K):
        s[i] = 1
        s[B - A - i] = 1
 
    for i in range(B - A + 1):
        if s[i] == 1:
            print(i + A)

else:
    ss = [0 for i in range(100)]
    sb = [0 for i in range(100)]

    for i in range(K):
        print(i + A)

    for i in range(K):
        print(B - K + i + 1)

Measured memory_bytes: 3064
def dfs(i, count, res):
    global ans
    if i == n:
        if min(count) < x:
            return
        ans = min(ans, res)
        return ans
    else:
        dfs(i+1, count, res)
        dfs(i+1, [count[k-1] + l[i][k] for k in range(1, m+1)], res + l[i][0])


n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]

ans = 10 ** 9
dfs(0, [0] * m, 0)

if ans == 10 ** 9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9220
#include<cstdio>

int n;
int cnt[10004];

int main() {
  scanf("%d", &n);
  for (int x = 1; x * x <= n; x++) {
    for (int y = 1; y * y <= n; y++) {
      for (int z = 1; z * z <= n; z++) {
        int res = x*x + y*y + z*z + x*y + y*z + x*z;
        if (res <= n) {
          cnt[res]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", cnt[i]);
  }
}


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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
    int r,D,x;
    cin>>r>>D>>x;

    for(int i=1;i<=10;i++){
        x = r*x - D;
        cout<<x<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define test int t ; cin>>t ; while(t--)
#define ll long long
#define inp(n) cin>>n;
#define loopp(i,a,b) for(ll i=a;i<b;i++)
#define loopn(i,a,b) for(ll i=a;i>=b;i--)

int main()
{
    int n;
    inp(n);
    int a=(n/1000)+1;
    int b=a*1000;
    if(n%1000==0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    cout<<b-n;
    return 0;
}


Measured memory_bytes: 3624