akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int a[30], b[30];
char s[1050];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 26; ++i) {
        a[i] = 100;
    }
    while (n--) {
        scanf("%s", s);
        memset(b, 0, sizeof(b));
        for (int i = 0; s[i]; ++i) {
            b[s[i] - 'a']++;
        }
        for (int i = 0; i < 26; ++i) {
            a[i] = min(a[i], b[i]);
        }
    }
    for (int i = 0; i < 26; ++i) {
        while (a[i]--) {
            printf("%c", i + 'a');
        }
    }
    return 0;
}

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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a) 

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

// -----



int main()
{
    ll x;
    cin >> x;
    
    ll mon = 100;
    ll ans = 0;
    do
    {
        mon += mon / 100;
        ++ans;
    } while (mon < x);
    pl(ans);
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>

using namespace std;
typedef long long  ll;

ll dx[] = { 1, 0 };
ll dy[] = { 0, 1 };

int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	vector<ll> b(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
		if (i != 0)
		{
			b[i] = b[i - 1] + a[i];
		}
		else
			b[i] = a[i];
	}
	ll ans = abs(2 * b[0] - b[N - 1]);
	for (ll i = 0; i < N - 1; i++)
	{
		ans = min(ans, abs(2 * b[i] - b[N - 1]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
n = int(input())
ab = []

for i in range(n):
  ab.append(list(map(int, input().split())))

ab.sort(key=lambda x:x[1])

result = 'Yes'
a_sum, b_sum = 0, 0

for i in ab:
  a_sum += i[0]
  
  if a_sum > i[1]:
    result = 'No'
    
print(result)



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

int main() {
  int N,M;cin>>N>>M;
  priority_queue<double> A;
  for(int i=0;i<N;i++){
    int wait;cin>>wait;
    A.push(wait);
  }
  for(int j=0;j<M;j++){
    double sale=A.top()/2;
    A.pop();
    A.push(sale);
  }
  // int ans=0;
  long ans=0;
  int Fx=0;
  while(Fx<N){
    ans += (int)A.top();
    A.pop();
    Fx++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4280
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n = INT()
ans = n * (n - 1) // 2
print(ans)

Measured memory_bytes: 60012
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int N;
	cin>>N;
	
	long long A,B;
	cin>>A>>B;
	A -= B;
	vector<long long> h(N);
	for(int i=0;i<N;i++)cin>>h[i];
	
	long long ng = 0;
	long long ok = 1000000000;
	
	while(ok-ng>1){
		long long mid = (ok+ng)/2;
		long long k = 0;
		for(int i=0;i<N;i++){
			long long a = h[i] - mid * B;
			if(a>0){
				k += (a + A - 1)/A;
			}
		}
		if(k>mid){
			ng=mid;
		}
		else{
			ok=mid;
		}
	}
	
	cout<<ok<<endl;
	
	
	
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct CumulativeSum{
  vector<int> data;
  CumulativeSum(int sz) : data(sz, 0) {};
  void add(int k, int x){
    data[k] += x;
  }
  void build(){
    for(int i = 1; i < data.size(); i++){
      data[i] += data[i - 1];
    }
  }
  int query(int k){
    if(k < 0) return 0;
    return (data[min(k, (int)data.size() - 1)]);
  }
  int query(int l, int r){
    return query(r - 1) - query(l - 1);
  }
};

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  REP(i, n) cin >> a[i];
  REP(i, m) cin >> b[i];
  CumulativeSum ca(n), cb(m);
  REP(i, n) ca.add(i, a[i]);
  REP(i, m) cb.add(i, b[i]);
  ca.build();
  cb.build();
  int ans = 0;
  for(int i = 0; i <= n; i++){
    int sa = ca.query(0, i);
    if(sa > k) break;
    int ok = 0, ng = m + 1;
    while(ng - ok > 1){
      int mid = (ok + ng) / 2;
      int sb = cb.query(0, mid);
      if(sa + sb > k) ng = mid;
      else ok = mid;
    }
    // cout << i << " " << sa << " " << ok << " " << cb.query(0, ok) << endl;
    ans = max(ans, i + ok);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9520
using System;

namespace ALDS1_3_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] num = input.Split(' ');
            int x = 0;
            int y = 0;

            for (int i = 0; i < num.Length; i++)
            {
                switch(num[i])
                {
                    case "+":
                        y = getPos(num, i);
                        x = getPos(num, y);

                        num[i] = (int.Parse(num[x]) + int.Parse(num[y])).ToString();
                        num[x] = "";
                        num[y] = "";

                        break;

                    case "-":
                        y = getPos(num, i);
                        x = getPos(num, y);

                        num[i] = (int.Parse(num[x]) - int.Parse(num[y])).ToString();
                        num[x] = "";
                        num[y] = "";

                        break;

                    case "*":
                        y = getPos(num, i);
                        x = getPos(num, y);

                        num[i] = (int.Parse(num[x]) * int.Parse(num[y])).ToString();
                        num[x] = "";
                        num[y] = "";

                        break;

                    default:
                        break;
                }
            }
            Console.WriteLine(num[num.Length - 1]);

        }

        public static int getPos (string[] arr, int n)
        {

            for (int i = n - 1; i >= 0; i--)
            {
                if (!string.IsNullOrEmpty(arr[i])) return i;
            }
            return 0;
        }
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

// N以下の素数を列挙して返す
vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

vector<ll> prime_factor(ll n){
	ll sn = sqrt(n)+1;
	auto prime_list = enum_prime(sn);
	vector<ll> res;
	for(int i=0,ei=prime_list.size();i<ei;i++){
		ll v = prime_list[i];
		if(v*v>n) break;
		while(!(n%v)){
			n /= v;
			res.push_back(v);
		}
	}
	if(n>1){
		res.push_back(n);
	}

	return res;
}

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

	ll A=in<ll>(),B=in<ll>();

	auto PA = prime_factor(A);
	PA.erase(unique(ALL(PA)),PA.end());
	auto PB = prime_factor(B);
	PB.erase(unique(ALL(PB)),PB.end());
	vector<ll> res;
	set_intersection(ALL(PA),ALL(PB),inserter(res,res.end()));

	out(res.size()+1LL);
	return 0;
}


Measured memory_bytes: 2972
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String str = "";
		Set<String> set = new HashSet<String>();
		for (int i = 0; i < n; i++) {
		    str = sc.next();
		    set.add(str);
		}

		System.out.println(set.size());
		
    }
}



Measured memory_bytes: 77744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

const int V = 100005;
vector<int> to[V * 2];
bool visited[V * 2];

vector<int> cnt;
void dfs(int v) {
  if (visited[v]) return;
  visited[v] = true;
  cnt[v / V]++;
  for (int u : to[v]) dfs(u);
}
int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    y += V;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  ll ans = 0;
  rep(i, V * 2) {
    if (visited[i]) continue;
    cnt = vector<int>(2);
    dfs(i);
    ans += (ll)cnt[0] * cnt[1];
  }
  ans -= n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 N;
int x[25],tot;
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);
    while(N) {
	x[++tot] = N % 10;
	N /= 10;
    }
    int ans = 0,sum = 0;
    for(int i = tot ; i >= 1 ; --i) {
	ans = max(ans,sum + x[i] - 1 + (i - 1) * 9);
	sum += x[i];
    }
    ans = max(ans,sum);
    out(ans);enter;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{   
    ll A,B,C;
    cin >> A >> B >> C;
    if(A + B + C == 0) cout<<0<<endl;
    else if(C > A+B)   cout<<(A+2*B+1)<<endl;
    else               cout<<(B+C)<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    private static int n;
    private static int q;
    private static int[] p;
    private static int[] rank;
 
    private static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    private static void unite(int x, int y) {
        int i = findSet(x);
        int j = findSet(y);
 
        if (i == j) return;

        if (rank[i] > rank[j]){
            p[j] = p[i];
        }
        else {
            p[i] = p[j];
            if(rank[i] == rank[j]){
            rank[j]++;
            }
        }	
    }
 
    private static int findSet(int i) {
        if(p[i] == i){ 
           return i;
        }else{
          return p[i] = findSet(p[i]);
        }
        
    }
 
    private static void DisjointSet() {
        p = new int[n];
        rank = new int[n];
 
        for (int i = 0; i < n; i++) {
            p[i] = i;
            rank[i] = 0;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        q = scanner.nextInt();
 
        DisjointSet();
        for (int i = 0; i < q; i++) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
 
            if (com == 0){
                unite(x, y);
            }
            if (com == 1){
                if (same(x, y)){
                    System.out.println(1);
                }else{
                    System.out.println(0);
		}
            }
        }
    }
}

Measured memory_bytes: 101988
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

// マクロ
/// ループ
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);++i)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);--i)
#define REP(i,n) FOR(i,0,n) 
#define REPD(i,n) FORD(i,n,0)
/// コンテナ用
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
/// 定数
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5 配列の最大のRANGE
/// 略記
#define PB push_back
#define MP make_pair
#define F first
#define S second

