akhauriyash/Code-Regression huggingface dataset:
N, K, C = list(map(int, input().split()))
S = input()

work_day_min = []
work_day_max = []

for i in range(N):
    if S[i] == 'o':
        if i > 0 and len(work_day_min) > 0:
            if i - work_day_min[-1] <= C:
                continue
        work_day_min.append(i)
    if len(work_day_min) == K:
        break

for i in range(N):
    if S[N - i - 1] == 'o':
        if i > 0 and len(work_day_max) > 0:
            if work_day_max[-1] - (N - i - 1) <= C:
                continue
        work_day_max.append(N - i - 1)
    if len(work_day_max) == K:
        break

for i in range(K):
    if work_day_min[i] == work_day_max[K-i-1]:
        print(work_day_min[i]+1)

Measured memory_bytes: 25104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ts  ll t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr ll n,i;cin>>n; ll a[n+1];for(i=0;i<n;i++)
#define ln cout<<"\n"; 
#define maxn 1000000

int main() 
{fast
 ll n,ans;
 cin>>n;
 if(n>=400&&n<=599)ans=8;
 else if(n>=600&&n<=799)ans=7;
 else if(n>=800&&n<=999)ans=6;
 else if(n>=1000&&n<=1199)ans=5;
else  if(n>=1200&&n<=1399)ans=4;
 else if(n>=1400&&n<=1599)ans=3;
else if(n>=1600&&n<=1799)ans=2;
 else if(n>=1800&&n<=1999)ans=1;
cout<<ans;
return 0;
}

Measured memory_bytes: 3644
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AtCoderBeginnerContest178
{
    class Program
    {
        static void Main(string[] args)
        {
            // 課題C - Ubiquity(2020/9/13)


            int input = int.Parse(Console.ReadLine());

            int modItem = 1000000007;

            long allPtn = 10;
            long delPtn = 9;
            long plusPtn = 8;

            for (int i = 0; i < input - 1; i++)
            {
                allPtn = allPtn * 10 % modItem;
                delPtn = delPtn * 9 % modItem;
                plusPtn = plusPtn * 8 % modItem;

            }

            long result = (allPtn - 2 * delPtn + plusPtn) % modItem;

            if (result < 0) result = result + modItem;

            Console.Write(result);


        }
    }
}


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

