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

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

    vector<vector<bool>> cake(H, vector<bool>(W, false));
    string s;
    vector<pair<int, int>> strawberry;
    vector<vector<int>> ans(H, vector<int>(W, 0));
    int color = 1;
    for (int i = 0; i < H; i++)
    {
        cin >> s;
        for (int j = 0; j < W; j++)
        {
            if (s[j] == '#')
            {
                cake[i][j] = true;
                strawberry.push_back(make_pair(i, j));
                ans[i][j] = color;
                color++;
            }
        }
    }

    int h, w;
    for (int i = 0; i < K; i++)
    {
        h = strawberry[i].first;
        w = strawberry[i].second;
        for (int j = w + 1; j < W; j++)
        {
            if (ans[h][j] == 0)
            {
                ans[h][j] = i + 1;
            }
            else
            {
                break;
            }
        }
        for (int j = w - 1; j >= 0; j--)
        {
            if (ans[h][j] == 0)
            {
                ans[h][j] = i + 1;
            }
            else
            {
                break;
            }
        }
    }

    for (int i = H - 2; i >= 0; i--)
    {
        for (int j = 0; j < W; j++)
        {
            if (ans[i][j] == 0)
            {
                ans[i][j] = ans[i + 1][j];
            }
        }
    }
    for (int i = 1; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (ans[i][j] == 0)
            {
                ans[i][j] = ans[i - 1][j];
            }
        }
    }

    for (vector<int> x : ans)
    {
        for (int y : x)
        {
            cout << y << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 2036
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void)
{
    int p, q, r;
    scanf("%d%d%d", &p, &q, &r);

    printf("%d\n", min(p + q, min(q + r, r + p)));
    return 0;
}

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

int main() {
  int h,w;
  cin >> h >> w;
  string ss = "";
  for (int i = 0; i < w+2; i++) {
     ss += "#";
  }

  cout << ss << endl;
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  cout << ss << endl;
}


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

const int INF=200000000;

int main(){
    int N,M,R;
    int ans=INF;
    cin >> N >> M >> R;
    int C[201][201];
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            C[i][j]=INF;
        }
    }
    int r[R];
    for(int i=0;i<R;i++){
        cin >> r[i];
    }

    for(int i=0;i<M;i++){
        int x,y,r;
        cin >> x >> y >> r ;
        C[x][y]=r;
        C[y][x]=r;
    }
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                C[i][j]=min(C[i][j],C[i][k]+C[k][j]);
            }
        }
    }
    sort(r,r+R);
    do{
        int tans=0;
        for(int i=0;i<R-1;i++){
            tans+=C[r[i]][r[i+1]];
            if(i==R-2) ans=min(ans,tans);
        }
    }while(next_permutation(r,r+R));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=2e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int r[N],last[20],a[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        r[i]=inf;
        for(int j=0;j<20;j++){
            if(a[i]&(1<<j)){
                if(last[j]){
                    r[last[j]]=min(i-1,r[last[j]]);
                }
                last[j]=i;
            }
        }
    }
    r[n+1]=n;
    for(int i=n;i;i--){
        r[i]=min(r[i],r[i+1]);
    }
    ll ans=0;
    for(int l=1;l<=n;l++){
        int len=r[l]-l+1;
        ans+=1ll*(len+1)*len/2;
        len=r[l-1]-l+1;
        ans-=1ll*(len+1)*len/2;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	llint a, b;
	cin >> a >> b;
	llint x, y;
	extGCD(a, b, x, y);
	cout << x << " " << y << endl;
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}


void init(ll n) {
	REP(i, n) {
		par[i] = i;
		depth[i] = 0;
	}
	return;
}

ll find(ll x) {
	if (par[x] == x) { return x; }
	else { return par[x] = find(par[x]); }
}

void merge(ll x, ll y) {
	x = find(x); y = find(y);
	if (x == y) { return; }
	if (depth[x] > depth[y]) {
		par[y] = x;
	}
	else {
		par[x] = y;
		if (depth[x] == depth[y]) {
			depth[y]++;
		}
	}
}

