akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair <int,int> P;
string mp[501];
int m,n,used[30];
vector <P>  a[30];

int saiki(int);

bool check_x(int y,int x1,int x2){
  for(int i=x1+1;i<x2;i++)
    if(mp[y][i]!='.'&&!saiki(mp[y][i]-'A'))return 0;
  return 1;
}

bool check_y(int y1,int y2,int x){
  for(int i=y1+1;i<y2;i++)
    if(mp[i][x]!='.'&&!saiki(mp[i][x]-'A')) return 0;
  return 1;
}


int saiki(int ch){  
  int x1=a[ch][0].x,x2=a[ch][1].x;
  int y1=a[ch][0].y,y2=a[ch][1].y;
  int res=0;
  if(used[ch])return 0;
  used[ch]=1;
  
  if(x1==x2&&y2-y1!=1) res=check_y(y1,y2,x1);
  if(y1==y2&&x2-x1!=1) res=check_x(y1,x1,x2);

  if(x1!=x2&&y1!=y2) {
    if(x1<x2){
      res=check_x(y1,x1,x2+1)&check_y(y1,y2,x2);
      res|=check_y(y1,y2+1,x1)&check_x(y2,x1,x2);
    }
    else{
      swap(x1,x2);
      res=check_x(y1,x1-1,x2)&check_y(y1,y2,x1);
      res |=check_y(y1,y2,x2)&check_x(y2,x1,x2+1);
      swap(x1,x2);
    }
  }
    

  if(res) mp[y1][x1]=mp[y2][x2]='.',a[ch].clear();
  used[ch]=0;
  return res;
}

int main(){

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

  int ans=0;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      if(mp[i][j]!='.')a[mp[i][j]-'A'].push_back(P(j,i)),ans++;
  
  
  for(int i=0;i<30;i++)if(a[i].size()) saiki(i);
  
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++) if(mp[i][j]!='.') ans--;

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

Measured memory_bytes: 1484
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    while (1) {
        int a, b; cin >> a >> b;
        if (a + b == 0) {
            break;
        }
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                cout << '#';
            }
            cout << '\n';
        }
        cout << '\n';
    }
}



Measured memory_bytes: 3080
N = int(input())
result = 0

if N < 10:
  result = N
elif 10 <= N and N < 100:
  result = 9
elif 100 <= N and N < 1000:
  result = 9 + (N - 100 + 1)
elif 1000 <= N and N < 10000:
  result = 9 + 900
elif 10000 <= N and N < 100000:
  result = 9 + 900 + (N - 10000 + 1)
elif N == 100000:
  result = 9 + 900 + 90000
  
print(result)

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

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

  map<int, int> MA;
  multiset<int> MS;
  for (int i = 0; i < W; i++) {
    MA[i] = i;
    MS.insert(0);
  }

  for (int i = 0; i < H; i++) {
    int A, B;
    cin >> A >> B, A--;
    auto it = MA.lower_bound(A);
    int tmp = -1;
    while (it != MA.end() && it -> first <= B) {
      tmp = max(tmp, it -> second);
      MS.erase(MS.find(it -> first - it -> second));
      MA.erase(it++);
    }
    if (tmp != -1 && B < W) {
      MA[B] = tmp;
      MS.insert(B - tmp);
    }
    if (MS.empty()) cout << -1 << "\n";
    else cout << *MS.begin() + i + 1 << "\n";
  }
}

Measured memory_bytes: 22336
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

ll vc = 1000000007, h, w, n, node[1000010], a, b, cnt, z, ans[11], i, j, t;