int main() {
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    
    long long x = max((a*c), (a*d));
    long long y = max((b*c), (b*d));
    cout << max(x,y) << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    ss=[SI() for _ in range(n)]
    cnt=Counter(ss)
    pv=-1
    for s,v in sorted(cnt.items(),key=lambda x:(-x[1],x[0])):
        if v!=pv and pv!=-1:break
        print(s)
        pv=v

main()

Measured memory_bytes: 61032
q = int(input())
for i in range(q):
    a,b,c,d,e,f,g,h = [int(i) for i in input().split()]
    A = a*d-b*c
    B = e*h-f*g
    C = d-b
    D = c-a
    E = f-h
    F = e-g
    det = C*F - D*E
    print((A*F + B*D)/det,(A*E + B*C)/det)

Measured memory_bytes: 7724
#include<iostream>

using namespace std;

int main(){
    int n;
    double m;
    int a[10000];
    cin >> n >> m;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    double sum = 0;
    for(int k=0;k<n;k++){
        sum += a[k];
    }
    double kijun = sum/(4*m);
    int flg = 0;
    for(int j=0;j<n;j++){
        if(a[j] >= kijun){
            flg += 1;
        }
    }
    if(flg>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}



int main(){
  string s, t;
  cin>>s;
  cin>>t;
  for(ll i=s.size()-1; i>=t.size()-1; i--) {
    bool f = true;
    for(ll j=t.size()-1; j>=0; j--) {
      if(s[i-(t.size()-1-j)]!=t[j] and s[i-(t.size()-1-j)]!='?') {
	f = false;
	break;
      }
    }
    if(f) {
      for(ll j=0; j<s.size(); j++) {
	if(i-(t.size()-1) <= j and j<=i) {
	  std::cout << t[j-(i-(t.size()-1))];
	}
	else if(s[j]=='?')
	  std::cout << 'a';
	else
	  std::cout << s[j];
      }
      std::cout << std::endl;
      return 0;
    }
  }
  std::cout << "UNRESTORABLE" << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    int p[100000], num[100000] = {}, ans = 0;
    for(int i=0;i<N;i++){
        cin >> p[i];
        if(i+1 == p[i])//pi=i
            num[i] = 1;
    }
    
    for(int i=0;i<N;i++){
        if(num[i] == 1){
            num[i+1] = 0;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, Sum=0;
  cin >> N;
  vector<int> S(N);
  rep(i, N){
    cin >> S.at(i);
    Sum+=S.at(i);
  }
  sort(S.begin(), S.end());
  if(Sum%10!=0) cout << Sum << endl;
  else {
    rep(i, N){
      Sum-=S.at(i);
      if(Sum%10!=0){
        cout << Sum << endl;
        break;
      }
      else if(i==N-1) cout << 0 << endl;
      else Sum+=S.at(i);
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	string a,b;
	cin>>n;
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]+n>'Z'){
			a[i]=a[i]+n-'Z'+'A'-1;
		}
		else a[i]=a[i]+n;
		}
		cout<<a;
		return 0;
}

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

int main() {
    long long int a,b;
    cin>>a>>b;
    
    if(a<=0 && b>=0) cout<<"Zero"<<endl;
    else if(a<0 && b<0 && (b-a)%2 ==0)  cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
    
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int L = scan.nextInt();

        int eat = Integer.MAX_VALUE;
        int sum = 0;
        for (int i = 1; i<=N; i++) {
            int m = L + i -1;
            sum += m;
            if (Math.abs(m) < Math.abs(eat)) {
                eat = m;
            }
        }
        System.out.println(sum - eat);
    }
}


Measured memory_bytes: 21716
INF = 10**10
arr = [INF,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i+arr[j]] = max(dp[i+arr[j]],dp[i] + 1)
dim = dp[N]
ans  = ''
while(dim > 0):
    for i in src[::-1]:
        if N >= arr[i] and dp[N-arr[i]] + 1 == dp[N]:
            ans += str(i)
            N -= arr[i]
            dim -= 1
            break
print(ans)

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

int main() {
   int N,Y;
   cin>>N>>Y;
    for(int i=0;i<=N;++i){
        for(int j=0;j<=N-i;j++){
            if((i*1000+j*5000+(N-i-j)*10000)==Y){
                cout<<(N-i-j)<<" "<<j<<" "<<i<<endl;
                return 0;
            };
        }
    }
    cout<<"-1 -1 -1"<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct UnionFind {
  vector<int> par, s; 
  UnionFind(int N) : par(N), s(N) { rep(i,N) { par[i] = i; s[i] = 1; } }
  int root(int x) { return par[x]==x ? x : par[x] = root(par[x]); }
  int size(int x) { return par[x]==x ? s[x] : s[x] = size(root(x)); }
  void unite(int x, int y) { int rx=root(x), ry=root(y); if (rx!=ry) { s[rx] += s[ry]; par[ry] = rx; } }
  bool same(int x, int y) {  int rx=root(x), ry=root(y); return rx==ry; }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  c_fac();
  int N; cin >> N;
  ll P[N]; rep(i,N) { cin >> P[i]; if (P[i]!=-1) P[i]--; }

  UnionFind uf(N);
  rep(i,N) if (P[i]!=-1) uf.unite(i,P[i]);
  bool loop[N] = {}; rep(i,N) if (P[i]==-1) loop[uf.root(i)] = true;

  ll pnm1[N+1] = {}; rep(i,N+1) pnm1[i] = i==0 ? 1 : pnm1[i-1]*(N-1)%MOD;
  ll lcnt = 0; vector<ll> lsize;
  rep(i,N) { 
    if (i==uf.root(i)) {
      if (!loop[i]) lcnt++;
      else lsize.push_back(uf.size(i));
    }
  }
  // debug(all(lsize));
  ll l = lsize.size();

  ll dp[l+1][l+1] = {}; dp[0][0] = 1;
  rep(i,l) rep(j,l+1) {
    if (j==0) dp[i+1][j] = dp[i][j];
    else dp[i+1][j] = ( dp[i][j] + dp[i][j-1]*lsize[i] ) % MOD;
  }
  // rep(i,l+1) debug(dp[i],dp[i]+(l+1));

  ll result = (N-lcnt) * pnm1[l] % MOD;
  ll lsum = 0;
  rep(i,l+1) {
    if (i==0) continue;
    else if (i==1) lsum = ( lsum + (dp[l][i]-l+MOD)%MOD * pnm1[l-i] ) % MOD;
    else lsum = ( lsum + (dp[l][i]*pnm1[l-i]%MOD) * fac[i-1] ) % MOD;
  }
  result = (result-lsum+MOD) % MOD;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 206792
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
 //   freopen("input.txt","r",stdin);
    int n,d;
    cin>>n>>d;
    if(n % (2*d+1) == 0) cout<<n / (2*d+1);
    else cout<<n/(2*d+1) +1;
    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
let input = '';
process.stdin.on('data', function(chunk) {input += chunk;});
process.stdin.on('end', function() {main(input.split("\n"));});

let count = 0;

function merge(A,left,mid,right) {
	let n1 = mid - left;
	let n2 = right - mid;
	let L = [];
	let R = [];
	for (let i = 0; i < n1; i++) L.push(A[left+i]);
	for (let i = 0; i < n2; i++) R.push(A[mid+i]);
	L.push(Number.MAX_SAFE_INTEGER);
	R.push(Number.MAX_SAFE_INTEGER);

	let i = 0,j = 0;
	for (let k = left; k < right; k++) {
		if (L[i] < R[j]) A[k] = L[i++];
		else A[k] = R[j++];
		count++;
	}
}

function mergeSort(A,left,right,count) {
	if (left + 1 >= right) return;
	let mid = Math.floor((left + right) / 2);
	mergeSort(A,left,mid);
	mergeSort(A,mid,right);
	merge(A,left,mid,right);
}

function main(lines) {
	let n = Number(lines[0]);
	let A = lines[1].split(" ").map(Number);
	mergeSort(A,0,n);

	console.log(A.join(" "));
	console.log(count);
}


Measured memory_bytes: 130196
#include <iostream>
#include <deque>

using namespace std;

int d[114514];

int main()
{
	int k;
	cin >> k;
	deque<int> q;
	for (int i = 0; i < k; i++)
		d[i] = i == 1 ? 0 : 100;
	q.push_back(1);
	while (!q.empty()) {
		int u = q.front();
		q.pop_front();
		for (int i = 0; i < 2; i++) {
			int v = (i ? u + 1 : u * 10) % k;
			int l = d[u] + i;
			if (d[v] <= l)
				continue;
			d[v] = l;
			i ? q.push_back(v) : q.push_front(v);
		}
	}
	cout << d[0] + 1 << endl;
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }

int n, k;

int main() {
	cin >> n >> k;
	
	cout << ce(n, k) - fl(n, k) << endl;
	
	return 0;
}


Measured memory_bytes: 764
const lines=readlines()
state=0
input()=lines[global state+=1]
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
floatSub(s::SubString{String})=parse(Float64,s)
intLine()=map(intSub,split(input()))
function main()
    s=input()
    println(any(s[i]==s[i+1] for i=1:3) ? "Bad" : "Good")
end
main()

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

using namespace std;

#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

const int N = 5e5+5;
const int mod = 1e9+7;
long long fact[N], factinv[N];

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;
}

long long inv(int a){
    return power(a, mod-2)%mod;
}

long long ncr(int n, int r){
    return fact[n]%mod *factinv[r]%mod *factinv[n-r]%mod;
}

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

    int n, m;
    cin>>n>>m;
    fact[0] = 1;
    factinv[0] = 1;
    for (int i=1; i<N; i++){
        fact[i] = (fact[i-1]*i)%mod;
        factinv[i] = inv(fact[i])%mod;
    }
    long long ans = 0;
    for (int i=0; i<=n; i++){
        long long curr = (i%2?-1:1);
        if (curr<0) curr += mod;
        curr = curr *(ncr(n, i))%mod *ncr(m-i, n-i)%mod *fact[n-i]%mod;
        ans = (ans+curr)%mod;
    }

    ans = ans *ncr(m, n)%mod *fact[n]%mod;

    cout<<ans<<endl;

    return 0 ;
}


Measured memory_bytes: 11340
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 605;

struct Edge
{
	int to;
	int nxt;
}edge[MAXN * MAXN * 40];

int n,D1,D2,ce;
int first[MAXN * MAXN];
int col[2][MAXN * MAXN];

vector<pair<int,int> > gg;
vector<pair<int,int> > bel[2][2];

int id(int x,int y)
{
	return x * 2 * n + y + 1;
}

void addE(int u,int v)
{
	edge[++ce] = (Edge){v,first[u]};
	first[u] = ce;
}

void work(int v)
{
	gg.clear();
	for (int i = 0;2 * i * i <= v;i++)
		for (int j = i;i * i + j * j <= v;j++)
			if (i * i + j * j == v)
			{
				gg.push_back(make_pair(i,j));
				gg.push_back(make_pair(j,i));
			}
}

void dfs(int u,int c,int tp)
{
	if (~col[tp][u])
		return;
	col[tp][u] = c;
	for (int i = first[u];i;i = edge[i].nxt)
		dfs(edge[i].to,c ^ 1,tp);
}

int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output1.txt","w",stdout);
	memset(col,-1,sizeof(col));
	scanf("%d%d%d",&n,&D1,&D2);
	work(D1);
	for (int i = 0;i < 2 * n;i++)
		for (int j = 0;j < 2 * n;j++)
			for (int k = 0;k < gg.size();k++)
				for (int o2 = -1;o2 <= 1;o2 += 2)
					if (i + gg[k].first >= 0 && i + gg[k].first < 2 * n && j + gg[k].second * o2 >= 0 && j + gg[k].second * o2 < 2 * n)
					{
						addE(id(i,j),id(i + gg[k].first,j + gg[k].second * o2));
						addE(id(i + gg[k].first,j + gg[k].second * o2),id(i,j));
					}
	for (int i = 1;i <= 4 * n * n;i++)
		if (col[0][i] == -1)
			dfs(i,0,0);
	work(D2);
	memset(first,0,sizeof(first));
	ce = 0;
	for (int i = 0;i < 2 * n;i++)
		for (int j = 0;j < 2 * n;j++)
			for (int k = 0;k < gg.size();k++)
				for (int o2 = -1;o2 <= 1;o2 += 2)
					if (i + gg[k].first >= 0 && i + gg[k].first < 2 * n && j + gg[k].second * o2 >= 0 && j + gg[k].second * o2 < 2 * n)
					{
						addE(id(i,j),id(i + gg[k].first,j + gg[k].second * o2));
						addE(id(i + gg[k].first,j + gg[k].second * o2),id(i,j));
					}
	for (int i = 1;i <= 4 * n * n;i++)
		if (col[1][i] == -1)
			dfs(i,0,1);
	for (int i = 0;i < 2 * n;i++)
		for (int j = 0;j < 2 * n;j++)
			bel[col[0][id(i,j)]][col[1][id(i,j)]].push_back(make_pair(i,j));
	for (int i = 0;i <= 1;i++)
		for (int j = 0;j <= 1;j++)
			if (bel[i][j].size() >= n * n)
			{
				for (int k = 0;k < n * n;k++)
					printf("%d %d\n",bel[i][j][k].first,bel[i][j][k].second);
				return 0;
			}
	return 0;
}

Measured memory_bytes: 84596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
void solve(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    ll comfort=0;
    sort(a.begin(),a.end(),greater<ll>());
    priority_queue<pair<int,int>> pq;
    pq.push(make_pair(a[0],a[0]));
    for(int i=1;i<n;i++){
        pair<int,int> pr=pq.top();
        int y=pr.first;
        int z=pr.second;
        int add=min(y,z);
        pq.pop();
        pair<int,int> ff,ss;
        ff=make_pair(a[i],y);
        ss=make_pair(a[i],z);
        pq.push(ff);pq.push(ss);
        comfort+=add;
    }
    cout<<comfort<<"\n";
}
int main() {
	int t=1;
	//cin>>t;
	while(t--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 6868
def main():
    N, A, B, C = map(int, input().split())
    variables = {
        "A": A,
        "B": B,
        "C": C
    }
    ans = [None] * N
    S = [None] * N
    for i in range(N):
        S[i] = input()
    for i in range(N):
        c1, c2 = S[i]
        if variables[c1] == variables[c2] == 0:
            print("No")
            return
        elif variables[c1] == variables[c2] and i+1 < N:
            if c1 in S[i+1]:
                ans[i] = c1
                variables[c1] += 1
                variables[c2] -= 1
            else:
                ans[i] = c2
                variables[c1] -= 1
                variables[c2] += 1
        elif variables[c1] > variables[c2]:
            ans[i] = c2
            variables[c1] -= 1
            variables[c2] += 1
        else:
            ans[i] = c1
            variables[c1] += 1
            variables[c2] -= 1
    print("Yes")
    for i in range(N):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 86284
c = Array.new(3) {Array.new(3,0)}
3.times do |i|
  tmp = gets.split("\s").map {|s|s.to_i}
  c[i][0] = tmp[0]
  c[i][1] = tmp[1]
  c[i][2] = tmp[2]
end

d00 = c[0][0] - c[1][0]
d10 = c[1][0] - c[2][0]
d20 = c[2][0] - c[0][0]
d01 = c[0][1] - c[1][1]
d11 = c[1][1] - c[2][1]
d21 = c[2][1] - c[0][1]
d02 = c[0][2] - c[1][2]
d12 = c[1][2] - c[2][2]
d22 = c[2][2] - c[0][2]

if d00==d01 && d01==d02 && d02==d00 &&
   d10==d11 && d11==d12 && d12==d10 &&
   d20==d21 && d21==d22 && d22==d20 then
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define rep(i,b) for(ll i=0;i<b;i++)
using namespace std;
ll n,a,dp[2][101];
signed main() {
    cin>>n;
    rep(i,2){
        rep(j,n){
            cin>>a;
            if(i+j==0)dp[0][0]=a;
            if (i!=0) dp[i][j]=max(dp[i][j],dp[i-1][j]+a);
            if (j!=0) dp[i][j]=max(dp[i][j],dp[i][j-1]+a);
        }
    }
    cout<<dp[1][n-1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;



int main(){
    int n;
    cin >> n ;
    string a,b,c;
    cin >> a >> b >> c;
    int ans=0;
    for (int i = 0; i < n; i++) {
        if(a[i]==b[i]&&b[i]==c[i]) continue;
        else if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]) ans+=1;
        else ans+=2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,K;
int V[50];
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>V[i];
	int ans=0;
	for(int L=0;L<N;L++)
	{
		for(int R=L;R<=N;R++)
		{
			if(L+(N-R)>K)continue;
			vector<int>a;
			int ret=0;
			for(int i=0;i<L;i++)a.push_back(V[i]),ret+=V[i];
			for(int i=R;i<N;i++)a.push_back(V[i]),ret+=V[i];
			sort(a.begin(),a.end());
			for(int i=0;i<K-(L+(N-R))&&i<a.size()&&a[i]<0;i++)ret-=a[i];
			ans=max(ans,ret);
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> cards(N);
  
  for (int i=0; i < N; i++){
    cin >> cards.at(i);
  }
  
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int alice = 0;
  int bob = 0;
  for (int i=0; i < N; i += 2){
    alice += cards.at(i);
  }
  for (int i=1; i < N; i += 2){
    bob += cards.at(i);
  }
    
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt(),m=sc.nextInt();
        int[] x=new int[m];
        for (int i = 0; i < m; i++) {
            x[i]=sc.nextInt();
        }
        long ans=0;
        if(m<=n){
            out.println(ans);
        }else {
            Arrays.sort(x);
            int[] d=new int[m-1];
            for (int i = 0; i < m-1; i++) {
                d[i]=x[i+1]-x[i];
            }
            for (int k:d)ans+=k;
            Arrays.sort(d);
            for (int i = m-2; i > m-n-1; i--) {
                ans-=d[i];
            }
            out.println(ans);
        }
    }
}

Measured memory_bytes: 50840
n=int(input())
a=list(map(int,input().split()))

count=0
total=0
min_=10**9
for i in range(n):
  total+=abs(a[i])
  if a[i]<0:
    count+=1
  if abs(a[i])<min_:
    min_=abs(a[i])
    
if count%2==0:
  print(total)
else:
  print(total-2*min_)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define MKP make_pair
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tpiii;
 
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
 
int fpow(int a,int b,int m)
{
	if(b==0) return 1;
	if(b==1) return a;
	int tmp=fpow(a,b/2,m);
	if(b%2) return a*tmp%m*tmp%m;
	return tmp*tmp%m;
}
 
struct Case
{
	int i,j,k,s;
	Case(int ni,int nj,int nk,int ns)
	{
		i=ni; j=nj; k=nk; s=ns;
	}
};
 
struct cmp2
{
	bool operator() (Case a,Case b)
	{
		return a.s<b.s;
	}
};
 
bool cmp(int a,int b) { return a>b; }
 
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x,y,z,lim; cin>>x>>y>>z>>lim;
	vector<int> a(x),b(y),c(z);
	For(i,0,x-1) cin>>a[i];
	For(i,0,y-1) cin>>b[i];
	For(i,0,z-1) cin>>c[i];
	sort(all(a),cmp);
	sort(all(b),cmp);
	sort(all(c),cmp);
	
	//priority_queue<int> pq;
	priority_queue<Case,vector<Case>,cmp2> que;
	set<tpiii> app;
	int cnt=0;
	que.emplace(0,0,0,a[0]+b[0]+c[0]);
	while(cnt<lim)
	{
		Case ca=que.top(); que.pop();
		tpiii tp=make_tuple(ca.i,ca.j,ca.k);
		if(app.count(tp)) continue;
		else app.insert(tp);
		cout<<ca.s<<"\n";
		cnt++;
		if(ca.i<x-1) que.emplace(ca.i+1,ca.j,ca.k,ca.s-a[ca.i]+a[ca.i+1]);
		if(ca.j<y-1) que.emplace(ca.i,ca.j+1,ca.k,ca.s-b[ca.j]+b[ca.j+1]);
		if(ca.k<z-1) que.emplace(ca.i,ca.j,ca.k+1,ca.s-c[ca.k]+c[ca.k+1]);
	}
	return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
 
int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
 
  size_t N, W, weight, value, V = 1000 * 1000 + 1;
  std::cin >> N >> W;
 
  std::vector<std::vector<size_t>> dp(2);
  dp[0] = std::vector<size_t>(V, W+1);
  dp[1] = std::vector<size_t>(V, W+1);
  dp[0][0] = 0;
 
  unsigned ans = 0;
 
  for (unsigned i = 0; i < N; ++i)
  {
    std::cin >> weight >> value;
    for (unsigned j = 0; j < V; ++j)
    { 
      if (j >= value)
      { 
        dp[1][j] = std::min(dp[0][j], dp[0][j-value] + weight);
      }
      else
      { 
        dp[1][j] = dp[0][j];
      }
      if (dp[1][j] <= W)
      { 
        ans = std::max(ans, j);
      }
    }
    dp[0].swap(dp[1]);
  }
  std::cout << ans;
 
  return 0;
}

Measured memory_bytes: 15872
from collections import deque
H, W = map(int, input().split())
X = [[1 if a == "#" else 0 for a in input()] for _ in range(H)]

def BFS(i0=0):
    Q = deque([i0])
    D = [-1] * (H * W)
    D[i0] = 0
    while Q:
        x = Q.popleft()
        i, j = x // W, x % W
        for di, dj in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W:
                if X[ni][nj] == 0:
                    y = ni * W + nj
                    if D[y] == -1:
                        D[y] = D[x] + 1
                        Q.append(y)
    return D

ma = 0
for i in range(H):
    for j in range(W):
        if X[i][j] == 0:
            ma = max(ma, max(BFS(i*W+j)))
print(ma)

Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;

// Kruskal法
//   証明: http://drken1215.hatenablog.com/entry/20121223/1356230697

class UnionFind {
    vector<int> par;
    int n;
public:
    UnionFind(int sz) : par(sz, -1) {}
    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -par[find(x)]; }
};

int kruskal(vector<vector<P>> &edge) {
    int n = edge.size();
    typedef pair<int, P> PP;
    vector<PP> weights;
    for (int i = 0; i < n; i++) {
        for (auto &e : edge[i]) weights.push_back({e.second, {i, e.first}});
    }
    sort(weights.begin(), weights.end());
    UnionFind uf(n);
    int ret = 0;
    for (auto &w : weights) {
        int from = w.second.first;
        int to = w.second.second;
        if (uf.unite(from, to)) ret += w.first;
    }
    return ret;
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp
void AOJ_GRL_2_A() {
    int V, E;
    cin >> V >> E;
    vector<vector<P>> edge(V);
    for (int i = 0; i < E; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        edge[s].push_back({t, w});
    }
    cout << kruskal(edge) << endl;
}

// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_A&lang=jp
void AOJ_ALDS1_12_A() {
    int n;
    cin >> n;
    vector<vector<P>> edge(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int w;
            cin >> w;
            if (w < 0) continue;
            if (j < i) continue;
            edge[i].push_back({j, w});
        }
    }
    cout << kruskal(edge) << endl;
}

int main() {
    // AOJ_GRL_2_A();
    AOJ_ALDS1_12_A();
    return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


struct Node{
    int cnt;
    int cost;
    bool operator< (const Node &r) const{
        if(cnt != r.cnt) return cnt > r.cnt;
        return cost < r.cost;
    }
};

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

    priority_queue<Node> que;
    que.push({0, 0});
    
    set<int> visited;
    while(true){
        Node node = que.top(); que.pop();

        if(node.cost == n){
            cout << node.cnt << endl;
            return 0;
        }

        if(0 < visited.count(node.cost)) continue;        
        visited.insert(node.cost);

        que.push({node.cnt+1, node.cost+1});
        for(int i = 1; node.cost+(int)pow(6, i) <= n; i++){
            que.push({node.cnt+1, node.cost+(int)pow(6, i)});
        }
        for(int i = 1; node.cost+(int)pow(9, i) <= n; i++){
            que.push({node.cnt+1, node.cost+(int)pow(9, i)});
        }
    }
    

    return 0;
}


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

int main() {
  long long x;
  cin >> x;
  int flag = 1;
  long long ans = 0;

  if (x / 500 != 0) {
    ans += (x / 500) * 1000;
    x -= (x / 500) * 500;
  }
  if (x / 5 != 0) {
    ans += (x / 5) * 5;
    x -= (x / 5) * 5;
  }
  cout << ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int count = 0;
		
		if(a / 100 == 1) {
			count++;
			a -= 100;
		}
		
		
		if(a / 10 == 1) {
			count++;
			a -= 10;
		}
		
		if(a / 1 == 1) {
			count++;
		}
		System.out.println(count);

		sc.close();
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

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


    // int cnt = 0;
    // for (int i = 1; i <= a; ++i) {
    //     for(int j = 1; j <= b; ++j) {
    //         if (i == j) {
    //             cnt++;
    //             break;
    //         }
    //     }
    // }

    if ( a <= b) {
        cout << a << endl;
    } else {
        cout << a-1 << endl;
    }
        
    return 0;

    // cout << cnt << endl;
    // return 0;
}

Measured memory_bytes: 256
import numpy as np

def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    # list of expected value
    e = [(p[j-1]+1)/2.for j in range(1, n+1)]
    # cumulative sum for e
    c_s = np.cumsum(e)
    # sum of range k
    s = c_s[k-1:] - np.r_[[0],c_s[:n-k]]
    # calculate max of s
    ans = max(s)

    print(ans)

if __name__ == "__main__":
    main()

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

const int N = 18, M = (1 << N) + 5,
  P = 998244353, I2 = (P + 1) / 2;

inline int fpow(int x, int y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}

int n, f[M], p[M], s;

inline void FWT(int A[], int o) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += i << 1)
      for (int k = 0; k < i; ++k) {
        int nx = A[j + k], ny = A[i + j + k];
        A[j + k] = (nx + ny) % P;
        A[i + j + k] = (nx - ny + P) % P;
        if (o == -1) {
          A[j + k] = 1ll * A[j + k] * I2 % P;
          A[i + j + k] = 1ll * A[i + j + k] * I2 % P;
        }
      }
}

int main() {
  scanf("%d", &n); n = 1 << n;
  for (int i = 0; i < n; ++i)
    scanf("%d", p + i), s += p[i];
  s = fpow(s, P - 2);
  for (int i = 0; i < n; ++i)
    p[i] = 1ll * p[i] * s % P;
  p[0] = (p[0] - 1 + P) % P;
  for (int i = 0; i < n; ++i)
    f[i] = P - 1;
  f[0] += n;
  FWT(p, 1), FWT(f, 1);
  for (int i = 0; i < n; ++i)
    f[i] = 1ll * f[i] * fpow(p[i], P - 2) % P;
  FWT(f, -1);
  for (int i = 0; i < n; ++i)
    printf("%d\n", (f[i] - f[0] + P) % P);
  return 0;
}


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

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

  pair<pair<string, int>, int> p[110];
  
  rep(i , N)
  {
    string s;
    int po;
    cin >> s >> po;
    p[i] = make_pair(make_pair(s, -po), i);
  }
  //sort(p.begin(), p.end());
  sort(p, p+N);
  rep(i , N)
  {
    cout << p[i].second+1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a, b;
    char op;
    char op1 = '+';
    char op2 = '-';
    char op3 = '*';
    char op4 = '/';
    char e = '?';
    

    for( int c = 0 ; c == 0 ; ) {
        scanf("%d %c %d", &a, &op, &b);
        if( op == op1 )     printf("%d\n", a + b);
        if( op == op2 )     printf("%d\n", a - b);
        if( op == op3 )     printf("%d\n", a * b);
        if( op == op4 )     printf("%d\n", a / b);
        if( op == e )   c++;
    }
    
    return 0;
}


Measured memory_bytes: 2088
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Console.WriteLine(N * (N + 1) / 2);
		
		
	}
	int N;
	public Sol(){
		N = ri ();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
const int mx = 200;
int main()
{
    int n, k;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    cout << ((n + 1) / 2)*1.0 / n;
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<vector>
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int c2=0,c5=0;

void f(int n){

	if(n%2==0){
		c2++;
		f(n/2);
	}
	else return;
}

void g(int n){

	if(n%5==0){
		c5++;
		g(n/5);
	}
	else return;
}

int main(){

while(true){

	int n;
	cin >> n;
	if(n==0) break;

	for(int i=2;i<=n;i+=2)
	f(i);

	for(int i=5;i<=n;i+=5)
	g(i);

	cout << min(c2,c5) << endl;

	c2=0; c5=0;

}

	return 0;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  string n;
  cin>>n;
  bool ans=false;
  //sort(n.begin(),n.end());
  rep(i,2){
    if(n[i]==n[i+1]&&n[i+1]==n[i+2]){
      ans=true;
      break;
    }
  }
  cout<<(ans? "Yes":"No")<<endl;
}


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

int N, X;
vector<int> L;

int main() {
    cin >> N >> X;
    L.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", &L[i]);
    int ans = 1;
    for (int i = 0; i < N; i++) {
        X -= L[i];
        if (X < 0) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
L,R = list(map(int, input().split()))

ans = 10**12
for i in range(L, R+1):
    tmp = i - L+1
    for j in range(L+tmp, R+1):
        ans = min(ans, i*j % 2019)
        if(ans == 0):
            print(0)
            exit()

print(ans)

Measured memory_bytes: 9132
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
		int H,W;
		do{
			H = scan.nextInt();
			W = scan.nextInt();
			if(H == 0 && W == 0){break;} // H = 0 W = 0 ??§??????
			for(int i = 0;i < H;i++){
				for(int j = 0;j < W;j++){
					System.out.print("#");
				}
					System.out.print("\n");
			}
			System.out.print("\n");	
		}while(true);
	}
}

Measured memory_bytes: 37640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>a(n),b(n);
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	long long sa=0,sb=0;
	vector<pair<int,int>>x;
	for(int i=0;i<n;i++)
	{
		x.emplace_back(a[i],i);
		x.emplace_back(b[i],i);
		sa+=a[i];
		sb+=b[i];	
	} 
	sort(x.begin(),x.end());
	vector<long long>pref(x.size()+1);
	pref[0]=0;
	for(int i=0;i<(int)x.size();i++)
		pref[i+1]=pref[i]+x[i].first;
	vector<vector<int>>pos(n);
	for(int i=0;i<(int)x.size();i++)
		pos[x[i].second].push_back(i);
	long long sum=(long long)2e18;
	for(int i=0;i<n;i++)
	{
		int j=n;
		while(1)
		{
			int cc=(pos[i][0]<j)+(pos[i][1]<j);
			if(cc==j-n)
				break;
			j++;
		}
		long long cur=pref[j];
		if(pos[i][0]<j)
			cur-=x[pos[i][0]].first;
		if(pos[i][1]<j)
			cur-=x[pos[i][1]].first;
		sum=min(sum,cur);
	}
	sum=min(sum,min(sa,sb));
	cout<<sum<<"\n"; 
	return 0;
}


Measured memory_bytes: 9584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n;cin>>n;
	string s;cin>>s;
	ll f[26];
	memset(f,0,sizeof(f));
	For(i,0,n) f[s[i]-'a']++;
	ll ans=1;

	For(i,0,26){
		ans = (ans*(1+f[i]))%Mod;
	}

	cout<<ans-1<<endl;









	
}

