akhauriyash/Code-Regression huggingface dataset:
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
 
 
int main()
{
    string formula;
    while (cin >> formula)
    {
        string a[3];
        int r = 0;
        for (int i = 0; i < formula.size(); i++)
        {
            if (formula[i] == '='||formula[i] == '+') {
                r++; continue;
            }
            a[r] += formula[i];
        }
        bool flag = true;
        for (char x = '0'; x <= '9'; x++)
        {
            if (x == '0' && ((a[0][0] == 'X'&&a[0].size()>=2) ||( a[1][0] == 'X'&&a[1].size()>=2) || (a[2][0] == 'X'&&a[2].size()>=2)))continue;
            string b[3];
            for (int i = 0; i < 3; i++)
            {
                for (int l = 0; l < a[i].size(); l++)
                {
                    if (a[i][l] == 'X')
                    {
                        b[i] += x;
                    }
                    else
                    {
                        b[i] += a[i][l];
                    }
                }
            }
 
            for (int i = 0; i < 3; i++)
            {
                reverse(all(b[i]));
                int s = 100 - b[i].size();
                for (int l = 0; l < s; l++)
                {
                    b[i] += "0";
                }
            }
 
            for (int i = 0; i < 100; i++)
            {
                b[0][i] += b[1][i] - '0';
                if (b[0][i]>'9')
                {
                    b[0][i] = '0' + b[0][i] - '9' - 1;
                    b[0][i + 1]++;
                }
            }
            if (b[0] == b[2])
            {
                cout << x << endl;
                flag = false;
            }
        }
        if (flag)cout << "NA" << endl;
    }
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  int k;
  cin >> a >> b >> c;
  cin >> k;
  bool ok = false;
  // 合計何回2倍にするか
  for (int i = 0; i <= k; i++) {
    // Bを何回2倍にするか
    for (int j = 0; j <= i; j++) {
      // Cを何回2倍にするか
      int l = i - j;
      int tmpB = b * pow(2, j);
      int tmpC = c * pow(2, l);
      if (tmpB > a && tmpC > tmpB) {
        ok = true;
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

#define int long long

signed main(){
  int n,m;
  cin >> n;
  m=n;
  
  int sum = 0;
  while(n){
    sum+=n%10LL;
    n/=10LL;
  }
  if(m%sum==0)
  cout << "Yes" << endl;
  else cout << "No" <<endl;
  return 0;}


Measured memory_bytes: 256
n = gets.chomp.to_i

xy_array = n.times.inject([]) do |acc, i|
  acc[i] = []
  gets.chomp.to_i.times do
    x, y = gets.split.map(&:to_i)
    acc[i] << [x - 1, y]
  end
  acc
end

[1, 0].repeated_permutation(n) do |combination|
  result = combination.each_with_index.all? {|c, i| 
    next true if c == 0

    xy_array[i].all? do |xy|
      combination[xy[0]] == xy[1]
    end
  }
  if result
    puts combination.count(1)
    exit
  end
end


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


using namespace std;


const int MOD = 1e9+7;


int main() {
    string s; cin >> s;

    int n_digits = s.size();

    vector<vector<long long>> dp(n_digits+1, vector<long long>(13, 0));
    dp[0][0] = 1;  // 0 (mod 13) \equiv 0

    long long digit = 1;
    for (int i=0; i<n_digits; i++) {

        // update dp[i+1][k]
        if (s[n_digits-i-1] != '?') {
            int k = s[n_digits-i-1] - '0';
            for (int j=0; j<13; j++) {
                dp[i+1][(digit*k+j)%13] += dp[i][j];
            }
        }

        else {
            for (int k=0; k<10; k++) {
                for (int j=0; j<13; j++) {
                    dp[i+1][(digit*k+j)%13] += dp[i][j];
                }
            }
        }

        for (int k=0; k<13; k++) dp[i+1][k] %= MOD;
        digit *= 10;
        digit %= 13;
    }

    cout << dp[n_digits][5] << endl;
    return 0;
}



Measured memory_bytes: 13632
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

int solve(int a, int b, int c, int d){
    if(llabs(c - a) < llabs(d - b)){
        swap(a, b); swap(c, d);
    }
    if(c < a){
        swap(a, c); swap(b, d);
    }

    if(d < b) swap(b, d);
    //cout << a << " " << b << " " << c << " " << d << endl;

    int ans = llabs(a - c) + llabs(b - d);
    int sz = 1;
    REP(i, 30){

        int A = (a / (3 * sz)) * (3 * sz) + sz;
        while(A <= a) A += 3 * sz;

        int B = (b / (3 * sz)) * (3 * sz) + sz;
        while(B > b) B -= 3 * sz;
        //debug(A); debug(B);

        if(A + sz - 1 < c && B + sz - 1 >= d){
            int t1 = llabs(b - (B - 1)) + llabs(a - c) + llabs(d - (B - 1));
            int t2 = llabs(b - (B + sz)) + llabs(a - c) + llabs(d - (B + sz));
            Max(ans, min(t1, t2));
        }

        sz *= 3;
    }

    return ans;
}

signed main(){

    int Q; cin >> Q;
    REP(_, Q){
        int a, b, c, d; cin >> a >> b >> c >> d;
        cout << solve(a - 1, b - 1, c - 1, d - 1) << endl;
    }

    return 0;
}


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

int main() {
  int h=0,w=0;
  cin >> h >> w;
  
  string s;
  for (int i=0; i < h; i++) {
    string ss;
    cin >> ss;
    s += ss;
  }
  
  for (int i=0; i < h; i++) {
    for (int j=0; j < w; j++) {
      int ans=0;
      char c;
      c = s.at(w*i+j);
      
      if (c == '.') {
        if (i-1 >= 0 && j-1 >= 0) {
          if (s.at((w*i-w)+(j-1)) == '#') ans++;
        }
        if (i-1 >= 0) {
          if (s.at((w*i-w)+j) == '#') ans++;
        }
        if (i-1 >= 0 && j+1 < w) {
          if (s.at((w*i-w)+(j+1)) == '#') ans++;
        }
        if (j-1 >= 0) {
          if (s.at(w*i+(j-1)) == '#') ans++;
        }
        if (j+1 < w) {
          if (s.at(w*i+(j+1)) == '#') ans++;
        }
        if (i+1 < h && j-1 >= 0) {
          if (s.at((w*i+w)+(j-1)) == '#') ans++;
        }
        if (i+1 < h) {
          if (s.at((w*i+w)+j) == '#') ans++;
        }
        if (i+1 < h && j+1 < w) {
          if (s.at((w*i+w)+(j+1)) == '#') ans++;
        }
        
        cout << ans;
        
        if ((w*i+j)%w == w-1) cout << endl;
      }
      else {
        cout << '#';
        
        if ((w*i+j)%w == w-1) cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	char arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	char ch = arr[0];
	//cout<<ch<<" ";
	int k=1;
	for (int i = 1; i <n ; ++i)
	{
		if(ch==arr[i])
			continue;
		else
		{
			ch = arr[i];
	//		cout<<ch<<" ";
			k++;
		}
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int x,y;
	int a[12] = {1,3,1,2,1,2,1,1,2,1,2,1};
	cin >> x >> y;
	
	if(a[x-1]!=a[y-1]) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<double> v;
	rep(i,0,n){
		int x;
		cin>>x;
		int s=(x*(x+1))/2;
		v.pb(s*1.0/x);
	}	
	double pre[n+5]={0.0};
	rep(i,1,n+1)
		pre[i]=pre[i-1]+v[i-1];
	double ans=0.0;
	rep(i,k,n+1){
		ans=max(ans,pre[i]-pre[i-k]);
	}
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(12);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3568
H, W = gets.split.map(&:to_i)
grid = H.times.map { gets.chomp.chars }

w_count = 0
H.times do |i|
  W.times do |j|
    w_count += 1 if grid[i][j] == '.'
  end
end

def steps(grid, si, sj)
  visited = Array.new(H) { Array.new(W, false) }
  visited[si][sj] = true
  dy = [-1, 0, 1, 0]
  dx = [0, 1, 0, -1]
  queue = [[si, sj, 1]]
  while !queue.empty?
    i, j, s = queue.shift
    4.times do |d|
      y = i + dy[d]
      x = j + dx[d]
      next if y < 0 || y >= H || x < 0 || x >= W
      next if grid[y][x] == '#'
      next if visited[y][x]
      visited[y][x] = true
      if y == H - 1 && x == W - 1
        return s + 1
      end
      queue.push([y, x, s + 1])
    end
  end
  nil
end

c = steps(grid, 0, 0)
ans = c ? w_count - c : -1
puts ans

Measured memory_bytes: 2172
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define multitest
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
inline ll add(ll a, ll b, ll m)
{
    return (((a % m + b % m) % m + m) % m);
}
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const ll MOD = 1e9 + 7;

struct dsu
{
    v32 par, sz;
    dsu(int n)
    {
        sz.assign(n + 1, 1);
        par.assign(n + 1, 0);
        iota(par.begin(), par.end(), 0);
    }
    int find(int x)
    {
        if (x != par[x])
            return (par[x] = find(par[x]));
        return par[x];
    }
    bool unite(int x, int y)
    {
        int a = find(x);
        int b = find(y);
        if (a != b)
        {
            if (sz[a] < sz[b])
            {
                par[a] = b;
                sz[b] += sz[a];
            }
            else
            {
                par[b] = a;
                sz[a] += sz[b];
            }
            return true;
        }
        else
            return false;
    }
};

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    v32 deg(n + 1, 0), ans(n + 1, 0);
    int u, v;
    dsu D(n);
    for (int i = 0; i < m; i++)
    {
        cin >> u >> v;
        D.unite(u, v);
        deg[u]++;
        deg[v]++;
    }
    for (int i = 1; i < n + 1; i++)
        ans[i] = D.sz[D.find(i)] - 1 - deg[i];
    for (int i = 0; i < k; i++)
    {
        cin >> u >> v;
        if (D.find(u) == D.find(v))
        {
            ans[u]--;
            ans[v]--;
        }
    }
    for (int i = 1; i < n + 1; i++)
        cout << ans[i] << " ";
    return;
}

int main()
{
    FASTIO;
    int t = 1;
#ifdef multitest
    cin >> t;
#endif
    for (int tc = 1; tc < t + 1; tc++)
        solve();
    return 0;
}


Measured memory_bytes: 2432
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = input()
    T = input()

    for i in range(N):
        j = 0
        for k in range(i, N):
            if S[k] != T[j]:
                break
            j += 1
        else:
            print(N * 2 - j)
            return
    print(N * 2)


main()


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int x, n;
    cin >> x >> n;
    int ans = 101;
    int d = INF;
    int p[n];
    rep(i, n) cin >> p[i];


    repr(i, 0, 101){
        bool ok = true;
        rep(j, n){
            if(i==p[j]){
                ok=false;
                break;
            }
        }
        if(!ok) continue;

        if(abs(x-i) < d){
            ans = i;
            d = abs(x-i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    let mut input: Vec<u32> = read_to_vec();
    input.sort();

    println!("{}", if input[0] + input[1] == input[2] {"Yes"} else {"No"});
}

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N;
ll L[MAXN], R[MAXN];

priority_queue<ll> lq;
priority_queue<ll,vector<ll>,greater<ll>> rq;

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

    ll ans = 0;
    ll lq_shift = 0, rq_shift = 0;

    lq.push(L[0]);
    rq.push(L[0]);

    for (int i = 1; i < N; i++)
    {
        rq_shift += R[i-1] - L[i-1];
        lq_shift -= R[i] - L[i];

        ll ltop = lq.top() + lq_shift;
        ll rtop = rq.top() + rq_shift;
        if (L[i] < ltop)
        {
            ans += abs (ltop - L[i]);
            lq.pop();
            rq.push(ltop-rq_shift);
            lq.push(L[i]-lq_shift);
            lq.push(L[i]-lq_shift);
        }
        else if (L[i] > rtop)
        {
            ans += abs (rtop - L[i]);
            rq.pop();
            lq.push(rtop-lq_shift);
            rq.push(L[i]-rq_shift);
            rq.push(L[i]-rq_shift);
        }
        else
        {
            lq.push(L[i]-lq_shift);
            rq.push(L[i]-rq_shift);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3572
#include"bits/stdc++.h"
using namespace std;

int n;
#define MAX 112
char buf[MAX];
string s;

int main() {
	cin >> n;
	scanf("%s", buf);
	s = buf;
	int red = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			red++;
		}
		else {
			red--;
		}
	}
	if (red > 0) {
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,h,ans;
char s[233];
int main()
{
    scanf("%d%s",&n,&s);
    for(int i=0;i<n;i++){
        if(s[i]=='I')
		h++;
        else
		h--;
        ans=max(h,ans);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll H, W, K;
char mp[333][333];

ll row_flg[333];
ll nxt = 1;
ll ans[333][333];

int main(){
    rep(i, 333)rep(j, 333)mp[i][j] = '@';
    rep(i, 333)rep(j, 333)ans[i][j] = INF;

    cin >> H >> W >> K;
    rep1(y, H)rep1(x, W){
        cin >> mp[y][x];
        ans[y][x] = 0;
        if(mp[y][x] == '#')row_flg[y] = 1;
    }
    rep1(y, H)if(row_flg[y]){
        rep1(x, W)if(mp[y][x] == '#'){
            ans[y][x] = nxt;
            for(ll nx = x - 1; ans[y][nx] == 0 && mp[y][nx] == '.'; nx--)ans[y][nx] = nxt;
            for(ll nx = x + 1; ans[y][nx] == 0 && mp[y][nx] == '.'; nx++)ans[y][nx] = nxt;
            nxt++;
        }
    }
    rep1(y, H)if(row_flg[y]){
        rep1(x, W){
            for(ll ny = y - 1; ans[ny][x] == 0; ny--)ans[ny][x] = ans[y][x];
            for(ll ny = y + 1; ans[ny][x] == 0; ny++)ans[ny][x] = ans[y][x];
        }
    }
    rep1(y, H){
        rep1(x, W){
            cout << ans[y][x];
            if(x < W)cout << " ";
            else cout << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n, _ := sc.NextInt()
	a, err := sc.NextInts(n)
	if err != nil {
		panic(err)
	}
	ans := solve(n, a)
	out := make([]interface{}, len(ans))
	for i := range out {
		out[i] = ans[i]
	}
	fmt.Println(out...)
}

func solve(n int, a []int) []int {
	ans := make([]int, n)
	xor := 0
	for i := 0; i < n; i++ {
		xor ^= a[i]
	}
	for i := 0; i < n; i++ {
		ans[i] = xor ^ a[i]
	}
	return ans
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

// NextInts reads n integers from io stream.
func (sc *Scanner) NextInts(n int) (arr []int, e error) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		v, e := sc.NextInt()
		if e != nil {
			return nil, e
		}
		arr[i] = v
	}
	return arr, nil
}


Measured memory_bytes: 21248
n = int(input())
h = list(map(int, input().split()))
max_cnt, cnt = 0, 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        cnt += 1
    else:
        cnt = 0
    max_cnt = max(max_cnt, cnt)
print(max_cnt)

Measured memory_bytes: 20644
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
//const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

int main(){
	string days[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string s;
	cin >> s;
	rep(i,7){
		if(s==days[i]){
			cout << 7 - i << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2)
 
int main() {
  int N;
  cin >> N;
  map<string, int> A;
  
  int app = 0;
  REP(i, N) {
    string S;
    cin >> S;
    A[S]++;
    app = max(app, A[S]);
  }
  
  for(pair<string, int> a : A) {
    if(a.second == app)
      cout << a.first << endl;
  }
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int n, k;
	cin >> n>> k;
	vector<ll> h(n);
	rep(i,n) cin >>h[i];
	SORT(h);
	ll ans = INF;
	int count = 0 ;
	rep(i,n-k+1){
		count ++ ;
		chmin(ans,h[i+k-1] - h[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int n = scan.nextInt();

		int[] a = new int[n];
		int[] b = new int[n];

		int i;
		for(i = 0; i < n; i++)
			a[i] = scan.nextInt();

		b[0] = a[n - 1] - a[0];
		for(i = 1; i < n; i++) {
			int end = i - 1;
			if(a[i] > a[end])
				b[i] = (a[end] + k) - a[i];
			else
				b[i] = a[end] - a[i];

		}

		long ans = Integer.MAX_VALUE;
		for(i = 0; i < n; i++) {
			if(b[i] < ans) {
				ans = b[i];
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 83800
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 5e5 + 111;
        
using namespace std;          

int a, b;

void solve(){
	cin >> a >> b;

	cout << 6 - a - b;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; ll k; cin >> s >> k;
    rep(i, min((ll)s.size(), k)){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if (k <= a) {
        cout << a - k << " " << b << endl;
    } else if (k <= a + b) {
        cout << 0 << " " << b - (k - a) << endl;
    } else {
        cout << 0 << " " << 0 << endl;
    }
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 998244353;
    unsigned long N, S;
    cin >> N >> S;
    vector<unsigned long> A(N);
    for(auto&& i : A)cin >> i;

    vector<unsigned long> dp(S + 1);
    dp[0] = [](unsigned long n){unsigned long r{1}, a{2}; while(n){if(n & 1)(r *= a) %= MOD; (a *= a) %= MOD; n >>= 1;}return r;}(N);

    for(const auto& i : A)for(unsigned long j{S}; j >= i; --j)(dp[j] += (dp[j - i] + (dp[j - i] & 1) * MOD) / 2) %= MOD;

    cout << dp.back() << endl;

    return 0;
}

Measured memory_bytes: 3672
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn operation_count(n: i32, xs: Vec<i32>) -> i32 {
    if xs.iter().all(|e| e % 2 == 0) {
        return operation_count(n + 1, xs.iter().map(|e| e / 2).collect());
    } else {
        return n;
    }
}

fn main() {
    let element_count: i32 = read();
    let xs: Vec<i32> = read_vec();
    let count = operation_count(0, xs);
    println!("{}", count);
}


Measured memory_bytes: 4352
#むちゃくちゃ大事
#街の数を受け取り、その経路の平均値を求めるプログラム


import numpy as np

import math

#街の数を受けとる
n = int(input())

#街の位置ベクトルを保存するためのリスト
a = []

#合計値
sum = 0

#街の一ベクトルを取得
for i in range(n):
    a.append(np.array(list(map(int,input().split()))))

for i in range(n):
    for s in range(i,n):
        sum += np.linalg.norm(a[s] - a[i])

#平均値を表示 sum : 経路の合計  math.factorial(n) : nの階乗
print(sum*2/n)


Measured memory_bytes: 21520
n=int(input())
A=list(map(int,input().split()))
ans=0
while True:
  count=0
  for i in range(n):
    if A[i]%2==0:
      A[i]=A[i]//2
      count+=1
    else:
      break
  if count==n:
    ans+=1
  else:
    break
print(ans)

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

int main() {
  long long N,sum = 0;
  cin >> N;
  vector<long long>vec(N);
  for(long long i=0; i<N; i++){
    cin >> vec[i];
  }
  for(long long i=0; i<N-1; i++){
    if(vec[i] > vec[i+1]){
      sum += vec[i]-vec[i+1];
      vec[i+1] = vec[i];
    }
  }
  cout << sum << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;
    ii LR[N];
    int p = 0, q = 0, r = 0;
    FOR(i,0,N-1){
        cin >> LR[i].fi >> LR[i].sc;
        if (LR[i].fi > LR[p].fi) p = i;
        if (LR[i].sc < LR[q].sc) q = i;
        if (LR[i].sc-LR[i].fi+1 > LR[r].sc-LR[r].fi+1) r = i;
    }

    int ans1 = LR[r].sc-LR[r].fi+1;
    ii se = LR[0 == r];
    FOR(i,0,N-1) if (i != r) {
        se.fi = max(se.fi, LR[i].fi);
        se.sc = min(se.sc, LR[i].sc);
    }
    ans1 += max(0,se.sc-se.fi+1);

    int ans2 = 0;
    ii ab[N];
    FOR(i,0,N-1){
        ab[i] = ii(max(0,LR[i].sc-LR[p].fi+1), max(0,LR[q].sc-LR[i].fi+1));
    }
    sort(ab,ab+N);
    int cur = ab[0].sc;
    FOR(i,1,N-1){
        ans2 = max(ans2, cur+ab[i].fi);
        cur = min(cur, ab[i].sc);
    }

    cout << max(ans1,ans2);
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

const long long BIGINF = 2e18 + 7;
const int INF = 2e9 + 7;


const int N = 2e5 + 5;
int factorial[N];

int mul(int x, int y) {
	return 1LL * x * y % MOD7;
}

int power(int x, int exp) {
	int res = 1;
	while (exp) {
		if (exp & 1) {
			res = mul(res, x);
		}
		x = mul(x, x);
		exp >>= 1;
	}
	return res;
}


int inv(int x) {
	return power(x, MOD7 - 2);	
}

int binomial(int x, int y){
	if (x < y) return 0;
	return mul(factorial[x], inv(mul(factorial[y], factorial[x - y])));
}

int sub(int x, int y) {
	int k = x - y;
	if (k < 0) k += MOD7;
	return k;
}


int main () {
	/*#ifndef ONLINE_JUDGE
		freopen("inputf.txt", "r", stdin);
		freopen("outputf.txt", "w", stdout);
	#endif*/
	int n, k;
	SCD(n);
	SCD(k);
	int x;
	factorial[0] = 1;
	for (int i = 1; i <= N; i++) {
		factorial[i] = mul(factorial[i - 1], i);
	}
	vector<int> v;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		SCD(x);
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++) {
		/*int diff = sub(v[i + 1], v[i]);
		int num_ways = binomial(n, k);
		num_ways = sub(num_ways, binomial(i + 1, k));
		num_ways = sub(num_ways, binomial(n - i - 1, k));*/
		int num_max = binomial(i, k - 1);
		int num_min = binomial(n - (i + 1), k - 1);
		num_max = mul(num_max, v[i]);
		num_min = mul(num_min, v[i]);
		int l = sub(num_max, num_min);	
		ans = (ans + l) % MOD7;
	}
	printf("%d", ans);
    return 0;
}



Measured memory_bytes: 1660
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

const int MAXN = 2000 + 10;

int N;
string a, b;
int answer = 0x7F7F7F7F;
int asum, bsum;

int pre[MAXN], nxt[MAXN], mx[MAXN];
void solve()
{
	memset(pre, 0x00, sizeof pre);
	memset(nxt, 0x00, sizeof nxt);
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j < N; j++)
			if(b[(i-j+N) % N] == '1')
			{
				pre[i] = j;
				break;
			}
		for(int j = 0; j < N; j++)
			if(b[(i+j)%N]  == '1')
			{
				nxt[i] = j;
				break;
			}
	}

	for(int i = 0; i < N; i++)
	{
		int tCnt = 0;
		memset(mx, 0x00, sizeof mx);
		for(int j = 0; j < N; j++)
			if(a[j] != b[(i + j) % N])
				tCnt++, mx[pre[j]] = max(mx[pre[j]], nxt[j]);
		int mn = 0x7F7F7F7F, cnt = i;
		for(int j = N - 1; j >= 0; j--)
			mn = min(mn, cnt + j), cnt = max(cnt, mx[j]);
		answer = min(answer, 2 * mn - i + tCnt);
	}
}

int main()
{
	cin >> a >> b ;
	N = a.length();

	for(const auto & x : a)
		if(x == '1')
			asum++;
	for(const auto & x : b)
		if(x == '1')
			bsum++;

	if(asum == 0 && bsum == 0)
		return cout << 0 << endl, 0;
	else if(bsum == 0)
		return cout << -1<< endl, 0;

	solve();
	reverse(a.begin(), a.end()), reverse(b.begin(), b.end());
	solve();
	cout << answer << endl ;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
// 1~1e5までの値について素数:自身の値, 合成数:最小の素因数 の配列を返す
constexpr int PSIZE = 1e4 + 1;
struct eratosthenes_sieve{
    int Primes[PSIZE];
    bool isPrime[PSIZE];
    constexpr eratosthenes_sieve(): Primes(), isPrime(){
        iota(Primes, Primes + PSIZE, 0);
        fill(isPrime, isPrime + PSIZE, 0);
        for (int i = 2; i < PSIZE; i++){
            if (Primes[i] != i) continue;
            for (int s = i * 2; s < PSIZE; s += i){
                Primes[s] = i;
            }
            isPrime[i] = true;
        }
    }
    
    // 数値vの素因数の配列を昇順で取得
    vector<int> get_pfactor(int v){
        vector<int> res;
        int p = Primes[v];
        while(v > 1){
            while (Primes[v] == p) v /= Primes[v];
            res.emplace_back(p);
            p = Primes[v];
        }
        reverse(res.begin(), res.end());
        return res;
    }

    // 数値vの素因数分解を取得
    map<int, int> get_factrization(int v){
        map<int, int> mp;
        while(v>1){
            mp[Primes[v]]++;
            v /= Primes[v];
        }
        return mp;
    }
};
using ES = struct eratosthenes_sieve;

int main() {
    init();
    ES es;
    ll N;
    cin >> N;

    ll ans = 0;
    rep(i, N){
        ll x;
        cin >> x;
        bool isok = true;
        repe(k, 2, (ll)sqrt(x) + 1){
            if(es.isPrime[k] and x%k==0){
                isok = false;
                break;
            }
        }

        ans += isok;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3252
N = int(input())
data = []
for _ in range(N):
    x, y, h = list(map(int, input().split()))
    data.append([x,y,h])
for x in range(101):
    for y in range(101):
        result = 0
        for dat in data:
            if dat[2] != 0:
                result = abs(dat[0] - x) + abs(dat[1] - y) + dat[2]
                break
        flag = True
        for dat in data:
            result2 = max(result - abs(dat[0] - x) - abs(dat[1] - y) , 0)
            if result2 != dat[2]:
                flag = False
                break
        if flag == True:print(x,y,result)

Measured memory_bytes: 3064
ds=gets.chomp.reverse.chars.map(&:to_i).push(0,0)
puts (0..ds.size-2).reduce(0){|s,i|
  dc=ds[i]
  dn=ds[i+1]
  if dc<5||dc==5&&dn<5
    s+=dc
  else
    s+=10-dc
    ds[i+1]=dn+1
  end
  s
}

Measured memory_bytes: 65456
n = int(input())
lst = list(map(int,input().split()))
lst2 = sorted(lst)
s = 0
for i in range(n-2):
  j = i + 1
  while j <= n-2:
    k = j + 1
    while k <= n-1:
      if lst2[i] + lst2[j] > lst2[k] and lst2[i]!= lst2[j] and lst2[j]!= lst2[k]:
        s +=1
      k += 1
    j+=1
  i+=1  

print(s)        
    
    

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int cntg = 0, cntp = 0;
    rep(i, sz(s)) {
        if (s[i] == 'p') cntp++;
        else cntg++;
    }
    cout << (cntg - cntp) / 2 << endl;

}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int n;
    while(scanf("%d",&n)!=EOF){
        if(n==0)
        break;
        int x,y,h,w,size,i,sum=0;
        for(i=1;i<=n;i++){
            scanf("%d %d %d %d",&x,&y,&h,&w);
            size=x+y+h;
            if(size<=60&&w<=2){
                sum+=600;
            }else if(size<=80&&w<=5){
                sum+=800;
            }else if(size<=100&&w<=10){
                sum+=1000;
            }else if(size<=120&&w<=15){
                sum+=1200;
            }else if(size<=140&&w<=20){
                sum+=1400;
            }else if(size<=160&&w<=25){
                sum+=1600;
            }
            
            
        }

        printf("%d\n",sum);    
    }
    
    
    
    
}


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

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

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i,0,n){
		cin >> v[i];
	}
	sort(all(v));
	int ans = 0;
	gmin(k,n);
	cout << accumulate(v.begin(), v.begin() + n - k, 0LL) << '\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,M,t; cin >> N >> M;
    ll mn = INF;
    REP(i,N){
        cin >> t;
        M -= t;
        chmin(mn,t);
    }
    cout << N + M / mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int Compare(const char *s1, const char *s2);
int main (int argc, char *argv[]) {
	int N, L, i, j, minj;
	scanf("%d %d[^\n]", &N, &L);
	if (N < 1 || N > 100 || L < 1 || L > 100) return -1;
	char **S, *min, *result;
	S = malloc(N * sizeof(char*));
	min = malloc((L + 1) * sizeof(char));
	result = malloc(N * (L + 1) * sizeof(char));
	for (i = 0; i < N; i++) {
		S[i] = malloc((L + 1) * sizeof(char));
		if (scanf("%s[^\n]", S[i]) != 1) return -1;
	}
	strcpy(result, "");
	for (i = 0; i < N; i++) {
		minj = -1;
		strcpy(min, "");
		for (j = 0; j < N; j++) {
			if (S[j] != NULL) {
				if (Compare(min, S[j]) > 0 || !strcmp(min, "")) {
					strcpy(min, S[j]);
					minj = j;
				}
			}
		}
		strcat(result, min);
		S[minj] = NULL;
	}
	printf("%s\n", result);
	return 0;
}

int Compare(const char *s1, const char *s2) {
	while (*s1 == *s2) {
		if (*s1 == '\0')
			return (0);
		s1++;
		s2++;
	}
	return (*s1 - *s2);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,i,s[11],g,r,w,S,j;
	char X[101];
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
			s[i]=0;
		}
		scanf("%s",X);
		w=-1; r=-1; g=0;
		while(w<=100){
			r++;
			w++;
			if(X[w]=='M'){
				s[r]++;
			}	
			else if(X[w]=='S'){
				g+=s[r]+1;
				s[r]=0;
			}
			else if(X[w]=='L'){
				s[r]+=g+1;
				g=0;
			}
			if(r==a-1){
				r=-1;
			}
		}
		for(i=0;i<a;i++){
			for(j=i+1;j<a;j++){
				if(s[i]>s[j]){
					S=s[i];
					s[i]=s[j];
					s[j]=S;
				}
			}
		}
		for(i=0;i<a;i++){
			printf("%d ",s[i]);
		}
		printf("%d\n",g);
	}
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 1e2 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";

int a[siz][3];

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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i][1] >> a[i][2];
    }

    bool ans = false;
    for (int i = 1; i <= n - 2; i++) {
        if (a[i][1] == a[i][2] && a[i + 1][1] == a[i + 1][2] && a[i + 2][1] == a[i + 2][2]) {
            ans = true;
            break;
        }
    }

    cout << yn(ans) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
 
int main(){
  int x ,y ,max ,min ,newmax;
  scanf("%d %d" ,&x ,&y);

  if(x > y){
   max = x;
   min = y;
  }
  else{
   max = y;
   min = x;
  }
   while(max != min && min != 0){
    newmax = min;
    min = max % min;
    max = newmax;
  }
   	printf("%d\n" ,max);

 return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n)  RFOR(i,0,n)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
const int MAX_V = 100;
const int MAX_E = 1000;

const int nmax=40,abmax=10;
int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

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

	int n,ma,mb;
	cin>>n>>ma>>mb;
	REP(i,n) cin>>a[i]>>b[i]>>c[i];

	REP(i,n+1)
		REP(j,nmax*abmax+1)
			REP(r,nmax*abmax+1)
				dp[i][j][r]=INF;

	dp[0][0][0]=0;
	
	REP(i,n){
		REP(j,nmax*abmax+1){
			REP(r,nmax*abmax+1){
				if(dp[i][j][r]==INF) continue; //INFなら更新の必要はないため
				chmin(dp[i+1][j][r],dp[i][j][r]); //i番目の商品を選ばない
				chmin(dp[i+1][j+a[i]][r+b[i]],dp[i][j][r]+c[i]); //i番目の商品を選ぶ
			}
		}
	}

	int result=INF;
	
	FOR(i,1,nmax*abmax+1)
		FOR(j,1,nmax*abmax+1)
			if(i*mb==j*ma) chmin(result,dp[n][i][j]);

	if(result==INF) print("-1");
	else print(result);

	return 0;
}


Measured memory_bytes: 25984
N=int(input())
S=input()

ans = S.count("R")*S.count("G")*S.count("B")

tmp=0

for i in range(N):
  for j in range(i,N):
    if j-i+j < N:
      if S[i]!=S[j] and S[j]!=S[j-i+j] and S[i]!=S[j-i+j]:
        tmp += 1

ans = ans - tmp
print(ans)

Measured memory_bytes: 9192