int main() {
    cin >> h >> w >> n;
    z = (h-2)*(w-2);

    while(n--) {
        cin >> a >> b;

        for(i = -2; i <= 0; i++) {
            for(j = -2; j <= 0; j++) {
                if(1 <= a+i && a+i <= h-2 && 1 <= b+j && b+j <= w-2) {
                    node[cnt++] = vc*(a+i) + (b+j);
                }
            }
        }
    }

    sort(node, node+cnt);

    for(i = 0, t = 1; i < cnt; i++) {
        if(node[i] == node[i+1]) {
            t++;
        }
        else {
            ans[t]++;
            z--;
            t = 1;
        }
    }

    cout << z << "\n";
    for(int i = 1; i < 10; i++) {
        cout << ans[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	bool ans=false;
	for(int i=1;i<s.length();i++){
		if(s[i-1]=='A' && s[i] == 'C')ans=true;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

	


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  int N, K;
  cin >> N >> K;
  int C[N], D[N-K+1];
  rep(i, N){
    cin >> C[i];
  }
  sort(C, C+N);
  rep(i, N-K+1){
    D[i] = C[i+K-1] - C[i];
  }
  sort(D, D+N-K+1);
  cout << D[0] << endl;
}

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

int main()
{
   long long int n,k,q,r;
    cin>>n>>k;
    q=n/k;
    r=n%k;
    if(r==0 && q!=0){
        cout<<"0\n";
    }
    else if(q==0){
        cout<<min(n,(k-n))<<endl;
    }
    else {
        cout<<min(r,(k-r))<<endl;
    }

}





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

int prime(int x);

int main(void)
{
  int num[30], c[30], data[30];
  int index = 0;
  int i;

  while(scanf("%d", &num[index]) != EOF){
       if((1 <= num[index]) && (num[index] <= 999999))
	 index++;
       if(index == 30) break;
  }

  for(i = 0; i < index; i++){
    c[i] = prime(num[i]);
    printf("%d\n", c[i]);
  }
  return 0;
}

int prime(int x){
  if(x < 2) return 0;
   if(x == 2) return 1;

  int count = 0;
  int i,j,n;
  int flg[x];

  for(i = 1; i <= x; i++)
    flg[i] = 1;
  
    for(j = 2; j <= x; j++){
      if(flg[j] == 1) count++;
      for(n = j*2; n <= x; n+=j)
	flg[n] = 0;
    }
  return count;
}

Measured memory_bytes: 4500
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){

  
 string S, ans;

 cin >> S ;

ans = "Yes";

for(int i = 0; i < S.size() ; i++){

  if(i%2 == 0){

    if(S[i] != 'L'){
      continue;
    }else{
      ans = "No";
    }

  }

  if(i%2 != 0){

    if(S[i] != 'R'){
      continue;
    }else{
      ans = "No";
    }

  }

}

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


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

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

    sort(A.begin(), A.end(), greater<int>());
    vector<int> longest;
    for (int i = 1; i < N; i++) {
        if (A[i] == A[i - 1]) {
            longest.push_back(A[i]);
            i++;
        }
        if (longest.size() == 2) {
            cout << (long long)longest[0] * longest[1] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 640
N, X = map(int, input().split())

num_list = list(map(int, input().split()))

lenge = 0
counter = 0
ans_list = [0]
tmp = 0
for i in range(len(num_list)):
    tmp += num_list[i]
    ans_list.append(tmp)


for s in range(len(ans_list)):
    if ans_list[s] <= X:
        counter += 1
    
    else:
        break

print(counter)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__

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

    vector<vector<char>> G(100, vector<char>(100));
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (j <= 49) {
                G[i][j] = '.';
            } else {
                G[i][j] = '#';
            }
        }
    }

    // A-1個塗る
    int cnt = 0;
    bool finish = false;
    for (int i = 0; i < 100; i += 2) {
        for (int j = 51; j < 100; j += 2) {
            if (cnt >= A - 1) {
                finish = true;
                break;
            };
            G[i][j] = '.';
            cnt++;
        }
        if (finish) break;
    }

    // B-1個塗る
    cnt = 0;
    finish = false;
    for (int i = 0; i < 100; i += 2) {
        for (int j = 0; j < 50; j += 2) {
            if (cnt >= B - 1) {
                finish = true;
                break;
            };
            G[i][j] = '#';
            cnt++;
        }
        if (finish) break;
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100) {
        rep(j, 100) {
            cout << G[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

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

  LL s,c;
  cin >> s >> c;
  if(s*2>c){
    cout << c / 2 << endl;
  }
  else
  {
    LL a = s * 2 + c;
    cout << a / 4 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n,ans;

int a,b;

int main(){
	cin >> a >> b;
	if(a==b)cout<<"Draw"<<endl;
	else if(a==1)cout<<"Alice"<<endl;
	else if(b==1)cout<<"Bob"<<endl;
	else if(a>b)cout<<"Alice"<<endl;
	else if(a<b)cout<<"Bob"<<endl;
}

Measured memory_bytes: 384
#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 long double ld;
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 int inf=1<<30;

int main(){
  int n,a,b,c; cin >> n >> a >> b >> c;
  vector<char> ans(n);
  map<char,int> mp;
  mp['A']=a; mp['B']=b; mp['C']=c;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  rep(i,n){
    if(mp[s[i][0]]==0&&mp[s[i][1]]==0) {cout << "No" << endl; return 0;}
    else if(mp[s[i][0]]>mp[s[i][1]]) {mp[s[i][0]]--; mp[s[i][1]]++; ans[i]=s[i][1];}
    else if(mp[s[i][0]]<mp[s[i][1]]) {mp[s[i][0]]++; mp[s[i][1]]--; ans[i]=s[i][0];}
    else{
      if(i+1<n&&(s[i][0]==s[i+1][0]||s[i][0]==s[i+1][1])) {mp[s[i][0]]++; mp[s[i][1]]--; ans[i]=s[i][0];}
      else {mp[s[i][1]]++; mp[s[i][0]]--; ans[i]=s[i][1];}
    }
  }
  cout << "Yes" << endl;
  rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 6428
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int h, w;
	cin >> h >> w;
	vector<vector < int >> a(h, vector<int>(w)), b(h, vector<int>(w)), c(h, vector<int>(w)), d(h, vector<int>(w));
	vector<string>x(h);
	for (int i = 0; i < h; i++)
		cin >> x[i];

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			if (x[i][j] == '.') {
				if (i < h - 1)b[i + 1][j] += b[i ][j] + 1;
				if (j < w - 1)a[i][j+1] += a[i ][j] + 1;
			}
			else {
				if (i < h - 1)b[i + 1][j] = 0;
				if (j < w - 1)a[i ][j+1] = 0;
			}
		}

	for (int i = h-1; i >=0 ; i--)
		for (int j = w-1; j >=0; j--) {
			if (x[i][j] == '.') {
				if (i )d[i -1][j] += d[i ][j] + 1;
				if (j )c[i ][j-1] += c[i ][j] + 1;
			}
			else {
				if (i )d[i - 1][j] = 0;
				if (j )c[i ][j-1] = 0;
			}
		}


	int r = 0;
	for(int i=0;i<h;i++)
		for (int j = 0; j < w; j++) {
			if (x[i][j] == '.')r = max(r, a[i][j] + b[i][j] + c[i][j] + d[i][j] + 1);
		}

	cout << r << endl;

	return 0;

}

Measured memory_bytes: 67200
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n;
	std::cin >> n;
	std::vector<std::pair<int,int> > work;
	rep(i,n) {
		int a,b;
		std::cin >> a >> b;
		work.emplace_back(b,a);
	}
	std::sort(all(work));
	int sum = 0;
	for(auto i:work) {
		sum+=i.second;
		if(sum>i.first) {
			print("No");
			return 0;
		}
	}
	print("Yes");
  return 0;
}


Measured memory_bytes: 6512
#include<iostream>
using namespace std;
int main(){
    int N;cin >> N;int max=1;int a[N];int count[100000+9]={};
    for (int i=0;i<N;++i){cin >> a[i];}
    for (int i=0;i<N;++i){count[a[i]]++;}
    for (int i=0;i<N;++i){if(count[i]+count[i+1]+count[i+2]>max)max=count[i]+count[i+1]+count[i+2];}               
    cout << max;
}

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

string s;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> s;
	
	cout << s;
	if(s.back() == 's') cout << "es";
	else cout << "s";
}

Measured memory_bytes: 3656
//package AtCoder.ABC157;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        int n = in.NI();
        if (n%2==0) out.println(n/2);
        else out.println(n/2+1);
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void a()
{
   int X, t;
    cin >> X >> t;
    if(X <= t)
    {
        cout << 0 << endl;
    }else{

        cout << X - t << endl;
    }
}

void b()
{
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if ((i % 2) == 0)
        {
            cout << s[i];
        }
    }
    cout << endl;
}

void c()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> v(100000, 0);
    for(auto e : a)
    {
        v[e]++;
    }
    int resut = v[0] + v[1];
    for(int i = 1; i < 100000 - 1; i++)
    {
        int temp = v[i - 1] + v[i] + v[i + 1];
        if (resut < temp) resut = temp;
    }
    cout << resut << endl;


}

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


Measured memory_bytes: 1024
a, b, c = map(int, input().split())

x = sorted([a, b, c])

yes = (
    (x[0] == x[1] and x[0] != x[2])
    or (x[0] == x[2] and x[0] != x[1])
    or (x[1] == x[2] and x[0] != x[1])
)

if yes:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
// Name: Kanisht Agarwal Copyright Think before u copy //
//Connect with me at LinkedIn

#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1)
#define nui 100
#define INF 100000000000

#define F(i,a,n) for(ll i=a;i<n;i++)
#define B(i,a,n) for(ll i=n-1;i>=a;i--)
#define tc int t;cin>>t;while(t--)
#define tcf int t;cin>>t;for(int w=1;w<=t;w++)



using namespace std;


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}

ll cal(int n)
{
    ll ct = 0;
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            if ((n / i) != i)
            {
                ct += 2;
            }
            else
            {
                ct++;
            }
        }
    }
    return ct;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //Problem A:

  	//Complexity : O(nlog n) Sieve
  
    int n;
    cin >> n;
    vector<ll>v(n + 1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= n; j += i)
        {
            v[j]++;
        }
    }
    ll ans = 0;
    F(i, 1, n + 1)
    {
        ans += i * v[i];
    }
    cout << ans << "\n";

    return 0;


}