Measured memory_bytes: 512
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    a = LI()
    a.sort()
    x = list(set(a))
    if len(x) > 3:
        print("No")
    elif len(x) == 3:
        x1 = bisect_right(a, x[0]) - bisect_left(a, x[0])
        x2 = bisect_right(a, x[1]) - bisect_left(a, x[1])
        x3 = bisect_right(a, x[2]) - bisect_left(a, x[2])
        if ((x[0] ^ x[1] ^ x[2]) == 0) and (x1 == x2 == x3):
            print("Yes")
        else:
            print("No")
    elif len(x) == 2:
        x1 = bisect_right(a, x[0]) - bisect_left(a, x[0])
        x2 = bisect_right(a, x[1]) - bisect_left(a, x[1])
        if x1 * 2 == x2 and x[0] == 0:
            print("Yes")
        else:
            print("No")
    elif len(x) == 1:
        if x[0] == 0:
            print("Yes")
        else:
            print("No")
    return

#B
def B():
    n, m = LI()
    if m % 2:
        print(-1)
        return
    edg = [[] for _ in range(n)]
    ins = defaultdict(int)
    c = defaultdict(int)
    for _ in range(m):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
        ins[a] += 1
        ins[b] += 1
    dag = [[] for _ in range(n)]
    q = deque()
    q.append((0, -1))
    for i in edg[0]:
        q.append((i, 0))
    while q:
        now, per = q.pop()
        if per == -1:
            continue
        if c[now]:
            pass
        
    for d in dag:
        if len(d) % 2:
            print(-1)
            return
    for num, d in enumerate(dag):
        for x in d:
            print(num + 1, x + 1)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		if (n % k == 0) {
			pr.println(0);
		} else {
			pr.println(1);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21972
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(bf.readLine());
        String[] str = bf.readLine().split(" ");
        List<Integer> h = new ArrayList<>();
        for(int i = 0; i < N; i++){
            h.add(Integer.parseInt(str[i]));
        }
        System.out.println(count(h));
    }
    public static Integer min(List<Integer> data){
        Integer min = data.get(0);
        for(int i = 1; i < data.size(); i++){
            Integer value = data.get(i);
            if(value < min){
                min = value;
            }
        }
        return min;
    }
    public static int count(List<Integer> data){
        int min = min(data);
        for(int i = 0; i < data.size(); i++){
            Integer value = data.get(i);
            data.set(i, value-min);
        }
        boolean zero = true;
        List<List> a = new ArrayList<>();
        for(int i = 0; i < data.size(); i++){
            int value = data.get(i);
            if(zero && value > 0){
                a.add(new ArrayList<Integer>());
                a.get(a.size()-1).add(value);
                zero = false;
            } else if(!zero){
                if(value > 0){
                    a.get(a.size()-1).add(value);
                } else{
                    zero = true;
                }
            }
        }
        int answer = min;
        for(int i = 0; i < a.size(); i++){
            answer += count(a.get(i));
        }
        return answer;
    }
}

