akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N, a[100005], b[100005], ds[100005], df[100005];
vector<int> G[100005];

void bfs(int s, int *d)
{
    queue<PA> que;
    bool used[100005] = {false};
    fill(d, d + N + 1, INFL);
    d[s] = 0;
    used[s] = true;
    que.push(mk(0, s));
    while(!que.empty()){
        int dis = que.front().first;
        int pos = que.front().second;
        que.pop();
        for(int i = 0; i < (int)G[pos].size(); i++){
            int to = G[pos][i];
            if(!used[to]){
                que.push(mk(dis + 1, to));
                d[to] = dis + 1;
                used[to] = true;
            }
        }
    }
}

int ansbfs(int s, int t)
{
    int res = 1;
    queue<int> que;
    bool used[100005] = {false};
    que.push(s);
    used[s] = true;
    used[t] = true;
    while(!que.empty()){
        int pos = que.front();
        que.pop();
        for(int i = 0; i < (int)G[pos].size(); i++){
            int to = G[pos][i];
            if(!used[to]){
                que.push(to);
                used[to] = true;
                res++;
            }
        }
    }
    return res;
}

signed main()
{
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        cin >> a[i] >> b[i];
        G[a[i]].pb(b[i]);
        G[b[i]].pb(a[i]);
    }
    //1からの最短路
    bfs(1, df);
    //Nからの最短路
    bfs(N, ds);
    int distf = df[N] / 2;
    int dists = df[N] - 1 - distf;
    int ansf = 0, anss = 0;
    for(int i = 0; i < N; i++){
        if(distf == df[a[i]] && dists == ds[b[i]]){
            //a[i]を根とするfの領地の数と、b[i]を根とするsの領地の数を求める
            ansf = ansbfs(a[i], b[i]);
            anss = ansbfs(b[i], a[i]);
        }
        else if(distf == df[b[i]] && dists == ds[a[i]]){
            ansf = ansbfs(b[i], a[i]);
            anss = ansbfs(a[i], b[i]);
        }
    }
    if(ansf <= anss){
        printf("Snuke\n");
    }
    else{
        printf("Fennec\n");
    }

    return 0;
}
/*


*/


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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int & x : p) {
        cin >> x;
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>

#define mod 1e9+7
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    ll ans = 0;
    string S,T;
    cin >> S;
    rep(i, S.size()) cout << "x";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int min=Integer.MAX_VALUE;
		int max=Integer.MIN_VALUE;
		long sum=0;
		for(int i=0;i<n;i++){
			int x=scan.nextInt();
			if(x > max)max=x;
			if(x < min)min=x;
                        sum+=x;
		}
		
		System.out.printf("%d %d ",min,max);
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 42492
n = int(input())
ans = [0]*(n+1)

for x in range(1, 10**2+1):
    for y in range(1, 10**2+1):
        for z in range(1, 10**2+1):
            if x**2+y**2+z**2+x*y+y*z+z*x <= n:
                ans[x**2+y**2+z**2+x*y+y*z+z*x] += 1

for i in range(1, len(ans)):
    print(ans[i])

Measured memory_bytes: 9248
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
#include <limits>

using namespace std;


int main(int argc, const char * argv[]) {
  long long n;
  cin >> n;
  int a;
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  long N = 0;
  long S = 0;
  //入力
  scanf("%ld", &N );
  //計算
  long ans = N;
  for (size_t i = 0; i < 9; i++) {
    S += N%10;
    N = N/10;
  }
  //出力
  if ( S == 0 ) {
    printf("Yes\n");
  } else if ( (ans%S) == 0 ) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int A,B,C; cin >> A >> B >> C;
    cout << min({A+B,B+C,C+A}) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char S[100005], T[100005];
int main() {
	scanf("%s%s", S, T);
	int n = strlen(S), m = strlen(T);
	vector<int> ss(n + 1), tt(m + 1);
	for (int i = 0; i < n; ++i) ss[i + 1] = ss[i] + 1 + (S[i] == 'B');
	for (int i = 0; i < m; ++i) tt[i + 1] = tt[i] + 1 + (T[i] == 'B');
	int q;
	scanf("%d", &q);
	while (q--) {
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		printf((ss[b] - ss[a - 1]) % 3 == (tt[d] - tt[c - 1]) % 3 ? "YES\n" : "NO\n");
	}
}


Measured memory_bytes: 1536
from networkx import*
(N,M,*S),*t=[map(int,t.split())for t in open(0)]
G=Graph()
for*u,a,b in t:G.add_edge(*u,y=a,s=b)
b=m=10**15
y,s,*r=map(eval(dir()[761]),(G,G),S,(m,m),'ys')
while N:b=min(b,y[N]+s[N]);r+=m-b,;N-=1
print(*r[::-1])

Measured memory_bytes: 209352
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;

	map<ll, ll> dic;
	vector<bool> flg(1000001, true);
	vll A(N);
	rep(i, 0, N) {
		std::cin >> A[i];
		dic[A[i]]++;
	}

	ll ans = 0;
	for (auto itr = dic.begin(); itr != dic.end(); itr++) {
		if (itr->second == 1 && flg[itr->first]) {
			ans++;
		}
		if (flg[itr->first]) {
			for (ll i = itr->first; i <= 1000000; i += itr->first) {
				flg[i] = false;
			}
		}
	}

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


Measured memory_bytes: 17456
def main():
    S = input()
    if len(S) % 2 == 1:
        print("No")
        return
    for i in range(0, len(S), 2):
        if S[i:i+2] != "hi":
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}



int atcoder(){
    int n,k;
  	string s;
  	cin>>n>>s>>k;
	REP(i,0,n) if(s[i]!=s[k-1]) s[i]='*';
	cout<<s<<ENT;
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
         
        #define LENGTH 100
         
        int main(void) {
          int x1 = 1;
          int x2 = 2;
          int x3 = 3;
          int x4 = 4;
          int x5 = 5;
          char input[LENGTH];
          //while (1) {
            fgets(input, LENGTH-1, stdin);
            sscanf(input, "%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);
            int n = 0;
            if (x1 == 0) n = 1;
            else if (x2 == 0) n = 2;
            else if (x3 == 0) n = 3;
            else if (x4 == 0) n = 4;
            else n = 5;
            printf("%d\n", n);
        //  }
          return 0;
         
        }

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

using namespace std;

vector<bool> isPrime;
vector<int> primes;

void SieveOfEratosthenes(int n) {
  isPrime = vector<bool>(n, true);
  isPrime[0] = false;
  isPrime[1] = false;

  for (int i = 2; i < n; i++) {
    if (isPrime[i]) {
      for (int j = i * 2; j < n; j += i) {
        isPrime[j] = false;
      }
      primes.push_back(i);
    }
  }
}

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

  vector<int> results;
  results.push_back(2);
  while (results.size() < N) {
    int current = results.back() + 5;
    while (!isPrime[current]) {
      current += 5;
    }
    results.push_back(current);
  }

  for (int i = 0; i < N; i++) {
    printf("%d", results[i]);
    if (i < N - 1) printf(" ");
  }
}


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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
template<class T> void __print( v<T> &arr ){
    int n = arr.size() ;
    cerr << "[ " ;
    for( int i = 0 ; i < n ; i++ ) {
        cerr << arr[i] ;
        if( i != n - 1 ) cerr << ", " ;
    }
    cerr << " ]" << endl ;
}
template<class T> void __print( T arr[], int n ){ 
    cerr << "[ " ;
    for( int i = 0 ; i < n ; i++ ) {
        cerr << arr[i] ;
        if( i != n - 1 ) cerr << ", " ;
    }
    cerr << " ]" << endl ;
}
#define print(x) cerr << "{ " << #x << " : " << x << " } " ;
// Template END

signed main(){
    int T = 1 ;
    while( T-- ){
        int x, n ; cin >> x >> n ;
        v<int> a(n), cnt(101, 0) ;
        for( int i = 0 ; i < n ; i++ ) {
            cin >> a[i] ;
            cnt[a[i]]++ ;
        }
        int diff = INT_MAX ;
        int res = -1 ;
        for( int i = -1 ; i <= 101 ; i++ ){
            if( i == -1 || i == 101 || !cnt[i] ){
                if( abs(i - x) < diff ){
                    diff = abs(i - x) ;
                    res = i ;
                }
            }
        }
        cout << res << endl ;        
    }
    return 0 ;   
}          

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int n, l, r, ok = 0;
	scanf("%d%d%d", &n, &l, &r);
	for(int i=l;i<=r;i++)
	{
		if(i%n==0)
		{
			ok = 1;
			break;
		}
	}
	if(ok) printf("OK\n");
	else printf("NG\n");
	return 0;
}

Measured memory_bytes: 1608
#include<iostream>
using namespace std;
int main() {
 string S;
 cin >> S;
 int L;
 L = S.size();
 S = S.erase(L-2);
 L = S.size();
 while (S.substr(0, L/2) != S.substr(L/2)) {
  S.erase(L-2);
  L = S.size();
 }
 cout << S.size() << endl;
 return 0;
}

Measured memory_bytes: 256
x = [[0]*50 for i in range(11)]
for i in range(0, 2**10):
    B = format(i,'b')[::-1]
    s,c,j = 0,0,0
    for e in B:
        if e=="1": s, c = s+j, c+1
        j += 1
    x[c][s] += 1

while 1:
    n,s = map(int, raw_input().split())
    if n==0 and s==0: break
    print 0 if s>=50 else x[n][s]

Measured memory_bytes: 4244
#include <bits/stdc++.h>
#define all(x) ((x).begin(), (x).end())
#define sz(x) ((int) (x).size())
using namespace std;
typedef pair<int,int> ii;
typedef long long lint;

int arr[200005];

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n; cin >> n;
	
	for(int i = 1;i <= n;i++) cin >> arr[i];
	arr[0] = -1;
	
	lint ans = -1;
	for(int i = 1;i <= n;i++){
		if(arr[i] - arr[i-1] >= 2){
			cout << -1;
			return 0;
		}
		
		if(arr[i] == arr[i-1] + 1) ans++;
		else ans += arr[i];
		
		//cout << ans << "\n";
	}
	
	cout << ans;
}