Measured memory_bytes: 81300
N = int(input())
S = [input() for _ in range(N)]

dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = 1
    
  else:
    dic[S[i]] += 1
    
maxim = max(dic.values())
ans = []

for keys in dic.keys():
  if dic[keys] == maxim:
    ans.append(keys)
    
ans.sort()

for i in range(len(ans)):
  print(ans[i])


Measured memory_bytes: 38340
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll n;
    cin >> n;
    
    string S;
    cin >> S;

    vector<int> RGB[3];
    rep(i, n) {
        if (S[i] == 'R') {
            RGB[0].push_back(i);
        }
        if (S[i] == 'G') {
            RGB[1].push_back(i);
        }
        if (S[i] == 'B') {
            RGB[2].push_back(i);
        }
    }

    ll res = 0;
    rep (ir, RGB[0].size()) {
        ll r = RGB[0][ir];
        rep (ig, RGB[1].size()) {
            ll g = RGB[1][ig];
            ll a = min(g, r);
            ll b = max(g, r);
            vector<ll> invalid = {
                b + (b - a),
                a - (b - a),
            };
            ll mid = (a + b) / 2;
            if (b - mid == mid - a) {
                invalid.push_back(mid);
            }

            ll nB = RGB[2].size();
            for (auto ng: invalid) {
                auto it = lower_bound(all(RGB[2]), ng);
                if (it != RGB[2].end() && *it == ng) {
                    nB--;
                }
            }

            res += nB;
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3672
def resolve():
    n = int(input())
    happy = [[0]*3 for i in range(n)]
    for i in range(n):
        a, b, c = map(int, input().split())
        if i == 0:
            happy[0][0] = a
            happy[0][1] = b
            happy[0][2] = c
        else:
            happy[i][0] = a + max(happy[i-1][1], happy[i-1][2])
            happy[i][1] = b + max(happy[i - 1][0], happy[i - 1][2])
            happy[i][2] = c + max(happy[i - 1][0], happy[i - 1][1])
    print(max(happy[n-1]))
resolve()

Measured memory_bytes: 61224
N, Y = gets.chomp.split.map(&:to_i)

result = [-1, -1, -1]
break_flg = false
(0..N).each do |i|
  (0..N-i).each do |j|
    if 10000 * i + 5000 * j + 1000 * (N-i-j) == Y
      result = [i, j, N-i-j]
      break_flg = true
      break
    end
  end
  break if break_flg
end

puts result.join(' ')

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

int main() {
    int N=0;
    cin>>N;
    if(N>0&&N<1000){
        cout << "ABC"<<endl;
    }else if(N>999&&N<2000){
        cout << "ABD"<<endl;
    }else{
        ;
    }
    return 0;
}

Measured memory_bytes: 256
//link: https://atcoder.jp/contests/abc065/tasks/arc076_b?fbclid=IwAR1vO2SW99X-GLymjDwBPDWoYj_0R0ylUtEdNcl6cyl92es3FU_n27ya33k
#include <bits/stdc++.h>
#define For(i,a,b) for(int i = a; i <= b; ++i)
#define maxN 200005
#define ll long long
#define fast_read ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pii pair<long long, long long>
#define fi first.first
#define se first.second
#define id second
using namespace std;
struct oo
{
    int u, v;
    ll w;
}edge[maxN];
pair<pii, int>d[maxN];
int n, cnt = 0, cur = 0, p[maxN], h[maxN];
ll ans = 0;
bool sortx(pair<pii, int> a, pair<pii, int> b)
{
    if(a.fi != b.fi)return a.fi < b.fi;
    return a.se < b.se;
}
bool sorty(pair<pii, int> a, pair<pii, int> b)
{
    if(a.se != b.se)return a.se < b.se;
    return a.fi < b.fi;
}
bool cmp (oo a, oo b)
{
    return a.w < b.w;
}
void Make_set(int i)
{
    p[i] = i;
    h[i] = 0;
}
int Find(int i)
{
    while(i != p[i])i = p[i];
    return i;
}
bool Union(int i, int j)
{
    int x = Find(i), y = Find(j);
    if(x == y)return false;
    if(h[x] < h[y])p[x] = y;
    else
    {
        p[y] = x;
        if(h[x] == h[y])h[x]++;
    }
    return true;
}
int main()
{
//    freopen("built.inp", "r", stdin);
//    freopen("built.out", "w", stdout);
    fast_read;
    cin>>n;
    For(i,1,n)Make_set(i);
    For(i,1,n)
    {
        cin>>d[i].fi>>d[i].se;
        d[i].id = i;
    }
    sort(d + 1, d + 1 + n, sortx);
    For(i,1,n - 1)
        edge[++cnt] = {d[i].id, d[i + 1].id, d[i + 1].fi - d[i].fi};
    sort(d + 1, d + 1 + n, sorty);
    For(i,1,n - 1)
        edge[++cnt] = {d[i].id, d[i + 1].id, d[i + 1].se - d[i].se};
    sort(edge + 1, edge + 1 + cnt, cmp);
    For(i,1,cnt)
        if(Union(edge[i].u, edge[i].v))
        {
            ans += edge[i].w;
            cur++;
            if(cur == n - 1)break;
        }
    cout<<ans;
}


Measured memory_bytes: 6784
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int k, s;

	scanf("%d", &k);

	while(k%2==0){
		k=k/2;
	}
	while(k%5==0){
		k=k/5;
	}
	if(k==1){
		s=1;
	}else{

	set<int> res, res1, resr;

	for(int i=0; i<k; i++){
		res1.insert(i);
	}

	int r=1, d;
	for(d=0; d<k; d++){
		res.insert(r);
		r=10*r%k;
		if(r==1){
			break;
		}
	}
	d++;

	int x, e;
	while(!res1.empty()){
		auto itr=res1.begin();
		x=*itr;
		resr.insert(x);
		for(int i=0; i<d; i++){
			res1.erase(x);
			x=10*x%k;
		}
	}

	s=1;
	while(res.find(0)==res.end()){
		for(auto itr=resr.begin(); itr!=resr.end();itr++){
			x=*itr;
			e=0;
			if(x!=0){
				for(int i=0; i<d; i++){
					if(res.find(x-1)!=res.end()){
						e=1;
					}
					x=10*x%k;
				}
			}else{
				if(res.find(k-1)!=res.end()){
					e=1;
				}
			}
			if(e==1){
				for(int i=0; i<d; i++){
					res1.insert(x);
					x=10*x%k;
				}
			}
		}
		s++;
		while(!res1.empty()){
			auto itr1=res1.begin();
			int y=*itr1;
			res1.erase(itr1);
			res.insert(y);
		}
	}
	}

	printf("%d\n", s);
	return 0;

}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*
*の制約が6個までということは全パターンやれということ？
双対問題を考える
制約通り辺を張ってベルマンフォードして負辺でinf
到達不可能で-1でいいのかな
*/
template<typename T>
struct edge{
    int src,to;//src source
    T cost;
    edge(int to,T cost):src(-1),to(to),cost(cost){}
    edge(int src,int to,T cost):src(src),to(to),cost(cost){}
};

//空を返したら負のループ
template<typename T>
vector<T> BellmanFord(vector<edge<T>> &edges,int V,int s){
    const auto TINF=numeric_limits<T>::max();
    vector<T> dist(V,TINF);
    dist[s]=0;
    for(int i=0;i<V-1;i++){
        for(auto &e:edges){
            if(dist[e.src]==TINF) continue;
            dist[e.to]=min(dist[e.to],dist[e.src]+e.cost);
        }
    }
    for(auto &e:edges){
        if(dist[e.src]==TINF) continue;
        if(dist[e.src]+e.cost<dist[e.to]) return vector<T>();
    }
    return dist;
}


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

    vector<edge<ll>> g;
    int V,E,r;
    cin>>V>>E>>r;
    rep(i,E){
        int u,v;ll w;cin>>u>>v>>w;
        g.push_back(edge<ll>(u,v,w));
    }
    auto ans=BellmanFord(g,V,r);
    if(ans.empty()) cout<<"NEGATIVE CYCLE"<<endl;
    else{
        for(auto x:ans){
            if(x>=LINF) cout<<"INF"<<endl;
            else cout<<x<<endl;
        }
    }
    return 0;
}



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


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

  deque<int> q;
  int t;
  cin>>t;
  while(t--){
    int c;
    cin>>c;
    if(c==0){
      int a,b;
      cin>>a>>b;
      if(a==0) q.push_front(b);
      else q.push_back(b);
    }else if(c==1){
      int x;
      cin>>x;
      cout<<q[x]<<endl;
    }else{
      int a;
      cin>>a;
      if(a==0) q.pop_front();
      else q.pop_back();
    }
  }


}


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