Measured memory_bytes: 21076
#!/usr/bin/env python
# coding: utf-8
#


def main(input_str):
    l = list(input_str)
    sum_ = 0
    for i in range(len(l)):
        if '+' == l[i]:
            sum_ += 1
        else:
            sum_ -= 1
    print(sum_)


if __name__ == '__main__':
    try:

        main(input().strip())
    except EOFError:
        pass


Measured memory_bytes: 2940
import java.util.*;

class Main {
	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++) d[i] = sc.nextInt();
		
		int sum = 0;
		for (int i = 0; i < N-1; i++) {
			for (int j = i+1; j < N; j++) {
				sum += d[i]*d[j];
			}
		}
		System.out.println(sum);
	}

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

Measured memory_bytes: 22740
import itertools
import bisect

n=int(input())
l=list(map(int,input().split()))

l.sort()
ans=0

for lst in itertools.combinations(range(n-1),2):
  a=l[lst[0]]
  b=l[lst[1]]
  ans+=bisect.bisect_left(l,a+b)-(lst[1]+1)


print(ans)

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

public static class Program
{
    public static void Main(string[] args)
    {
        var nkq = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var result = new int[nkq[0]];
        for (int i = 0; i < nkq[2]; i++)
            result[int.Parse(Console.ReadLine()) - 1]++;
        for (int i = 0; i < nkq[0]; i++)
        {
            var num = nkq[2] - result[i];
            Console.WriteLine(nkq[1] - (nkq[2] - result[i]) > 0 ? "Yes" : "No");
        }
    }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin >> v[i];
    
    sort(v.begin(),v.end());
    int k = n/2- 1;
    long long int ans = v[k+1] - v[k];
    cout << ans;

}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int gcd(int A,int B){
    if(B == 0){
        return A;
    }
    return gcd(B,A%B);
}

/*
2
1000000000
1
-999999999
*/
int main(){
    
    int n,min = (int)pow(10,10);
    int range = - min;
    scanf("%d",&n);

    for(int i = 0;i<n;i++){
        int buff;
        scanf("%d",&buff);

        if(range <= buff - min){
            range = buff - min;
        }

        if(buff < min){
            min = buff;
        }
        //printf(" %d %d\n",min,range);
    }

    printf("%d\n",range);



    
    

    return 0;
}



Measured memory_bytes: 2744