akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <functional>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 100000000
template<class T, class C> void chmax(T& a, C b) { a>b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a<b ? : a = b; }

int sx, sy, tx, ty;

int main() {
	cin >> sx >> sy >> tx >> ty;
	int xs = tx - sx;
	int ys = ty - sy;
	for (int i = 0; i < ys; i++) cout << "U";
	for (int i = 0; i < xs; i++) cout << "R";
	for (int i = 0; i < ys; i++) cout << "D";
	for (int i = 0; i < xs; i++) cout << "L";
	cout << "L";
	for (int i = 0; i < ys+1; i++) cout << "U";
	for (int i = 0; i < xs + 1; i++) cout << "R";
	cout << "D";
	cout << "R";
	for (int i = 0; i < ys + 1; i++) cout << "D";
	for (int i = 0; i < xs + 1; i++) cout << "L";
	cout << "U" << endl;
	return 0;
}


Measured memory_bytes: 256
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	vector<int> x(6);
	for(int i = 1; i <= 5; i++) {
		cin >> x[i];
		if(x[i] == 0) {
			cout << i << endl;
			return 0;
		}
	}	
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
	int n,i,j,r,x;
	char s[128],t[128];
	scanf("%d",&n);
	scanf("%s",s);
	scanf("%s",t);
	r=2*n;
	for(i=1;i<=n;i++){
		x = n-i;
		for(j=0;j<i;j++){
			if(s[j+x] != t[j]){break;}
			if(j == i-1){r=2*n-i;}
		}
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 128
s=input()
t=input()
lt=len(t);ls=len(s)
ans=lt
for i in range(ls-lt+1):
    cnt=0
    for j in range(len(t)):
        if s[i:i+lt][j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
string a,b;
int n,m;
string s;
int main(){
    cin>>a>>b;
    read(n),read(m);
    cin>>s;
    if(s==a){
        n--;
    }
    if(s==b){
        m--;
    }
    cout<<n<<" "<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
d ={}
for i in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
M = int(input())
for j in range(M):
  a = input()
  if a in d:
    d[a] -= 1
  else:
    d[a] = -1
li = d.values()
print(max(li) if max(li) >= 0 else 0)

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 * 2 + 5;

ll adds[MAXN];
ll ans[MAXN];

vector<int> G[MAXN];

void dfs(int cur, int p, ll count) {
  count += adds[cur];
  ans[cur] = count;
  for (int i = 0; i < (int)G[cur].size(); ++i) {
    if (G[cur][i] != p) {
      dfs(G[cur][i], cur, count);
    }
  }
}

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

  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    // cerr << "a, b: " << a << " " << b << endl;
    a--; b--;    
    G[a].push_back(b);
  }

  for (int i = 0; i < q; ++i) {
    int p; ll x;
    cin >> p;
    cin >> x;
    p--;
    adds[p] += x;
  }

  dfs(0, -1, 0);
  for (int i = 0; i < n; ++i) {
    cout << ans[i];
    if (i == n - 1) cout << endl;
    else cout << " ";
  }
  return 0;
}



Measured memory_bytes: 31872
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var list = nextIntArray();
	myout(list.indexOf(0) + 1);
}

Measured memory_bytes: 30104
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  X,K,D=LI()

  if abs(X)>=K*D:
    return abs(X)-K*D

  x=abs(X)
  c1=(x+D-1)//D

  K-=c1
  x1=c1*D-x

  if K%2==0:
    return x1

  return D-x1

# main()
print(main())