int main() {

  int N, L;
  cin >> N >> L;

  vector<string> v;

  for (int i = 0; i < N; i++) {
    string a;
    cin >> a;
    v.push_back(a);
  }

  sort(v.begin(),v.end());

  for (int i = 0 ; i < N ; i++) {
    cout << v.at(i);
  }

  cout << endl;

}


Measured memory_bytes: 256
char s[4005];u[4005],m,j,c,d;main(n){for(;d=~scanf("%s ",s);m=!printf("%d\n",m))for(n=strlen(s);d-10;d=getchar())for(j=n;j--;m<c?m=c:0)u[j+1]=c=s[j]-d?0:u[j]+1;}

Measured memory_bytes: 432
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

fn eratosthenes(p: &mut Vec<i64>, m: usize){
    let mut f: Vec<bool> = vec![true; m + 1];
    f[0] = false;
    f[1] = false;
    for i in 2..m + 1{
        if f[i]{
            p.push(i as i64);
        }
        let mut j = i * 2;
        while j <= m{
            f[j] = false;
            j += i;
        }
    }
}

fn is_prime(p: &Vec<i64>, x: i64) -> bool{
    for i in p.iter(){
        if *i >= x{
            break;
        }else if x % i == 0{
            return false;
        }
    }
    true
}

