akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int n,r;
    cin>>n>>r;

    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+100*(10-n)<<endl;
    }


}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int sum=0;
    for(int i=0;i<k;i++)sum+=arr[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 3592
#include<stdio.h>

#define MAX 2000001
#define VMAX 10000

void CountingSort(int, int*, int*);
int A[MAX],B[MAX];
int n;
int  main() {

  
  int i;
  scanf("%d",&n);
  

  for(i = 1; i < n+1; i++) {
    scanf("%d", &A[i]);
  }

  CountingSort(VMAX,A,B);
  for(i = 1; i <= n; i++) {
    printf("%d",B[i]);
    if(n != i) printf(" ");
  } 
  printf("\n");
  return 0;
}

void CountingSort(int k,int *A, int *B ){
  int i,C[VMAX + 1];

  for(i = 0; i <= VMAX; i++) {
    C[i] = 0;
  }

  for(i = 1; i <=n; i++) {
    C[A[i]]++;
  }
  
  for(i = 1; i < VMAX+1; i++) {
    C[i] += C[i-1];
  }

  for( i = 1; i <= n; i++) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
 return;
}

Measured memory_bytes: 16264
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let s: String = scan(tokens);
    let t: String = scan(tokens);
    let mut u = Vec::with_capacity(2 * n);
    for i in 0..n {
        u.push(s.as_bytes()[i]);
        u.push(t.as_bytes()[i]);
    }
    println!("{}", String::from_utf8(u).unwrap());
}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  int num;
  cin >> num;
  int res=0;
  for(int i=0;i<num;i++){
    int v;
    cin >> v;
    while(!(v%2)){
      v/=2;
      res++;
    }
  }
  cout << res << endl;
}

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


Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n,m;
    cin >> n >> m;
    
    if(n==m)
    cout << "Yes";
    else
    cout << "No";
    
	return 0;
    
}

Measured memory_bytes: 8832
// Template Headers {{{
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}


int Solver::solve() {
	int n; cin >> n;
	vi a(n); cin >> a;
	ll ans = 0;
	for (int x : a) ans += x - 1;
	cout << ans << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solver.solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

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

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long n = in.nextLong();
            long m = in.nextLong();

            long ans = 0;
            if (m > n * 2) {
                ans += n;
                m -= n * 2;
                ans += m / 4;
            } else {
                ans += m / 2;
            }
            out.print(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 20820
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    lis=[LI() for i in range(n)]
    lis.sort(key=lambda x:x[1])
    print(lis[0][1]+lis[0][0])
    

        
        
        
        
    
if __name__=="__main__":
    main()



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

int main(){
int A, B, K;
string X;
    X = "IMPOSSIBLE";
cin >> A >> B;

if (A % 2 == 0){
    if(B % 2 == 0){
        if(A > B){
            K = (A - B) / 2;
            K = K + B;
            cout << K << endl;
        }
        else{
            K = (B - A) / 2;
            K = K + A;
            cout << K << endl;
        }
    }
    else{
        cout << X << endl;
    }
    }
else if(B % 2 == 1){
    if(A > B){
            K = (A - B) / 2;
            K = K + B;
            cout << K << endl;
        }
        else{
            K = (B - A) / 2;
            K = K + A;
            cout << K << endl;
        }
}
else{
    cout << X << endl;
}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using lint = long long;


lint gcd(lint a, lint b) {
	if (a%b == 0) return b;
	else return gcd(b, a%b);
}

lint lcm(lint a, lint b) {
	return a * b / gcd(a, b);
}

int main() {
	lint N, M;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;
	lint divide = gcd(N, M);
	lint sit = N / divide;
	lint tit = M / divide;
	bool isGood = true;
	int count = 0;
	for (int i = 0; i < divide; i++) {
		if (S[sit*i] == T[tit*i]) continue;
		else{
			isGood = false;
			break;
		}
	}

	if (isGood) cout << lcm(N, M) << endl;
	else cout << "-1" << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

import static java.util.Arrays.sort;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        while (n != 0) {
            int[] score = new int[n];

            for(int i = 0; i < n; i++)
                score[i] = sc.nextInt();

            sort(score);

            int ave = 0;

            for(int i = 1; i < score.length - 1; i++)
                ave += score[i];

            ave /= n - 2;

            System.out.println(ave);

            n = sc.nextInt();
        }
        sc.close();
    }
}



Measured memory_bytes: 29436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector <int> T(N);
  int t;

  for (int i = 0; i < N; i++) {
    cin >> t;
    T.at(i) = t;
  }

  int M;
  cin >> M;

  vector <int> T_cal(N);
  int P, X;
  
  for (int i = 0; i < M; i++) {
    T_cal = T;
    cin >> P >> X;

    T_cal[P-1] = X;
    cout << accumulate(T_cal.begin(), T_cal.end(), 0) << endl;
  }
}

Measured memory_bytes: 256
//----->|try=0; while(!success) try++;|<------
//----->|Belief Yourself,Respect Yourself|<----
//----->|Be Proud Of Yourself,You're Doing Your best|<-----
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, n) for(int i = 1; i <= n; ++i)
#define rep1(i,start,n) for(int i=start;i<n;++i)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define MP make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return r;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    string s;
    while(getline(cin,s))
    {
        vector<string>v;
        string ss="";
        s+="1";
        rep(i,s.size())
        {
            if((s[i]>='A' && s[i]<='Z') || (s[i]>='a' && s[i]<='z'))
            {
                //ss+=s[i];
                ss+=s[i];
            }
            else
            {
                v.push_back(ss);
                ss="";
            }

        }
        string sss;
        rep(i,v.size())
        {
            sss=v[i];
            cout<<sss[0];
        }
        cout<<endl;
    }

}




