akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
using namespace std;


int main() {

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

    long long best = 0;

    int n;
    long long c;

    cin >> n >> c;

    vector<pair<long long, long long> > values(n);
    for (int i=0; i<n; i++) {
        cin >> values[i].first >> values[i].second;
    }

    long long left[n + 1], right[n + 1];
    memset(left, 0, sizeof(left));
    memset(right, 0, sizeof(right));

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

    vector<pair<long long, long long> > rvalues(values);
    reverse(rvalues.begin(), rvalues.end());

    for (int i=1; i <= n; i++) {
        left[i] = left[i-1] + values[i - 1].second;
    }

    for (int i=1; i <= n; i++) {
        left[i] = max(left[i] - values[i - 1].first, left[i-1]);
    }

    for (int i=1; i <= n; i++) {
        right[i] = right[i-1] + rvalues[i - 1].second;
    }

    for (int i=1; i <= n; i++) {
        right[i] = max(right[i] - (c - rvalues[i - 1].first), right[i-1]);
    }

    //how many to take on the left
    for (int i=0; i <= n; i++) {

        long long current = left[i];
        long long other = right[n-i];

        if (i > 0) {
            other -= values[i - 1].first;
        }

        best = max(best, current + max(other, 0ll));
    }



    //how many to take on the right
    for (int i=0; i <= n; i++) {

        long long current = right[i];
        long long other = left[n-i];

        if (i > 0) {
            other -= (c - rvalues[i - 1].first);
        }

        best = max(best, current + max(other, 0ll));
    }


    cout << best << endl;
    return 0;
}


Measured memory_bytes: 4992
#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;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	ll a, b;
	cin >> a >> b;
	ll G ,ans;
	G = __gcd(a,b);
	ans = (a * b) / G;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