fn gcd(a: i64, b: i64) -> i64{
    if b == 0{
        a
    }else{
        gcd(b, a % b)
    }
}

fn main(){
    let a: i64 = read();
    let b: i64 = read();
    let mut p: Vec<i64> = vec![];
    eratosthenes(&mut p, 1e6 as usize);
    let g = gcd(a, b);
    let mut ans = 0;
    let mut i = 1;
    while i * i <= g{
        if g % i == 0{
            if is_prime(&p, i){ans += 1;}
            if i * i != g && is_prime(&p, g / i){ans += 1;}
        }
        i += 1;
    }
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main() {
  int num,kind;
  cin>>num;
  string s[num],ans;
  for(int i=0 ; i<num ; i++){
    cin>>s[i]; 
    if(s[i]=="Y"){
      ans = "Four";
      break;
    }
  }
  if(ans!="Four"){
    ans="Three";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace ABC119_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split('/');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);
            if(a < 2019)
            {
                Console.WriteLine("Heisei");
                
            }else if((a == 2019) && (b <= 04))
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
            
            
        }
    }
}


Measured memory_bytes: 11092
//1回の移動では、いくつかの（連続しているとは限らない）ゴミを選んで回収するとみなせる。一番遠くまで行って、帰りに回収するのが最適。
//往復回数Kを固定する
//x = {1,2,…,N}としても最適な割り振り方は変わらない。（どうせコストはΣa_i * x_iの形になるので）
//できるだけ均等な個数だけ割りふる（[2個,4個]とかだと4個の重みが大きいので、[3個,3個]とかにしたい)
//K個飛ばしの要領で拾う (遠くのやつを一気に拾うのは大変なのでできるだけ分散させて拾いたい、というお気持ち？）
//各KについてO(N)かけると400点。O(N/K)かけると700点。だと思う。
//オーバーフローが怖い