Measured memory_bytes: 10804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n;cin >> n;
    vector<int> res;
    for(int i = 1;i*i <= n;i++){
        if(n%i == 0){
            res.push_back(i);
        }

    }
    int ans = 1001001001001ll;
    for(auto p:res){
        
        ans = min(ans,abs(p-1) + abs(n/p - 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {

    int a, b, c;
    std::cin >> a >> b >> c;

    int count = 0;

    for ( int i = a; i <= b; i++ ) {

        if ( c % i == 0 ) count++;

    }

    std::cout << count << std::endl;

    return 0;
}



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

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

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int


char map[22][22];

int func(int y, int x){
    char test[22][22];
    int ans[22][22];
    rep(i, 0, 22){
        rep(j, 0, 22){
            test[i][j] = map[i][j];
            ans[i][j] = 0;
        }
    }
    int ys[1000], xs[1000], l=0, p = 0;
    ys[0] = y; xs[0] = x; l++;
    test[y][x] = '#';
    ans[y][x] = 0;
    while(p<l){
        int ny = ys[p], nx = xs[p];
        if(test[ny-1][nx] == '.'){
            ys[l] = ny-1;
            xs[l] = nx;
            l++;
            test[ny-1][nx] = '#';
            ans[ny-1][nx] = ans[ny][nx] + 1;
        }
        if(test[ny][nx+1] == '.'){
            ys[l] = ny;
            xs[l] = nx+1;
            l++;
            test[ny][nx+1] = '#';
            ans[ny][nx+1] = ans[ny][nx] + 1;
        }
        if(test[ny+1][nx] == '.'){
            ys[l] = ny+1;
            xs[l] = nx;
            l++;
            test[ny+1][nx] = '#';
            ans[ny+1][nx] = ans[ny][nx] + 1;
        }
        if(test[ny][nx-1] == '.'){
            ys[l] = ny;
            xs[l] = nx-1;
            l++;
            test[ny][nx-1] = '#';
            ans[ny][nx-1] = ans[ny][nx] + 1;
        }
        p++;
    }
    int max = 0;
    rep(i, 0, 22){
        rep(j, 0, 22){
            //printf("%d ", ans[i][j]);
            if(max < ans[i][j] && map[i][j] == '.'){
                max = ans[i][j];
            }
        }
        //printf("\n");
    }
    return max;
}

int main(){
    int h, w;
    scanf("%d %d", &h, &w);
    rep(i, 0, 22){
        rep(j, 0, 22){
            map[i][j] = '#';
        }
    }
    rep(i, 1, h+1){
        char s[w+1];
        scanf("%s", s);
        rep(j, 0, w){
            map[i][j+1] = s[j];
        }
    }
    int ans = 0;
    rep(i, 1, h+1){
        rep(j, 1, w+1){
            if(map[i][j] == '.'){
                int buf = func(i, j);
                if(ans < buf){
                    ans = buf;
                    //printf("%d %d\n", i, j);
                }
            }
        }
    }
    /*rep(i, 0, 22){
        rep(j, 0, 22){
            printf("%c", map[i][j]);
        }
        printf("\n");
    }*/
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
/*
problem's name:
statue:
writer:Chris
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const ll INF=20050208;
/*------------main part------------*/



ll num[1000005];
ll pre[1000005];
ll dat[1000005][2];
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>num[i];
	}
	pre[0]=num[0];
	for(ll i=1;i<n;i++)
	{
		pre[i]=pre[i-1]+num[i];
	}
	ll cnt=0;
	for(ll i=1;i<n-2;i++)
	{
		ll l=pre[cnt];
		ll r=pre[i]-pre[cnt];
		while(r-l>num[cnt+1])
		{
			cnt++;
			l=pre[cnt];
			r=pre[i]-pre[cnt];
		}
		dat[i][0]=cnt;
	}
	cnt=n-2;
	for(ll i=n-3;i>=1;i--)
	{
		ll l=pre[cnt]-pre[i];
		ll r=pre[n-1]-pre[cnt];
		while(l-r>num[cnt])
		{
			cnt--;
			l=pre[cnt]-pre[i];
			r=pre[n-1]-pre[cnt];
		}
		dat[i][1]=cnt;
	}
	ll ans=1e9;
	ll x=0,y=0;
	for(ll i=1;i<n-2;i++)
	{
		x=dat[i][0];
		y=dat[i][1];
		ll ma=max(max(pre[x],pre[i]-pre[x]),max(pre[y]-pre[i],pre[n-1]-pre[y]));
		ll mi=min(min(pre[x],pre[i]-pre[x]),min(pre[y]-pre[i],pre[n-1]-pre[y]));
		ans=min(ans,ma-mi);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12544
# coding: utf-8
# Here your code !
import math

def func():
    try:
        line=input().rstrip()
        numbers=line.split(" ")
        
        width=float(numbers[0])
        height=float(numbers[1])
        x=float(numbers[2])
        y=float(numbers[3])
        r=abs(float(numbers[4]))
        
    except:
        print("input error")
        return -1
    
    wsign=math.copysign(1,width)
    hsign=math.copysign(1,height)
    
    
    result="No"
    if(wsign*x+r <= wsign*width):
        if(wsign*x-r >= 0):
            if(hsign*y+r <= hsign*height):
                if(hsign*y-r >= 0):
                    result="Yes"
  
    print(result)
    
func()

Measured memory_bytes: 7660
fun main(args: Array<String>){
    val (a, b, c, d) = readLine()!!.split(' ').map { x -> x.toInt() }
    val abc: Array<Int> = arrayOf(a, b, c)

    if (Math.abs(abc[2] - abc[0]) <= d){
        println("Yes")
    }else{
        abc.sort()
        if (abc[2] - abc[1] <= d && abc[1] - abc[0] <= d){
            println("Yes")
        }else{
            println("No")
        }
    }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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 end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n),b(n),c(n);
    rep(i,0,n)scanf("%d",&a[i]);
    rep(i,0,n)scanf("%d",&b[i]);
    int ans=0;
    rrep(k,29,-1){
        int m=1<<k,cnt=0;
        rep(i,0,n)c[i]=a[i]%m;
        sort(ALL(c));
        rep(i,0,n){
            int d=b[i]%m;
            cnt+=lower_bound(ALL(c),4*m/2-d)-lower_bound(ALL(c),3*m/2-d);
            cnt+=lower_bound(ALL(c),2*m/2-d)-lower_bound(ALL(c),m/2-d);
        }
        ans+=(cnt&1)*m/2;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll MOD = 998244353;
//const ll MOD = 1e9+7;
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; }
#define print(x) cerr << #x << " is " << x << endl;

//ll dp[3001][3001];
ll dp[3001];

int main() {
    ll N, S;
    cin >> N >> S;
    vector<ll> A(N + 1);
    rep(i, N)cin >> A[i + 1];
    
    ll ans = 0;
    reps(i, 1, N + 1){
        dp[S] = 0;
        for (int j = S; j > A[i]; j--){
            (dp[j] += dp[j - A[i]])%=MOD;
        }
        (dp[A[i]] += i) %= MOD;
        (ans += dp[S] * (N - i + 1))%=MOD;
#if 0        
        (dp[i][A[i]] += i) %= MOD;
        rep(j, S + 1){
            if (j != S)
                (dp[i][j] += dp[i - 1][j])%=MOD;
            if (j > A[i])
                (dp[i][j] += dp[i - 1][j - A[i]])%=MOD;
        }
        (ans += dp[i][S] * (N - i + 1))%=MOD;
        //rep(j, S + 1){
        //    fprintf(stderr, "dp[%d][%d] = %d\n", i, j, dp[i][j]);
        //}
#endif
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

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

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 3;
const int LG = 18;
const int SQ = 320;

int n, q, t, a[N], b[N], c[N], d[N], ed[N], in[N], out[N], h[N], par[N][LG], sum[N][LG];
int nr, re, hm[N], id[N];
PII cur[N], wyn[SQ][N];
bool vis[N];
VII child[N];

void dfs(int v) {
  vis[v] = true;
  in[v] = t++;
  for (int i = 1; i < LG; ++i) {
    par[v][i] = par[par[v][i-1]][i-1];
    sum[v][i] = sum[v][i-1]+sum[par[v][i-1]][i-1];
  }
  for (auto p: child[v])
    if (!vis[p.ST]) {
      h[p.ST] = h[v]+1;
      par[p.ST][0] = v;
      sum[p.ST][0] = d[p.ND];
      ed[p.ST] = p.ND;
      dfs(p.ST);
    }
  out[v] = t++;
}

bool anc(int u, int v) {
  if (u == 0)
    return true;
  return (in[u] <= in[v] && out[v] <= out[u]);
}

int lca(int u, int v) {
  if (anc(u, v))
    return u;
  for (int i = LG-1; i >= 0; --i) {
    while (i >= 0 && anc(par[u][i], v))
      --i;
    if (i >= 0)
      u = par[u][i];
  }
  return par[u][0];
}

int suma(int u, int v) {
  int dis = h[v]-h[u];
  int res = 0;
  assert(dis >= 0);
  assert(anc(u, v));
  for (int i = LG-1; i >= 0; --i)
    if (dis&(1<<i)) {
      res += sum[v][i];
      v = par[v][i];
    }
  return res;
}

void dfs2(int v) {
  vis[v] = true;
  if (h[v]%SQ == re) {
    for (int i = 1; i < n; ++i)
      wyn[nr][i] = cur[i];
    id[v] = nr++;
  }
  for (auto p: child[v])
    if (!vis[p.ST]) {
      cur[c[p.ND]].ST += d[p.ND];
      cur[c[p.ND]].ND++;
      dfs2(p.ST);
      cur[c[p.ND]].ST -= d[p.ND];
      cur[c[p.ND]].ND--;
    }
}

PII get(int v, int col) {
  PII res = {0, 0};
  while (v != 0 && h[v]%SQ != re) {
    if (c[ed[v]] == col)
      res = {res.ST+d[ed[v]], res.ND+1};
    v = par[v][0];
  }
  if (v)
    res = {res.ST+wyn[id[v]][col].ST, res.ND+wyn[id[v]][col].ND};
  return res;
}

signed main() {
  init_ios();
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    child[a[i]].PB({b[i], i});
    child[b[i]].PB({a[i], i});
  }
  dfs(1);
  /*while (1) {
    int x, y;
    cin >> x >> y;
    int z = lca(x, y);
    cout<<z<<","<<suma(z, x)+suma(z, y)<<"\n";
  }*/
  for (int i = 1; i <= n; ++i) {
    ++hm[h[i]%SQ];
    vis[i] = false;
  }
  for (int i = 1; i < SQ; ++i)
    if (hm[i] < hm[re])
      re = i;
  dfs2(1);
  while (q--) {
    int x, y, u, v;
    cin >> x >> y >> u >> v;
    int z = lca(u, v);
    PII r1 = get(u, x);
    PII r2 = get(v, x);
    PII r3 = get(z, x);
    PII hm = {r1.ST+r2.ST-2*r3.ST, r1.ND+r2.ND-2*r3.ND};
    cout<<suma(z, u) + suma(z, v) - hm.ST + y*hm.ND<<"\n";
  }
}

Measured memory_bytes: 536192
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
s=s0()

c=Counter(s)
d=list(c.values())
MOD=10**9+7

def prod(line):
    r=1
    for i in line:
        r*=i
#         r%=MOD
    return r


ans=prod([i+1 for i in d])
print((ans-1)%MOD)

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


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

	int hunds[3] = { 1, 100, 10000 };
	if(N == 100) {
		cout << 101 * hunds[D] << endl;
	}else {
		cout << N * hunds[D] << endl;
	}
	return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    string s;
    cin >> s;

    int p_num = 0;
    REP(i,s.size()) if(s[i]=='p') p_num++;

    int g_num = s.size() - p_num;

    int ans = s.size() / 2 - p_num;

    pl(ans)

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
class Main {
	public static void main(String[] a) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long sum=0;
		for(long i = 1 ; i <= n ; i++) {
			sum+=((n/i)*i+i)*(n/i)/2;
		}
		System.out.println(sum);
	}
}



Measured memory_bytes: 35640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,T,A;cin >> N >> T >> A;
    std::vector<int> H(N);for(int i=0;i<N;i++) cin >> H[i];
    int a=0;
    for(int i=0;i<N;i++){
        if(abs(A-(T-H[a]*0.006))>abs(A-(T-H[i]*0.006))){
            a = i;
        }

    }
    cout << a+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    if(a + b < 10) cout << a+b << endl;
    else cout << "error" << endl;
}

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

int main(){
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<int>> train(M,vector<int>(2));
  for(int i=0; i<M; i++){
    for(int j=0; j<2; j++){
      cin >> train.at(i).at(j);
    }
  }
  vector<vector<int>> query(Q,vector<int>(2));
  for(int i=0; i<Q; i++){
    for(int j=0; j<2; j++){
      cin >> query.at(i).at(j);
    }
  }
  
  vector<vector<int>> ans(N+1,vector<int>(N));
  for(int i=0; i<M; i++){
    int x = train.at(i).at(0);
    int y = train.at(i).at(1);
    ans.at(x).at(y-1)--;
    ans.at(0).at(y-1)++;
  }
  for(int i=0; i<N; i++){
    for(int j=1; j<N; j++){
      ans.at(i).at(j) += ans.at(i).at(j-1);
    }
  }
  
  for(int i=1; i<N+1; i++){
    for(int j=0; j<N; j++){
      ans.at(i).at(j) += ans.at(i-1).at(j);
    }
  }
  
  /*for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << ans.at(i).at(j);
    }
    cout << endl;
  }*/
  
  for(int i=0; i<Q; i++){
    int x = query.at(i).at(0);
    int y = query.at(i).at(1);
    cout << ans.at(x-1).at(y-1) << endl;
  }
  
}

Measured memory_bytes: 18304
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      String op = sc.next();
      int b = sc.nextInt();
      if (op.equals("+")) {
         System.out.println(a + b);
      }else if (op.equals("-")) {
         System.out.println(a - b);
      }else {
      }
   }
}

Measured memory_bytes: 9808
n = int(input())
s = list(input())

x = [0 for _ in range(n + 1)]

for i in range(n):
    if s[i] == 'I':
        x[i+1] = x[i] + 1
    else:
        x[i+1] = x[i] - 1

print(max(x))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PI;
int distL[200][200];
int distS[200][200];
int dp[2][200];
int z[1000];
int main() {
	int N, M;
	while (cin >> N >> M, N) {
		fill((int*)distL, (int*)(distL + 200), 1 << 25);
		fill((int*)distS, (int*)(distS + 200), 1 << 25);
		for (int i = 0; i < N; i++) distL[i][i] = distS[i][i] = 0;
		for (int i = 0; i < M; i++) {
			int x, y, t;
			char sl[2];
			cin >> x >> y >> t >> sl;
			x--; y--;
			if (sl[0] == 'L') {
				distL[x][y] = distL[y][x] = min(distL[x][y], t);
			}
			else {
				distS[x][y] = distS[y][x] = min(distS[x][y], t);
			}
		}
		for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					distL[i][j] = min(distL[i][j], distL[i][k] + distL[k][j]);
					distS[i][j] = min(distS[i][j], distS[i][k] + distS[k][j]);
				}
			}
		}
		int R;
		cin >> R;
		for (int i = 0; i < R; i++) {
			cin >> z[i];
			z[i]--;
		}
		fill((int*)dp, (int*)(dp + 2), 1 << 25);
		dp[0][z[0]] = 0;
		for (int i = 1; i < R; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					if (j == k) dp[i % 2][k] = min(dp[i % 2][k], dp[(i - 1) % 2][j] + distL[z[i - 1]][z[i]]);
					else dp[i % 2][k] = min(dp[i % 2][k], dp[(i - 1) % 2][j] + distL[z[i - 1]][j] + distS[j][k] + distL[k][z[i]]);
				}
			}
			for (int j = 0; j < N; j++) dp[(i - 1) % 2][j] = 1 << 25;
		}
		int ans = 1 << 25;
		for (int i = 0; i < N; i++) ans = min(ans, dp[(R - 1) % 2][i]);
		cout << ans << endl;
	}
}