#define max(a,b) ((a)<(b)?(b):(a))
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a<=0&&b<=0&&c>=0&&d>=0)
		cout << b*c << endl;
	else if(a>=0&&b>=0&&c<=0&&d<=0)
		cout << a*d << endl;
	else
		cout << max(a*c,b*d) << endl;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int sum=0;
	int M=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		sum+=x;
		M=max(M,x);
	}
	if(2*M>=sum)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x;
    cin >> x;
    for (int i=x; ; i++) {
        int j = 2;
        while (j<=i/2) {
            if (i%j==0) break;
            j++;
        }
        if (j > i/2) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

ll d[100000];
ll cnt[100000];

int main() {


  ll n;
  ll div = 998244353;
  ll sum = 1;
  ll max = -1;
  cin >> n;
  rep(i, n) {
    cin >> d[i];
    ++cnt[d[i]];
  }

  rep(i, n) {
    if(max<d[i]) max = d[i];
  }

  if(d[0] != 0 || cnt[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  for(int i=1; i<=max; ++i) {
    if(cnt[i]==0) {
      cout << 0 << endl;
      return 0;
    }else {
      rep(j, cnt[i]) {
        sum = sum * cnt[i-1] % div;
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string a;
    cin>>a;
    int k;
    cin>>k;
    int n=a.length();
    int ans1=0,ans2=0,ans3=0,ans4=0;
    string temp="",temp2="";
    temp=a;
    int cnt=0;
    for (int i = 0; i < n-1; ++i) {
        if(temp[i+1]==temp[i])
        {
            temp[i+1]=char(48+cnt);
            cnt=(cnt+1)%10;
        }
    }

    for (int i = 0; i < n; ++i) {
        if(a[i]!=temp[i])
        {
            ans1++;
        }
    }

    temp=a+a;
    temp2=a+a;
    cnt=0;
    for (int i = 0; i < 2*n-1; ++i) {
        if(temp[i+1]==temp[i])
        {
            temp[i+1]=char(48+cnt);
            cnt=(cnt+1)%10;
        }
    }

    for (int i = 0; i < 2*n; ++i) {
        if(temp[i]!=temp2[i])
        {
            ans2++;
        }
    }


    temp=a+a+a;
    temp2=a+a+a;
    cnt=0;
    for (int i = 0; i < 3*n-1; ++i) {
        if(temp[i+1]==temp[i])
        {
            temp[i+1]=char(48+cnt);
            cnt=(cnt+1)%10;
        }
    }

    for (int i = 0; i < 3*n; ++i) {
        if(temp[i]!=temp2[i])
        {
            ans3++;
        }
    }

    temp=a+a+a+a;
    temp2=a+a+a+a;
    cnt=0;
    for (int i = 0; i < 4*n-1; ++i) {
        if(temp[i+1]==temp[i])
        {
            temp[i+1]=char(48+cnt);
            cnt=(cnt+1)%10;
        }
    }

    for (int i = 0; i < 4*n; ++i) {
        if(temp[i]!=temp2[i])
        {
            ans4++;
        }
    }

    if(k==1)
        cout<<ans1;
    else if(k==2)
        cout<<ans2;
    else if(k%2)
    {
        int z=ans3-ans1;
        z*=(k/2);
        z+=ans1;
        cout<<z;
    } else
    {
        int z=ans4-ans2;
        z*=(k/2-1);
        z+=ans2;
        cout<<z;
    }
}

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

int main(){

  int n, wh;
  int v[1000], w[1000];
  int dp[101][10001] = {};

  cin >> n >> wh;
  for(int i = 0; i < n; i++){
    cin >> v[i] >> w[i];
  }
  for(int i = 0; i <= wh; i++){
    if(i >= w[0]) dp[0][i] = v[0];
  }
  for(int i = 1; i < n; i++){
    for(int j = 0; j <= wh; j++){
      if(j < w[i]){
        dp[i][j] = dp[i-1][j];
      }else{
        dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i]] + v[i]);
      }
    }
  }
  cout << dp[n-1][wh] << endl;
  return 0;
}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }

        
  int main(){
      lint k,s;
      lint ans=0;
      cin>>k>>s;
      rep(i,k+1){
          rep(j,k+1){
              lint z=s-i-j;
              if(z>k||z<0)continue;
              else ans++;
          }
      }
      cout<<ans;
     }
  

  
     
  

Measured memory_bytes: 256
#include <cstdio>

int nextInt() {
	int a; scanf("%d", &a);
	return a;
}

long long f(long long a) {
	return a * a * a * a * a;
}

int main() {
	int X = nextInt();
	for (int a = -120; a <= 120; a++) {
		for (int b = -120; b <= 120; b++) {
			if (f(a) - f(b) == X) {
				printf("%d %d", a, b);
				return 0;
			}
		}
	}
}

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

const int MAX = 100;
int64_t gcm(int64_t a, int64_t b);
int64_t lcm(int64_t a, int64_t b);
int main() {
	int N;
	int64_t T[MAX], time;
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> T[i];
	time = T[0];
	for (int i = 1;i < N;i ++) {
		time = lcm(time, T[i]);
	}
	cout << time;
	return 0;
}

int64_t gcm(int64_t a, int64_t b) {
	if (a < b) return gcm(b, a);
	if (b == 0) return a;
	return gcm(b, a % b);
}

int64_t lcm(int64_t a, int64_t b) {
	return a / gcm(a, b) * b;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#define MAX_V 200010

typedef int F;
const F INF = TEN(9);

struct edge {
	int to, rev;
	F cap;
	edge(int to, F cap, int rev) : to(to), cap(cap), rev(rev) {};
};

vector<edge> G[MAX_V];
int level[MAX_V]; 
int iter[MAX_V]; 

void add_edge(int from, int to, F cap) {
	G[from].emplace_back(to, cap, (int)G[to].size());
	G[to].emplace_back(from, 0, (int)G[from].size() - 1);
}

void bfs(int s) {
	memset(level, -1, sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);

	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (edge &e : G[v]) {
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

F dfs(int v, int t, F f) {
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			F d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

F max_flow(int s, int t) {
	F flow = 0;
	while (true) {
		bfs(s);
		if (level[t] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		F f;
		while ((f = dfs(s, t, INF)) > 0) flow += f;
	}
}

int main() {
	int N; cin >> N;
	vi P(N), Q(N);
	vi cmP(N, -1), cmQ(N, -1);

	rep(i, N) cin >> P[i];
	rep(i, N) cin >> Q[i];

	int nowP = 0, nowQ = 0;
	rep(i, N) {
		if (cmP[i] == -1 && P[i] != i) {
			int p = i;
			while (cmP[p] == -1) {
				cmP[p] = nowP;
				p = P[p];
			}
			++nowP;
		}
		if (cmQ[i] == -1 && Q[i] != i) {
			int q = i;
			while (cmQ[q] == -1) {
				cmQ[q] = nowQ;
				q = Q[q];
			}
			++nowQ;
		}		
	}

	int num = N;
	int s = 0, t = 1 + nowP + nowQ; //V = t + 1
	int same = 0;

	rep(i, N) {
		if (P[i] == i && Q[i] == i) {
			++same;
		} else if (P[i] == i) {
			add_edge(s, cmQ[i] + 1 + nowP, 1);
		} else if (Q[i] == i) {
			add_edge(cmP[i] + 1, t, 1);
		} else {
			add_edge(cmP[i] + 1, cmQ[i] + 1 + nowP, 1);
			if (P[i] == Q[i]) {
				add_edge(cmQ[i] + 1 + nowP, cmP[i] + 1, 1);
			}
		}
	}

	same += max_flow(s, t);

	cout << N - same << endl;

	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(void){

    int N,K,C; cin>>N>>K>>C;
    string S; cin>>S;
    vector<int> A(N,0),B(N,0);

    int cnt=0;
    for (int i = 0; i < N; ++i) {
        if(S[i]=='o'){
            cnt++;
            A[i]=cnt;
            i += C;
        }
        if(cnt>K) break;
    }

    cnt = K+1;
    for (int i = N-1; i >= 0; --i) {
        if(S[i]=='o'){
            cnt--;
            B[i]=cnt;
            i -= C;
        }
        if(cnt<=0) break;
    }

    for (int i = 0; i < N; ++i) {
        if(A[i]==B[i] && A[i]!=0) cout<<i+1<<endl;
    }

    return 0;
}

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

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

    int now = 0;
    int res = 1;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        now = now + l;
        if (now <= x) {
            ++res;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<vector<ll>> G(10001);
vector<ll> memo(10001),c(10001);
priority_queue<ll> que;
ll ans = 0;
ll dfs(ll v, ll c){
    for(auto& u:G[v]){
        if(memo[u]!=0)continue;
        ll c2 = que.top();
        memo[u] = c2;
        que.pop();
        ans += min(c,c2);
        dfs(u,c2);
    }
    return 0;
}


int main(){
    ll N;
    cin >> N;
    ll a,b;
    rep(i,N-1){
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,N){
        cin >> c[i];
        que.push(c[i]);
    }
    ll t = que.top();
    memo[0] = t;
    que.pop();
    dfs(0,t);
    cout << ans << endl;
    PR(memo,N);
}

Measured memory_bytes: 4672
N, M = list(map(int, input().split()))

PYs = {}

py2nummap = {}
py2 = []
for _ in range(M):
    p, y = list(map(int, input().split()))
    if p not in PYs:
        PYs[p] = []
    PYs[p].append(y)
    py2nummap[(p,y)] = ''
    py2.append((p,y))

for p in sorted(PYs.keys()):
    str_p = '{}'.format(p).zfill(6)
    for idx, c in enumerate(sorted(PYs[p])):
        py2nummap[(p,c)] = (str_p + '{}'.format(idx + 1).zfill(6))


for y in py2:
    # print(y)
    print(py2nummap[y])
# print(py2nummap)
# print(PYs)


Measured memory_bytes: 61196
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
int main(){
  ll int a,b,v,w,t;
  scanf("%lld %lld",&a,&v);
  scanf("%lld %lld",&b,&w);
  scanf("%lld",&t);
  if(a==b){
    printf("YES");
    return 0;
  }
  if(v<=w){
    printf("NO");
    return 0;
  }
  
  if(llabs(b-a)<=(v-w)*t){
    printf("YES");
    return 0;
  }
  else{
    printf("NO");
    return 0;
  }
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  int n;
  cin >> n;
  if(n < 10) cout << n << endl;
  else if(n < 100) cout << 9 << endl;
  else if(n < 1000) cout << 9 + (n - 99) << endl;
  else if(n < 10000) cout << 909 << endl;
  else if(n == 100000) cout << 90909 << endl;
  else cout << 909 + (n - 9999) << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N - 1);
  int result = 0;

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> C.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    result += B.at(A.at(i) - 1);
    if (i < N - 1 && A.at(i) + 1 == A.at(i + 1)) {
      result += C.at(A.at(i) - 1);
    }
  }

  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  vector<int> R(n+1), G(n+1), B(n+1);
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      R[i+1] = R[i] + 1;
      G[i+1] = G[i];
      B[i+1] = B[i];
    } else if (s[i] == 'G') {
      R[i+1] = R[i];
      G[i+1] = G[i] + 1;
      B[i+1] = B[i];
    } else if (s[i] == 'B') {
      R[i+1] = R[i];
      G[i+1] = G[i];
      B[i+1] = B[i] + 1;
    }
  }

  ll ans = 0;
  for (int i = 0; i < n-2; ++i) {
    for (int j = i + 1; j < n-1; ++j) {
      char s1 = s[i], s2 = s[j];
      if (s1 == s2) continue;

      auto sub = j - i;
      if (s1 != 'R' and s2 != 'R') {
        // B
        ans += R[n] - R[j];
        if (j + sub < n && s[j+sub] == 'R') ans -= 1;
      } else if (s1 != 'G' and s2 != 'G') {
        ans += G[n] - G[j];
        if (j + sub < n && s[j+sub] == 'G') ans -= 1;
      } else if (s1 != 'B' and s2 != 'B') {
        ans += B[n] - B[j];
        if (j + sub < n && s[j+sub] == 'B') ans -= 1;
      }
    }
  }

  cout << ans << endl;
}

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

int kaijo(int N) {
  if (N == 1) return 1;
  return N * kaijo(N-1);
}

int main() {
  int N;
  cin >> N;
  vector<pair<double, double>> locate(N);
  for (auto &m : locate) {
    cin >> m.first >> m.second;
  }
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    A[i] = i;
  }
  
  double ave = 0;
  int n = 0;
  do {
    double s = 0;
    
    for (int i = 0; i < N-1; i++) {
      double delx = locate[A[i+1]].first - locate[A[i]].first;
      double dely = locate[A[i+1]].second - locate[A[i]].second;
      double dist = sqrt(delx*delx + dely*dely);
      s += dist;
    }
    
    ave += s / kaijo(N);
  }while (next_permutation(A.begin(), A.end()) || n == 1);
  
  cout << fixed << setprecision(10);
  cout << ave << endl;
}

Measured memory_bytes: 256
loop do
    m, f, r = gets.split.map(&:to_i)
    break if m == -1 && f == -1 && r == -1
    if m < 0 || f < 0 || m + f < 30
        puts "F"
    elsif m + f >= 80
        puts "A"
    elsif m + f >= 65
        puts "B" 
    elsif m + f >= 50 || r >= 50
        puts "C"
    else
        puts "D"
    end
end


Measured memory_bytes: 8904
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
int w, h, n;
int lx, rx, ly, ry;
void solve() {
    cin >> w >> h >> n;
    lx = ly = 0;
    rx = w;
    ry = h;
    int x, y, a;
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> a;
        if(a == 1) {
            lx = max(lx, x);
        } else if(a == 2) {
            rx = min(rx, x);
        } else if(a == 3) {
            ly = max(ly, y);
        } else {
            ry = min(ry, y);
        }
    }
    if(lx >= rx || ly >= ry) cout << 0 << endl;
    else {
        cout << (rx - lx) * (ry - ly) << endl;
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

int n, q;
string s;
bool C_left(vector<pair<char, char>>& a, int idx) {
	rep(i, q) {
		if (s[idx] == a[i].first) { idx = idx + (a[i].second == 'R' ? 1 : -1); }
		if (idx < 0) return true;
		if (idx >= n) return false;
	}
	return false;
}
bool C_right(vector<pair<char, char>>& a, int idx) {
	rep(i, q) {
		if (s[idx] == a[i].first) { idx = idx + (a[i].second == 'R' ? 1 : -1); }
		if (idx < 0) return false;
		if (idx >= n) return true;
	}
	return false;
}

signed main() {
	cin >> n >> q >> s;

	vector<pair<char, char>> a(q);
	rep(i, q) {
		char s, t;
		cin >> s >> t;
		a[i] = make_pair(s, t);
	}

	//rep(i, n) { cout << i << ' ' << C_left(a, i) << endl; }
	//rep(i, n) { cout << i << ' ' << C_right(a, i) << endl; }

	int ans_left;
	{
		int right = n, left = 0;
		rep(i, 100) {
			int mid = (right + left) / 2;
			// cout << mid << ' ' << C_left(a, mid) << endl;
			if (C_left(a, mid))
				left = mid;
			else
				right = mid;
		}
		ans_left = left;
	}

	int ans_right;
	{
		int right = n, left = 0;
		rep(i, 100) {
			int mid = (right + left) / 2;
			// cout << mid << ' ' << C_right(a, mid) << endl;
			if (C_right(a, mid))
				right = mid;
			else
				left = mid;
		}
		ans_right = right;
	}
	// cout << ans_left << ' ' << ans_right << endl;

	cout << max(0LL, ans_right - ans_left - 1) << endl;
}


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

int main(void){
    int n;
    cin >> n;
    if(n<1000){
        cout << "ABC";
    }
    else{
        cout << "ABD";
    }
    
    
    return 0;
}






















































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	string s;
  cin >> s;
  int n=s.length();
	ll ans=0;
	map<int, int> mp;
	++mp[0];
		int t=0, p2=1;
		for(int i=n-1; ~i; --i) {
			t=(t+(s[i]-'0')*p2)%2019;
			ans+=mp[t];
			mp[t]++;
			p2=p2*10%2019;
		}
	
	cout << ans;
}

Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int dp[4001][2001]; // 全体で置いたボールの数　黒の数
int posW[2001];
int posB[2001];
int cntW[4001][2001];
int cntB[4001][2001];
string c[4001];
int a[4001];
int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= 2 * N; i++) {
		cin >> c[i] >> a[i];
		if (c[i] == "W") {
			cntW[i][a[i]]++;
			posW[a[i]] = i;
		}
		else {
			cntB[i][a[i]]++;
			posB[a[i]] = i;
		}
	}
	for (int i = 1; i <= 2 * N; i++) {
		for (int j = 1; j <= N; j++) {
			cntW[i][j] += cntW[i - 1][j];
			cntB[i][j] += cntB[i - 1][j];
		}
	}
	for (int i = 1; i <= 2 * N; i++) {
		for (int j = N - 1; j >= 1; j--) {
			cntW[i][j] += cntW[i][j + 1];
			cntB[i][j] += cntB[i][j + 1];
		}
	}
	fill((int*)dp, (int*)(dp + 4001), 1 << 30);
	dp[0][0] = 0;
	for (int i = 0; i < 2 * N; i++) {
		for (int j = 0; j <= min(N, i); j++) {
			int k = i - j;
			if (j + 1 <= N) {
				int cost = 0;
				if (j + 2 <= N) cost += cntB[posB[j + 1]][j + 2];
				if (k + 1 <= N) cost += cntW[posB[j + 1]][k + 1];
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + cost);
			}
			if (k + 1 <= N) {
				int cost = 0;
				if (j + 1 <= N) cost += cntB[posW[k + 1]][j + 1];
				if (k + 2 <= N) cost += cntW[posW[k + 1]][k + 2];
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost);
			}
		}
	}
	cout << dp[2 * N][N] << endl;
}