auto main(int argc, char *argv[]) -> signed {
    int a, b;
    cin >> a >> b;

    if ((a * b) % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;

    return 0;
}


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

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

    int m[N];
    for (int i=0; i<N; i++) cin >> m[i];

    int sum=0;
    for (int i=0; i<N; i++) sum+=m[i];

    int min=m[0];
    for (int i=0; i<N; i++){
        if (m[i]<min) min=m[i];
    }

    int rest=0;
    rest=(X-sum)/min;

    int ans=N+rest;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
l = len(s)
res = 0
for pat in range(2 ** (l-1)):
    #print(pat)
    shiki = s[0]
    for i in range(l-1):
        if (pat >> i & 1) == 1:
            shiki += "+" + s[i+1]
        else:
            shiki +=  s[i+1]
    res += eval(shiki)
    #print(shiki)
print(res)


Measured memory_bytes: 39408
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
#define int long long
inline int read() {
	int x(0),neg(1);char ch(getchar());
	while(ch<'0'||ch>'9') {
		if (ch=='-') neg=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*neg;
}
deque<int> num[10005],now,a,ans;
int used[10005];
int cnt,tot=1;
inline void solve() {
	while(cnt) {
		if (!now.size()) {
			puts("-1");
			exit(0);
		}
		++tot;
		while(a.size()) {
			used[a[0]]=0;
			a.pop_front();
		}
		while(now.size()) {
			int t=now[0];now.pop_front();
			if(!num[t].size())continue;
			int to=num[t][0];
			if(!num[to].size()) {
				puts("-1");
				exit(0);
			}
			if(used[t]||used[to]||num[to][0]!=t) {
				continue;
			}
			--cnt;
			a.push_back(t),a.push_back(to);
			ans.push_back(t),ans.push_back(to);
			num[t].pop_front(),num[to].pop_front();
			used[t]=used[to]=1;
		}
		while(ans.size()) now.push_back(ans[0]),ans.pop_front();
	}
}
ll n;
inline void init() {
	n=read();
	for (int i=1;i<=n;++i) {
		for (int j=1;j<n;++j) {
			num[i].push_back(read());
			++cnt;
		}
	}
	cnt/=2;
}
main() {
	init();
	for (int i=1;i<=n;++i) {
		if (!used[i]&&!used[num[i][0]]&&num[i][0]!=i&&num[num[i][0]][0]==i) {
			a.push_back(i),a.push_back(num[i][0]);
			now.push_back(i),now.push_back(num[i][0]);
			used[i]=used[num[i][0]]=1;
			num[num[i][0]].pop_front(),num[i].pop_front();
			--cnt;
		}
	}
	solve();
	
	printf("%lld\n",tot);
	return 0;
}

Measured memory_bytes: 15104
/*
                            Author: Ankit Kaul
*******Code Belongs to Respective Author Only*************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
/*freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}   
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes";
    else
    cout<<"No";
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	int h[100000];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	sort(h,h+n);
	int ans=1e9+7;
	for(int i=0;i<n-k+1;i++){
		ans=min(ans,abs(h[i]-h[i+k-1]));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
using namespace std;
using ll = long long int;
 
int main(){
    int n; cin >> n;
    int min_b = 1e9 + 10;
    ll total = 0;
    bool anydiff = false;
    for(int i=0; i<n; i++){
        int a, b; cin >> a >> b;
        total += a;
        if(a > b){
            min_b = min(min_b, b);
        }
        if(a != b){
            anydiff = true;
        }
    }
    if(anydiff){
        cout << total - min_b << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;

typedef long long ll;
ll X,Y,cunt;

int main(){
    cin>>X>>Y;

    while(Y>=X){
        Y/=2;
        cunt++;
    }
    cout<<cunt<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int main() {

    long double a, b, c;
    std::cin >> a >> b >> c;

    long double left = a + b + 2 * std::sqrt(a*b);
    long double right = c;

    std::cout << (left < right ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String S = sc.next(); 
        int x = 0;
        int max = 0;
        
        for(int i = 0; i < N ; i++){
            if(S.charAt(i) == 'I'){
                x++;
            }else{
                x--;   
            }
            if(max < x) max = x;
        }
        System.out.println(max);
    }
}


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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
//#define modulo ll (1e9 + 7)
#define modulo ll (1e6 + 3)
const long double PI = 3.141592653589793238L;


typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.in","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

int main(){
    init();
    int n,mn = 2e9, mx = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        mn = min(mn, x);
        mx = max(mx, x);
    }
    cout << mx - mn;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> count(101000);
  rep(i,(int)count.size()) count[i]=0;
  int a,b;
  rep(i,N){
    cin >> a >> b;
    count[a] += b;
  }
  ll sum = 0;
  int ans = 1;
  rep(i,(int)count.size()){
    sum += count[i];
    if(sum >= K){
      ans = i;
      break;
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[25],b[25],c[25];
	for(int i=1; i<=n; i++)
		cin>>a[i];
	for(int i=1; i<=n; i++)
		cin>>b[i];
	for(int i=1; i<n; i++)
		cin>>c[i];
		
	int ans=0;	
	ans+=b[a[1]];
	for(int i=2;i<=n;i++)
	{
		ans+=b[a[i]];
		if(a[i]-a[i-1]==1)
		{
			ans+=c[a[i-1]];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
num=[0]*n
num[0]=1
if d[0]!=0 or d.count(0)!=1:
    print(0)
else:
    ans=1
    for i in range(1,n):
        num[d[i]]+=1
    for i in range(1,max(d)+1):
        ans*=num[i-1]**num[i]
        ans%=998244353
    print(ans)


Measured memory_bytes: 20580
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
ll n;

void fanc(ll cur, ll use, ll &cnt){
     if(cur > n) return;
     if(use == 0b111) cnt++;
     fanc(cur*10+3, use | 0b001, cnt);
     fanc(cur*10+5, use | 0b010, cnt);
     fanc(cur*10+7, use | 0b100, cnt);
 }

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

    cin>>n;
    ll res = 0;

    fanc(0,0,res);

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

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int const m = 10000;
    int n, a;
    cin >> n >> a;
    vector<int> x(n+1, 0);
    vector< vector<long long> > dp(n+1, vector<long long>(m*2, 0));
    for(int i=1;i<=n;i++){
        cin >> x[i];
        x[i] -= a;
    }
    dp[0][m] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<m*2;j++){
            dp[i][j] = dp[i-1][j];
            if(x[i] <= j && j-x[i] < m*2) dp[i][j] += dp[i-1][j-x[i]];
        }
    }
    cout << dp[n][m]-1 << endl;
}


Measured memory_bytes: 8576
dish = [int(input()) for i in range(5)]

ans = 0
modmin = 10

for d in dish:
    ans += (d + 10 - 1) // 10
    if d % 10 != 0:
        modmin = min(modmin, d % 10)

print(ans * 10 - (10 - modmin))


Measured memory_bytes: 2940
N,M = map(int,input().split())
A = [0]*M
B = [0]*M
for i in range(M):
    A[i],B[i] = map(int,input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
    
    
uf = UnionFind(N)
for i in range(M):
    uf.union(A[i]-1,B[i]-1)

answer = 1
uflist = uf.parents
for i in range(N):
    time = uf.size(uflist[i])
    answer = max(time,answer)
print(answer)

Measured memory_bytes: 82308
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,double> P;
#define fi first
#define se second

deque<P> d;		//first: v(水) second: t(温度)
signed main(){
	int n, v, L;
	scanf("%lld%lld", &n, &L);
	
	double t, V = 0;
	for(int i = 0;i < n;i++){
		scanf("%lf%lld", &t, &v);
		int u = v;
		
		while(i && u > 0){
			P p = d.front();
			int dis = min(p.fi, u);
			u -= dis;
			V -= dis*p.se;
			d.pop_front();
			if(p.fi-dis > 0)d.push_front(P(p.fi-dis, p.se));
		}
		
		while(!d.empty() && d.back().se > t){
			P p = d.back();d.pop_back();
			V -= p.fi*p.se;
			t = (t*v+p.fi*p.se)/(v+p.fi);
			v += p.fi;
		}
		
		V += t*v;
		d.push_back(P(v, t));
		printf("%lf\n", V/L);
	}
	return 0;
}


Measured memory_bytes: 16784
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			ans += (d[i] * d[j]);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  tuple<int, int, int> p[n - 1];
  rep(i, n - 1) {
    int c, s, f;
    cin >> c >> s >> f;
    p[i] = make_tuple(c, s, f);
  }
  rep(i, n - 1) {
    int a, b, c, ans = 0;
    tie(a, b, c) = p[i];
    ans += b;
    ans += a;
    repi(j, i + 1, n - 1) {
      int d, e, f;
      tie(d, e, f) = p[j];
      if (ans < e) ans = e;
      if (ans % f != 0) ans += (f - ans % f);
      ans += d;
    }
    /*if (i == n - 1) {
      cout << 0 << endl;
      return 0;
    }*/
    cout << ans << endl;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split("").map(&:to_i)
k = gets.chomp.to_i
head_count_one = 0
next_num = -1

s.each do |i|
    if i == 1 then
        head_count_one += 1
    else
        next_num = i
        break
    end
end

puts head_count_one >= k ? 1 : next_num

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

M = max(a)
biggest_prime = [0] * (M+10)
for i in range(2, M+10):
    if biggest_prime[i] == 0:
        biggest_prime[i] = i
        for j in range(i*i, M+1, i):
            biggest_prime[j] = i

def fact(n):
    arr=[]
    while n>1:
        now=n
        cnt=0
        p=biggest_prime[now]
        while now % p == 0:
            now//=p
            cnt+=1
        arr.append([p,cnt])
        n=now
    return arr

from collections import defaultdict
cntd=defaultdict(int)
for i in range(len(a)):
    lis = fact(a[i])
    for num,cnt in lis:
        if num==1:
            continue
        cntd[num]+=1
flg=False
for c in cntd.values():
    if c==n:
        print("not coprime")
        exit()
    if c>1:
        flg=True
if flg:
    print("setwise coprime")
else:
    print("pairwise coprime")

Measured memory_bytes: 189740
N = int(input())
a = list(map(int, input().split()))
sa = [a[0]]
for i in range(1, N):
    sa.append(sa[-1] + a[i])

ans = int(1e20)
for i in range(N-1):
    ans = min(ans, abs(sa[i] - (sa[-1] - sa[i])))
print(ans)


Measured memory_bytes: 24812
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n, a, b;
	cin >> n >> a >> b;
	
	ll ans = 0;
	
	ll k = n / (a + b);
	ans += k * a;
	ll rem = n % (a + b);
	
	ans += min(rem, a);
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int INFTY = 1001001001;

int num_digit(int value)
{
    int nd = 1;
    while (value != 0)
    {
        value /= 10;
        nd*=10;
    }
    return nd / 10;
}

int main()
{
    int N, K, nd;
    cin >> N >> K;
    vector<int> D(K), E(K);
    for (int i = 0; i < K; ++i)
    {
        cin >> D[i];
    }

    nd = num_digit(N);
    string num;
    bool flag;
    for(int i=nd; i<nd*100;++i){
        num = to_string(i);
        flag = true;
        for(auto c : num){
            for(int i=0;i<K;++i){
                if(c - '0' == D[i]) flag = false;
            }
        }
        if(flag){
            if(i >= N)
                break;
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m,c,b[22],ans;

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

  cin >> n >> m >> c;
  for(int i=1;i<=m;i++)cin>>b[i];
  for(int i=1;i<=n;i++){
    int cur = c;
    for(int j=1;j<=m;j++){
      int x;
      cin >> x;
      cur+= b[j]*x;
    }
    if(cur>0)ans++;
  }
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m,k = map(int, input().split())
class UnionFind:
    def __init__(self, n):
        #親ノードの番号を格納
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)
    def find(self, x):
        #根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self, x, y):
        #同じかどうかの確認
        return self.find(x) == self.find(y)
    def union(self, x, y):
        #統合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0
        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
        else:
            self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
    def getsize(self, x):
        p = self.find(x)
        return self.size[p]
u = UnionFind(n)
ans_li = [-1 for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    u.union(a,b)
    ans_li[a] -= 1
    ans_li[b] -= 1
for i in range(k):
    a,b = map(int, input().split())
    if u.find(a) == u.find(b):
        ans_li[a] -= 1
        ans_li[b] -= 1
for i in range(1,n+1):
    ans_li[i] += u.getsize(i)
    print(ans_li[i], end = " ")



Measured memory_bytes: 87916
/*---Bismillahir Rahmanir Rahim---*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define vi vector <int> 
#define pii pair<int, int>
using namespace std; 

int  gcd(int a,int b){
	return  (b==0)?a: gcd(b,a%b);
}

inline void solve() {
	string s,h[2];
	int  f=0, n, q, ans=0 ; 
	cin >> s >> q ; 
	while (q--){
		cin>>n;
		if (n==2){
			int a; char c;
			cin >> a >> c ; 
			if (a==1) h[f] += c; 
			else h[!f] += c; 
		}
		else f = f^1;
	}
	string res;
	if (f&1) {
		reverse(h[1].begin(),h[1].end());
		reverse(s.begin(),s.end());
		res = h[1]; res += s; res += h[0];
	}
	else{
		reverse(h[0].begin(),h[0].end()); 
		res = h[0]; res += s; res += h[1];
	}
	cout << res << endl;
} 

signed main()
{
	int n = 1;
//	cin >> n;
	while (n--)
		solve();
	return 0;
}

/*
a
4
2 1 p
1
2 2 c
1

*/


Measured memory_bytes: 4320
#include <iostream>
using namespace std;
 
int main() {
    int sum;
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if (N >= K){
      sum = K * X + (N - K) * Y;
    }else{
      sum = N * X;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

bool isprime(int n){
  if(n<2)return false;
  FOR(i,2,(int)sqrt(n)+1)if(n%i==0)return false;
  return true;
}

int main(){
  int N;
  cin>>N;
  int k=1;
  REP(i,N){
    while(!isprime(10*k+1))k++;
    cout<<10*k+1<<" ";
    k++;
  }
  cout<<endl;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal ll = sc.nextBigDecimal();
        BigDecimal ans2 = ll.divide(new BigDecimal(3.0), 7, BigDecimal.ROUND_HALF_UP);
        BigDecimal ans3 = ans2.multiply(ans2).multiply(ans2);
        System.out.println(ans3);
    }
}


Measured memory_bytes: 37420
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
const int N=2*1e5+100;
int n,v[N],w,a[N],sum[N],father[N],fa[N];
int tot,first[N],nxt[N*2],point[N*2];
int dp[N][2];
struct node
{
	int id,zero,one;
};
bool operator <(node a,node b)
{
	return a.one*b.zero>a.zero*b.one;
}
priority_queue <node> q;
int find(int x)
{
	if (x==fa[x]) return x;
	return fa[x]=find(fa[x]);
}
void add_edge(int x,int y)
{
	tot++;
	nxt[tot]=first[x];
	first[x]=tot;
	point[tot]=y;
}
signed main()
{
	tot=-1;
	memset(first,-1,sizeof(first));
	memset(nxt,-1,sizeof(nxt));
	scanf("%lld",&n);
	for (int i=2;i<=n;i++)
	{
		scanf("%lld",&father[i]);
		add_edge(father[i],i);
	}
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=n;i++) scanf("%lld",&v[i]);
	for (int i=1;i<=n;i++)
	{
		dp[i][v[i]]++;
		if (i!=1) q.push(node{i,dp[i][0],dp[i][1]});
	}
	int ans=0;
	while (!q.empty())
	{
		node x=q.top();
		q.pop();
		if (x.one!=dp[x.id][1] || x.zero!=dp[x.id][0]) continue;
		int y=find(father[x.id]);
		ans+=dp[y][1]*dp[x.id][0];
		dp[y][0]+=dp[x.id][0],dp[y][1]+=dp[x.id][1];
		if (y!=1) q.push(node{y,dp[y][0],dp[y][1]});
		fa[x.id]=y;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 22604
#include <stdio.h>
#define NDEBUG
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

// for DEBUG {{{
#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))
// }}}

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}
void merge_int(int *a, int *b, int lower, int sep, int upper) {// {{{
	int i_lower = lower;
	int i_upper = sep;
	int i_b = 0;
	while ((i_lower < sep) && (i_upper < upper)) {
		if (a[i_lower] < a[i_upper]) {
			b[i_b++] = a[i_lower++];
		} else {
			b[i_b++] = a[i_upper++];
		}
	}
	if (i_lower >= sep) {
		while (i_upper < upper) {
			b[i_b++] = a[i_upper++];
		}
	} else {
		while (i_lower < sep) {
			b[i_b++] = a[i_lower++];
		}
	}
	for (i_lower = 0; i_lower < i_b; i_lower++) {
		a[i_lower+lower] = b[i_lower];
	}
}// }}}
void merge_sort_int(int *a, int *b, int lower, int upper) {// {{{
	int sep;
	if ((lower == upper) || (lower + 1 == upper)) {
		return;
	}
	sep = (lower + upper) / 2;
	merge_sort_int(a,b,lower,sep);
	merge_sort_int(a,b,sep,upper);
	merge_int(a,b,lower,sep,upper);
}// }}}

#define S_MAX 30000
int main(int argc, char **argv) {
	int n;
	char s[S_MAX+1];
	fscanf(stdin,"%d",&n) > 0;
	fscanf(stdin,"%s",s) > 0;
	assert(strlen(s) == n);

	int init_index[10];
	int end_index[10];
	{
		int i;
		for (i = 0; i < 10; i++) {
			init_index[i] = -1;
			end_index[i] = -1;
		}
	}
	{
		int i;
		for (i = 0; i < n; i++) {
			int index = (s[i] - '0');
			end_index[index] = i;
			if (init_index[index] < 0) {
				init_index[index] = i;
			}
		}
	}
#ifndef NDEBUG
	{
		int i;
		for (i = 0; i < 10; i++) {
			fprintf(stderr,"%d %d %d\n", i, init_index[i],end_index[i]);
		}
	}
#endif
	int ret = 0;
	{
		int i;
		for (i = 0; i < 10; i++) {
			int init = init_index[i];
			if (init < 0) {
				continue;
			}
			int j;
			for (j = 0; j < 10; j++) {
				int end = end_index[j];
				if (init >= end) {
					continue;
				}
				DEBUG_PRINT("%d %d %d %d\n",i,j,init,end);
				int mid_index[10];
				memset(mid_index,0,sizeof(int)*10);
				{
					int k;
					for (k = init+1; k < end; k++) {
						int index = (s[k] - '0');
						mid_index[index] = 1;
					}
				}
				{
					int k;
					for (k = 0; k < 10; k++) {
						ret += mid_index[k];
					}
				}
			}
		}
	}
	fprintf(stdout,"%d\n",ret);
	return 0;
}



Measured memory_bytes: 128
package main
import "fmt"

func main(){
  var a, b, ans int
  
  fmt.Scanf("%d %d",&b,&a)
  
  if b == 0 {
    ans = 1
  } else if b == 1{
    ans = 100
  } else {
    ans = 10000
  }
  
  if a == 100 {
    ans = ans * 101
  } else {
    ans = ans * a
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
//static const int INFTY = (1<<20);


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

	map<string, int> dict;
	string str;
	set<string> S;
	rep(i, N) {
		cin >> str;
		dict[str]++;
		S.insert(str);
	}

	int max_val = 0;
	for (auto str : S) {
		max_val = max(dict[str], max_val);
	}

	vector<string> vec;
	for (auto str : S) {
		if (dict[str] == max_val) {
			vec.push_back(str);
		}
	}
	sort(vec.begin(), vec.end());
	rep(i, vec.size()) {
		cout << vec.at(i) << endl;
	}
}

Measured memory_bytes: 36212
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	a = input()
	print(a[:3]+'8'+a[4:])

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 63596
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    ll N,A,B,C,D,E;
    string S,T;
    cin >> N;
    vl H(N);
    FOR(i,0,N)cin >> H[i];
    ll ans = 0 ;
    FOR(i,0,N){
        bool flag = true;
        FOR(j,0,i)if(H[j] > H[i])flag = false;
        ans += flag;
    }
    cout << ans << endl;
}

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

b = []
if n % 2 == 0:
    for i in range(n//2):
        b.append(a[-1-i*2])
    for i in range(n//2):
        b.append(a[i*2])
else:
    for i in range(n//2+1):
        b.append(a[-1-i*2])
    for i in range(0, n//2):
        b.append(a[1+i*2])
print(' '.join(map(str, b)))

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<string,int>Psi;

typedef struct rest{
  int num;
  string city;
  int score;
}rest;

bool compare_s(rest &left,rest &right){
  if(left.city!=right.city){
    return left.city<right.city;
  }else{
    return left.score>right.score;
  }
}

int main(){
  int n;
  cin>>n;
  rest s;
  rest v[n];
  REP(i,n){
    cin>>s.city>>s.score;
    s.num=i+1;
    v[i]=s;
  }
  sort(v,v+n,compare_s);
  REP(i,n){
    cout<<v[i].num<<endl;
  }
  return 0;
}

Measured memory_bytes: 256