bool same(ll x, ll y) {
	if (find(x) == find(y)) {
		return false;
	}
	return true;
}

//------------------変数-----------------------//
ll n, a, b, c;
string str;
//-------------------関数----------------------//
int main() {
	cin >> n;
	ll r[200000];
	REP(i, n) {
		cin >> r[i]; 
	}
	sort(r, r + n);
	vector<ll>vec;
	REP(i, n - 1) {
		if (r[i] == r[i + 1]) { vec.push_back(r[i]); i++; }
	}
	if (vec.size() < 2) { cout << 0 << endl; return 0; }
	ll si = vec.size();
	cout << vec[si - 1] * vec[si - 2] << endl;
	return 0;
}

Measured memory_bytes: 1660
import java.util.*;

class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		StringBuilder r=new StringBuilder();
		if(n==0)
			r.append(0);
		while(n!=0){
			int b=Math.abs(n%2);
			r.append(b);
			n=(n-b)/-2;
		}
		System.out.println(r.reverse());
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int mypow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x;
		}
		x = x * x;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
int mystoi(string x) {
	int res = 0;
	rep(i, x.size()) {
		res = res * 10 + x[i] - '0';
	}
	return res;
}
/*--------Library Zone!--------*/

int n, x[105], y[105], h[105];
signed main() {
	cin >> n;
	rep(i, n)cin >> x[i] >> y[i] >> h[i];
	rep(i, 101) {
		rep(j, 101) {
			int ans;
			rep(k, n) {
				if (h[k] != 0) {
					ans = abs(i - x[k]) + abs(j - y[k]) + h[k];
					break;
				}
			}
			rep(k, n) {
				if (h[k] != 0 && ans != abs(i - x[k]) + abs(j - y[k]) + h[k])goto loop;
				else if (h[k] == 0 && ans > abs(i - x[k]) + abs(j - y[k]))goto loop;
			}
			cout << i << " " << j << " " << ans << endl;
			return 0;
		loop:;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int lef, cen, rit;

    scanf("%d %d %d", &lef, &cen, &rit);
    if(lef < cen && cen < rit)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k; cin >> n >> k;
    ll mod = n % k;
    cout << min(mod, k-mod) << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	string s, t;
	bool b = true;

	cin >> s >> t;

	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());

	REP(i, s.size() - t.size() + 1) {
		REP(j, t.size()) {
			if (s[i + j] != t[j] && s[i + j] != '?') {
				b = false;
				break;
			}
		}

		if (b) {
			REP(j, t.size()) {
				s[i + j] = t[j];
			}

			REP(j, s.size()) {
				if (s[j] == '?') {
					s[j] = 'a';
				}
			}

			reverse(s.begin(), s.end());

			cout << s << endl;

			return 0;
		}

		b = true;
	}

	cout << "UNRESTORABLE" << endl;
}

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

using namespace std;

const int N = 1e4 + 5;

int a[N], b[N], n;
long long suma = 0, sumb = 0, opa = 0, opb = 0;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), suma += a[i];
    for (int i = 1; i <= n; i++) scanf("%d", &b[i]), sumb += b[i];

    if (suma > sumb) printf("No");
    else {
        for (int i = 1; i <= n; i++) {
            if (a[i] >= b[i]) opb += (a[i] - b[i]);
            else {
                if ((b[i] - a[i]) % 2 == 0) opa += (b[i] - a[i]) / 2;
                else {
                    opa += (b[i] - a[i] + 1) / 2;
                    opb++;
                }
            }
        }

        if (suma + max(opa, opb) > sumb) printf("No");
        else printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
    int N,K,i,j;
    int sum=0;
    char S[100002];
    scanf("%d %d",&N,&K);
    scanf("%s",&S);
    i=0;
    for(i = 0 ; i < N ; i++){
        if(S[i] == S[i+1]){
            sum++;
        }
    }
    if( ( sum+2*K ) < ( N-1 )){
        printf("%d",sum+2*K);
    }else{
        printf("%d",N-1);
    }
    return 0;
}

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