Measured memory_bytes: 94336
N = int(input())
A = [0]*N
for i in range(N):
  A[i] = int(input())
  
A.sort()

S = sum(A)
if S%10 != 0:
  print(S)
  exit()

for i in range(N):
  if A[i]%10 !=0:
    print(S-A[i])
    exit()
    
print(0)

Measured memory_bytes: 9052
#include<iostream>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if ((a + b) % 2)
	{
		printf("IMPOSSIBLE\n");
	}
	else
	{
		printf("%d\n", (a + b) / 2);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,c,d,e,h,r,l,q;
ll k;
ll x[500005], y[500005], z[500005];
// char s[500005];
string s, t, u;

int main(){
    cin >> s;
    n = s.size();
    for(ll i=0;i<n;i++){
        pu("x");
    }
    el;
    return 0;
}


















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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

const ll mod = 1000000007LL;

void solve() {

}

ll dp[100010][14];
int main() {
  string s;
  cin >> s;
  reverse(ALL(s));
  dp[0][0] = 1;
  ll ten = 1;
  rep(i,(int)s.size()) {
    rep(j,13) {
      char c = s[i];
      if( c == '?' ) {
	rep(k,10) {
	  ( dp[i+1][(j+k*ten)%13] += dp[i][j] ) %= mod;
	}
      } else {
	( dp[i+1][(j+(c-'0')*ten)%13] += dp[i][j] ) %= mod;
      }
    }
    ( ten *= 10LL ) %= 13;
  }
  cout << dp[(int)s.size()][5] << endl;
  return 0;
}


Measured memory_bytes: 11392
/*input
10 7 3 4
*/
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

const long long MOD = 1e9+7;

long long f[1000010], revf[1000010];

long long qpow(long long a, long long b){
  long long res = 1;
  while (b){
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}

void init(){
  f[0] = 1;
  revf[0] = qpow(f[0], MOD - 2);
  for (long long i = 1; i < 1000010; i++){
    f[i] = i * f[i-1] % MOD;
    revf[i] = qpow(f[i], MOD-2);
  }
}

long long C(long long n, long long m){
  return (f[n] * revf[m]) % MOD * revf[n-m] % MOD;
}

long long n_way(long long a, long long b, long long c, long long d){
  long long tot = (c - a) + (d - b);
  long long down = (c - a);
  long long res = C(tot, down);
  return res;
}

int main()
{
    init();
    long long h, w, a, b;
    cin >> h >> w >> a >> b;
    long long tot = n_way(1, 1, h, w);
    for (long long i = 1; i <= b; i++){
        long long tmp = n_way(1, 1, h-a, i) * n_way(h-a+1, i, h, w) % MOD;
        while (tot < tmp) tot += MOD;
        tot = (tot - tmp) % MOD;
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

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

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


int m;
int w,n;
pair <int,int> dp[1050][1050];
char t;
vector<pair <int,int> > pa;
pair<int,int> tpa;

pair<int,int> maxpair(pair <int,int> a,pair <int,int> b){
	return a.second==b.second ? a.first>b.first ? b:a  :  a.second>b.second ? a:b;
}

pair <int,int> rec(int i,int j){
	if(dp[i][j].second>=0) return dp[i][j];
	if(i==pa.size()){
		tpa.second = 0;
		tpa.first=0;
	}
	else if(j<pa[i].first){
		tpa = rec(i+1,j);
		
	}
	else{
		pair <int,int> tpa1=rec(i+1,j);
		pair <int,int> tpa2=rec(i+1,j-pa[i].first);
		tpa2.first+=pa[i].first;
		tpa2.second+=pa[i].second;
		tpa = maxpair(tpa1,tpa2);
	}
	return dp[i][j] = tpa;
	
}

int main(){
	int e=1;
	while(cin>>w,w!=0){
		memset(dp,-1,sizeof(dp));
		cout<<"Case "<<e++<<":\n";
		tpa.first=0;
		tpa.second=0;
		cin>>n;
		rep(i,n){
			int t1,t2;
			cin>>t1>>t>>t2;
			pair <int,int> tm;
			tm.first=t2;
			tm.second=t1;
			pa.push_back(tm);
		}
		//rep(i,pa.size())cout<<pa[i].first<<" "<<pa[i].second<<endl;
		rec(0,w);
		
		cout<<dp[0][w].second<<endl<<dp[0][w].first<<endl;
		pa.clear();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

struct Attack {
    ll a;
    ll mp;
};

struct CheckPoint {
    ll damage;
    ll mp;
};

vector<CheckPoint> initialize(vector<Attack> &attacks, ll h) {
    vector<CheckPoint> res;
    for (Attack &a : attacks) {
        ll count = ((h / 2) / a.a);
        ll use_mp = count * a.mp;
        ll damage = count * a.a;
        CheckPoint cp{damage, use_mp};
        res.push_back(cp);
    }
    return res;
}

int main() {

    ll h, n;
    cin >> h >> n;

    vector<Attack> attacks(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        attacks[i].a = a;
        attacks[i].mp = b;
    };

    map<ll, ll> dp;

    auto ecmin = [&](ll next_damage, ll next_use_mp) {
        if (dp.find(next_damage) == dp.end()) {
            dp[next_damage] = next_use_mp;
        } else {
            cmin(dp[next_damage], next_use_mp);
        }
    };

    vector<CheckPoint> ini = initialize(attacks, h);
    for (CheckPoint &cp : ini) {
        ecmin(cp.damage, cp.mp);
    }

    for (auto e : dp) {
        ll current = e.first;
        ll use_mp = e.second;

        if (current > h) continue;

        for (Attack &a : attacks) {
            ll next_use_mp = use_mp + a.mp;
            ll next_damage = current + a.a;

            ecmin(next_damage, next_use_mp);
        }
    }

    ll ans = INF;
    for (auto e : dp) {
        if (e.first < h) continue;
        cmin(ans, e.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){

  int A,B,C,X,Y;

  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;
  cin >> Y;

  if(2*C >= A+B){
    cout << A*X + B*Y << endl;
    return 0;
  }
  else if(2*C <= min(A,B)){
    cout << 2*C * max(X,Y) << endl;
    return 0;
  }
  else{
    
    cout << min(2*C*min(X,Y) + (X-min(X,Y))*A + (Y-min(X,Y))*B,2*C * max(X,Y)) << endl;
    return 0;
  }
  
  return 0;
}


Measured memory_bytes: 256
li = ["0","1","2","3","4","5","6","7","8","9"]
a,b = map(int,input().split())
s = input()
for i in range(a+b):
    if i != a:
        if s[i] not in li:
            print("No")
            exit()
    else:
        if s[i] != "-":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 9148
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: u32,
        m: u32,
    }
    println!("{}", if n == m {"Yes"} else {"No"});
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        S: String,
    }

    if S == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


Measured memory_bytes: 2060
A = [list(map(int, input().split())) for j in range(3)]

N = int(input())

B = [int(input()) for i in range(N)]

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j] = 0

for i in range(3):
    judge = 0
    for j in range(3):
        judge += A[i][j]
    if judge == 0:
        print("Yes")
        exit()

for j in range(3):
    judge = 0
    for i in range(3):
        judge += A[i][j]
    if judge == 0:
        print("Yes")
        exit()

judge = 0

for k in range(3):
    judge += A[k][k]
if judge == 0:
    print("Yes")
    exit()

judge = 0

judge += A[0][2] + A[1][1] + A[2][0]
if judge == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
using System;

    class NIKKEIB
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string a;
            string b;
            string c;
            a = Console.ReadLine();
            b = Console.ReadLine();
            c = Console.ReadLine();

            int count = 0;

            for (int i = 0; i < n; i++)
            {
                if (a[i] != b[i])
                {
                    count++;
                }
                if(a[i] != c[i])
                {
                    if (b[i] != c[i])
                        count++;
                }
            }

            Console.WriteLine(count);
        }
    }


Measured memory_bytes: 13140
import qualified Data.IntMap as M
import Data.List
 
main = do
  [_,a] <- map read . words <$> getLine
  ds <- map ((a-) . read) . words <$> getLine
  print (tak ds)
 
tak = pred . (M.! 0) . foldr dp (M.singleton 0 1)
 
dp x m = M.unionWith (+) m (mapKeyValue (x+) id m)
 
mapKeyValue f g = M.fromList . map (\(k,v) -> (f k, g v)) . M.toList

Measured memory_bytes: 2812
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln("aeiou".canFind(s) ? "vowel" : "consonant");
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, j;
  int h, w;
  
  while (1) {
    scanf("%d %d", &h, &w);
    if (h == 0 && w == 0) break;

    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        if (!(i % 2)) {
          if (!(j % 2)) {
            putchar('#');
          } else {
            putchar('.');
          }
        } else {
          if (!(j % 2)) {
            putchar('.');
          } else {
            putchar('#');
          }
        }
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}



Measured memory_bytes: 2032
#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn rotate_left<T>(v: &mut Vec<T>) {
    let x = v.remove(0);
    v.push(x);
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let (mut s, t) = (sc.chars(), sc.chars());
    let n = s.len();

    let mut ans = false;
    for _ in 0..n {
        if s == t {
            ans = true;
            break;
        }
        rotate_left(&mut s);
    }

    println!("{}", if ans { "Yes" } else { "No" });
}


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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;

  map<int, int> ans;

  for (int x = 1; x <= 100; x++) {
    for (int y = x; y <= 100; y++) {
      for (int z = y; z <= 100; z++) {
        ll nn = x * x + y * y + z * z + x * y + y * z + z * x;
        if (nn > n)
          break;
        if (x == y && y == z) {
          ans[nn]++;
        } else if (x == y || y == z) {
          ans[nn] += 3;
        } else {
          ans[nn] += 6;
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  map<int, int> boss;
  for(int i=0;i<N;i++) boss[i];
  int A;
  for(int i=0;i<N-1;i++){
    cin >> A;
    boss[A-1] += 1;
  }
  for(int i=0;i<N;i++){
    cout << boss.at(i) << endl;
  }
}

Measured memory_bytes: 12972
#include <iostream>
#include <vector>
#include <map>

using namespace std;
int n;
string str;
int main() {
  cin >> n >> str;
  int res = 0;
  for (int i = 0;i <= n -3; i++) if (str.substr(i, 3) == "ABC") res++;
  cout << res;


  return 0;
}



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

const int INF = -1;
int n;
int a[100][100], d[100];

int dist(int id) {
	int t = 0;
	queue<int> pd;

	for (int i = 0; i < n; i++)
		d[i] = INF;

	pd.push(1);
	d[0] = 0;

	while (pd.size()) {
		int id1 = pd.front();
		pd.pop();

		if (id1 == id)
			break;

		for (int i = 0; i < n; i++) {
			if (a[id1 - 1][i] && d[i] == INF) {
				pd.push(i + 1);
				d[i] = d[id1 - 1] + 1;
			}
		}
	}
	return d[id - 1];
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		int u, k, v;
		cin >> u >> k;
		
		for (int j = 0; j < k; j++) {
			cin >> v;
			a[u - 1][v - 1] = 1;
		}
	}

	for (int i = 1; i < n + 1; i++) {
		int dmin = dist(i);
		cout << i << " " << dmin << endl;
	}

	return 0;
}


Measured memory_bytes: 3160
import sys
from io import StringIO
import unittest

doTest=0

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n,a,b=list(map(int, readline().strip().split()))
    xx=list(map(int, readline().strip().split()))
    p=0
    for i in range(1,len(xx)):
        d=xx[i]-xx[i-1]
        p+=min(d*a,b)
    #n,m,k=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    print(p)

    return

if doTest==0:
    resolve()
    sys.exit()

### ----------------
### ここまでコピぺえ 
### ----------------

Measured memory_bytes: 17372
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}


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

    int N; cin >> N;
    vl a(N); REP(i, N) cin >> a[i];
    const int AMAX = 1e5-1;

    vi h(AMAX+MGN, 0);
    REP(i, N) h[a[i]]++;

    vi sum(AMAX+MGN, 0);
    REP(i, AMAX+1) sum[i + 1] = sum[i] + h[i];

    int ans = sum[3] - sum[0];
    FOR(i,3,AMAX+1){
        ans = max(ans, sum[i + 1] - sum[i - 2]);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int N, M, X, Y, x, y;
	cin >> N >> M >> X >> Y;
	for (int i = 0;i < N;++ i) {
		cin >> x;
		X = X > x ? X : x;
	}
	for (int i = 0;i < M;++ i) {
		cin >> y;
		Y = Y < y ? Y : y;
	}
	cout << (X < Y ? "No " : "") << "War";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

xに関しては最大のみ、yに関しては最小のみ考えれば良くて、後は場合分けで終わる
要はxMax, X < Z ≦ Y, yMinとなるので、X<Yは与えられてるから後の3つを比較すれば良い
Xもxの一種と考えると3つどころか一つ比較だけでおｋ
*/

Measured memory_bytes: 256
until(s=gets.gsub(/\d+/){|k|?1*k.hex})[?#]
n=1+s.index(?/)
eval"s[n*c-n+e-1]=?1;s[n*g-n+i-1]=?bdfh".tr('c-i',gets)
$><<s.gsub(/1+/,&:size)
end

Measured memory_bytes: 8820
#テーブル初期化　0入れ
table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

#データ数
N = int(input())

#テープルにデータを追加
for loop in range(N):
    building,floor,room,value = map(int,input().split())
    table[building-1][floor-1][room-1] += value

x = 0

#棟数
for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

	#階数
    for a in range(3):
        #部屋数
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()


Measured memory_bytes: 5624
#include<iostream>
 
using namespace std;
 
int main(){
 
  int n;
 
  while(cin>>n){
 
 
 
    if(n==0){
      break;
    }
    int a[n];
    int max,min;
 
    max=0;
    min=1000;
 
    for(int i=0;i<n;i++){
      cin>>a[i];
 
      if(a[i]>max){
    max=a[i];
      }
 
      if(a[i]<min){
    min=a[i];
      }
    }
 
    int sum;
 
    sum=0;
 
    for(int p=0;p<n;p++){
      sum=sum+a[p];
    }
 
    sum=sum-max-min;
 
   
 
    cout << sum/(n-2) << endl; 
 
    
 
  }
 
   
 
 
 
  return 0;
}

Measured memory_bytes: 3060