#include <iostream>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, c;
int x[200000];
int rx[200001];

signed main() {
	int i, j;
	
	cin >> n >> c;
	rep(i, n) cin >> x[n - 1 - i];
	rep(i, n) rx[i + 1] = rx[i] + x[i];
	
	//i往復する
	int ans = (1LL << 60);
	for (i = 1; i <= n; i++) {
		int sumCost = 0, weight = 3;
		for (j = 0; j < n; j += i) {
			sumCost += (rx[min(n, j + i)] - rx[j]) * weight;
			weight += 2;
			if (sumCost >= ans) break;
		}
		sumCost += rx[i] * 2;
		ans = min(ans, sumCost + (n + i) * c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
#define inf 2000000000

int A[500010],n,L[500010/2+2],R[500010/2+2],cnt=0;

void merge(int left,int right, int mid){
	int n1=mid-left;
	int n2=right -mid;
	for(int i=0;i<n1;i++){L[i]=A[left+i];}
	for(int i=0;i<n2;i++){R[i]=A[mid+i];}
	L[n1]=R[n2]=inf;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt ++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}
		else{
			A[k]=R[j++];
		}
	}
}

void mergesort(int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergesort(left,mid);
		mergesort(mid,right);
		merge(left,right,mid);
	}
}

int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	mergesort(0,n);
	for(int i=0;i<n;i++){
		if(i){cout<< " ";}
		cout <<A[i];
	}
	cout <<endl<<cnt<<endl;
}


Measured memory_bytes: 6908
n,x = map(int,input().split())
cou = 0
lis = list(map(int,input().split()))
lis.sort()
for i in range(n):
  if i != n-1:
    if x >= lis[i]:
      x -= lis[i]
      cou += 1
  else:
    if x == lis[i]:
      cou += 1
print(cou)


Measured memory_bytes: 2940
k, x = map(int, input().split())
pos_list = list(range(x - k + 1, x + k))
pos_list = [x for x in pos_list if x > -1000000 and x < 1000000]
pos_list.sort()
for i in pos_list:
  print('{}'.format(i), sep='', end=' ')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length = 2*(a+b);
        System.out.println(area+" "+length);
    }
}


Measured memory_bytes: 26216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
	int n,A,B;
	A = B = 0;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;++i) cin >> a[i];
	sort(a.begin(),a.end());
	for(int i=0;i<n;++i){
		if(i%2==0) A+=a[n-1-i];
		else B+=a[n-1-i];
	}
	cout << A-B << endl;
	return 0;		
}
 

Measured memory_bytes: 256
#Problem B

A,B,C = map(int, input().split())
K = int(input())

for i in range(K):

    if A >= B:
        B *= 2
    elif B > A:
        if B >= C:
            C *= 2
        elif B < C:
            pass
    else:
        pass

if A < B and B < C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int INF=1e9;