Measured memory_bytes: 3336
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    print(S[0] + str(len(S)-2) + S[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
double f(int a, int b, double theta){
    if (theta == 180.0) return double(a+b);
    double n = a*a + b*b - (2 * a * b * cos(theta/180*M_PI));
    n = sqrt(n);
    return n;
}
int main(){
    double a, b, h, m;
    double t, ht, mt;
    cin>>a>>b>>h>>m;
    h += m/60; 
    ht = h*30.0;
    mt = m*6.0;
    t = abs(ht-mt);
    if (t > 180.0) {
        t *= -1;
        t += 360;
    }
    printf("%.15f\n", f(a,b,t));
    
}


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

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

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

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

using namespace std;
typedef long long ll;

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> rmemo(k);
    for(int i=1;i<=n;i++){
        rmemo[i%k]++;
    }
    ll ans=0;
    for(int a=0;a<k;a++){
        int b=(k-a)%k;
        int c=(k-a)%k;
        if((b+c)%k==0){
            ans+=rmemo[a]*rmemo[b]*rmemo[c];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

// 動作環境 : C++14 AOJ
int main(){
    int A[100000], B[100000], count = 0;
    char C[100000];
    while(1){
        int a, b;
        char op;
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?') break;
        A[count] = a;
        B[count] = b;
        C[count] = op;
        count++;
    }

    rep(i, 0, count){
        int a = A[i];
        int b = B[i];
        switch(C[i]){
            case '+':
                printf("%d\n", a + b);
                break;
            case '-':
                printf("%d\n", a - b);
                break;
            case '*':
                printf("%d\n", a * b);
                break;
            case '/':
                printf("%d\n", a / b);
                break;
        }
    }

    return 0;
}



Measured memory_bytes: 2040
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int N, K;
int dp[4001][2001];
int fact[4010000], inv_fact[4010000];

int modpow(int x, int k) {
  int a = 1;
  while (k) {
    if (k&1) a = (1LL*a*x) % MOD;
    x = (1LL*x*x)%MOD;
    k >>= 1;
  }
  return a;
}
inline int nCr(int n, int k) {
  //if (k < 0 || k > n) return 0;
  return ((1LL*((1LL*fact[n]*inv_fact[k]))%MOD)*inv_fact[n-k]) % MOD;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  fact[0] = 1;
  for (int i=1; i<4010000; i++) fact[i] = (1LL*i*fact[i-1])%MOD;
  rep(i, 4010000) inv_fact[i] = modpow(fact[i], MOD-2);
  cin >> N >> K;
  if (K == 1) {
    cout << 1 << "\n";
    return 0;
  }

  dp[0][0] = 1;
  rep(i, 2*N) {
    // put ○
    rep(j, N+1) if (i-j+1 <= j) add(dp[i+1][j], dp[i][j]);
    // put ●
    rep(j, N) add(dp[i+1][j+1], (1LL*dp[i][j]*nCr(i+(j+1)*(K-2), K-2))%MOD);
  }
  int s = dp[2*N][N];
  for (int i=1; i<=N; i++) s = (1LL*i*s) % MOD;
  cout << s << "\n";
  return 0;
}


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

const int MAX = 210000;
ll fac[MAX], finv[MAX], inv[MAX];

void cominit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i=2; i<MAX; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll com(ll n, ll k)
{
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll modpow(ll a, ll n)
{
  ll res=1;
  while (n>0) {
    if (n&1) res = res*a % mod;
    a = a*a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  cominit();

  ll ans = modpow(m, n) % mod;
  ll sum = 0;
  for (int i=0; i<n-k-1; i++) {
    ll tmp = m * modpow(m-1, i) % mod;
    tmp = (tmp * com(n-1, i)) % mod;
    sum = (sum + tmp) % mod;
  }
  ans = (ans + mod - sum) % mod;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8568
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

const bool Closed = false;
const bool Open = true;

int main() {
  int N, M;
  cin >> N;
  set<string> ids;
  REP(i, N) {
    string id;
    cin >> id;
    ids.insert(id);
  }

  bool door = Closed;
  
  cin >> M;
  REP(i, M) {
    string card;
    cin >> card;
    if (ids.find(card) == ids.end()) {
      cout << "Unknown " << card << endl;
    } else if (door == Closed) {
      cout << "Opened by " << card << endl;
      door = Open;
    } else {
      cout << "Closed by " << card << endl;
      door = Closed;
    }
  }
}

Measured memory_bytes: 1232
#include <stdio.h>


int main(int argc, char *args[])
{
	int cost_zero = 0;		//0までのコスト
	int cost_max = 0;		//Nまでのコスト

	int max_num = 0;		//入力1：最大マス数(N)
	int money_num = 0;		//入力1：料金所の数
	int now_pos = 0;		//入力1：現在地

	int money[100] = {0};	//入力2：料金所(最大100)


	//入力1
	scanf("%d %d %d", &max_num,  &money_num, &now_pos);

	//入力2
	for (int i = 0; i <= money_num; i++)
	{
		scanf("%d ", &money[i]);
	} 

	// 異常系(必要なら)
	// ・指定された料金所が異常の場合
	// ・料金所にゴールを指定された場合

	// 現在地～0までのコスト計算
	//for 0 to 現在地
	for (int i = 0; i < now_pos; i++)
	{
		//料金所だったらコスト(cost_zero)加算
		for (int j = 0 ; j < money_num ;j++)
		{
			if (i == money[j])
			{
				cost_zero++;
			}
		}
	}

	// 現在地～Nまでのコスト計算
	//for 現在地 to N
	for (int i = now_pos; i < max_num; i++)
	{
		//料金所だったらコスト(cost_max)加算
		for (int j = 0 ; j < money_num ; j++)
		{
			if (i == money[j])
			{
				cost_max++;
			}
		}
	}

	// コストが安い方を出力
	if (cost_zero < cost_max)
	{
		printf("%d", cost_zero);
	}
	else
	{
		printf("%d", cost_max);
	}

}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc099_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, K;
  cin >> N >> K;
  
  vector<int> c(N);
  int s = 0;
  rep(i, N) { 
    cin >> c[i];
    if (c[i] == 1) s = i;
  }

  ll ans = INF;
  repi(i, s - K, s + 1) {
    ll tmp = 0;
    int l = max(0, i);
    int r = N - min(i + K, N);
    tmp = ceil((double)l / (K - 1)) + ceil((double)r / (K - 1));
    ans = min(tmp, ans);
  }

  cout << ans + 1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
typedef long long ll;
ll max(ll x, ll y) {
	return x > y ? x : y;
}
int main() {
	ll a, b, n;
	scanf("%lld%lld%lldd", &a, &b, &n);
	ll x = n / b * b - 1;
	printf("%lld\n", max(a * x / b - a * (x / b), a * n / b - a * (n / b)));
	return 0;
}


Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  scanf("%d\n", &n);

  map<int, bool> arr;

  bool success = true;
  int val;
  REP(i, n) {
    scanf("%d", &val);
    if (arr.count(val) == 1) {
      success = false;
      break;
    } else {
      arr[val] = true;
    }
  }

  const char *str = (success ? "YES" : "NO");
  printf("%s\n", str);

  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;
typedef pair<ll, string> PLS;

string s;
int n, cnt[100100];

int main(){
	cin >> s >> n;
	REP(i, s.size()){
		cnt[i] = s[i] - 'a';
	}
	int pos = 0;
	while (n > 0){
		if (cnt[pos] != 0){
			int num = 26 - cnt[pos];
			if (n >= num){
				s[pos] = 'a';
				n -= num;
			}
		}
		if (pos == s.size() - 1){
			n %= 26;
			break;
		}
		pos++;
	}
	if (n > 0){
		s[s.size() - 1] += n;
	}
	cout << s << endl;
}



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

int main() {
  int n;
  cin >> n;
  
  vector<long long> v(n), maxnum;
  vector<int> tp;
  long long maxh = 0;
  
  for(int i=0; i<n; i++){
    cin >> v.at(i);
    if(v.at(i) > maxh){
      maxh = v.at(i);
      maxnum.push_back(v.at(i));
      tp.push_back(i);
    }
  }

  
  long long step = 0;
  int cursor = 0;
  
  for(int i=0; i<tp.size(); i++){
	
    int endp = (i+1>=tp.size()) ? n : tp.at(i+1);
    for(int j=cursor; j<endp; j++){
      step += (maxnum.at(i) - v.at(j));
    }
    
    cursor = endp;
  }
  cout << step << endl;
}


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



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

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

Measured memory_bytes: 3632
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/09/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct UF {
  vector<int> vec;
  UF(int size) : vec(size) {
    iota(vec.begin(), vec.end(), 0);
  }
  int root(int a) {
    if (vec[a]==a)
      return a;
    return vec[a] = root(vec[a]);
  }
  void unite(int a, int b) {
    vec[root(b)] = root(a);
  }
};

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

  int n,m; cin>>n>>m;
  UF uf(n);
  for (int i = 0; i < m; i++) {
    int x,y,z; cin>>x>>y>>z; x--; y--;
    uf.unite(x,y);
  }
  set<int> num;
  for (int i = 0; i < n; i++)
    num.insert(uf.root(i));
  cout << num.size() << endl;

  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll S;
    S = 0;
    for (int i = 0; i < N; i++) {
        S += A[i];
    }

    vector<int> D;
    for (ll i = 1; i*i <= S; i++) {
        if(S % i == 0){
            if(i * i != S){
                D.push_back(i);
                D.push_back(S / i);
            }
            else{
                D.push_back(i);
            }
        }
    }

    ll ans = 1;
    ll L = D.size();

    vector<ll> B(N);
    ll a;
    ll k;
    ll tmp;
    for (int i = 0; i < L; i++) {
        a = D[i];
        for (int j = 0; j < N; j++) {
            B[j] = A[j] % a;
        }
        k = 0;
        for (int j = 0; j < N; j++) {
            k += B[j];
        }
        k = k / a;
        sort(ALL(B));

        tmp = 0;
        for (int j = 0; j < N-k; j++) {
            tmp += B[j];
        }
        for (int j = N-k; j < N; j++) {
            tmp += (a - B[j]);
        }

        if(tmp <= 2*K){
            ans = max(ans, a);
        }


    }

    printf("%lld\n", ans);

}

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

int main(){
    auto f = [](long a){
        long t(a & ~3), ret(0);
        for(; t <= a; ++t)ret ^= t;
        return ret;
    };
    long A, B;
    cin >> A >> B;

    cout << (f(B) ^ f(A - 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <bits/stdc++.h>

using namespace std;


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

int H, W;
string s[110];
int dist[110][110]; 

int main() {
    
    cin >> H >> W;
	int ans = 0;
	for (int i = 0; i < H; ++i) {
        cin >> s[i];
        for (int j = 0; j < W; ++j) {
            if (s[i][j] == '.') ans++;
        }
	}
  
//幅優先探索
  
    memset(dist, -1, sizeof(dist));
	dist[0][0] = 1;
	queue<pair<int,int>> que;
  
	que.push(pair<int,int>(0, 0));
	while (!que.empty()) {
        pair<int,int> cur = que.front();
        que.pop();
        int x = cur.first;
        int y = cur.second;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir];
          
            int ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
          
            if (s[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
              
                dist[nx][ny] = dist[x][y] + 1;
              
                que.push(pair<int,int>(nx, ny));
            }
        }
	}
  
	if (dist[H-1][W-1] == -1) cout << -1 << endl;
  
	else  cout << ans - dist[H-1][W-1] << endl;
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない



int main() {
	ull a[100000];
	ull N, x;
	ull ans = 0;

	cin >> N >> x;

	rep(i, 0, N) {
		cin >> a[i];
	}

	rep(i, 0, N - 1) {
		if (i == 0 && a[0] > x) {
			ans += a[0] - x;
			a[0] = x;
		}
		if (a[i] + a[i + 1] > x) {
			ull c = a[i + 1];
			a[i + 1] = x - a[i];
			ans += c - a[i + 1];
		}
	}



	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N;
  string S;
  cin >> N >> S;
  lint ans=1;
  lint alf[26]={};
  rep(i,N) alf[S[i]-'a']++;
  rep(i,26) ans=(ans*(alf[i]+1))%MOD;
  ans--;
  if(ans==-1) cout << MOD-1 << endl;
  else cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  map<pair<char, char>, int> MA;
  for (int i = 1; i <= N; i++) {
    MA[{to_string(i).front(), to_string(i).back()}]++;
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += MA[{to_string(i).back(), to_string(i).front()}];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3672
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){

  int a,b;
  while(scanf("%d %d",&a,&b) != EOF){
  int i = 0;
  a = a + b;
  while(a > 0){
    a = a / 10;
    i++;
      }

  cout << i << endl;

  }
}

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

int main() {
  
  int X, Y;
  cin >> X >> Y;
  
  string ans = "No";
  for (int i = 0; i <= X; i++) {
    if ( 2 * i + 4 * (X - i) == Y) {
      ans = "Yes";
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3616
//include
//------------------------------------------
#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 <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
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(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string a, b, c;
	cin >> a >> b >> c;

	ll base = 50000;
	vector<bool> ab_matched(base * 2, true);
	vector<bool> ac_matched(base * 2, true);
	vector<bool> bc_matched(base * 2, true);

	ll i, j;
	REP (i, a.size()) {
		REP(j, b.size()) {
			if (a[i] != '?' && b[j] != '?' && a[i] != b[j]) {
				ab_matched[i - j + base] = false;
			}
		}
	}
	REP(i, a.size()) {
		REP(j, c.size()) {
			if (a[i] != '?' && c[j] != '?' && a[i] != c[j]) {
				ac_matched[i - j + base] = false;
			}
		}
	}
	REP(i, b.size()) {
		REP(j, c.size()) {
			if (b[i] != '?' && c[j] != '?' && b[i] != c[j]) {
				bc_matched[i - j + base] = false;
			}
		}
	}

	ll len_a = a.size();
	ll len_b = b.size();
	ll len_c = c.size();

	ll res = 1LL << 60LL;
	ll length;
	for (i = -4000; i <= 4000; ++i) {
		for (j = -4000; j <= 4000; ++j) {
			if (ab_matched[i + base] && ac_matched[j + base] && bc_matched[j - i + base]) {
				length = max(len_a, max(i + len_b, j + len_c)) - min(0LL, min(i, j));
				res = min(res, length);
			}
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256