akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s;

bool solve(int n)
{
    int sz=s.size(),last;
    int i=0;
    if(n==(sz+3)/2)
    {
        i=n;
        sz=(sz+3)/2;
    }
    if(n==(sz-1)/2)
        sz=(sz-1)/2;

    last=sz-1;
    for(int i=0;i<sz/2;i++)
    {
        if(s[i]!=s[last])
            return 0;
        last--;
    }
//    cout<<(n+3)/2<<endl;
//  cout<<n/2+(n-(n+3)/2)/2+1<<endl;

    last=sz-1;
    for(int i=(n+3)/2-1;i<n/2+(n-(n+3)/2)/2+1;i++)
    {
//
//        cout<<s[i]<<" "<<s[last]<<endl;
        if(s[i]!=s[last])
            return 0;
        last--;
    }

    last=(sz-1)/2-1;
    for(int i=0;i<(sz-1)/2/2;i++)
    {
        if(s[i]!=s[last])
            return 0;
        last--;
    }
    return 1;
}

int main()
{
    cin>>s;

    if(solve(s.size()))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;


int main(){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    if(n*a<b)printf("%d",n*a);
    else printf("%d",b);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	bool h = false;
	while (n > 0) {
		if (n % 10 == 9) {
			h = true;
		}
		n /= 10;
	}
	if (h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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


int main(){
	int N;cin>>N;
	long long total = 0,left = 1e9;
	for(int i=0;i<N;i++){
		long long a,b;cin>>a>>b;
		total += a;
		if(a > b) left = min(left,b);
	}
	if(left == 1e9) cout<<0<<endl;
	else cout<<total - left<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;


fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let n: String = read(&mut stdin).unwrap();
    let sn = n.chars()
        .map(|x| u32::from(x) - u32::from('0'))
        .fold(0, |acc, x| acc + x);

    println!("{}", if u32::from_str(&n).unwrap() % sn == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<Character> alice = in.next().chars().mapToObj(c -> (char) c).collect(Collectors.toList());
        List<Character> bob = in.next().chars().mapToObj(c -> (char) c).collect(Collectors.toList());
        List<Character> charlie = in.next().chars().mapToObj(c -> (char) c).collect(Collectors.toList());

        Map<Character, Deque<Character>> players = new HashMap<>();
        players.put('a', new ArrayDeque<>(alice));
        players.put('b', new ArrayDeque<>(bob));
        players.put('c', new ArrayDeque<>(charlie));
        char current = 'a';

        while (true) {
            Deque<Character> characters = players.get(current);
            if (characters.isEmpty()) {
                System.out.println(Character.toUpperCase(current));
                break;
            }
            Character next = characters.pop();
            if (next == current) {
                continue;
            }
            current = next;
        }

    }
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>i>>j;

	ret(max(i+j,max(i-j,i*j)))	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

int main(){
	ll N;
	cin >> N;
	vector<int> A(N),B(N);
	FOR(i,0,N) cin >> A[i];
	FOR(i,0,N) cin >> B[i];
	//　もともとiにいたカードは位置jmod2 == imod2 のjで赤

	int ans = -1;
	FOR(s,0,(1<<N)){
		vector<int> zero,one;
		vector<pair<int,int>> onex,zerox;
		int invcount = 0;
		FOR(i,0,N)if(s&(1<<i))invcount++;
		//if(invcount%2) continue;
		FOR(i,0,N){
			if(s&(1<<i)){//裏返す
				if(i&1){
					zero.push_back(i);
					zerox.push_back({B[i],i});
				}else{
					one.push_back(i);
					onex.push_back({B[i],i});
				}
			}else{//裏返さない
				if(i&1){
					one.push_back(i);
					onex.push_back({A[i],i});
				}else{
					zero.push_back(i);
					zerox.push_back({A[i],i});
				}
			}
		}
		int zl = zerox.size();
		int ol = onex.size();
		if( zl!=ol && zl!=(ol+1) ){
			continue;
		}
		SORT(onex);SORT(zerox);
		bool none = false;
		
		vector<ll> to_this_ind,xxx;
		FOR(i,0,ol){
			xxx.push_back(zerox[i].first);
			xxx.push_back(onex[i].first);
			to_this_ind.push_back(zerox[i].second);
			to_this_ind.push_back(onex[i].second);
		}
		if(zl>ol)to_this_ind.push_back(zerox[ol].second),xxx.push_back(zerox[ol].first);
		FOR(i,0,N-1){
			if(xxx[i]>xxx[i+1])none = true;
		}
		if(none)continue;
		int cnt = 0;
		set<int> se;
		FOR(i,0,N)se.insert(i);
		FOR(i,0,N){
			auto ind = se.lower_bound(to_this_ind[i]);
			int indc = 0;
			auto ite = se.begin();
			while(ite!=ind){ite++;indc++;}
			cnt += indc;
			se.erase(to_this_ind[i]);
		}
		if(ans==-1) ans = cnt;
		ans = min(ans,cnt);
	}

	cout << ans << endl;
}


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

int main() {
  int x;
  cin >> x;
  while (1) {
    bool ok = true;
    for (int i = 2; i < x; ++i) {
      if (x%i == 0) {
        ok = false;
        break;
      } 
    }
    if (ok) break;
    ++x;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]

cnt = 0
for t in T:
    low = 0
    high = len(S) - 1
    while low <= high:
        mid = (low + high) // 2
        if t == S[mid]:
            cnt += 1
            break
        elif t < S[mid]:
            high = mid - 1
        else:
            low = mid + 1
print(cnt)

Measured memory_bytes: 18968
function gcd(a, b){
  for (var r = a % b; r != 0; r = a % b) {
            a = b;
            b = r;
  }
  return b;
}

function main(input){
  	const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);
	console.log(a / gcd(a,b) * b);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int mincost(int a[],int n)
    {
        int dp[100001]={0},i;
        for(i=2;i<=n;i++)
            {
                int x,y;
                x=abs(a[i]-a[i-2])+dp[i-2];
                y=abs(a[i]-a[i-1])+dp[i-1];
                dp[i]=min(x,y);
            }
        return dp[n];
    }


int main()
{
    
        int a[100001],i,n;
        cin >> n;
        a[0]=99999;
        for(i=1;i<=n;i++)
            {
                cin >> a[i]; 
            }
        cout << mincost(a,n);
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//vvi(n, vector<int>(m, -1))
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()
#define out(x) cout << (x) << endl;

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> s >> k;

	rep(i, n){
		if(s[i] != s[k-1]){
			cout << '*';
		}else{
			cout << s[i];
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const ll mod = 1e9 + 7;
int n, c[N], cnt[N], siz[N];
ll cal(int x) {
	return 1ll * x*(x - 1) / 2 + x;
}
ll ans[N];
vector<int>G[N];
void dfs(int u, int _fa) {
	siz[u] = 1;
	int tmp = cnt[c[u]];
	for (int v : G[u]) {
		if (v == _fa)continue;
		cnt[c[u]] = 0;
		dfs(v, u);
		siz[u] += siz[v];
		ans[c[u]] += cal(siz[v] - cnt[c[u]]);
	}
	cnt[c[u]] = tmp + siz[u];
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%d", &c[i]);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		printf("%lld\n", cal(n) - ans[i] - cal(n - cnt[i]));
	}
	return 0;
}

Measured memory_bytes: 34044
#include <iostream>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A == 1) {
		A = 14;
	}

	if (B == 1) {
		B = 14;
	}

	if (A > B) {
		cout << "Alice" << endl;
	}
	else if (A < B) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
}





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

int main (){
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	} else if (N == 2) {
		int A,B;
		cin >> A >> B;
		cout << A+B << endl;
	}
	return 0;
}



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

struct Node{
    int idx=-1;
    int first_l_idx=0;
    int second_l_idx=0;
    int first_r_idx=0;
    int second_r_idx=0;
    int val;
};

stack<Node> t;
Node node_list[100010];

int n;

int main(){
    cin>>n;Node temp;
    for(int i=1;i<=n;i++){
        cin>>node_list[i].val;
        node_list[i].idx = i;
        node_list[i].first_r_idx=n+1;
        node_list[i].second_r_idx=n+1;
    }
    temp.val=INF;
    temp.idx=0;
    t.push(temp);

    for(int i=1;i<=n;i++){
        temp = t.top();
        while(temp.val<node_list[i].val){
            t.pop();
            node_list[temp.idx].first_r_idx = node_list[i].idx;
//            temp.first_r_idx = node_list[i].idx;
            temp = t.top();
        }
        t.push(node_list[i]);
    }
    while(!t.empty()) t.pop();
    temp.val=INF;
    temp.idx=n+1;

    t.push(temp);
    for(int i=n;i>=1;i--){
        temp = t.top();
        while(temp.val<node_list[i].val){
            t.pop();
            node_list[temp.idx].first_l_idx = node_list[i].idx;
//            temp.first_l_idx = node_list[i].idx;
            temp = t.top();
        }
        t.push(node_list[i]);
    }

    for(int i=1;i<=n;i++){

        int temp_idx = node_list[node_list[i].first_l_idx].first_l_idx;

        for(int k=node_list[i].first_l_idx-1;k>=temp_idx;k--){
            if(node_list[k].val>node_list[i].val){
                node_list[i].second_l_idx=k;
                break;
            }
        }

        temp_idx = node_list[node_list[i].first_r_idx].first_r_idx;

        for(int k=node_list[i].first_r_idx+1;k<=temp_idx;k++){
            if(node_list[k].val>node_list[i].val){
                node_list[i].second_r_idx=k;
                break;
            }
        }
    }

    long long ans = 0;
    long long l1,l2,r1,r2;
    for(int i=1;i<=n;i++){
        l1 = node_list[i].first_l_idx;
        l2 = node_list[i].second_l_idx;
        r1 = node_list[i].first_r_idx;
        r2 = node_list[i].second_r_idx;
//        cout<<l1<<" "<<l2<<" "<<r1<<" "<<r2<<endl;
        ans += ((l1-l2)*(r1-node_list[i].idx) + (r2-r1)*(node_list[i].idx-l1))*node_list[i].val;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265359
int INF = 1000000000;

int main() {
  int D, G, p[11], c[11]; cin >> D >> G;
  rep(i, D) {
    cin >> p[i] >> c[i];
  }
  
  int ans = INF;
  for(int bit=0; bit<(1<<D); bit++) {
    int s = 0, num = 0, rest_max = -1;
    rep(i, D) {
      if(bit >> i & 1) {
        s += 100 * (i+1) * p[i] + c[i];
        num += p[i];
      }
      else rest_max = i;
    }
    if(s < G) {
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      // 最高点の問題を全部解いても条件を満たさない場合、今の状況＋最高点のbitが出現するため無視していい
      if(need >= p[rest_max]) continue;
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

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

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll sx, ll sy, ll tx, ll ty) {
  int x = tx - sx, y = ty - sy;
  string res;
  REP(i,y) res += 'U';
  REP(i,x) res += 'R';
  REP(i,y) res += 'D';
  REP(i,x) res += 'L';
  res += 'L';
  REP(i,y) res += 'U';
  res += 'U';
  res += 'R';
  REP(i,x) res += 'R';
  res += 'D';
  res += 'R';
  REP(i,y) res += 'D';
  res += 'D';
  res += 'L';
  REP(i,x) res += 'L';
  res += 'U';
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll sx;
	ll tx;
	ll sy;
	ll ty;
	scanf("%lld", &sx);
	scanf("%lld", &sy);
	scanf("%lld", &tx);
	scanf("%lld", &ty);
	solve(sx, sy, tx, ty);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<int[]> Solve(string S)
        {
            int N = S.Length;
            if (S.Last() != '0') { return null; }
            if (S.First() != '1') { return null; }
            for (int i = 0; i < N - 2 - i; ++i)
            {
                if (S[i] != S[N - 2 - i]) { return null; }
            }
            var set = new List<int> { 0 };
            for (int i = 1; i < N; ++i) { if (S[i] == '1') { set.Add(i + 1); } }
            set.Add(N);
            var edges = new List<int[]>();
            for (int i = 1; i < set.Count; ++i)
            {
                for (int j = set[i - 1] + 1; j < set[i]; ++j)
                {
                    edges.Add(new int[] { j, set[i] });
                }
                if (i + 1 < set.Count)
                {
                    edges.Add(new int[] { set[i], set[i + 1] });
                }
            }
            return edges;
        }
        static void Main(string[] args)
        {
            var edges = Solve(Read());
            if (edges == null)
            {
                Console.WriteLine(-1);
            }
            else
            {
                foreach (var edge in edges) { Console.WriteLine(string.Join(" ", edge)); }
            }
        }
    }
}


Measured memory_bytes: 24268
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<stdbool.h>

#define MOD 998244353

#define MIN(a,b) ((a)<(b)?(a):(b));
#define MAX(a,b) ((a)>(b)?(a):(b));

typedef long long int64;

int main(void){

    int64 N,A,B,C,D,E;
    scanf("%lld",&N);
    scanf("%lld",&A);
    scanf("%lld",&B);
    scanf("%lld",&C);
    scanf("%lld",&D);
    scanf("%lld",&E);
    
    int64 min;

    min=MIN(A,B);
    min=MIN(min,C);
    min=MIN(min,D);
    min=MIN(min,E);
    
    if(N%min==0){
        printf("%lld",N/min+4);
    }else{
        printf("%lld",N/min+5);
    }
    
    

    return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


int main()
{
	int n;
	string s;
	cin >> n >> s;
	int x = 0;
	int max = 0;
	FOR(i, 0, n) {
		if (s[i] == 'I') {
			x++;
		}
		else x--;
		max = std::max(x, max);
	}
	cout << max << endl;
}


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

struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }
  // M inv() const {
  //   int x, y;
  //   extgcd(this->v, MOD, x, y);
  //   return *this + M(x);
  // }

  static long long MOD;
  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    finv.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  ModInt::build(h + w);
  ModInt ans = 0;
  for (int i = 0; i < h - a; i++) {
    ans += ModInt::comb(i + b - 1, i) * ModInt::comb(h - i - 1 + w - b - 1, h - i - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int[] input = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        long cnt = IntStream.range(0, input[3] / input[0] + 1)
                .mapToLong(i -> IntStream.range(0, input[3] / input[1] + 1).filter(j -> {
                    int c = input[3] - i * input[0] - j * input[1];
                    return c >= 0 && c % input[2] == 0;
                }).count())
                .sum();
        System.out.println(cnt);
    }
}


Measured memory_bytes: 28628
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s[3];
  int t = 0;
  cin >> s[0] >> s[1] >> s[2];
  int top[3] = {0};

  while(1) {
	char c = s[t][top[t]];
	top[t]++;


	if(c == 'a') {
		t = 0;
	} else if(c == 'b') {
		t = 1;
	} else {
		t = 2;
	}

	if(top[t] == s[t].size()) {
		if(t == 0) cout << 'A' << endl;
		else if(t == 1) cout << 'B' << endl;
		else cout << 'C' << endl;
		break;
	}
  }
  return 0;
}
  


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

int main(void){
	int r, D, x;
	cin >> r >>  D >>  x;
	int ans = x;
	for (int i = 0; i < 10 ; i++){
		ans = r*ans - D;
		cout << ans << endl;
    }
	
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

ll dp[100005][3];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> a(n), b(n), c(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    dp[0][0]=a[0]; dp[0][1]=b[0]; dp[0][2]=c[0];
    for(i=1; i<n; i++) {
        dp[i][0]=MAX(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=MAX(dp[i-1][2],dp[i-1][0])+b[i];
        dp[i][2]=MAX(dp[i-1][0],dp[i-1][1])+c[i];
    }
    printf("%lld\n", MAX(MAX(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta (bas + (son-bas)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1e18
#define N 1000005

using namespace std;
 
typedef long long ll;

string s;

int main()
{
	cin >> s;

	for(int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0 && s[i] == 'L')
		{
			cout << "No";
			return 0;
		}
		else if (i % 2 != 0 && s[i] == 'R')
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200001
#define SW 1
using namespace std;
typedef long long ll;
ll n, cnt, p1, p2, mx = 0;
const double PI = acos(-1);
struct point {
    ll x, y;
    bool operator<(const point& r)const {
        return x < r.x || (x == r.x && y < r.y);
    }
    ll ccw(point p, point q) { // 벡터 외적
        return (p.x - x) * (q.y - y) - (p.y - y) * (q.x - x);
    }
} a[N], convex[N];
void convexhull() {
    scanf("%lld", &n);
    ll i;
    for (i = 1;i <= n;i++)
        scanf("%lld %lld", &a[i].x, &a[i].y);
    // sort O(nlogn)
    sort(a + 1, a + 1 + n);
    //convexhull O(n)
    // convex에 볼록다각형의 꼭짓점 좌표를 저장한다.
    for (i = 1;i <= n;i++) {
        for (;cnt >= 2 && convex[cnt - 1].ccw(convex[cnt], a[i]) <= 0;--cnt);
        convex[++cnt] = a[i];
    }
    for (p2 = cnt, i = n - 1;i >= 1;--i) {
        for (;cnt >= p2 + 1 && convex[cnt - 1].ccw(convex[cnt], a[i]) <= 0;--cnt);
        convex[++cnt] = a[i];
    }
    // cnt는 볼록 외피 꼭짓점 갯수
    p1 = 1;cnt--;
}
ll cal_dis() {
    // 볼록 다각형 두 점 사이의 거리구하기
    return abs(convex[p1].x - convex[p2].x) + abs(convex[p1].y - convex[p2].y);
}
void rotating_calipers()
{
    ll i;
    ll x1, y1, x2, y2, xx1, yy1, xx2, yy2;
    double cos1, cos2;

    // x1과 y1은 왼쪽 캘리퍼스의 벡터, x2와 y2는 오른쪽 캘리퍼스이 벡터
    x1 = x2 = 0;
    y1 = -1, y2 = 1;
    //p1은 초기에 왼쪽에 있는 캘리퍼스가 볼록다각형의 접해있는 점, p2는 오른쪽에 있는 캘리퍼스가 다각형의 접해있는 점

    for (i = 1;i <= cnt;i++) {
        mx = max(mx, cal_dis());
        //다각형의 변의 벡터인 xx1,yy1,xx2,yy2를 구한다.
        xx1 = (convex[p1 % cnt + 1].x - convex[p1].x);yy1 = (convex[p1 % cnt + 1].y - convex[p1].y);
        xx2 = (convex[p2 % cnt + 1].x - convex[p2].x);yy2 = (convex[p2 % cnt + 1].y - convex[p2].y);

        //벡터의 내적으로 두 벡터 사이각의 코사인을 구한다.
        // 각도는 항상 180도 미만이므로 각이 작을 수록 코사인 값이 크다.
        cos1 = (double)(x1 * xx1 + y1 * yy1) / sqrt(x1 * x1 + y1 * y1) / sqrt(xx1 * xx1 + yy1 * yy1);
        cos2 = (double)(x2 * xx2 + y2 * yy2) / sqrt(x2 * x2 + y2 * y2) / sqrt(xx2 * xx2 + yy2 * yy2);

        if (cos1 > cos2) {// cos의 실수 오차를 없애고 싶으면 양변 제곱해서 통분 하면 된다.

            //왼쪽 캘리퍼스가 볼록 다각형에 접해있는 점(p1)을  반시계로  하나 이동 시키고
            // 다각형 변의 벡터가 캘리퍼스의 벡터가 된다.
            p1 = p1 % cnt + 1;
            x1 = xx1;y1 = yy1;

            // 오른쪽 캘리퍼스는 왼쪽 캘리퍼스와 방향만 반대고 평행
            x2 = -x1;y2 = -y1;
        }
        else {

            //오른쪽 캘리퍼스가 볼록 다각형에 접해있는 점(p2)을  반시계로  하나 이동 시키고
               // 다각형 변의 벡터가 캘리퍼스의 벡터가 된다.
            p2 = p2 % cnt + 1;
            x2 = xx2;y2 = yy2;
            x1 = -x2;y1 = -y2;
        }
    }
    printf("%lld\n", mx);
}
int main() {
    convexhull();
    rotating_calipers();
}

Measured memory_bytes: 6896
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	long long int total = 0;
	long long int min = 1000000000000000;
	long long int peak = 0;

	cin >> n;
	vector<int>a(n + 1);
	FOR(i, 1, n) {
		cin >> a[i];
		total += a[i];
	}
	FOR(i, 1, n-1) {
		peak += a[i];
		if (abs(peak - (total - peak)) < min) {
			min = abs(peak - (total - peak));
		}
	}
	cout << min << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> w = {};

    for(int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        w.push_back(tmp);
    }

    // sort(w.begin(), w.end());
    int ans = 9999999;

    for (int i = 0; i < N; ++i){
        int left = 0;
        int tmp = 0;
        for(int j = 0; j <= i; ++j) {
            left += w[j];
        }

        int right = 0;
        for(int j = i+1; j < N; ++j) {
            right += w[j];
        }
        // cout << left << ' ' << right << endl;

        tmp = abs(left - right);
        if(ans > tmp) {
            ans = tmp;
        }

    }
        cout << ans << endl;
}

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

using namespace std;

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

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

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n %= 10;

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

Measured memory_bytes: 3652
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353
const string YES = "Yes";
const string NO = "No";

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	string s;
  cin>>s; s;
	reps(i,1,10){
		string t;
		rep(_,i) t+="hi";
		if(t==s){
			cout<<"Yes" NL;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans=0;
    int curmin=1e9;
    for(int i=0;i<n;i++){
        curmin=min(curmin,p[i]);
        if(curmin==p[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct MaxSegTree{
    long n; vector<ll> dat;
    //初期化
    MaxSegTree(long _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,-1);
    }
    //k番目(0-indexed)の値をaに変更
    void update(long k, ll a){
        k+=n-1;
        dat[k]=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    //k番目(0-indexed)の値からaを引く
    void minus(long k, ll a){
        k+=n-1;
        dat[k]-=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }
    ll get(long idx)
    {
        return dat[idx+n-1];
    }
    //内部的に投げられるクエリ
    ll _query(long a, long b, long k, long l, long r){
        if(r<=a || b<=l) return -1;

        if(a<=l && r<=b) return dat[k];
        else{
            ll vl=_query(a,b,2*k+1,l,(l+r)/2);
            ll vr=_query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
    //[a,b)の最大値を求める
    ll query(long a, long b){
        return _query(a,b,0,0,n);
    }
};

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

    MaxSegTree st(n);

    rep(i,n)
    {
        int a;
        scanf(" %d", &a);
        st.update(i,a);
    }

    ll ans=st.get(0)-1;
    st.update(0,1);


    for(int i=1; i<n; ++i)
    {
        ll p=st.query(0,i)+1;
        ll val=st.get(i);

        ll add=val/p;
        if(val%p==0) --add;
        if(add==0) continue;

        val-=(add-1)*p;
        ans+=add;
        st.update(i,1);

        // printf(" --- %d end , p= %lld\n", i,p);
        // rep(j,n) printf(" %lld\n", st.get(j));
        // printf("  ans = %lld\n", ans);
    }

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


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a+w<b){
        cout << b-a-w << endl;
    }else if(b+w<a){
        cout << a-b-w << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int food[5];
    rep(i, 5) cin >> food[i];
    pair<int, int> time[5];
    rep(i, 5){
        if(food[i] % 10 == 0) time[i].first = 0, time[i].second = food[i];
        else {
           time[i].first = 10 - food[i] % 10, time[i].second = food[i];
        }
    }
    sort(time, time + 5);
    int ans = 0;
    rep(i, 4){
        ans += time[i].first + time[i].second;
    }
    ans += time[4].second;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n>>a>>b;
	ll u = min(a,b);
	ll v = max(a,b);
	ll ans[n+1];
	memset(ans,0,sizeof(ans));
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			ll d = j-i;
			if (j<=u or i>=v)
			{
				ans[d]++;
			}
			else
			{
				if (i<=u and j<=v)
				{
					d = min(d,u-i+1+v-j);
				}
				else if (i<=u)
				{
					d = min(d,u-i+1+j-v);
				}
				else if (j<=v)
				{
					d = min(d,i-u+1+v-j);
				}
				else
				{
					d =min(d,i-u+1 + j-v);
				}
				ans[d]++;
			}

		}
	}
	for(ll i=1;i<n;i++)
	{
		cout<<ans[i]<<"\n";
	}
}

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

int main() {
    int n, m; scanf("%d %d", &n, &m);
    vector<int> frac;
    for(int i = 1; i*i <= m; ++i) {
        if(i * i == m) frac.emplace_back(i);
        else if(m % i == 0) frac.emplace_back(i), frac.emplace_back(m / i);
    }
    sort(frac.begin(), frac.end(), greater<int>());
    for(auto x : frac) if(m / x >= n) return !printf("%d\n", x);
}

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

int n, x;
int ans;
int gcd(int x, int y){
	if(x % y == 0) return y;
	return gcd(y, x % y);
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> x;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		if(i == 0) ans = abs(t-x);
		else ans = gcd(abs(t-x), ans);
	}
	cout << ans << "\n";
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    std::vector<int> l;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    std::sort(l.begin(), l.end());
    
    int sum = 0;
    std::vector<int>::iterator itr;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int tmp = l[i]+l[j];
            itr = std::lower_bound(l.begin()+(j+1), l.end(), tmp);
            sum += std::distance(l.begin()+(j+1), itr);
        }
    }

    cout << sum << endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;

  char b[H][W];
  // vector<int> b[H][W];

  bool x[H];  // i行目（0~）は削除可能か
  bool y[W];  // i列目（0~）は削除可能か

  for (int i = 0; i < H; i++) {
    x[i] = true;
  }
  for (int i = 0; i < W; i++) {
    y[i] = true;
  }

  char tmp;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> tmp;
      b[i][j] = tmp;
      if (tmp == '#') {
        x[i] = false;
        y[j] = false;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if (x[i]) {
      continue;
    }
    for (int j = 0; j < W; j++) {
      if (y[j]) {
        // pass
      } else {
        cout << b[i][j];
      }
    }
    cout << "\n";
  }
}

Measured memory_bytes: 256
<?php 
fscanf(STDIN, "%d %d", $q_count, $answer_count);
if (empty($answer_count)) {
  echo "0 0"; exit;
}
for ($i=1; $i <= $answer_count; $i++) {
  fscanf(STDIN, "%d %s", $q_num_s[$i], $results[$i]);
}

foreach ($q_num_s as $key => $q_num) {
  if ($goukei[$q_num]["AC"] == 1) {
    continue;
  }

  if ($results[$key] == "AC") {
	$goukei[$q_num]["AC"] = 1;
  } elseif ($results[$key] == "WA") {
	if (!empty($goukei[$q_num]["WA"])) {
		$goukei[$q_num]["WA"] += 1;
	} else {
		$goukei[$q_num]["WA"] = 1;
	}
  }
}

foreach ($goukei as $key => $value) {
  if (empty($value["AC"])) {
    $goukei[$key]["WA"] = 0;
  }
}

echo array_sum(array_column($goukei, 'AC'));
echo " ";
echo array_sum(array_column($goukei, 'WA'));

Measured memory_bytes: 69876
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
ll mod = 1000000007;

vector<pair<int, int>> v;
int main()
{
	int n;
	cin >> n;
	int p[100000];

	p[0] = -1;
	rep(i, n) {
		cin >> p[i + 1];
	}

	int count = 0;
	rep(i, n + 1) {
		if (i == 0) {
			continue;
		}
		if (i == p[i]) {
			swap(p[i], p[i + 1]);
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 640
//B - Postal Code: 
//Assunto: 
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int a, b, stop = -1, h = 0, n1 = 0, n2 = 0;
    string s;
    bool ans = false;
    cin >> a >> b;
    cin >> s;
    loop(i, 0, s.size()) {
        if(s[i] == '-') {
            stop = i;
            h++;
        }
        if(h == 0 and isdigit(s[i])) n1++;
        if(h > 0 and isdigit(s[i])) n2++;
    }
    if(n1 == a and n2 == b and h == 1) ans = true;
    if(ans) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <map>

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

int main() {
    ll N,K;
    cin >> N >> K;
    vector<pair<ll,ll>> P(N);
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        P[i] = make_pair(b,a);
    }
    sort(P.rbegin(),P.rend());
    set<ll> se;
    ll ans=0;
    priority_queue<pr,vector<pr>,greater<pr>> Q_s;
    priority_queue<pr> Q_w;
    for(int i=0;i<N;i++){
        if(i<K){
            if(!se.count(P[i].second)){
                se.insert(P[i].second);
            }
            else {
                Q_s.push(P[i]);
            }
            ans+=P[i].first;
        }
        else{
            if(!se.count(P[i].second)){
                Q_w.push(P[i]);
            }
        }
    }
    ans+=se.size()*se.size();
    ll preas=ans;
    while(!Q_w.empty() && !Q_s.empty()){
        pr tmp = Q_w.top();Q_w.pop();
        ll v = tmp.second;
        if(se.count(v)) continue;
        else{
            pr tmpp = Q_s.top();
            preas=preas-tmpp.first+tmp.first+2*se.size()+1;
            Q_s.pop();
            se.insert(tmp.second);
            ans = max(ans,preas);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5752
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    int ans = 0;
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    for(int i = 0;i<N-1;i++){
        if(retu.at(i) == retu.at(i+1)){
            retu.at(i+1) = 114514;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if (
        (x - r) >= 0 &&
        (y - r) >= 0 &&
        (x + r) <= w &&
        (y + r) <= h)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    REP(i, N) {
        cin >> L >> R;
        ans += R - L + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3516
//
//  Created by 赵宏祝 .
//

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <iterator>

#define FOR0(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define FOR1(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define FOR(i, l, r) for(int (i) = (l); (i) <= (r); (i)++)
#define lowbit(x) (x)&(-x)
#define MEMSET(x, y) memset((x), (y), sizeof(x))

using namespace std;
//============================
char s[300000];
int T;
//============================



int main(){
	cin >> s;
	int t = strlen(s);
	int tc = 0, ts = 0;
	int ans = 0;
	FOR0(i, t) {
		if (s[i] == 'T') {
			if (ts) {
				ts--;
			}
			else {
				ans++;
			}
		}
		else {
			ts++;
		}
	}
	cout << ans + ts << endl;
    return 0;
}

Measured memory_bytes: 384