int main(){
	int n; cin>>n;
	rep(i,n){
		int sum=0;
		rep(h,2){
			string s; cin>>s;
			int len=s.size();
			int tmp=1;
			rep(j,len){
				if(s[j]=='m') sum+=tmp*1000;
				if(s[j]=='c') sum+=tmp*100;
				if(s[j]=='x') sum+=tmp*10;
				if(s[j]=='i') sum+=tmp;
				tmp=1;
				if('1'<s[j] and s[j]<='9') tmp=s[j]-'0';
			}
		}
		//cout<<sum<<endl;
		string ans;
		int div=1000;
		char c[]={'m','c','x','i'};
		rep(j,4){
			int x=sum/div;
			if(x==1) ans+=c[j];
			if(x>1){
				ans+='0'+x; ans+=c[j];
			}
			sum=sum%div;
			div/=10;
		}
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3112
#include <stdio.h>

int main() {

  int n, i, x;
  scanf("%d", &n);
  for ( i = 1; i <= n; i++) {
    if (i % 3 == 0)
      printf(" %d", i);
    else {
      x = i;
      while ( x > 0 ) {
	if (x % 10 == 3) {
	  printf(" %d", i);
	  break;
	}
	x /= 10;
      }
    }
  }
  printf("\n");

  return 0;

}

Measured memory_bytes: 596
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
r = []
g = []
b = []
for i in range(3*n):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    else:
        b.append(i)
from collections import defaultdict
d = defaultdict(list)
M = 998244353
for rr,gg,bb in zip(r,g,b):
    d[rr<gg, gg<bb, bb<rr].append(sorted([rr,gg,bb]))
ans = 1
def sub(l1, l2, l3):
    n = len(l1)
    l1.sort()
    l2.sort()
    l3.sort()
#     print(l1,l2,l3)
    ans = 1
    i2 = n-1
    i3 = n-1
    for i in range(n-1, -1, -1):
        while i2>=1 and l2[i2-1]>l1[i]:
            i2 -= 1
        ans *= (n - i2 - (n-(i+1)))
        ans %= M
    for i in range(n-1, -1, -1):
        while i3>=1 and l3[i3-1]>l2[i]:
            i3 -= 1
        ans *= (n - i3 - (n-(i+1)))
        ans %= M
    return ans%M

# for k in d.keys():
#     ans *= sub(*[[item[0] for item in d[k]], [item[1] for item in d[k]], [item[2] for item in d[k]]])
#     ans %= M
l1 = []
l2 = []
l3 = []
for k in d.keys():
    l1 += [item[0] for item in d[k]]
    l2 += [item[1] for item in d[k]]
    l3 += [item[2] for item in d[k]]
ans *= sub(l1,l2,l3)
ans %= M

for i in range(1, n+1):
    ans *= i
    ans %= M
print(ans%M)

Measured memory_bytes: 113548
using System.Linq;
using System.Collections.Generic;
using System;

public class Gengo
{
    public string gengo { get; set; }
    public int sfrom { get; set; }
    public int sto { get; set; }
}

public class hello
{
    public static void Main()
    {
        var gengos = new List<Gengo>();
        SetGengo(gengos);
        string[] line = Console.ReadLine().Trim().Split(' ');
        var e = int.Parse(line[0]);
        var y = int.Parse(line[1]);
        if (e == 0) Console.WriteLine(GetWareki(gengos, y));
        else Console.WriteLine(GetSeireki(gengos, e, y));
    }
    public static void SetGengo (List<Gengo> g)
    {
        g.Add(new Gengo { gengo = "M", sfrom = 1868, sto = 1911 });
        g.Add(new Gengo { gengo = "T", sfrom = 1912 , sto = 1925 });
        g.Add(new Gengo { gengo = "S", sfrom = 1926, sto = 1988 });
        g.Add(new Gengo { gengo = "H", sfrom = 1989, sto = 2016 });
    }
    public static int GetSeireki(List<Gengo> g, int a , int yy)
    {
        var wa = g[a - 1];
        return wa.sfrom + yy - 1;
    }
    public static string GetWareki(List<Gengo> g,  int yy)
    {
        var a = g.Where(x => x.sfrom <= yy).First(x => x.sto >= yy);
        return a.gengo + (yy - a.sfrom+1).ToString();
    }
}

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int X,A;

    cin>>X>>A;

    if(X<A){
        cout<<"0"<<endl;
    }
    else{
        cout<<"10"<<endl;
    }


    return 0;
}


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

int n;
int r[1010], w[1010];

int dp[1000010];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    while(cin >> n && n){
        int sum_r = 0, sum_w = 0, max_r = 0;
        for(int i = 0; i < n; ++i){
            cin >> r[i] >> w[i];
            if(r[max_r] < r[i]){
                max_r = i;
            }
            sum_r += r[i];
            sum_w += w[i];
        }
        if(r[max_r] * 2 <= sum_r){
            cout << sum_r + sum_w << endl;
        } else {
            swap(r[n-1], r[max_r]);
            swap(w[n-1], w[max_r]);
            int rem = r[n-1]*2 - sum_r;
            fill(dp, dp+rem+10, 0);
            dp[0] = true; // mudanazikannni tsumekomi
            for(int i = 0; i < n-1; ++i){
                for(int j = rem; j >= w[i]; --j){
                    dp[j] |= dp[j-w[i]];
                }
            }
            int dead = -1;
            for(int i = rem; i >= 0; --i){
                if(dp[i]){
                    dead = rem - i;
                    break;
                }
            }
            cout << sum_r + sum_w + dead << endl; 
        }
    }
}

Measured memory_bytes: 3088
#include <stdio.h>