Measured memory_bytes: 4436
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
int n;
const int INF=1e9+7;
int p[200005];
int pos[200005];
struct Tree{
	int odd,even;
}tree[800005];
void push_up(int node){
	tree[node].even=min(tree[node<<1].even,tree[(node<<1)+1].even);
	tree[node].odd=min(tree[node<<1].odd,tree[(node<<1)+1].odd);
	return;
}
void build(int l,int r,int node){
	if (l==r){
		if (l%2==1){
			tree[node].odd=p[l];
			tree[node].even=INF;
		}
		else{
			tree[node].even=p[l];
			tree[node].odd=INF;
		}
		return;
	}
	int mid=(l+r)>>1;
	build(l,mid,node<<1);
	build(mid+1,r,(node<<1)+1);
	push_up(node);
}
int getodd(int l,int r,int node,int L,int R){
	if (L>R){
		return INF;
	}
	if (l==L && r==R){
		return tree[node].odd;
	}
	int mid=(l+r)>>1;
	int re=min(getodd(l,mid,node<<1,L,min(mid,R)),getodd(mid+1,r,(node<<1)+1,max(mid+1,L),R));
	return re;
}
int geteven(int l,int r,int node,int L,int R){
	if (L>R){
		return INF;
	}
	if (l==L && r==R){
		return tree[node].even;
	}
	int mid=(l+r)>>1;
	int re=min(geteven(l,mid,node<<1,L,min(mid,R)),geteven(mid+1,r,(node<<1)+1,max(mid+1,L),R));
	return re;
}
priority_queue<pair<int,pair<int,int> > > q;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		pos[p[i]]=i;
	}
	build(1,n,1);
	q.push(make_pair(-tree[1].odd,make_pair(1,n)));
	while (!q.empty()){
		pair<int,pair<int,int> > t=q.top();
		//cout<<"t.first="<<-t.first<<endl;
		q.pop();
		int L=pos[-t.first];
		int R;
		int nxt;
	    if (t.second.first%2==1){
	    	nxt=geteven(1,n,1,L+1,t.second.second);
	    	R=pos[nxt];
	    }
	    else{
	    	nxt=getodd(1,n,1,L+1,t.second.second);
	    	R=pos[nxt];
	    }
	    //cout<<L<<" "<<R<<endl;
	    pair<int,pair<int,int> > n1,n2,n3;
	    n1.second=make_pair(t.second.first,L-1);
	    n2.second=make_pair(L+1,R-1);
	    n3.second=make_pair(R+1,t.second.second);
	    if (n1.second.second>n1.second.first){
	        if (n1.second.first%2==1){
	        	n1.first=-getodd(1,n,1,n1.second.first,n1.second.second);
	        }
	        else{
	        	n1.first=-geteven(1,n,1,n1.second.first,n1.second.second);
	        }
	      //  cout<<"n1:"<<-n1.first<<" "<<n1.second.first<<" "<<n1.second.second<<endl;
	        q.push(n1);
	    }
	    if (n2.second.second>n2.second.first){
	        if (n2.second.first%2==1){
	        	n2.first=-getodd(1,n,1,n2.second.first,n2.second.second);
	        }
	        else{
	        	n2.first=-geteven(1,n,1,n2.second.first,n2.second.second);
	        }
	        //cout<<"n2:"<<-n2.first<<" "<<n2.second.first<<" "<<n2.second.second<<endl;
	        q.push(n2);
	    }
	    if (n3.second.second>n3.second.first){
	        if (n3.second.first%2==1){
	        	n3.first=-getodd(1,n,1,n3.second.first,n3.second.second);
	        }
	        else{
	        	n3.first=-geteven(1,n,1,n3.second.first,n3.second.second);
	        }
	         //cout<<"n3:"<<-n3.first<<" "<<n3.second.first<<" "<<n3.second.second<<endl;
	        q.push(n3);
	    }
	    printf("%d %d ",-t.first,nxt);
	}
	return 0;
}

