akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod


int main(){
    ll H,W,K; cin>>H>>W>>K;
    ll s[2], g[2];
    rep(i,2) {cin>>s[i]; s[i]--;}
    rep(i,2) {cin>>g[i]; g[i]--;}
    mat ans(H,vec(W,-INF));
    vector<vector<bool>> arrived(H,vector<bool>(W,false));
    queue<P> Q;
    const ll MAXN=1000010;
    rep(i,H){
        string S; cin>>S;
        rep(j,W) if(S[j]=='.') ans[i][j]=INF;
    }
    Q.push(mp(0,s[0]*MAXN+s[1]));
    ans[s[0]][s[1]]=0;
    //cout<<"arrived"<<endl;
    while(!Q.empty()){
        ll h=Q.front().second/MAXN, w=Q.front().second%MAXN;
        ll A=Q.front().first;
        Q.pop();
        if(h==g[0] && w==g[1]) break;
        if(!arrived[h][w]){
            arrived[h][w]=true;
            ll hh=h+1;
            while(hh<H){
                if(abs(hh-h)>K) break;
                if(ans[hh][w]<0) break;
                if(ans[hh][w]==A) break;
                if(ans[hh][w]>A+1){
                    ans[hh][w]=A+1;
                    Q.push(mp(A+1,hh*MAXN+w));
                }
                hh++;
            }
            hh=h-1;
            while(hh>=0){
                if(abs(hh-h)>K) break;
                if(ans[hh][w]<0) break;
                if(ans[hh][w]==A) break;
                if(ans[hh][w]>A+1){
                    ans[hh][w]=A+1;
                    Q.push(mp(A+1,hh*MAXN+w));
                }
                hh--;
            }
            ll ww=w+1;
            while(ww<W){
                if(abs(ww-w)>K) break;
                if(ans[h][ww]<0) break;
                if(ans[h][ww]==A) break;
                if(ans[h][ww]>A+1){
                    ans[h][ww]=A+1;
                    Q.push(mp(A+1,h*MAXN+ww));
                }
                ww++;
            }
            ww=w-1;
            while(ww>=0){
                if(abs(ww-w)>K) break;
                if(ans[h][ww]==A) break;
                if(ans[h][ww]<0) break;
                if(ans[h][ww]>A+1){
                    ans[h][ww]=A+1;
                    Q.push(mp(A+1,h*MAXN+ww));
                }
                ww--;
            }
        }
    }
    if(ans[g[0]][g[1]]<INF) cout<<ans[g[0]][g[1]]<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 18772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <list>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int n,k;
    cin >>n>>k;
    
    char s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    
    if(s[k-1]=='A')s[k-1]='a';
    else if(s[k-1]=='B')s[k-1]='b';
    else if(s[k-1]=='C')s[k-1]='c';
    
    for(int i=0;i<n;i++){
        cout <<s[i];
    }
    
   
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll; 
int main(void)
{
	string s;	
	cin >> s;
	int a = s.size();
	int R = 0;
	for (int i = 0; i<(a/2); i++) {
		if (s[i] != s[a - i-1])R++;
	}
	cout << R << endl;



	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

S = input().rstrip()
n = len(S)
l = [0]*2019
d = 10

t = int(S[n-1])
l[t%2019] += 1

l[0] += 1

for i in range(n-2, -1, -1):
    t += int(S[i])*d%2019
    l[t%2019] += 1 
    d *= 10
    d %= 2019

ans = 0

for i in l:
    ans += i*(i-1)//2

print(ans)

Measured memory_bytes: 68320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int m[26][26];

int main(){
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < (int)s.size(); i++) m[s[i] - 'a'][t[i] - 'a'] = 1;
    for (int i = 0; i < 26; i++){
        int cnt1 = 0, cnt2 = 0;
        for (int j = 0; j < 26; j++){
            cnt1 += m[i][j];
            cnt2 += m[j][i];
        }
        if (cnt1 > 1 || cnt2 > 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
N, M = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(M)]

count_dict = {}

gate = set(range(10**5 + 1))

L = 1
R = 10**5

for i in range (M):
    l = LR[i][0]
    r = LR[i][1]

    if l > L:
        L = l
    if r < R:
        R = r

print(len(range(L, R+1)))

Measured memory_bytes: 30916
#include<stdio.h>
int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		if(1<=a&&a<=9&&1<=b&&b<=9)
		printf("%d\n",a*b);
		else
		printf("%d\n",-1);
	}
	return 0;
} 

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    vector<int> query;
    for(int i=0;i<q;++i){
        int k;
        cin >> k;
        query.push_back(k);
    }

    vector<int> cumsum_c(n+1, 0), cumsum_m(n+1, 0);
    vector<pair<int, int>> idx_c;
    vector<pair<char, int>> idx_dc;
    for(int i=0;i<n;++i){
        cumsum_c[i+1] = cumsum_c[i];
        cumsum_m[i+1] = cumsum_m[i];
        if(s[i] == 'D'){
            idx_dc.emplace_back('D', i);
        }else if(s[i] == 'M'){
            cumsum_m[i+1]++;
        }else if(s[i] == 'C'){
            cumsum_c[i+1]++;
            idx_c.emplace_back(i, (int)idx_dc.size());
            idx_dc.emplace_back('C', i);
        }
    }

    for(auto k: query){
        i64 ans = 0, num_c = 0, num_d = 0;
        vector<int> imos(idx_dc.size());
        for(int i=0;i<idx_dc.size();++i){
            if(idx_dc[i].first == 'D'){
                if(i > 0){
                    ans += num_c * (cumsum_m[idx_dc[i].second]-cumsum_m[idx_dc[i-1].second+1]);
                }
                int valid = -1, invalid = (int)idx_c.size();
                while(invalid-valid > 1){
                    int mid = (valid + invalid) / 2;
                    if(idx_c[mid].first < idx_dc[i].second + k)valid = mid;
                    else invalid = mid;
                }
                if(valid < 0)continue;
                i64 c = cumsum_c[idx_c[valid].first+1] - cumsum_c[idx_dc[i].second];
                //cerr << c << endl;
                c = max(c, (i64)0);
                num_c += c;
                num_d++;
                imos[idx_c[valid].second]++;
                //cerr << num_c << endl;
            }else{
                if(i == 0)continue;
                ans += num_c * (cumsum_m[idx_dc[i].second]-cumsum_m[idx_dc[i-1].second+1]);
                num_c -= num_d;
                num_d -= imos[i];
            }
            //cerr << ans << endl;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 29164
#include <stdio.h>

int	main(void)
{
  	int	N;
  	int	d[51];
  	int	num;
  	int	i;
  	int	j;
  	int	sum;
  
  	num = scanf("%d", &N);
  	if (num != 1)
      	return (0);
  
  	for (i=1; i<=N; i++)
    {
      	num = scanf("%d", &d[i]);
      	if (num != 1)
          	return (0);
    }
  
  	sum = 0;
  	for (i=1; i<=N-1; i++)
      	for (j=i+1; j<=N; j++)
        {
          	sum += d[i] * d[j];
        }
  
  	printf("%d", sum);
  	return (0);
}

Measured memory_bytes: 128
n,a=map(int,input().split())
arr=list(map(int,input().split()))
l=n*max(a,max(arr))
dp=[[[0]*(l+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  xi=arr[i-1]
  for j in range(0,i+1):
    for k in range(0,l+1):
      if k<xi:
        dp[i][j][k]=dp[i-1][j][k]
      elif j>=1:
        dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-xi]
ans=0
for i in range(1,n+1):
  ans+=dp[n][i][i*a]
print(ans)

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


bool is_prime(int x){
  if(x<2) return false;
  for(int ii=2; ii*ii<=x; ii++){
    if(x%ii==0) return false;
  }
  return true;
}


int main(){
  int X;
  cin >> X;
  while(!is_prime(X)) X++;
  cout << X << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int solve(int u, int v, int n){
    if (n == 1) return min(u, v);
    set<int> st;
    while (u){
        st.insert(u);
        u = (u + n - 2) / n;
    }
    while (1){
        if (st.count(v)) return v;
        v = (v + n - 2) / n;
    }
}
 
int main() {
    int n, q;
    cin >> n >> q;
    while (q--){
        int u, v;
        cin >> u >> v;
        cout << solve(u, v, n) << endl;
    }
 
 
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <map>
#include <utility>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 998244353,ans = 1;
ll dp[100010][8] = {};
map<pair<ll,ll>,ll> mp,mp1;
set<pair<ll,ll>> s;
ll pow(ll a, ll x){
	ll ret = 1;
	while(x>0){
		if(!(x&1)){
			x /= 2;(a *= a) %= mod;
		}
		x--; (ret *= a) %= mod;
	}
	return ret;
}

bool ch(int i, int j){
	int k,a[3];
	for(k=0;k<3;k++) a[k] = -1;
	if(mp1.find({i,i})!=mp1.end()) a[0] = mp1[{i,i}];
	if(mp1.find({i,i+1})!=mp1.end()) a[1] = mp1[{i,i+1}];
	if(mp1.find({i+1,i})!=mp1.end()) a[2] = mp1[{i+1,i}];
	for(k=0;k<3;k++){
		if(a[k]!= -1 && a[k]!=(j&1)) return false;
		j /= 2;
	}
	return true;
}

int x,y,z;
void f(int i){
	x = -1; y = -1; z = -1;
	if(mp1.find({i+2,i})!=mp1.end()) x = mp1[{i+2,i}];
	if(mp1.find({i,i+2})!=mp1.end()) y = mp1[{i,i+2}];
	if(mp1.find({i+1,i+1})!=mp1.end()) z = mp1[{i+1,i+1}];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll i,j,k,n,m;
	cin >> n >> m;
	for(i=0;i<n-2;i++){
		for(j=0;j<=2;j++){
			s.insert({i,i + j}); s.insert({i + j,i}); 
		}
	}
	for(i=n-2;i<n;i++){
		for(j=n-2;j<n;j++){
			s.insert({i,j});
		}
	}
	for(i=0;i<m;i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		if(!s.count({a,b})) mp[{a,b}] = c;
		else mp1[{a,b}] = c;
	}
	if(n==2){
		ll ans = 0;
		for(i=0;i<(1<<4);i++){
			int x = __builtin_popcount(i);
			if(x&1) continue;
			k = i;
			for(j=0;j<4;j++){
				if(mp1.find({j&1,j/2})!=mp1.end() && mp1[{j&1,j/2}]!=(k&1)) break;
				k /= 2;
				if(j==3) ans++;
			}
		}
		cout << ans << endl;
		return 0;
	}
	ll cnt = (n - 3)*(n - 2)/2;
	for(auto x: mp){
		cnt--;
		int a = x.first.first,b = x.first.second;
		if(mp.find({b,a})!=mp.end()){
			if((mp[{a,b}] + mp[{b,a}])&1){
				ans = 0;
			}
			mp.erase({b,a});
		}
	}
	f(0);
	for(j=0;j<8;j++){
		if(!ch(0,j)) continue;
		int k = __builtin_popcount(j);
		if(z!=-1 && (k + z)&1){
			dp[0][j] = 0;
			continue;
		}
		if(x!=-1 && y!=-1 && (k + x + y)&1) dp[0][j] = 0;
		else if(x==-1 && y==-1) dp[0][j] = 2;
		else dp[0][j] = 1;
	}
	for(i=1;i<n-2;i++){
		f(i);
		for(j=0;j<8;j++){
			if(!ch(i,j)) continue;
			int t = __builtin_popcount(j);
			if(z!=-1 && (t + z)&1){
				dp[i][j] = 0;
				continue;
			}
			if(x!=-1 && y!=-1 && (x + y + t)&1){
				dp[i][j] = 0;
				continue;
			}
			t = j&1;
			for(k=0;k<8;k++){
				int x = __builtin_popcount(k);
				if(!((x + t)&1)) (dp[i][j] += dp[i-1][k]) %= mod;
			}
			if(x==-1 && y==-1) (dp[i][j] *= 2) %= mod;
		}
	}
	ll res = 0;
	for(i=0;i<8;i++){
		int u = __builtin_popcount(i);
		int x = -1,y = -1,z = -1;
		if(mp1.find({n-2,n-1})!=mp1.end()) x = mp1[{n-2,n-1}];
		if(mp1.find({n-1,n-2})!=mp1.end()) y = mp1[{n-1,n-2}];
		if(mp1.find({n-1,n-1})!=mp1.end()) z = mp1[{n-1,n-1}];
		for(j=0;j<8;j++){
			int s = j,b[3];
			for(k=0;k<3;k++){
				b[k] = s&1; s /= 2;
			}
			if(x!=-1 && x!=b[0]) continue;
			if(y!=-1 && y!=b[1]) continue;
			if(z!=-1 && z!=b[2]) continue;
			int v = __builtin_popcount(j);
			if((u+v)&1) continue;
			(res += dp[n-3][i]) %= mod;
		}
	}
	(ans *= res*pow(2,cnt)) %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 42752
#include<stdio.h>
int main() {
    long long int k;
    long long int n;
    long long int a=0;
    long long int b=0;
    long long int c=0;
    long long int max=0;
    long long int p=0;
    long long int q=0;
    scanf("%lld %lld", &k, &n);
    for(long long int i=1;i<=n;i++) {
        a=b;
        scanf("%lld", &b);
        c=b-a;
        if(max<c) max=c;
        if(i==1) p=b;
        if(i==n) q=b;
        
    }
    if(max<p+k-q) max=p+k-q;
    printf("%lld", k-max);
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const ll inf=1ll<<60;

ll dp[200010][3];

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n)rep(j,3) dp[i][j]=-inf;
  ll ans=-inf;
  if(n%2==0){
    dp[0][0]=a[0];
    dp[1][1]=a[1];
    rep(i,n)rep(j,2){
      if(i-2>=0) chmax(dp[i][j],a[i]+dp[i-2][j]);
      if(i-3>=0&&j-1>=0) chmax(dp[i][j],a[i]+dp[i-3][j-1]);
    }
    chmax(ans,dp[n-2][0]);
    chmax(ans,dp[n-1][1]);
  }
  else{
    dp[0][0]=a[0];
    dp[1][1]=a[1];
    dp[2][2]=a[2];
    rep(i,n)rep(j,3){
      if(i-2>=0) chmax(dp[i][j],a[i]+dp[i-2][j]);
      if(i-3>=0&&j-1>=0) chmax(dp[i][j],a[i]+dp[i-3][j-1]);
      if(i-4>=0&&j-2>=0) chmax(dp[i][j],a[i]+dp[i-4][j-2]);
    }
    chmax(ans,dp[n-3][0]);
    chmax(ans,dp[n-2][1]);
    chmax(ans,dp[n-1][2]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 8732
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		double a = input.nextDouble();
		double b = input.nextDouble();
		double c = input.nextDouble();
		double rad = Math.toRadians(c);
		System.out.println( a*b*Math.sin(rad)/2 );
		System.out.println( a + b + Math.sqrt(a*a + b*b -2*a*b*Math.cos(rad)) );
		System.out.println( b*Math.sin(rad) );
		input.close();
	}
}

Measured memory_bytes: 28148
// https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_b

#include <bits/stdc++.h>

using namespace std;

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

    long n, a, b;
    string s;

    cin >> n >> a >> b >> s;

    a += b;

    bool cond;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'a')
        {
            cond = a > 0;
            a--;
        }
        if (s[i] == 'b')
        {
            cond = (a > 0) & (b > 0);
            if (cond)
            {
                a--;
                b--;
            }
        }
        if (s[i] == 'c')
        {
            cond = false;
        }
        cout << (cond ? "Yes" : "No") << endl;
    }
    return 0;
}


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

int main()
{
        vector<int> x;
        vector<int> y;

        int a, b;
        while (1) {
                cin >> a >> b;
                if (a == 0 && b == 0) {
                        break;
                }
                x.push_back(a);
                y.push_back(b);
        }

        int n = x.size();
        for (int i = 0; i < n; ++i) {
                if (x[i] > y[i]) {
                        cout << y[i] << " " << x[i] << endl;
                }
                else {
                        cout << x[i] << " " << y[i] << endl;
                }
        }


}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<int,Pil>Piil;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	ll n,d;
	cin>>n>>d;
	ll ans=0;
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=d)ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3648
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var M = one[0];
  var D = one[1];
  var output = 0;
  for(var i = 1; i <= M; i++){
    for(var j = 22; j <= D; j++){
      var L = Math.floor(j / 10);
      var R = j % 10;
      if(L >= 2 && R >= 2 && L * R == i){
        output++;
      }
    }
  }
  myout(output);
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;

int n, res;
char s[N];

int main()
{
    scanf("%d%s", &n, s);
    for(int i = 0; i < n; i++)
    {
        int j = i;
        while(j < n && s[j + 1] == s[j]) j++;
        res++;
        i = j;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<ll> A;
    vector<vector<int>> treeone;

    void input() {
        cin >> N;
        A.resize(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }
        treeone.resize(N);
        for (int i = 0; i < N - 1; ++i) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            treeone[a].push_back(b);
            treeone[b].push_back(a);
        }
    }

    bool flag = true;

    ll dfs(int n, int p) {
        if (treeone[n].size() == 1 && p != -1) return A[n];
//        ll par = 2 * A[n];
//        if(treeone[n].size() == 1) par = A[n];

        ll chi = 0;
        ll max_chi = 0;
        for (auto e : treeone[n]) {
            if (e != p) {
                ll tmp = dfs(e, n);
                chi += tmp;
                chmax(max_chi, tmp);
            }
        }
        if (A[n] > chi) flag = false;
        ll ret = 2 * A[n] - chi;
        if (ret < 0) flag = false;
        if (ret < 2 * max_chi - chi) flag = false;

        return ret;
    }

    void solve() {
        input();
        int leaf;
        for (int i = 0; i < N; ++i) {
            if (treeone[i].size() == 1) {
                leaf = i;
                break;
            }
        }
        ll val = dfs(leaf, -1);
        if (val == A[leaf] && flag) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 14336
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
	int a, b,ans=0;
	rep(i, 2) {
		cin >> a >> b;
		ans += min(a, b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(len(a)-1):
    #print(' '.join([str(i) for i in a]))

    l = i
    j = l + 1


    while l >= 0:
        #print(l, j)
        #print(*a)
        # val1 = a[i]
        # val2 = a[j]

        #if val2 < val1:
        if a[j] < a[l]:
            # switch
            temp = a[l]
            a[l] = a[j]
            a[j] = temp
            l -= 1
            j -= 1
            #print(*a)
        else:
            break
    print(*a)


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
typedef unsigned long long ull;
const ull BASE = 1e9 + 7;
ull mul[4003];

string A, B;
int n, m;

bool check(int k) {
	if (k == 0) return true;
	
	vector< int > c(26, 0);
	for_(i,0,k) c[A[i] - 'a']++;
	
	ull h = 0;
	for_(i,0,26) h = h + c[i] * mul[i];
	
	unordered_set< ull > hash_set;
	hash_set.insert(h);
	
	auto hash_update = [&](int i, int add) {
		h = h - c[i] * mul[i];
		c[i] += add;
		h = h + c[i] * mul[i];
	};
	
	for_(i,k,n) {
		hash_update(A[i-k]-'a', -1);
		hash_update(A[i]-'a', 1);
		hash_set.insert(h);
	}
	
	c.assign(26, 0);
	for_(i,0,k) c[B[i] - 'a']++;
	
	h = 0;
	for_(i,0,26) h = h + c[i] * mul[i];
	
	if (hash_set.count(h)) return true;
	
	for_(i,k,m) {
		hash_update(B[i-k]-'a', -1);
		hash_update(B[i]-'a', 1);
		if (hash_set.count(h)) return true;
	}
	
	return false;
}

int main() {
	cin >> A;
	cin >> B;
	n = A.size();
	m = B.size();
	
	mul[0] = 1;
	for_(i,1,4003) mul[i] = mul[i-1] * BASE;
	
	for_rev(i,min(n,m),0) {
		if (check(i)) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 3340
n, a, b = map(int, input().split())
#aとbの合計値がnを割り切れるだけの個数 X aの個数分
ans = n // (a + b) * a
#aとbの合計値でnが余ってしまった時の個数
rem = n % (a + b)
#aだけ入れれた場合か、bも混ざっている場合か、どちらかをansに追加
ans += min(rem, a)
print(ans)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

template <typename F>
inline constexpr decltype(auto) fix(F&& f) noexcept {
    return [=](auto g) {
        return [=](auto&&... args) {
            return f(g(g), std::forward<decltype(args)>(args)...);
        };
    }([=](auto g) {
        return [=](auto&&... args) {
            return f(g(g), std::forward<decltype(args)>(args)...);
        };
    });
}

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int K;
    cin >> K;
    set<ll> st;

    auto dfs = [&](auto&& dfs, ll x) -> void {
        if (st.find(x) != st.end()) {
            return;
        }
        st.insert(x);

        int nd = 0;
        ll x_tmp = x;
        while (x_tmp > 0) {
            ++nd;
            x_tmp /= 10;
        }
        if (nd >= 11) return;

        int l = x % 10;
        if (l == 9) {
            dfs(10 * x + l - 1);
            dfs(10 * x + l);
        }
        else if (l == 0) {
            dfs(10 * x + l);
            dfs(10 * x + l + 1);
        }
        else {
            dfs(10 * x + l - 1);
            dfs(10 * x + l);
            dfs(10 * x + l + 1);
        }
    };

    for (int i = 1; i <= 9; i++) {
        fix(dfs)(i);
    }

    cout << *next(st.begin(), K - 1) << endl;

    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++) {
        cin >> red[i];
    }

    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };

    for (string t: blue) {
        ans = max(ans, calc(t));
    }

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, k, b[MX], a[MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> k;
	forn (i, n) cin >> a[i];	

	while (k--) {
		int f = 0;
		forn (i, n) f |= a[i] < n;
		if (!f) break;

		memset(b, 0, sizeof(b));

		forn (i, n) {
			b[max(0, i - a[i])]++;
			b[min(MX - 1, i + a[i] + 1)]--; 
		}

		forn (i, n) {
			if (i) b[i] += b[i - 1];
			a[i] = b[i];
		}
	}

	forn (i, n) cout << a[i] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 5188
import java.util.Scanner;

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

        r = sc.nextInt();
        D = sc.nextInt();
        x = sc.nextInt();

        for(int i = 0;i < 10; i++) {
            x = r*x - D;
            System.out.println(x);
        }
    }
}

Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>
#include <iomanip>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

#define REP(i,n) for(int i=0; i<n; ++i)

typedef unsigned long long u64;
typedef long long i64;

int n, m;
int a[100005];
u64 b[100005];

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

        cin >> n >> m;
        REP(i, m)
                cin >> a[i];

        int idx = 0;
        b[0] = 1;
        b[1] = 1;
        if (a[0] == 1) {
                b[1] = 0;
                idx++;
        }
        REP(i,n) {
                if (i+2 == a[idx]) {
                        idx++;
                        continue;
                }
                b[i+2] = (b[i+1] + b[i])%1000000007UL;
        }

        cout << b[n] << endl;


        return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2) % MOD;
  }

  int mod_pow(int n, int p){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

//因数分解
map<int,int> prime_factor(int n){
  map<int,int> mp; //{約数,個数}
  for(int i = 2; i*i <= n; i++){
    while(n%i == 0){
      mp[i]++;
      n /= i;
    }
  }
  if(n != 1) mp[n] = 1; //n=素数
  return mp;
}

const int MOD = 1e9 + 7;

signed main(){

  int n, m; cin >> n >> m;

  auto dp = prime_factor(m);
  int ans = 1;
  comb.init(1e6);
  for(auto p : dp){
    ans = ans * comb.nCr(p.second + n-1, p.second) % MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8064
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int ans = 0;

  int stack = 0;
  int before = (int)1e5;
  REP(i, n) {
    int h;
    cin >> h;
    if(i != 0 && before >= h) {
      stack += 1;
      ans = max(stack, ans);
    } else {
      stack = 0;
    }
    before = h;
  }

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


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args){
		//?§?????????§???????????\???
		Scanner scan = new Scanner(System.in);
		//?§???????
		int s = scan.nextInt();
		int[] time;
		time = new int [3];
		time = timeSplit(s);
		System.out.println(time[0] + ":" + time[1] + ":" + time[2]);
	}
	//?????°?§?????????§?????????????§??????????return
	public static int[] timeSplit(int x){
		//?????????????§????????´???????????????????
		int[] time;
		time = new int[3];
		//?¨???????????´?
		//?§?
		time[2] = x % 60;
		x /= 60;
		//???
		time[1] = x % 60;
		x /= 60;
		//???
		time[0] = x;
		//????????????
		return time;
	}
}

Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(0); cin.tie(0);
void input(){
 #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
 #endif	
}
/*****************************************************************************/


 int main(){ 
	//input();
	speed	

	int q;	cin>>q;
	double sum=0;
	for (int i=1;i<=q;i++){
		if (i%2==1)
			sum++;
	}
	
	double ans=sum/q*1.0;
	cout<<ans;

 return 0;
}

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

int main() {
  int N;
  cin >> N;  
  string S;
  map<string, int> mp;
  for (int i=0; i<N; i++) {
    cin >> S;
    if(mp.find(S) != mp.end()) {
      mp[S] += 1;
    } else {
      mp[S] = 0;
    }
  }
  
  int counter = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
//    std::cout << "key = " << itr->first << ", val = " << itr->second << "\n";    // 値を表示
    if (itr->second > counter) counter = itr->second;
  }

  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
//    std::cout << "key = " << itr->first << ", val = " << itr->second << "\n";    // 値を表示
    if (itr->second == counter) cout << itr->first << endl;
  }
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    map<int,int> mp;
    REP(_,N) {
        int d; cin >> d;
        mp[d]++;
    }
    int M; cin >> M;
    bool ok = true;
    REP(_,M) {
        int T; cin >> T;
        mp[T]--;
        if (mp[T] < 0) ok = false;
    }

    CFYN(ok)

    return 0;
}

Measured memory_bytes: 12984
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++)
		{
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			System.out.println((a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b) ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e9+7;


int main() {
    
    int n, k;
    scanf("%d%d",&n,&k);
    
    vector<int> stones(n);
    vector<bool> dp(k+1, false);
    
    // dp[i] - win = ( false ? true) if in your turn there are i stones
    
    int small = 0;
    
    for(int& i : stones) {
        scanf("%d", &i);
        small = min(small, i);
    }
    
    for(int i = 0; i < small; ++i) {
        dp[i] = false;
    }
    
    for(int left = small; left <= k; ++left) {
        for(int x : stones) {
            if(left-x >= 0) {
                if(dp[left-x] == false) {
                    dp[left] = true;
                    break;
                }
            }
        }
    }
    
    (dp[k] == true ? printf("First\n") : printf("Second\n"));
    
    return 0;
}




Measured memory_bytes: 256
# ABC107 C - Candles
N,K = map(int,input().split())
C = list(map(int,input().split()))

l=0
r=0
ans=10**9

for i in range(N-K+1):
    l = C[i]
    r = C[i+K-1]
    t = min(abs(l)+abs(r-l),abs(r)+abs(l-r))
    ans = min(ans,t)
print(ans)

Measured memory_bytes: 14384
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int n;
int h[100001];
ll dp[100001];

int main() {

	cin>>n;

	rep(i,n){
		cin>>h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2; i<n; i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}

	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define mod 1000000007

ll dp[105][100005];

int main()
{
      ll n, k;
      cin >> n >> k;
      ll arr[n];
      for(int i = 0 ; i < n ; i ++)
        cin >> arr[i];

      dp[n][0] = 1;
      for(int i = 1 ; i <= k ; i ++)
        dp[n][i] += dp[n][i - 1];

      for(int i = n - 1; i >= 0; i --)
      {
        for(int left = 0 ; left <= k ; left ++)
        {
          int u = left - arr[i] - 1;
          dp[i][left] =( dp[i + 1][left] % mod - (u >= 0? dp[i + 1][u] : 0) % mod + mod) % mod;


          if(left)
            dp[i][left] += dp[i][left - 1];
            dp[i][left] %= mod;
        }
      }

      cout << (dp[0][k] - dp[0][k - 1] + mod ) % mod;
}


Measured memory_bytes: 80128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
typedef pair<int, int>P;
typedef pair<P, int> PP;
#define int long long

signed main() {
	int n;
	cin >> n;
	string s;
	cout << 0 << endl;
	cin >> s;
	if (s == "Vacant")return 0;
	int rs = 0, re = n-1;
	for (int i = 0; i < 19; i++) {
		int a = (rs + re+1) / 2;
		cout << a<<endl;
		string rsp;
		cin >> rsp;
		if (rsp == "Vacant")return 0;
		if (a & 1) {
			if (rsp != s) {
				rs = a ;
			}
			else re = a ;

		}
		else {
			if (rsp == s) {
				rs = a;
			}
			else re = a;
		}
	}
}

Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    long long tk = K + 1;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<int> bit(40, 0);
    long long ans = 0;
    vector<int> bi(40, 0);
    for(int i = 0; i < N; i++){
        int c = 0;
        long long a = A[i];
        while(a > 0){
            if(a % 2 == 1) bi[c]++;
            c++;
            a >>= 1;
        }
    }
    K++;
    int cnt = 0;
    while(K > 0){
        if(K % 2 == 1) bit[cnt]++;
        cnt++;
        K >>= 1;
    }
    for(int i = 0; i < 40; i++){
        if(bit[i] == 1){
            long long t = tk & (~(1LL << i));
            for(int j = 0; j < i; j++){
                if(bi[j] > N - bi[j]) t &= (~(1LL << j));
                else t |= (1LL << j);
            }
            long long res = 0;
            for(int j = 0; j < N; j++) res += A[j]^t;
            ans = max(ans, res);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
fun main() {
    var ac = 0
    var wa = 0
    var tle = 0
    var re = 0
    val n = readLine()!!.toInt()
        for(i in 1..n){
            val s = readLine()!!
            if(s == "AC"){
                ac++
            }
            else if(s == "WA"){
                wa++
            }
            else if(s == "TLE"){
                tle++
            }
            else if(s == "RE"){
                re++
            }
        }
        println("AC x ${ac}")
        println("WA x  ${wa}")
        println("TLE x ${tle}")
        println("RE x ${re}")
}

Measured memory_bytes: 57528
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
map<string,int>M;
char in[20];
int main(){
	int a;scanf("%d",&a);
	int t=0;
	for(int i=0;i<a;i++){
		scanf("%s",in);
		string tmp=in;
		M[tmp]++;
		t=max(t,M[tmp]);
	}
	for(map<string,int>::iterator it=M.begin();it!=M.end();it++){
		if((it->second)==t)printf("%s\n",(it->first).c_str());
	}
}

Measured memory_bytes: 23808
/*
ID: Barry Wang
LANG: C++11
TASK: 
*/
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
#define X first
#define Y second
#define Chtolly return 0
/*---define types---*/
typedef long long ll;
typedef list<int> li;
typedef queue<int> qi;
typedef deque<int> dqi;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef unsigned int uint;
/*---define variables---*/
const int inf=(1<<29);
int n;
int x[100005],y[100005],v[100005];
int val[100005];
int cnt[100005];
ll ans;
uint st;
bool zero[1<<16];
ll dp[1<<16];
/*---define function---*/

/*---main code---*/
int main(){
	cin>>n;
	for(int i=1;i<n;++i){
		cin>>x[i]>>y[i]>>v[i];
		val[x[i]]^=v[i];val[y[i]]^=v[i];
	}
	for(int i=1;i<=n;++i){
		cnt[val[i]]++;
	}
	for(int i=1;i<=15;++i){
		ans+=cnt[i]/2;
		if(cnt[i]%2){
			st|=(1<<i);
		}
	}
	for(int mask=0;mask<(1<<16);++mask){
		int V=0;
		for(int i=0;i<16;++i){
			if(mask&(1<<i)){
				V^=i;
			}
		}
		if(V==0){
			zero[mask]=1;
		}
	}
	for(int mask=0;mask<(1<<16);++mask){
		if(mask&1){
			continue;
		}
		int M=mask;
		while(M>0){
			if(zero[M]){
				dp[mask]=max(dp[mask],dp[mask^M]+1);
			}
			M=(M-1)&mask;
		}
	}
	cout<<ans+__builtin_popcount(st)-dp[st]<<'\n';
	return 0;
}


Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.TreeMap;

public class Main {

  
    public static void main(String[] args)  {

    	try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            TreeMap<String,ArrayList<Integer>>index = new TreeMap<String,ArrayList<Integer>>();
            while((line=br.readLine())!=null){if(line.isEmpty())break;
                    String[] spl = line.split(" ");
	            String moji = spl[0]; int kazu = Integer.parseInt(spl[1]);
                    if(index.containsKey(moji)){
                        index.get(moji).add(kazu);
                        Collections.sort(index.get(moji));
                    }else{
                        ArrayList <Integer> al1 = new ArrayList<Integer>();
                        al1.add(kazu);
                        index.put(moji,al1);
                    }
                    
                    
                    
                    
                    
            }//End WHILE
            for(String key : index.keySet()){
                System.out.println(key);
                ArrayList al2 = index.get(key);
                for(int i=0; i<al2.size();i++){
                    System.out.print(al2.get(i));
                    if(i<al2.size()-1){System.out.print(" ");}
                    else{System.out.println("");}
                }
            }

        }catch(Exception e){e.printStackTrace();}

    }


}

Measured memory_bytes: 17064
def is_valid(ans_types: list, ans_val: int) -> bool:
    """ans_types(1-indexed)を選んだときに、
    答えがans_valになるかどうかを確かめる。"""
    res = 0

    tmp_last_days = {}
    for c_type in range(C_TYPES):
        tmp_last_days[c_type] = 0
   
    for day in range(1, DAYS + 1):
        c_type = ans_types[day - 1] - 1
        res += s[day][c_type]

        tmp_last_days[c_type] = day
        for c_type in range(C_TYPES):
            res -= c[c_type] * (day - tmp_last_days[c_type])

    return res == ans_val

def search_max_point(day: int, last_days: dict):
    """day-1日目までに選んだコンテストが確定している状態で
    day日目にどのコンテストを選べば満足度を最適化できるか貪欲に探索する。
    dayは1-indexedに注意。
    返値として、選ぶコンテスト(0-indexed)、そのときに得られる満足度を返す。
    """
    max_val = -INF
    max_type = -1
    for c_type in range(C_TYPES):
        tmp = s[day][c_type]
        for c_type2 in range(C_TYPES):
            if c_type2 == c_type:
                continue
            tmp -= c[c_type2] * (day - last_days[c_type2])
        if max_val < tmp:
            max_val = tmp
            max_type = c_type
    return max_type, max_val


d = int(input())  # 365
c = list(map(int, input().split()))
s = [[0 for i in range(26)]] + [list(map(int, input().split())) for i in range(d)]
DAYS = d
C_TYPES = 26
INF = 10 ** 18


# 最後にコンテストを行った日
last_days = {}
for c_type in range(C_TYPES):
    last_days[c_type] = 0

ans_val = 0
ans_types = []
for day in range(1, DAYS + 1):
    c_type, val = search_max_point(day, last_days)
    ans_types.append(c_type + 1)
    ans_val += val
    last_days[c_type] = day


if not is_valid(ans_types, ans_val):
    print(re)
    exit()
    
for t in ans_types:
    print(t)

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

using namespace std;

using intL = long long;

#define MOD_NUMBER 1000000007

template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  int n, a;
  cin >> n >> a;
  cout << n*n-a << endl;
  return 0;
}


Measured memory_bytes: 256