int main(void){

   int n,b,f,r,v,i,j,a,c;

   

   scanf("%d",&n);

   int count[4][3][10]={{{0}}};

   for(i=0;i < n;i++){

       scanf("%d %d %d %d",&b,&f,&r,&v);

       count[b-1][f-1][r-1]=count[b-1][f-1][r-1]+v;

   }

   

   for(j=0;j < 4;j++){

       for(a=0;a < 3;a++){

           for(c=0;c < 10;c++){

               printf(" %d",count[j][a][c]);

           }

           printf("\n");

       }

       if(j == 3)break;

       printf("####################\n");

   }
    //printf("\n");
return 0;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    int l,sum=0,longest=0;
    rep(i,n){
        cin>>l;
        sum+=l;
        longest=max(longest,l);
    }
    if(longest<sum-longest) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    string x;cin>>x;
    int ans=x.size();
    int s=0;
    REP(i,x.size()){
        if(x[i]=='S'){
            s++;
        }
        else if(s>0){
            s--;
            ans-=2;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	while(cin>>s)
	{
		int len=s.size();
		int flag=0;
     for(int i=0;i<len;i++)
      for(int j=i;j<len;j++)
      {
      	if(s[i]==s[j])
      	{
      		flag++;
		  }
	  }
	  if(flag==6)
	  cout<<"Yes\n";
	  else
	  cout<<"No\n";
	    
	}
 } 

Measured memory_bytes: 256
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>
using namespace std;

int main() {
    long n;
    cin >> n;
    long ans = 0;
    for (long i = 0; i < n; i++) {
        ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	double a[n+2];
	for(int i=0;i<n;i++)cin >> a[i];
	double sum=0.0;
	for(int i=0;i<n;i++){
		sum+=1.0/a[i];
	}
	printf("%.5f",1/sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll x; cin >> x;

    ll ans = 0;
    ll jud = 100;

    while(jud < x){
        jud += jud/100;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#define INF (1e9)
using namespace std;
int n,dis[41],t[41],maxkai,ans,memo[3][41];

void saiki(int x,int now,int ball,int sum,int kai){
  maxkai=max(maxkai,kai);
  if(kai==n&&!ball)ans=min(ans,sum);
  if(ball)saiki(0,now+x*(1+ball),0,sum+x,kai);
  if(ball==3||kai==n) return;
  
  int nx=dis[kai];
  int nsum=sum+abs(x-nx);
  int nnow=now+abs(x-nx)*(1+ball);
  if(nnow<=t[kai]&&memo[ball][kai]>nsum){
    memo[ball][kai]=nsum;
    saiki(nx,t[kai],ball+1,nsum,kai+1);
  }
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin >>dis[i]>>t[i];
      for(int j=0;j<3;j++) memo[j][i]=INF;
    }
    maxkai=0,ans=INF;
    saiki(0,0,0,0,0);
    if(maxkai==n)cout <<"OK "<<ans<<endl;
    else cout<<"NG "<<maxkai+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#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 <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int ,int> P;
bool ma[51][51];
char ma2[51][51];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int ans=-1;
int h,w;
int desx,desy;
const int inf=100000;
int d[51][51];
void bfs(int x,int y){

  queue<P> que;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=inf;
    }
  }
  que.push(P(x,y));
  d[x][y]=0;
  while(que.size()){
    P p=que.front();que.pop();
    if(p.first==desx and p.second==desy)break;
    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx and nx<h and 0<=ny and ny<w and ma2[nx][ny]!='#' and d[nx][ny]==inf ){
        que.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }

}
  
int main(){
  int res=0;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>ma2[i][j];
      if(ma2[i][j]=='#')res--;
    }
  }
  desx=h-1;
  desy=w-1;
  bfs(0,0);
  if(d[h-1][w-1]==inf)cout<<-1<<endl;
  else cout<<h*w-d[h-1][w-1]-1+res<<endl;

}


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

int main() {
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  bool ans = true;

  /* x方向のチェック */
  if (x-r < 0 || x + r > w) ans = false;
  
  /* y方向のチェック */
  if (y - r < 0 || y + r > h) ans = false;

  if (ans) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;

}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

map<ll,int> factP;

#pragma region Debug
void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cout << H << " ";
	debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#pragma endregion

// コンパイル時、エイリアス「debug」を使用 --> マクロが使えるように

class Calc
{
    // 宣言
    ll a;

    public:
        // 素因数分解
        void decompositPrime(ll a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(ll n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            factP[a]++;
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    factP[n]++;
}

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	Calc obj;
	ll N;
	cin >> N;
	if(N == 1){
		cout << 0 << endl;
		return;
	}

	obj.decompositPrime(N);
	int ans = 0;

/*
	for(auto [key, value]: factP){
		debug(key, "/", value);
	}
*/

	for(auto [key, value]: factP){
		ll z = key;
		while(N % z == 0){
			N /= z;
			ans++;
			z *= key;
		}
	}

	cout << ans << endl;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3644