Measured memory_bytes: 9848
import math
 
N, M=input().split(" ")
N=int(N)
M=int(M)
 
def get_number(M):
    result=list()
    for i in range(1,int(math.sqrt(M))):
        if M%i==0:
            result.append(i)
            result.append(int(M/i))
    result.sort()
    return(result)
    
def check_number(N,M):
    if N==1:
        return(M)
    number=get_number(M)
    answer=list()
    for i in number:
        if M/i>=N:
            answer.append(i)
            
    return(answer[-1])
    
print(check_number(N,M))

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

using namespace std;

int main(){
  char s;
  int kazu=0;

  for(int i=0;i <4;i++){
    
  cin >> s;

  if(s == '+')
    {
      kazu++;
    }
  else
    {
      kazu--;
    }
  }

  cout << kazu << endl;
}


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

int main(){

    ll N,a,b,ret,_ret;
    cin >> N;

    a = N;
    b = 1;
    ret = a + 1 - 2;

    for (int i=1; i<=1000000; i ++){
        if(a%i == 0){
            _ret = (a/i) + (b*i) - 2;
            if(ret > _ret){
                ret = _ret;
            }
        }
    }

    cout << ret<< endl;


    return 0; 
}

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

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

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  while(1){
    int w,d; cin >> w >> d;
    if(w == 0) break;

    map<int,int> mph,mpd;
    rep(i,w){
      int h; cin >> h;
      mph[h]++;
    }
    rep(i,d){
      int h; cin >> h;
      mpd[h]++;
    }

    int ans = 0;
    for(auto x : mph){
      auto y = mpd.find(x.fst);
      if(y == mpd.end()) ans += x.fst * x.snd;
      else ans += x.fst * max(x.snd, y->snd);
    }
    for(auto y : mpd){
      auto x = mph.find(y.fst);
      if(x == mph.end()) ans += y.fst * y.snd;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
long long sum;
int a[200050];
int main()
{
	int n,k;
	cin>>n>>k;
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	if (k>=n)
		cout<<0;
	else
	{
		for (int i=0;i<n-k;i++)
			sum+=a[i];
		cout<<sum;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
int a[200005],n,b[200005],i,l,A,M,r=200005;
int P(int x){for(i=1;i<n*2;i++)b[i]=(a[i]>=x);b[0]=b[1];
for(i=n;i<=n+n;i++){if(b[i]==b[i+1])return b[i];if(b[n+n-i]==b[n+n-i-1])return b[n+n-i];}}
int main(){std::cin>>n;for(i=1;i<n*2;i++)std::cin>>a[i];
while(l<=r){M=(l+r)/2;if(P(M))l=M+1,A=M;else r=M-1;}std::cout<<A;}

Measured memory_bytes: 1792
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n = arr.shift()-0;
var s = (n.toString(2) + "").split("").map(Number);
var sum = s.reduce((a,b)=>a+b); 
var l = (n.toString(2) + "").length - 1;
console.log(Math.max(sum,l));


Measured memory_bytes: 17212
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int cnt = 0;
	int val = n;
	while (val > 0) {
		cnt += val % 10;
		val /= 10;
	}
	if (n%cnt == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>

using namespace std;

int main() {

	int a,b,c,d;
	int tmp1, tmp2;
	cin >> a>>b>>c>>d;
	
	for (;;) {
		
		c -= b;
		if (c <= 0) {
			cout << "Yes";
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No";
			break;
		}
		//cout << a << " " << c<<endl;

	}


	return 0;
}

Measured memory_bytes: 3128
#define NguyenDangQuan the_author
#define my_heart love_you_to_the_moon_and_back

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

bool typetest;
inline void fastIOfileinput()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	typetest = 0;
}

const int N = 3e3 + 3;
int m, n, k;
ll a[N][N], dp[N][N][5];

void Read()
{
	cin >> m >> n >> k;
	for (int i = 1; i <= k; ++i)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		a[u][v] = w;
	}
}

ll &f(int x, int y, int z)
{
	return dp[x][y][z];
}

void Solve()
{
	for (int i = 1; i <= m; ++i)
		for (int j = 1; j <= n; ++j)
		{
			f(i, j, 0) = max(f(i, j - 1, 0), f(i - 1, j, 4));
			f(i, j, 1) = max(f(i, j - 1, 0) + a[i][j], max(f(i - 1, j, 4) + a[i][j], f(i, j - 1, 1)));
			f(i, j, 2) = max(f(i, j - 1, 2), f(i, j - 1, 1) + a[i][j]);
			f(i, j, 3) = max(f(i, j - 1, 3), f(i, j - 1, 2) + a[i][j]);
			f(i, j, 4) = max(max(f(i, j, 0), f(i, j, 1)), max(f(i, j, 2), f(i, j, 3)));
			//cout << f(i, j, 4) << (j == n ? "\n" : " ");
		}
	cout << f(m, n, 4);
}

int32_t main()
{
	fastIOfileinput();
	if (typetest)
	{
		int t;
		cin >> t;
		while (t--)
		{
			Read();
			Solve();
		}
	}
	else
	{
		Read();
		Solve();
	}
}

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

int main(void){
  int a, b;
  cin >> a >> b;
  
  for(int i = 1; i <= 3; i ++){
    if((a * b * i) % 2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>  
   
int a[105][105],b[10000+50];  
   
int main ()  
{  
    int h,w;  
    while(scanf("%d %d",&h,&w)!=EOF)  
    {  
        int i,j,t,k=0;  
        scanf("%d",&t);  
        for(i=0;i<t;i++)  
            scanf("%d",&b[i]);  
        for(i=0;i<h;i++)  
        {  
            if(i%2==0)  
                for(j=0;j<w;j++)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
            if(i%2==1)  
                for(j=w-1;j>=0;j--)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
        }  
        for(i=0;i<h;i++)  
        {  
            for(j=0;j<w-1;j++)  
                printf("%d ",a[i][j]);  
            printf("%d\n",a[i][w-1]);  
        }  
    }  
}  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const ll INFL = 2e18;
const int MAX_N = 1;

ll D, G, ans = INFL;

int main() {
  cin >> D >> G;
  vi p(D), c(D), cmpl(D);
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
    cmpl[i] = (i+1)*p[i] + c[i];
  }
  for (int i = 0; i < (1<<D); i++) {
    ll sum = 0, cnt = 0;
    for (int d = 0; d < D; d++) {
      if (i & (1<<d)) {
        sum += p[d]*100*(d+1) + cmpl[d];
        cnt += p[d];
      }
    }
    if (sum >= G) ans = min(ans, cnt);
    for (int d = 0; d < D; d++) {
      if (i & (1<<(D-d-1))) continue;
      for (int j = 1; j < p[D-d-1]; j++) {
        sum += (D-d)*100;
        cnt++;
        if (sum >= G) ans = min(ans, cnt);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int n,m,sum[100010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n>>m;
	int s;
	rep(i,n-1){
		cin>>s;
		sum[i+1]=sum[i]+s;
	}
	int cur=0,a;
	ll ans=0;
	rep(i,m){
		cin>>a;
		ans+=abs(sum[cur]-sum[cur+a]);
		cur+=a;
	}
	cout<<ans%100000<<endl;
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,i,j,k,cnt=0;
	cin >> n;
	int s[n];
	for(i=0;i<n;i++) cin >> s[i];
	for(i=0;i<n;i++)
	for(j=i+1;j<n;j++)
	for(k=j+1;k<n;k++)
	{
		if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k])
		{
			if(s[i]+s[j]>s[k] && s[i]+s[k]>s[j] && s[k]+s[j]>s[i])
			{
				cnt++;
			}
		}
	}
	
	cout << cnt << endl;

	
	return 0;
}

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

const int mod = 998244353;
int n, k;
long long dp[200010];
int l[20], r[20];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < k; ++i)
		scanf("%d%d", &l[i], &r[i]);
	dp[1] = 1;
	for (int i = 2; i <= n; ++i) {
		for (int j = 0; j < k; ++j)
			if (l[j] <= i - 1)
				dp[i] = (dp[i] + dp[i - l[j]] - (i - r[j] >= 2 ? dp[i - r[j] - 1] : 0)) % mod;
		dp[i] = (dp[i] + dp[i - 1]) % mod;
	}
	printf("%lld\n", ((dp[n] - dp[n - 1]) % mod + mod) % mod);
	return 0;
}



Measured memory_bytes: 5292
//
// Created by Ryuta Kremer on 2018-12-08.
//

//uncorrect

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ull A(ull num, ull x)
{
    if (x == 0) {
        return 0;
    }
    if (num == 1 && x == 1) {
        return 0;
    } else if (num == 1 && x == 2) {
        return 1;
    } else if (num == 1 && x == 3) {
        return 2;
    } else if (num == 1 && x == 4) {
        return 3;
    } else if (num == 1 && x == 5) {
        return 3;
    }
    //cout<<num<<endl;
    ull l = (1ull << (num + 1)) - 3;
    if (x == 2 * l + 3) {
        return A(num-1, l) * 2 + 1;
    } else if (x > l + 2) {
        return A(num-1, l) + 1 + A(num-1, x-l-2);
    } else if (x == l + 2){
        return A(num-1, l) + 1;
    } else {
        return A(num-1, x-1);
    }
}

int main()
{
    ull n, x;
    cin>>n>>x;

    ull ans = A(n,x);

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
broken = {-1 => true}
m.times{broken[gets.to_i] = true}
arr = [1]
1.upto(n){|i|
    arr << 0
    next if broken[i]
    arr[i] = (arr[i] + arr[i - 2]) % 1_000_000_007
    arr[i] = (arr[i] + arr[i - 1]) % 1_000_000_007
}
puts arr.last

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;
using ll = long long;


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

    bool ok = true;
    rep(i, n-1) if(v[i] > v[i+1]) ok = false;

    rep(i, n){
        rep(j, n){
            auto t = v;
            swap(t[i], t[j]);
            bool flag = true;
            rep(k, n-1){
                if(t[k] > t[k+1]) flag = false;
            }
            if(flag) ok = true;
        }
    }

    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],cnt;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=n;i>=1;i--)
    {
        for(int j=i<<1;j<=n;j+=i)
            a[i]^=a[j];
        if(a[i])cnt++;
    }
    cout<<cnt<<endl;
    for(int i=1;i<=n;i++)if(a[i])cout<<i<<' ';
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

template <typename T>
void dumpvec(vector<T> vec) {
  for (T cnt : vec) {
    cout << cnt << ", ";
  }
  cout << endl;
}

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

vector<string> split(string s, string delimiter) {
  int first = 0;
  int last = s.find_first_of(delimiter);
  vector<string> result;

  while (first < s.size()) {
    string sub = s.substr(first, last - first);
    result.push_back(sub);
    first = last + 1;
    last = s.find_first_of(delimiter, first);

    if (last == string::npos) {
      last = s.size();
    }
  }

  return result;
}

string join(vector<string> strings, string delimiter) {
  string result = "";
  for (int i = 0; i < strings.size(); i++) {
    if (result != "") result += delimiter;
    result += strings[i];
  }
  return result;
}

class Solution {
 public:
  void solve() {
    int N, K;
    cin >> N >> K;
    set<int> availables{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    for (int i = 0; i < K; i++) {
      int n;
      cin >> n;
      availables.erase(n);
    }
    while (true) {
      // dump(N);
      if (satisfy(N, availables)) {
        cout << N << endl;
        return;
      }
      N++;
    }
  }

  bool satisfy(int n, set<int> &availables) {
    if (n == 0) {
      return availables.count(0) > 0;
    }

    while (n > 0) {
      int digit = n % 10;
      if (availables.count(digit) == 0) return false;
      n /= 10;
    }
    return true;
  }
};

int main() { Solution().solve(); }

Measured memory_bytes: 256
fn solve(graph: Vec<Vec<(usize, i64)>>, start: usize) {
    let size = graph.len();
    let mut shortest: Vec<_> = vec![20_000_000; size];
    shortest[start] = 0;
    let mut prev: Vec<_> = vec![size + 1; size];
    prev[start] = start;
    for _ in 0..size - 1 {
        for (from, edges) in graph.iter().enumerate() {
            if shortest[from] != 20_000_000 {
                for &(to, weight) in edges {
                    let alternative_path = shortest[from] + weight;
                    if alternative_path < shortest[to] {
                        shortest[to] = alternative_path;
                        prev[to] = from;
                    }
                }
            }
        }
    }
    // Check negative cycle.
    for from in (0..size).filter(|&from| shortest[from] != 20_000_000) {
        for &(to, weight) in &graph[from] {
            let alternative_path = shortest[from] + weight;
            if alternative_path < shortest[to] {
                // Negative cycle.
                println!("NEGATIVE CYCLE");
                return;
            }
        }
    }
    for s in shortest {
        if s == 20_000_000 {
            println!("INF");
        } else {
            println!("{}", s);
        }
    }
}

use std::io::{BufRead, BufReader};
fn main() {
    let mut read = BufReader::new(std::io::stdin())
        .lines()
        .filter_map(|e| e.ok());
    let (v, _e, start) = {
        let line = read.next().unwrap();
        let line: Vec<&str> = line.split(' ').collect();
        let v: usize = line[0].parse().unwrap();
        let e: usize = line[1].parse().unwrap();
        let start: usize = line[2].parse().unwrap();
        (v, e, start)
    };
    let graph = {
        let mut graph: Vec<Vec<_>> = vec![vec![]; v]; // Adj list
        for edge in read {
            if edge.is_empty() {
                break;
            }
            let mut edge = edge.split(' ');
            let start: usize = edge.next().unwrap().parse().unwrap();
            let end: usize = edge.next().unwrap().parse().unwrap();
            let weight: i64 = edge.next().unwrap().parse().unwrap();
            graph[start].push((end, weight));
        }
        graph
    };
    solve(graph, start);
}



Measured memory_bytes: 5044
S = list(input())
S = [int(x) for x in S]

ans = float('inf')
target = 753
for i in range(len(S)-2):
    num = S[i] * 100 + S[i+1] * 10 + S[i+2] * 1
    diff = abs(target - num)
    ans = min(ans, diff)

print(ans)

Measured memory_bytes: 9172
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i=0;i<n;++i)
    {
        cin >> w[i];
    }

    int s1 = 0;
    int s2 = accumulate(w.begin(), w.end(), 0);
    int ret = abs(s1 - s2);

    for(int i=0; i<n;++i)
    {
        s1 += w[i];
        s2 -= w[i];

        ret = min(ret, abs(s1-s2));
    }

    cout << ret << endl;
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt[27]={0};
    f(i,0,n-1)
    {
        cnt[s[i]-'a']++;
    }
    int ses=1;
    f(i,0,25)
    {
       if(cnt[i]==0)continue;
       ses=gun(ses,cnt[i]+1);
    }
    ses=sub(ses,1);
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3768
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n;
  cin >> n;
  vi vec(n);
  REP(i,n) cin >> vec[i];
  sort(ALL(vec));
  vec[n-1] /= 2;
  int sum = 0;
  REP(i,n) sum += vec[i];
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	
	public static class UnionFind{
		int[] dat;
		
		public UnionFind(int n){
			dat = new int[n];
			for(int i = 0; i < n; i++){
				dat[i] = i;
			}
		}
		
		public int find(int x){
			if(dat[x] == x){
				return x;
			}else{
				return dat[x] = find(dat[x]);
			}
		}
		
		public void union(int x, int y){
			if(find(x) == find(y)){
				return;
			}else{
				dat[find(x)] = find(y);
			}
		}
		
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[] count = new int[26];
			
			HashSet<Integer> using = new HashSet<Integer>();
			UnionFind uf = new UnionFind(26);
			int start = -1;
			for(int i = 0; i < n; i++){
				char[] in = sc.next().toCharArray();
				
				final int from = in[0] - 'a';
				final int to = in[in.length - 1] - 'a';
				count[from]--;
				count[to]++;
				uf.union(from, to);
				using.add(from);
				using.add(to);
				
				if(start == -1){
					start = from;
				}
			}
			
			boolean flag = true;
			for(int in : using){
				if(!uf.same(in, start) || count[in] != 0){
					flag = false;
					break;
				}
			}
			
			if(!flag){
				System.out.println("NG");
			}else{
				System.out.println("OK");
			}
		}
	}

}

Measured memory_bytes: 49744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main() {
  string s;
  while(cin >> s, s != "-") {
    int m, h;
    cin >> m;
    rep(i, m) {
      cin >> h;
      s = s.substr(h) + s.substr(0, h);
    }
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    cin.tie(0); cin.sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
      if (s[i] == s[i + 1]) {
        cout << "Bad" << endl;
        exit(0);
      }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = Console.ReadLine().Split();
    var a = int.Parse(aho[0]);
    var b = int.Parse(aho[1]);
    if(a%b ==0){    Console.WriteLine(a/b);}
    else {Console.WriteLine(a/b+1);}
  
  }
}

Measured memory_bytes: 13140
//abc179_e.cpp
//Sat Sep 19 22:12:48 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (ll i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,x,m;
	cin >> n >> x >> m;

	ll amari[m];
	rep(i,m){
		amari[i] = i*i%m;
	} 

	ll ans = 0;
	ll when[100010];
	fill(when,when+m,-1);
	ll a[100010];
	rep(i,100010){
		if (i==0){
			a[0] = x;
			when[x] = i;
		}else {
			a[i] = amari[a[i-1]];
			if (when[a[i]]==-1){
				when[a[i]] = i;
			}else {
				int loopstart = when[a[i]];
				int loopend = i-1;

				if (n<i){
					ll ans = 0;
					rep(j,n){
						ans += a[j];
					}
					cout << ans << endl;
					return 0;
				}

				ll sumbefloop = 0;
				rep(j,loopstart){
					sumbefloop += a[j];
				}
				ll loopsum = 0;
				for (int j=loopstart;j<=loopend;j++){
					loopsum += a[j];
				}

				ll tmp = n-loopstart;
				ll z = tmp/(loopend-loopstart+1);
				ans = sumbefloop+loopsum*z;
				ll v = tmp%(loopend-loopstart+1);
				for (int j=loopstart;j<loopstart+v;j++){
					ans += a[j];
				}
				cout << ans << endl;
				return 0;
			}
		}
	}
}


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

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

const long long MOD = 1000000007;

int main(){
  string s;
  bool ans = false;
  cin >> s;
  rep(i,2){
    if(s.at(i) != s.at(i+1)) ans = true;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

int sn[100010], tn[100010];
int ss[100010], ts[100010];

signed main(){
    string s, t;
	cin >> s >> t;
	rep(i, 0, s.size()){
		if(s[i] == 'A') sn[i] = 1;
		else sn[i] = 2;
	}
	rep(i, 0, t.size()){
		if(t[i] == 'A') tn[i] = 1;
		else tn[i] = 2;
	}
	ss[0] = 0;
	rep(i, 1, s.size() + 1){
		ss[i] = ss[i - 1] + sn[i - 1];
	}
	ts[0] = 0;
	rep(i, 1, t.size() + 1){
		ts[i] = ts[i - 1] + tn[i - 1];
	}
	int q;
	cin >> q;
	rep(i, 0, q){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int t1 = ss[b] - ss[a - 1];
		int t2 = ts[d] - ts[c - 1];
		if(t1 % 3 == t2 % 3) cout << "YES" << endl;
		else cout << "NO" << endl; 
	}
}

Measured memory_bytes: 3968
l,r = map(int,input().split())

lq = l // 2019
lr = l % 2019
rq = r // 2019
rr = r % 2019

if lq < rq:
    print(0)
else:
    m = 2018 * 2018
    for i in range(lr,rr+1):
        for j in range(i+1,rr+1):
            if m > (i*j)%2019:
                m = (i*j)%2019
    print(m)

Measured memory_bytes: 3060
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    int l;
    l=s.size();

    string substr = t.substr(0,l);
    if (substr==s){
        cout << "Yes" ;
        return 0;
    }
    // cout << substr;
    cout << "No";


    return 0;
}

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

struct SobaDisc {
  int gram;   //< ???
  int price;  //< ??????
};

vector<int> memo(5000+1, 1 << 20);

SobaDisc ShopInfo[6]{
  { 200, 380 },
  { 300, 550 },
  { 500, 850 },
  { 1000,1520 },
  { 1200,1870 },
  { 1500,2244 },
};

inline int min(int a, int b) { return a < b ? a : b; }

// ?????\??????????????????
void MinMoney() {
  for (int i = 0; i < 6; i++) {
    int gram  = ShopInfo[i].gram;
    int price = ShopInfo[i].price;
    memo[0] = 0;
    for (int j = 0; j + gram <= 5000; j+=100) {
      memo[j + gram] = min(memo[j + gram], memo[j] + price);
    }
  }
}

int main() {
  MinMoney();

  int input_gram;
  while (cin >> input_gram, input_gram != 0) {
    cout << memo[input_gram] << endl;
  }
}

Measured memory_bytes: 1212