int main(){
    int max=-1;
    int n[3];
    int m, k;
    for(int i=0; i<3; i++){
        cin >> n[i];
        if(max<n[i]){
            max=n[i];
            m=i;
        }
    }
    cin >> k;

    while(k!=0){
        n[m]=max*2;
        max=max*2;
        for(int i=0; i<3; i++){
            if(max<n[i]){
                max=n[i];
                m=i;
            }
        }
        k--;
    }

    cout << n[0]+n[1]+n[2] << endl;
    return 0;
}

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

int main()
{
	int i, h_i, h1 = -1, h2 = -1, h3 = -1;

	for ( i = 1; i <= 10; ++i )
	{
		scanf( "%d", &h_i );

		if ( h_i >= h1 )
		{
			h3 = h2;
			h2 = h1;
			h1 = h_i;
		}
		else if ( h_i >= h2 )
		{
			h3 = h2;
			h2 = h_i;
		}
		else if ( h_i >= h3 )
		{
			h3 = h_i;
		}

	}

	printf( "%d\n%d\n%d\n", h1, h2, h3 );

	return EXIT_SUCCESS;
}

Measured memory_bytes: 600
while !((n, x = gets.split.map(&:to_i)).all?(&:zero?))
  num_array = (1..n).to_a
  count = 0
  comb = []
  num_array.each do |f|
    (f..n).each do |s|
      (s..n).each do |t|
        if f + s + t == x && ([f, s, t].count - [f, s, t].uniq.count) == 0
          count += 1
        elsif f + s + t > x
          break
        end
      end
    end
  end
  puts count
end


Measured memory_bytes: 6876
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var s = (Console.ReadLine().Split()).Select(x => int.Parse(x)).ToArray();
        var count = 1;
        if (s[0] != s[1]) count++;
        if (s[0] != s[2] && s[1] != s[2]) count++;
        Console.WriteLine(count);
    }
}

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

void fnInput(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int fnGcdGet(int nNumA, int nNumB)
{
  int nDividend = max(nNumA, nNumB);
  int nDivisor  = min(nNumA, nNumB);

  while (nDividend % nDivisor != 0)
  {
    int nRemain = nDividend % nDivisor;
    nDividend = nDivisor;
    nDivisor  = nRemain;
  }
  return nDivisor;
}

int fnMaxGcd(const vector<int>& cnrvnNum)
{
  vector<int> vnLeftGcd(cnrvnNum.size());
  vector<int> vnRigtGcd(cnrvnNum.size());
  vector<int> vnRemnGcd(cnrvnNum.size());

  vnLeftGcd[0] = cnrvnNum[0];
  
  for (int i = 1; i < cnrvnNum.size(); i++)
    vnLeftGcd[i] = fnGcdGet(vnLeftGcd[i - 1], cnrvnNum[i]);
  
  vnRigtGcd[cnrvnNum.size() - 1] = cnrvnNum[cnrvnNum.size() - 1];

  for (int i = cnrvnNum.size() - 2; i >= 0; i--)
    vnRigtGcd[i] = fnGcdGet(vnRigtGcd[i + 1], cnrvnNum[i]);

  for (int i = 0; i < cnrvnNum.size(); i++)
    if (i == 0)
      vnRemnGcd[i] = vnRigtGcd[i + 1];
    else if (i == cnrvnNum.size() - 1)
      vnRemnGcd[i] = vnLeftGcd[i - 1];
    else
      vnRemnGcd[i] = fnGcdGet(vnLeftGcd[i - 1], vnRigtGcd[i + 1]);
  
  auto it = max_element(begin(vnRemnGcd), end(vnRemnGcd));
  return *it;
}
 
int main()
{
  vector<int> vnNum;

  fnInput(vnNum);
  cout << fnMaxGcd(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 4788
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    string S;
    io >> S;

    int ans;
    if (S == "RRR")
        ans = 3;
    else if (S == "RRS" || S == "SRR")
        ans = 2;
    else if (S == "RSR" || S == "RSS" || S == "SSR" || S == "SRS")
        ans = 1;
    else
        ans = 0;

    io << ans << BR;
}

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n,ans=0;
    string a,b,c;
    cin>>n>>a>>b>>c;
    REP(i,0,n){
        if(a[i]==b[i] && b[i]==c[i]) continue;
        else if(a[i]!=b[i] && a[i]!=c[i] && c[i]!=b[i]) ans+=2;
        else ans++;
    }
    cout<<ans<<ENT;
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;
import java.lang.Math;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int[] x=new int[n];
    int[] y=new int[n];
    for(int i=0;i<n;i++){
      x[i]=Integer.parseInt(scan.next());
    }
    for(int i=0;i<n;i++){
      y[i]=Integer.parseInt(scan.next());
    }
    double ans1=0;
    double ans2=0;
    double ans3=0;
    double ans4=Math.abs(x[0]-y[0]);
    for(int i=0;i<x.length;i++){
      ans1+=Math.abs(x[i]-y[i]);
      ans2+=Math.pow(x[i]-y[i],2);
      ans3+=Math.pow(Math.abs(x[i]-y[i]),3);

      if(i==x.length-1){
        ans2=Math.sqrt(ans2);
        ans3=Math.cbrt(ans3);
      }
      try{
        ans4=Math.max(ans4,Math.abs(x[i]-y[i]));
      }catch(Exception e){
        System.out.println(i);
      }
    }

    System.out.printf("%.8f\n",ans1);
    System.out.printf("%.8f\n",ans2);
    System.out.printf("%.8f\n",ans3);
    System.out.printf("%.8f\n",ans4);
  }
}