Measured memory_bytes: 256
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s,t,s1;
    cin>>s;
    getchar();
    cin>>t;
    ll l1,l2,ans=100000000,c;
    l1=s.size();
    l2=t.size();
    for(int i=0;i<=l1-l2;i++)
    {
        s1=s.substr(i,l2);
        if(s1==t)
        {
            ans=0;break;
        }
        else
        {
            c=0;
            for(int j=0;j<l2;j++)
            {
                if(s1[j]!=t[j])c++;
            }
            ans=min(ans,c);
        }
    }
    cout<<ans<<endl;
}



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

int main(){
    int n,a,b,c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    for (auto i = 0; i < n; i++)
    {
        int l_i;
        cin >> l_i;
        l[i] = l_i;
    }

    ll ans = 1000000000000000;

    for (auto bit = 0; bit < pow(4,n); bit++)
    {
        int tmpa=0, tmpb=0, tmpc=0;
        vector<int> bits(n);
        int tmp = bit;
        for (auto i = 0; i < n; i++)
        {
            int t = tmp % 4;
            bits[i] = t;
            if(t == 1){
                tmpa += 1;
            }else if(t == 2){
                tmpb += 1;
            }else if(t == 3){
                tmpc += 1;
            }
            tmp /= 4;
        }
        if(tmpa*tmpb*tmpc == 0){
            continue;
        }

        int la = 0, lb = 0, lc = 0;
        for (auto i = 0; i < n; i++)
        {
            if(bits[i] == 0){
                continue;
            }else if(bits[i] == 1){
                la += l[i];
            }else if(bits[i] == 2){
                lb += l[i];
            }else{
                lc += l[i];
            }
        }

        ll tmp_ans = abs(a - la) + abs(b - lb) + abs(c - lc) + (tmpa + tmpb + tmpc - 3) * 10;
        if(tmp_ans < ans){
            ans = tmp_ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 5005
using namespace std;
typedef long long ll;
ll f[MN][MN];
int n,m;char ch[MN];
const int mod=1e9+7;
int pow(int x,int y){
	ll tmp=1;
	while(y){
		if(y&1)tmp=tmp*x%mod;
		x=1ll*x*x%mod,y>>=1;
	}return tmp;
}
void add(ll &x,ll y){(x+=y)>=mod?x-=mod:0;}
int main(){
	scanf("%d%s",&n,ch+1);m=strlen(ch+1);f[0][0]=1;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++){
			add(f[i+1][j+1],f[i][j]*2%mod);
			add(f[i+1][max(j-1,0)],f[i][j]);
		}printf("%lld\n",f[n][m]*pow(pow(2,m),mod-2)%mod);
}


Measured memory_bytes: 194048
#include<stdio.h>
int main(){
	int M=100000000;
	int n,m,i,u,s,c[510],f[20010],t[20010];
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0&&m==0){
			break;
		}
		for(i=u=1;i<=n;i++){
			c[i]=M;
		}
		for(i=s=c[1]=0;i<m*2;i+=2){
			scanf("%d %d",&f[i],&t[i]);
			f[i+1]=t[i];
			t[i+1]=f[i];
		}
		while(u){
			for(i=u=0;i<=m*2;i++){
				if(c[f[i]]==M||c[t[i]]<=c[f[i]]+1){
					continue;
				}
				c[t[i]]=c[f[i]]+1;
				u=1;
			}
		}
		for(i=2;i<=n;i++){
			if(c[i]<3){
				s++;
			}
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 2888
#include <iostream>

using namespace std;

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

  unsigned count = 0;
  for (int n=0; n<N; ++n) {
    unsigned a;
    cin >> a;

    while(a%2==0) {
      a /= 2;
      ++count;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder.ABC121.A
{
    class Program
    {
        public static void Main()
        {
            // Solve(3, 2, 2, 1);
            // Solve(5, 5, 2, 3);
            // Solve(2, 4, 2, 4);

            var a = Console.ReadLine().Split(' ');
            var H = int.Parse(a[0]);
            var W = int.Parse(a[1]);
            var b = Console.ReadLine().Split(' ');
            var h = int.Parse(b[0]);
            var w = int.Parse(b[1]);
            Solve(H, W, h, w);
        }

        static void Solve(int H, int W, int h, int w)
        {
            Console.WriteLine((H * W) - (h * W) - (w * H) + (h * w));
        }
    }
}


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

int main() {

  int	h;
  int	w;
  cin >> h >> w;
  
  
  int	i;
  int	j;
  vector<string> strs(h);
  string s = "";
  rep(i, h) cin >> strs[i];
  rep(i, h) strs[i] = "#" + strs[i] + "#";
  rep(i, w+2) s += "#";
  cout << s << endl;
  rep(i, h) cout << strs[i] << endl;
  cout << s << endl;
  return 0;
  
  /*
  j = 1;
  while (j <= h)
  {
    i = 1;
    while (i <= w)
    {
      if (j == 1 || j == h || i == 1 || i == w)
      {
        cout << "#";
      }
      else
      {
        count << lines.at(i + 1)
      }
      i++;
    }
    cout << endl;
    j++;
  }*/
  
  //cout << h << w << lines.at(0) << endl;

}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        HashSet<string> set = new HashSet<string>();
        var s = Console.ReadLine();
        set.Add(s);
        char lastChar = s.Last();
        for (int i = 0; i < n - 1; i++)
        {
            s = Console.ReadLine();
            if(!set.Add(s) || s.First() != lastChar)
            {
                Console.WriteLine("No");
                return;
            }
            lastChar = s.Last();
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  stack<char> st;
  rep(i,s.size())
    if(st.size()&&s[i]=='T'&&st.top()=='S')
      st.pop();
    else
      st.push(s[i]);
  cout<<st.size()<<endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    vector<ll> sumV(N, 0);
    REP(i, N)
    {
        cin >> V[i];
        if (i == 0) sumV[i] = V[i];
        else sumV[i] = sumV[i - 1] + V[i];
    }

    ll ans = 0;
    for (int j = 0; j <= min(K, N); ++j)
    {
        for (int k = 0; k <= min(K, N) - j; ++k)
        {
            priority_queue<ll, vector<ll>, greater<ll>> q;
            REP(p, j) q.push(V[p]);
            REP(p, k) q.push(V[N - 1 - p]);
            ll currentSum = 0;
            if (j != 0) currentSum += sumV[j - 1];
            if (k != N) currentSum += sumV[N - 1] - sumV[N - 1 - k];
            else currentSum += sumV[N - 1];
            ans = max(ans, currentSum);
            REP(l, K - (j + k))
            {
                if (!q.empty())
                {
                    ll v = q.top();
                    q.pop();
                    currentSum -= v;
                    ans = max(ans, currentSum);
                }
                else
                {
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int c[200020];
int rec[200020];
int back[200020];

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>c[i];
  
  for(int i=0;i<=n;i++) rec[i]=-1;
  for(int i=1;i<=n;i++){
    back[i]=rec[c[i]];
    rec[c[i]]=i;
  }

  //for(int i=1;i<=n;i++) cout<<i<<" "<<back[i]<<endl;

  ll dp[n+1]={};
  dp[0]=1;
  for(int i=1;i<=n;i++){
    dp[i]=dp[i-1];
    if(back[i]==-1||back[i]==i-1) continue;
    for(int j=i;j>0;){
      if(back[j]==-1||back[j]==j-1) break;
      dp[i]=(dp[i]+dp[back[j]-1])%MOD;
      j=back[j];
    }
  }

  //cout<<endl;
  //for(int i=1;i<=n;i++) cout<<i<<" "<<dp[i]<<endl;

  cout<<dp[n]<<endl;

  return 0;
}


Measured memory_bytes: 4096
while True:
    n = int(input())
    if n == 0: break
    num = []
    for i in range(n):
        score = list(map(int, input().split()))
        score.extend([0,0,0])
        cnt = 0
        flag = 0
        flame = 1
        for j in range(len(score[1:])):
            cnt+=score[j+1]
            if flame >= 10:
                pass
            elif score[j+1] == 10 and flag == 0:
                cnt+=score[j+2]+score[j+3]
                flame+=1
            elif score[j+1]+score[j]==10 and flag == 1:
                cnt+=score[j+2]
                flag = 0
                flame+=1
            elif flag == 1:
                flag = 0
                flame+=1
            elif flag == 0:
                flag = 1
        num.append([score[0], cnt])
    for i in sorted(num, key = lambda x: (-x[1], x[0])):
        print(*i)


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

const int maxn = 233;
const int MOD = 1000000007;
char s[2][maxn];
int n, f[maxn], flag[maxn];

int main(){
	scanf("%d", &n);
	scanf("%s", s[0]+1);
	scanf("%s", s[1]+1);
	for (int i=1; i<=n; i++){
		if (s[0][i] != s[1][i]){
			if (flag[i-1] == 1) flag[i] = 2;
			else flag[i] = 1;
		}
	}
	if (flag[1]) f[1] = 6;
	else f[1] = 3;
	for (int i=2; i<=n; i++)
		if (flag[i] == 2){
			f[i] = f[i-1];
		}
		else if (flag[i] == 1){
			if (!flag[i-1]) f[i] = f[i-1] * 2 % MOD;
			else f[i] = (f[i-1]*2%MOD + f[i-1]) % MOD;
		}
		else{
			if (!flag[i-1]) f[i] = f[i-1] * 2 % MOD;
			else f[i] = f[i-1];
		}
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];

  vector<ll> s(n+1);
  REP(i,n) s[i+1] = a[i] + s[i];

  ll ans = 0;

  for (int i = 0; i < n-1; i++) {
    ll v = (s[n] - s[i+1]) % MOD;
    ans += (a[i] * v) % MOD;
    ans %= MOD;
  }

  COUT(ans);

  return 0;
}


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

using namespace std;

int main(){
   int n, m, a, b, flag;
   string s = "IMPOSSIBLE";

   cin >> n >> m;

   vector<int> ve(200001);

   flag = 0;
   for(int i = 0; i < m; i++){
      cin >> a >> b;
      if(flag == 0){
         if(a == 1){
            if(ve[b] == 0){
               ve[b]++;
            }else{
               s = "POSSIBLE";
               flag = 1;
            }
         }
         if(b == n){
            if(ve[a] == 0){
               ve[a]++;
            }else{
               s = "POSSIBLE";
               flag = 1;
            }
         }
      }
   }
   cout << s << endl;
}

Measured memory_bytes: 4060
import sys

readline = sys.stdin.buffer.readline


def binary_search(A, n, p):
    if p == "+":
        n += 0.5
    else:
        n -= 0.5

    left = 0
    right = len(A) - 1

    if n < A[0]:
        return 0
    else:
        while left <= right:
            mid = (left + right) // 2
            if A[mid] < n:
                left = mid + 1
            else:
                right = mid - 1

        return left


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A, B, C = sorted(A), sorted(B), sorted(C)

    cnt = 0
    for i, b in enumerate(B):
        ab = binary_search(A, b, "-")
        bc = N - binary_search(C, b, "+")
        cnt += ab * bc

    print(cnt)


main()


Measured memory_bytes: 72448
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const int dh[4]={1, 0, -1, 0};
const int dw[4]={0, 1, 0, -1};

int main() {
    int H, W;
    cin >> H >> W;
    
    vector<string> field(H);
    for(int h=0; h<H; h++) {
        cin >> field[h];
    }
    
    int ans=0;
    for(int h=0; h<H; h++) {
        for(int w=0; w<W; w++) {
            if(field[h][w]=='#') continue;
            queue<int> que;
            que.push(h+w*H);
            vector<vector<int> > dist(H, vector<int>(W, -1));
            dist[h][w]=0;
            while(!que.empty()) {
                int curh=que.front()%H;
                int curw=que.front()/H;
                que.pop();
                
                ans = max(ans, dist[curh][curw]);
                for(int i=0; i<4; i++) {
                    if(curh+dh[i]<0 || curh+dh[i]>=H || curw+dw[i]<0 || curw+dw[i]>=W) continue;
                    if(field[curh+dh[i]][curw+dw[i]]=='#') continue;
                    if(dist[curh+dh[i]][curw+dw[i]]!=-1) continue;

                    dist[curh+dh[i]][curw+dw[i]] = dist[curh][curw]+1;
                    que.push((curh+dh[i])+(curw+dw[i])*H);
                }
            }
        }
    }
    
    cout << ans << endl;
    

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int d(ll a,ll b){
    int s{};
    if(a>b) while(!(a<=b)) b*=4,++s;
    else while(a*4<=b) a*=4,--s;
    return s;
}

vector<ll> B(vector<ll>&a){
    int n=a.size();
    vector<ll> m(n-1),b(n);
    fr(i,n-1){
        m[i]=d(a[i],a[i+1]);
    }
    stack<pair<int,ll>> st;
    st.emplace(n-1,LLONG_MAX);
    ifr(i,n-1){
        b[i]=b[i+1];
        if(m[i]<0){
            st.emplace(i,-m[i]);
        }
        else{
            fr(j,m[i]){
                b[i]+=st.top().first-i;
                --st.top().second;
                if(!st.top().second) st.pop();
            }
        }
    }
    return b;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> a(n);
    for(auto&i:a) cin>>i;
    auto b=B(a);
    reverse(a.begin(),a.end());
    auto f=B(a);
    reverse(f.begin(),f.end());
    ll ans=min(2*b[0],2*f[n-1]+n);
    fr(i,n-1){
        chmin(ans,i+1+2*f[i]+2*b[i+1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6500
#include<stdio.h>
int main(void)
{
	int n,m,a,b;
	scanf("%d %d %d",&n,&m,&a);
	b=n+m+a;
	if(21>=b){
		printf("win\n");
	}
	else{
		printf("bust\n");
	}
	return 0;
}

Measured memory_bytes: 128
import sys

s = [x for x in sys.stdin.readline().rstrip()]

black = float("inf")
ans = 0

for i in range(len(s)):
    if s[i] == "B" and black > i:
        black = i
    elif s[i] == "W" and black != float("inf"):
        ans += i - black
        black += 1

print(ans)

Measured memory_bytes: 5096
#include <stdio.h>
#include<math.h>
int s[1000]; 

void reset(void);

main()
{
	int n,i;
	double a=0,m=0;
	
	while(1){
		reset();
		a=0,m=0;
		scanf("%d",&n);
		if(n==0){break;}
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
		}
		
		for(i=0;i<n;i++){
			m+=s[i];
		}
		m/=(double)n;
		
		for(i=0;i<n;i++){
			a+=(((double)s[i]-m)*((double)s[i]-m));
		}
		a/=(double)n;
		
		a=sqrt(a);
		
		printf("%f\n",a);
	}
	return 0;
}

void reset(void){
	int a;
	for(a=0;a<1000;a++){
		s[a]=0;
	}
}

Measured memory_bytes: 636
fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s);
  let hp_atk: Vec<i32> = s.trim().split_whitespace().map(|e| e.parse::<i32>().unwrap()).collect();
  let hp = hp_atk.first().unwrap();
  let attack = hp_atk.last().unwrap();
  let result = if hp % attack == 0 {
    hp / attack
  } else {
    (hp / attack) + 1
  };
  println!("{}", result);
}


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

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

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

	sort(vec.begin(), vec.end(), greater<int>());

	int alice = 0;
	int bob = 0;
	int j = 0;
	while (true) {
		alice += vec[j];
		++j;
		if (j == vec.size()) break;
		bob += vec[j];
		++j;
		if (j == vec.size()) break;
	}

	cout << alice - bob << endl;
}

Measured memory_bytes: 256
n = int(input())
S = [input() for _ in range(n)]

def bag_of_char(s):
	boc = {}
	sl = list(s)
	for c in sl:
		boc[c] = boc[c] + 1 if c in boc else 1
	return boc

boc = bag_of_char(S[0])

for s in S:
	for k in boc.keys():
		boc_s = bag_of_char(s)
		if k in boc_s:
			boc[k] = min(boc[k], boc_s[k])
		else:
			boc[k] = 0

res = ""
for k,v in boc.items():
	res = res + k * v

res = sorted(list(res))
print("".join(res))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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


	string N;
	cin >> N;

	if (N[0] == N[2]) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
	    Scanner x=new Scanner(System.in);
	    int s = x.nextInt();
		int[] r=new int[s];
		for(int i=0;i<s;i++){
		    r[i]=x.nextInt();
		}
		int Max=r[1]-r[0];
		int Min=Math.min(r[1],r[0]);
		for(int i=2;i<s;i++){
				Max = Math.max(Max,r[i]-Min);
				Min = Math.min(Min,r[i]);
			}
		System.out.println(Max);
	}
}


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

int func(int n){
    if(n%2){
        return 3*n+1;
    }else{
        return n/2;
    }
}

int main() {
    //input
    string s;
    cin >> s;
    vector<int> a(0);
    for(char c : s){
        a.push_back(c-48);
    }
    int res = 10000;
    for(int i=0;i<a.size()-2;i++){
        int num = a.at(i) * 100 + a.at(i+1) * 10 + a.at(i+2);
        res = min(res,abs(753-num));
    }
    cout << res << endl;
    return 0;
}

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

template <typename T>
class seg {
	T t;
	using N = typename T::N;
	using F = typename T::F;
	vector<N> nt;
	vector<F> ft;
	void eval(int p, int l, int r) {
		if (ft[p] == t.IF)
			return;
		nt[p] = t.FN(ft[p], r - l, nt[p]);
		if (l + 1 < r) {
			t.FF(ft[p], ft[p + 1]);
			t.FF(ft[p], ft[p + (r - l & -2)]);
		}
		ft[p] = t.IF;
	}
	N init(N n, int p, int l, int r) {
		if (l + 1 == r)
			return nt[p] = n;
		int m = (l + r) / 2;
		return nt[p] = t.NN(init(n, p + 1, l, m), init(n, p + (r - l & -2), m, r));
	}
	N upd(int a, int b, F f, int p, int l, int r) {
		eval(p, l, r);
		if (b <= l || r <= a)
			return nt[p];
		if (a <= l && r <= b)
			return t.FN(ft[p] = f, r - l, nt[p]);
		int m = (l + r) / 2;
		return nt[p] = t.NN(upd(a, b, f, p + 1, l, m), upd(a, b, f, p + (r - l & -2), m, r));
	}
	N get(int a, int b, int p, int l, int r) {
		if (b <= l || r <= a)
			return t.IN;
		eval(p, l, r);
		if (a <= l && r <= b)
			return nt[p];
		int m = (l + r) / 2;
		return t.NN(get(a, b, p + 1, l, m), get(a, b, p + (r - l & -2), m, r));
	}
public:
	const int s;
	seg(int s) :s(s), nt(s * 2 - 1, t.IN), ft(s * 2 - 1, t.IF) {}
	seg(int s, N n) :seg(s) {
		init(n, 0, 0, s);
	}
	void upd(int a, int b, F f) {
		upd(a, b, f, 0, 0, s);
	}
	N get(int a, int b) {
		return get(a, b, 0, 0, s);
	}
};
struct L {
	typedef long N, F;
	const N IN = 0;
	const F IF = 0;
	N NN(N m, N n) { return m + n; }
	N FN(F f, int, N n) { return f + n; }
	void FF(F f, F &g) { g += f; }
};
int main() {
	int q;
	cin >> q;
	seg<L> m(222222), a(222222);
	vector<long> u;
	vector<tuple<int, int, long>> v;
	for (int i = 0; i < q; i++) {
		int c, a, b;
		scanf("%d", &c);
		if (c > 1)
			continue;
		scanf("%d%d", &a, &b);
		v.emplace_back(i, a, b);
	}
	sort(v.begin(), v.end(), [](auto x, auto y) {return get<1>(x) < get<1>(y); });
	for (auto &a : v) {
		u.push_back(get<1>(a));
		if (u.size() > 1 && u.back() == u.rbegin()[1])
			u.erase(u.end() - 1);
		get<1>(a) = u.size() - 1;
	}
	sort(v.begin(), v.end());
	int j = 0;
	for (int i = 0; i < q; i++) {
		if (j < v.size() && i == get<0>(v[j])) {
			m.upd(0, get<1>(v[j]), -1);
			a.upd(0, get<1>(v[j]), u[get<1>(v[j])] + get<2>(v[j]));
			m.upd(get<1>(v[j]), 222222, 1);
			a.upd(get<1>(v[j]), 222222, -u[get<1>(v[j])] + get<2>(v[j]));
			j++;
			continue;
		}
		int l = -1, r = 222000;
		while (l + 1 < r) {
			int t = (l + r) / 2;
			if (t + 1 < u.size() && m.get(t, t + 1)*u[t] + a.get(t, t + 1) > m.get(t + 1, t + 2)*u[t + 1] + a.get(t + 1, t + 2))
				l = t;
			else r = t;
		}
		cout << u[r] << ' ' << m.get(r, r + 1)*u[r] + a.get(r, r + 1) << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 19824
#include <cstdio>
using namespace std;
 
struct Node {
    Node *parent;
    Node *left;
    Node *right;
    int key;
};
 
Node *NIL = NULL;
 
void preorder(Node *v) {
    if (v == NIL) return;
    printf(" %d", v->key);
    preorder(v->left);
    preorder(v->right);
}
 
void inorder(Node* v) {
    if (v == NIL) return;
    inorder(v->left);
    printf(" %d", v->key);
    inorder(v->right);
}
 
void postorder(Node* v) {
    if (v == NIL) return;
    postorder(v->left);
    postorder(v->right);
    printf(" %d", v->key);
}
 
void insert(Node* &T, Node *z) {
    Node *y = NIL;
    Node *x = T;
    while (x != NIL) {
        y = x;
        if (z->key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    z->parent = y;
 
    if (y == NIL)
        T = z;
    else if (z->key < y->key)
        y->left = z;
    else
        y->right = z;
}
 
 
int main()
{
    int n;
    scanf("%d", &n);
 
    Node *T = NIL;
    for (int i = 0; i < n; ++i) {
        char cmd[20];
        int v;
        scanf("%s %d", cmd, &v);
        if (cmd[0] == 'i') {
            Node *p = new Node;
            p->key = v;
            insert(T, p);
        } else if (cmd[0] == 'p') {
            inorder(T);
            printf("\n");
            preorder(T);
            printf("\n");
        }
    }
 
    return 0;
}

Measured memory_bytes: 26192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func ZAlgorithm(s string) []int {
	n := len(s)
	a := make([]int, n)
	a[0] = n
	for i, j := 1, 0; i < n; {
		for i+j < n && s[j] == s[i+j] {
			j++
		}
		a[i] = j
		if j == 0 {
			i++
			continue
		}
		k := 1
		for i+k < n && k+a[k] < j {
			a[i+k] = a[k]
			k++
		}
		i += k
		j -= k
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, s := nextInt(), next()

	ans := 0
	for i := 0; i < n-1; i++ {
		a := ZAlgorithm(s[i:])
		for j := range a {
			if a[j] <= j {
				ans = max(ans, a[j])
			}
		}
	}

	puts(ans)
}


Measured memory_bytes: 18176
# -*- coding: utf-8 -*-
import math

# input
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

# solve
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        dis = 0
        for k in range(D):
            dis += abs(X[i][k] - X[j][k])**2
        if math.sqrt(dis).is_integer():
            ans += 1

# output
print(ans)


Measured memory_bytes: 3060
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var s = Console.ReadLine();
		var c = new int[3];
		foreach (var x in s) c[x - 'a']++;
		Console.WriteLine(c.Max() - c.Min() <= 1 ? "YES" : "NO");
	}
}


Measured memory_bytes: 13408
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	cin >> n >> m;
	pair<ll, ll> a[n];
	for(ll i=0; i<n; i++)
		cin >> a[i].first >> a[i].second;
	sort(a, a+n);
	ll ans = 0;
	for(ll i=0; m!=0; i++){
		if(a[i].second <= m){
			m-=a[i].second;
			ans += a[i].first*a[i].second;
		}
		else if(a[i].second > m){
			ans += a[i].first *m;
			m -= m;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch DoubleHelix | diff DoubleHelix.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address DoubleHelix.cpp && ./a.out

/*
 
 5/9/2019
 
 16:11-
 
 */

char c;
void solve() {
  char res='?';
  if(c=='A') res='T';
  if(c=='T') res='A';
  if(c=='G') res='C';
  if(c=='C') res='G';
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>c;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
//include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring> 
#include <set>
#include <map>
#define db double 
#define LL long long
#define int LL
#define rep(i,x,y) for (int i=x;i<=y;++i)
#define mp make_pair
#define ft first
#define sd second
#define P pair<int ,int >
#define pb push_back 
using namespace std;
const int N  =  233;
//const int mod = ;
void read(int &x)
{
	int f=1;
	x=0;
	char ch=getchar();
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
	return ;
}
int n,a[N],sum;
signed main()
{
	read(n);read(sum);
	rep(i,1,n ) read(a[i]);//sum+=a[i];
	sort(a+1,a+1+n);
	rep(i,1,n) 
	{
		if (sum>=a[i]) sum-=a[i];
		else return printf("%lld",i-1),0;
		if (sum==0) return printf("%lld",i),0;
		
	}
	if (sum>0) printf("%lld",n-1);
	else printf("%lld",n);
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

#define _USE_MATH_DEFINES
#include<cmath>

using namespace std;

int main(void){
	double r;
	double pai = 3.141592653589;
	
	cin >> r;
	
	printf("%.6f %.6f\n", r*r*pai, 2*r*pai);
	
	return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
#include<string.h>
 
int main(){
int room[4][3][10];
int n;
int b,d,r,v;
scanf("%d",&n);

    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                room[i][j][k]=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&d,&r,&v);
        room[b-1][d-1][r-1]=room[b-1][d-1][r-1]+v;
    }


    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                printf(" %d",room[i][j][k]);
            }
        printf("\n");
        }
        if(i==3){break;}
        printf("####################\n");
    }
}



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

int main(){
 int a[3], i;
 for(i = 0; i < 3; i++) cin >> a[i];
 sort(a,a+3);
 cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}

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

int main()
{
    int k, t, sum = 0;
    cin >> k >> t;
    vector<int> a(t);
    rep(i, t)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(ALL(a));
    int max = a[t - 1];
    if (2 * max - sum - 1 <= 0)
        cout << 0 << endl;
    else
        cout << 2 * max - sum - 1 << endl;
    return 0;
}

Measured memory_bytes: 256