Measured memory_bytes: 26408
/*input
2 1 1
1 1 2
1 1 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[maxn],b[maxn],c[maxn];
map<int,int> mp;


int main()
{
	int n,A,B;
	cin>>n>>A>>B;	
	REP(i,n) cin>>a[i]>>b[i]>>c[i];
	{
		REP(i,1<<(n/2)) if(i){
			int cur=0;
			int cost=0;
			REP(j,n/2) if(i&(1<<j)){
				cur+=B*a[j]-A*b[j];
				cost+=c[j];
			}
			if(!mp.count(cur)||mp[cur]>cost) mp[cur]=cost;
		}
	}
	int ans=INF;
	{
		int k=n-n/2;
		REP(i,1<<k){
			int cur=0;
			int cost=0;
			REP(j,k) if(i&(1<<j)){
				cur+=B*a[n/2+j]-A*b[n/2+j];
				cost+=c[n/2+j];
			}
			if(mp.count(-cur)) if(cost+mp[-cur]>0) ans=min(ans,cost+mp[-cur]);
			if(cur==0&&cost!=0) ans=min(ans,cost);
		}
	}
	if(ans==INF) cout<<"-1\n";
	else cout<<ans<<'\n';

	return 0;
}


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


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

    int m;
    cin>>m;
    int ret=abs(x-m);
    for(int i=1;i<n;i++){
        int t;
        cin>>t;
        ret=__gcd(ret,abs(t-x));
    }
    cout<<ret;

}


Measured memory_bytes: 256
#たのん
S=input()
Q=int(input())
head=[]
tail=[]
rev=False
for i in range(Q):
  tmp=list(input().split())
  if tmp[0]=='1':#文字列を反転させる操作のとき
    if rev==False:#反転していない状態であれば反転した状態にする
      rev=True
    else:
      rev=False#反転した状態であれば反転していない状態にする
  if tmp[0]=='2':#文字を追加する操作のとき
    if rev==False:#反転していない状態であれば、先頭への追加はそのまま先頭に、末尾への追加もそのまま末尾に追加する
      if tmp[1]=='1':
        head.append(tmp[2])
      else:
        tail.append(tmp[2])
    if rev==True:#反転した状態であれば、先頭への追加は末尾への追加に、末尾への追加は先頭への追加に置き換える
      if tmp[1]=='1':
        tail.append(tmp[2])
      else:
        head.append(tmp[2])
head=''.join(map(str,head))#文字列として結合しておく
tail=''.join(map(str,tail))

ans=head[::-1]+S+tail#答えは(先頭に追加した文字列の逆順)+(元の文字列)+(末尾に追加した文字列)となる
if rev==True:#もし最終的に文字列が反転した状態なら答えの文字列を反転させる
  ans=ans[::-1]
print(ans)

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

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	ll n, a, b, cur, prev, fat = 0; cin >> n >> a >> b;
	cin >> prev;
	for (int i = 0; i < n-1; i++) {
		cin >> cur;
		fat += min(b, (cur-prev)*a);
		prev = cur;
	}
	cout << fat;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
L=0
R=0
mx=0
mn=100000
for i in range(M):
  L, R = map(int,input().split())
  if L > mx:
      mx=L
  if R < mn:
      mn=R

result =mn-mx+1
if result < 0:
    result = 0
print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<long>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long n,W;
  cin >> n >> W;
  vector<long> w(n);
  vector<long> v(n);
  rep(i,n){
    cin >> w.at(i) >> v.at(i);
  }
  vvi dp(n+1,vi(W+1,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<=W;j++){
      if(j - w.at(i) >= 0){
        dp.at(i+1).at(j) = max(dp.at(i+1).at(j), dp.at(i).at(j-w.at(i)) + v.at(i));
      }
      dp.at(i+1).at(j) = max(dp.at(i+1).at(j),dp.at(i).at(j));
    }
  }
  cout << dp.at(n).at(W) << endl;
}

Measured memory_bytes: 80256
package main

import (
	"fmt"
	"math"
)

func dist(x1, y1, x2, y2 int) float64 {
	dx := float64(x1 - x2)
	dy := float64(y1 - y2)
	return math.Sqrt(dx*dx + dy*dy)
}

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i], &y[i])
	}

	ans := 0.0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			ans += dist(x[i], y[i], x[j], y[j])
		}
	}
	fmt.Println(ans / (float64)(n))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define OFF 48

char field[51][51];

int check(int i, int j)
{
	return (field[i - 1][j - 1] == '#') + (field[i - 1][j] == '#') + (field[i - 1][j + 1] == '#')
		 + (field[i][j - 1] == '#') + (field[i][j + 1] == '#')
		 + (field[i + 1][j - 1] == '#') + (field[i + 1][j] == '#') + (field[i + 1][j + 1] == '#');
}

int main()
{
	int w, h;
	cin >> w >> h;
	memset(field, 0, sizeof(field));
	
	
	for (int i = 0; i < w; i++)
	{
		for (int j = 0; j < h; j++)
		{
			cin >> field[i][j];
		}
	}
	
	for (int i = 0; i < w; i++)
	{
		for (int j = 0; j < h; j++)
		{
			if (field[i][j] == '.')
			{
				field[i][j] = check(i, j) + '0';
			}
		}
	}

	for (int i = 0; i < w; i++)
	{
		for (int j = 0; j < h; j++)
		{
			cout << field[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("0 0 1 2");
            //UURDDLLUUURRDRDDDLLU
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("-2 -2 1 1");
            //UURRURRDDDLLDLLULUUURRURRDDDLLDL
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int SX = wkArr[0];
        int SY = wkArr[1];
        int TX = wkArr[2];
        int TY = wkArr[3];

        //1回目と2回目の移動
        var sb = new System.Text.StringBuilder();
        for (int I = 1; I <= TX - SX; I++) sb.Append('R');
        for (int I = 1; I <= TY - SY; I++) sb.Append('U');
        string wkStr1 = sb.ToString();
        Console.Write(wkStr1);
        Console.Write(DeriveRevStr(wkStr1));

        //3回目と4回目の移動
        sb.Length = 0;
        sb.Append('D');
        for (int I = 1; I <= TX - SX + 1; I++) sb.Append('R');
        for (int I = 1; I <= TY - SY + 1; I++) sb.Append('U');
        sb.Append('L');
        string wkStr2 = sb.ToString();
        Console.Write(wkStr2);
        Console.Write(DeriveRevStr(wkStr2));
        Console.WriteLine();
    }

    //対称をなす移動経路を返す
    static string DeriveRevStr(string pStr)
    {
        var sb = new System.Text.StringBuilder();
        foreach (char EachChar in pStr) {
            if (EachChar == 'R') sb.Append('L');
            if (EachChar == 'L') sb.Append('R');
            if (EachChar == 'U') sb.Append('D');
            if (EachChar == 'D') sb.Append('U');
        }
        return sb.ToString();
    }
}


Measured memory_bytes: 2904
mod = 10**9+7

n, a, b = map(int, input().split())

def comb(n, r):
    c = 1
    for i in range(r):
        c *= n-i
        c %= mod

    d = 1
    for i in range(1, r+1):
        d *= i
        d %= mod

    return (c * pow(d, mod-2, mod)) % mod

ans = pow(2, n, mod) - 1 - comb(n, a) - comb(n, b)

ans %= mod

print(ans)



Measured memory_bytes: 9012
#include<iostream>
#include<cstdio>
using namespace std;
int k,s;
long long res;
int ans[5010];
int main()
{
	scanf("%d%d",&k,&s);
	for(int i=0;i<=2*k;i++)ans[i]=min(i,k)+1-max(i-k,0);
	for(int i=max(0,s-2*k);i<=min(s,k);i++)res+=ans[s-i];
	printf("%lld",res);
	return 0;
}

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

int H,W;
int Ch,Cw,Dh,Dw;
char S[2000][2000] = {0};

typedef struct {int to; long long cost; } edge;
typedef pair<long long,int> P;
int V;
vector<edge> G[1000001];
long long d[1000001];
const long long INF = 100000000000000000ll;


int conv(int i, int j){
	return i * W + j;
}
void dump(){
	for(int t = 0; t < conv(H,W); t++){
		for(int i = 0; i < G[t].size(); i++){
			printf("%d %d %lld\n",t,G[t][i].to,G[t][i].cost);
		}
	}
}
void dump2(){
	for(int i = 0; i < H*W; i++){
		printf("%d %lld\n",i,d[i]);
	}
	printf("target : %d\n",conv(Dh,Dw));
}

void solve(){
	fill(d,d+1000001,INF);
	priority_queue<P,vector<P>,greater<P> > que;
	d[conv(Ch,Cw)] = 0;
	que.push(P(0,conv(Ch,Cw)));
	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	long long x = d[conv(Dh,Dw)];
	if(x == INF) {
		printf("-1\n");
		return;
	}
	x /= 100000000;
	printf("%lld\n",x);
}

int main(){
	scanf("%d%d",&H,&W);
	scanf("%d%d",&Ch,&Cw);
	scanf("%d%d",&Dh,&Dw);
	Ch--; Cw--; Dh--; Dw--;
	for(int i = 10; i < H+10; i++){
		scanf("%s",S[i]+10);
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			edge e;
			int idx = conv(i,j);
			for(int li = i-2; li <= i+2; li++){
				for(int lj = j-2; lj <= j+2; lj++){
					if(li < 0 || li >= H || lj < 0 || lj >= W) continue;
					int si = li + 10;
					int sj = lj + 10;
					if(S[si][sj] != '.') continue;
					if(li == i && (lj == j-1 || lj == j || lj == j+1)){
						e.to = conv(li,lj); e.cost = 1;
						G[idx].push_back(e);
					}
					else if(lj == j && (li == i-1 || li == i+1)){
						e.to = conv(li,lj); e.cost = 1;
						G[idx].push_back(e);
					}
					else{
						e.to = conv(li,lj); e.cost = 100000000;
						G[idx].push_back(e);
					}
				}
			}
		}
	}
	solve();

	return 0;
}


Measured memory_bytes: 308732
# import numpy as np
# import queue
# import heapq


def main():
    N, M, X = map(int, input().split())

    books = [list(map(int, input().split())) for _ in range(N)]

    min_total_cost = 10**9
    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                C, *As = books[j]
                total_cost += C

                for ids, a in enumerate(As):
                    learned[ids] += a

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin(n);
    int pow = 1;
    for(int i=1;i<=n;i++){
        pow *= (i%INF);
        pow %= INF;
    }
    cout<<pow<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll m = 100;
    ll x; cin >> x;
    int i = 0;
    while (m < x) {
        m *= 1.01;
        i++;
    }
    cout << i;
    return 0;
}


Measured memory_bytes: 3636
/**
 *    author:  math2do
 *    created: 22.03.2020 18:09:10
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
  int L;
  cin >> L;
  double d = (double) L / 3;
  cout << d * d * d << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int alice = 0;
    int bob = 0;
    for (int i = N-1; i >= 0; i--) {
      if ((N-1)%2 == i%2) {
        alice += a[i];
      } else {
        bob += a[i];
      }
    }
    
    System.out.println(alice - bob);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
long long x[110000];
long long dp[2100][2100];
int s[2100];
int t[2100];
long long cur[2100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",s+i);
	for(int i=0;i<b;i++)scanf("%d",t+i);
	dp[0][0]=1;
	for(int i=1;i<=a;i++){
		for(int j=0;j<=b;j++){
			cur[j]=(cur[j]+dp[i-1][j])%mod;
		}
		long long tmp=cur[0];
		for(int j=1;j<=b;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=tmp;
			}
			tmp=(tmp+cur[j])%mod;
		}
	}

	long long ret=0;
	for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)ret=(ret+dp[i][j])%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 33408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            long x = long.Parse(lines[0]);
            long y = long.Parse(lines[1]);
            string[] ans = { "Alice", "Brown" };

            Console.WriteLine(ans[Math.Abs(x - y) <= 1 ? 1 : 0]);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(all(vec));
  bool can = true;
  rep(i,n-1){
    if(vec[i] == vec[i+1]){
      can = false;
    }
  }

  if(can){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

using namespace std;

const int N=100005;
char a[N];
int n,cnt;

int judge()
{
    if(a[n]=='1')return 0;
    if(a[1]=='0')return 0;
    if(a[n-1]==0)return 0;
    int i=1,j=n-1;
    while(i<j)
    {
        if(a[i]!=a[j])return 0;
        i++;
        j--;
    }
    return 1;
}

void solve()
{
    cnt=0;
    int root=0,num=0;
    for(int i=1;i<=n-1;i++)
    {
        if(a[i]=='0')continue;
        int newroot=++cnt;
        for(int j=num+1;j<i;j++)
        {
            cout<<++cnt<<" "<<newroot<<endl;
        }
        if(root!=0)
        {
            cout<<root<<" "<<newroot<<endl;
        }
        root=newroot;
        num=i;
    }
    cout<<root<<" "<<++cnt<<endl;
}

int main()
{
    scanf("%s",a+1);
    n=strlen(a+1);
    if(!judge())
    {
        printf("-1\n");
        return 0;
    }
    solve();
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int n,k,i=1;
int main(){
	cin>>n>>k;
	for(int j=1;j<=n;j++)
	{
		if(i<=k) i*=2;
		else i+=k;
	}
	cout<<i;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
MAX = max(A)
count = A.count(MAX)
if count >= 2:
    for i in range(N):
        print(MAX)
else:
    for i in range(N):
        if A[i] == MAX:
            SECOND = max(A[:i] + A[i+1:])
            print(SECOND)
        else:
            print(MAX)


Measured memory_bytes: 15604
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		if(N.equals("ABC")) {
		N="ARC";
		}else {
			N="ABC";
		}
		System.out.println(N);
	}
}

Measured memory_bytes: 35620
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())

    for i in range(N//7 + 1):
        for j in range(N//4 + 1):
            if 7*i + 4*j == N:
                print("Yes")
                return
    
    print("No")


if __name__ == '__main__':
    main()

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

using namespace std;

const int N = 2e5 + 5;

int n, a[N], b[N], ans;
int ca[N], cb[N];

int main(){
      cin >> n;

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

      for(int i = 1; i <= n; i ++)
            cin >> b[i];

      for(int bit = 0; bit <= 28; bit ++){
            int cnt = 0, T = 1 << bit;

            for(int i = 1; i <= n; i ++)
                  ca[i] = a[i] % (T * 2), cb[i] = b[i] % (T * 2);

            sort(cb + 1, cb + n + 1);

            for(int i = 1; i <= n; i ++){
                  int l, r;
                  l = lower_bound(cb + 1, cb + n + 1, T - ca[i]) - cb;
                  r = upper_bound(cb + 1, cb + n + 1, 2 * T - ca[i] - 1) - cb;
                  cnt += r - l + 1;
                  l = lower_bound(cb + 1, cb + n + 1, 3 * T - ca[i]) - cb;
                  r = upper_bound(cb + 1, cb + n + 1, 4 * T - ca[i] - 1) - cb;
                  cnt += r - l + 1;
            }

            if(cnt & 1) ans += 1 << bit;
      }

      cout << ans << endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x < 1200){
			System.out.print("ABC");
		}else{
			System.out.print("ARC");
		}
	}
}

Measured memory_bytes: 23764
let () = Scanf.scanf "%d %d %d" (fun n a b ->
  let visited_a = Array.make_matrix n n false in
  let visited_b = Array.make_matrix n n false in
  let dp_a = Array.make_matrix n n None in
  let dp_b = Array.make_matrix n n None in
  let rec alice a b =
    match dp_a.(a).(b) with
    | Some b -> b
    | None ->
        if visited_a.(a).(b) then None
        else begin
          visited_a.(a).(b) <- true;
          begin
          [a - 1; a + 1]
          |> List.filter (fun a -> 0 <= a && a <> b && a < n)
          |> (fun as_ ->
              if List.exists (fun a ->
                match borys a b with
                | None -> false
                | Some b -> not b) as_ then Some true
              else if List.for_all (fun a ->
                match borys a b with
                | None -> true
                | Some b -> b) as_ then Some false
              else None)
          |> (fun r ->
              dp_a.(a).(b) <- Some r;
              visited_a.(a).(b) <- false; r)
          end
        end
  and borys a b =
    match dp_b.(a).(b) with
    | Some b -> b
    | None ->
        if visited_b.(a).(b) then None
        else begin
          visited_b.(a).(b) <- true;
          begin
          [b - 1; b + 1]
          |> List.filter (fun b -> 0 <= b && a <> b && b < n)
          |> (fun bs ->
              if List.exists (fun b ->
                match alice a b with
                | None -> false
                | Some b -> not b) bs then Some true
              else if List.for_all (fun b ->
                match alice a b with
                | None -> true
                | Some b -> b) bs then Some false
              else None)
          |> (fun r ->
              dp_b.(a).(b) <- Some r;
              visited_b.(a).(b) <- false; r)
          end
        end in
  alice (a - 1) (b - 1)
  |> (function Some true -> "Alice" | Some false -> "Borys" | None -> "Draw")
  |> print_endline)

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  sort(a,a+n);
  int min_sum=0;
  for(int i=0;i<k;i++)
  {
    min_sum+=a[i];
  }
  
  cout<<min_sum<<"\n";
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
//sort(y,y+j, greater<int>
ll x[1000000];
int main()
{
    ll a,b,c,d,e,i,j,k=0,n,sq,mul,r;
    char s[10000],z[1000];
    in>>a;
    for(i=0;i<a;i++)
    {
        out<<"ACL";
    }

}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int> >vv(m+1);
    rep(i,n){
        int a,b;cin>>a>>b;
        if(a<=m)vv[a].push_back(b);
    }
    priority_queue<int> pq;
    ll ans=0;
    rep(i,m){
        rep(j,vv[i+1].size())pq.push(vv[i+1][j]);
        if(!pq.empty()){
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll X, A;
    cin >> X >> A;

    cout << (X<A ? 0 : 10) << endl;
    return 0;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)
ans = 0

for i in range(1 << (n-1)):#+を入れるかどうか
    fomula = s[0]
    for j in range(n-1):#+を入れるかどうか
        if i & (1 << j):#bitで考えるとわかりやすい
            fomula += "+"
        fomula += s[j+1]

    ans += eval(fomula)

print(ans)


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int X, Y, Z; cin >> X >> Y >> Z;
  cout << (X - Z) / (Y + Z) << endl;
  return 0;
}


Measured memory_bytes: 256