akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <> POINT read<POINT>() { int x, y; cin >> x >> y; return POINT(x, y); }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
	isPrime = vector<unsigned char>(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, n)
	{
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i * 2; j <= n; j += i)
			isPrime[j] = false;
	}
}
/// template end ///

static int fromMcxi(const string &s, map<char, int> &m)
{
	int ret = 0;
	int k = 1;
	for(auto c : s)
	{
		if (isdigit(c & 0xFF)) { k = c - '0'; }
		else { ret += k * m[c]; k = 1; }
	}
	return ret;
}

static string toMcxi(int n, map<char, int> &m, const string &order)
{
	string ret;
	for (char c : order)
	{
		int x = m[c];
		if (n >= x)
		{
			if (n / x > 1)
			{
				ret.push_back(n / x + '0');
			}
			ret.push_back(c);
			n %= x;
		}
	}
	return ret;
}


void solve()
{
	READ(int, datasets);
	REP(dataset, datasets)
	{
		READ(string, a, b);
		map<char, int> m;
		m['m'] = 1000; m['c'] = 100; m['x'] = 10; m['i'] = 1;
		write(toMcxi(fromMcxi(a, m) + fromMcxi(b, m), m, "mcxi"));
	}
}

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

int main(void) {
    
    string s;cin >> s;
    cout << "2018/01/" << s[8] << s[9] << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.next();
        String s2[] = s1.split("");
        int count = 0;
        if(s2[0].equals("1")){
            count++;
        }
        if(s2[1].equals("1")){
            count++;
        }
        if(s2[2].equals("1")){
            count++;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35588
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int m,sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&m);
		if(m%2==1)
			sum++;
	}
	if(sum%2==0) printf("YES");
	else printf("NO");                
	return 0;
}

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

int main() {
    ll K;
    cin >> K;
    queue<ll> que;
    for (int i=1; i<=9; i++) {
        que.push(i);
    }

    ll x;
    for (ll i=0; i<K; i++) {
        x = que.front();

        if (x%10 != 0) {
            que.push(10*x + (x%10-1));
        }

            que.push(10*x + (x%10));

        if (x%10 != 9) {
            que.push(10*x + (x%10+1));
        }

        que.pop();
    }

    cout << x << endl;
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int X,Y,Z;
cin >> X >> Y >> Z;

cout << (X-Z)/(Y+Z) << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n), b(n), c(n - 1);
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n - 1)cin >> c[i];
	rep(i, n)a[i]--;
	int ans = 0;
	rep(i, n) {
		ans += b[a[i]];
		if (i >= 1) {
			if (a[i] - 1 == a[i - 1]) {
				ans += c[a[i-1]];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;


int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

vector<string> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int H, W;
bool seen[510][510];

void dfs(int h, int w)
{
    seen[h][w] = true;
    for (int dir = 0; dir < 4;dir++)
    {
            int nh = h + dx[dir];
            int nw = w + dy[dir];
        
        if(nh < 0|| nh >= H || nw < 0 || nw >= W){
            continue;
        }
        if(field[nh][nw] == '#'){
            continue;
        }
        if(seen[nh][nw]){
            continue;
        }
        dfs(nh, nw);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    int N;
    cin >> N;
    set<ll> st;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        st.insert(A);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B;
    int ans[3];
    cin >> A >> B;
    ans[0] = A * 2 - 1;
    ans[1] = A + B;
    ans[2] = B * 2 - 1;
    cout << max({ans[0], ans[1], ans[2]}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<ll> L(M), R(M);
    vector<vector<ll>> t_num(N, vector<ll>(N, 0));
    for (ll i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
        t_num[L[i]][R[i]]++;
    }

    for (ll i = 0; i < N; i++) {
        for (ll j = 1; j < N; j++) {
            t_num[i][j] += t_num[i][j - 1];
        }
    }
    for (ll j = 0; j < N; j++) {
        for (ll i = N - 2; i >= 0; i--) {
            t_num[i][j] += t_num[i + 1][j];
        }
    }

    vector<ll> p(Q), q(Q);
    for (ll i = 0; i < Q; i++) {
        cin >> p[i] >> q[i];
        p[i]--;
        q[i]--;
    }

    for (ll i = 0; i < Q; i++) {
        cout << t_num[p[i]][q[i]] << endl;
    }
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin>>N;
    vector<ll> A;
    rep(i,0,N){
        ll a;
        cin>>a;
        A.pb(a+N-i-1);
    }
    rev(A);
    if(A[N-1]!=N-1){
        cout <<-1<<"\n";
        return 0;
    }
    rep(i,0,N-1){
        if(A[i]>A[i+1]){
            cout <<-1<<"\n";
            return 0;
        }
    }
    ll ans=0;
    vector<ll> sum;
    sum.pb(1);
    rep(i,1,N){
        if(A[i]>A[i-1]) sum.pb(sum[i-1]+1);
        else sum.pb(sum[i-1]);
    }
    uniq(A);
    rep(i,1,N){
        ll t=sum[i-1]-(lb(A,i)-A.begin());
        ans+=max(t,ll(0));
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 4848
n, k = input().split()
n = int(n)
k = int(k)

count = 0
for i in range(1,n+1):
    if int(n/i)*(i-k) > 0:
        count += int(n/i)*(i-k)
        #print("{}:{}".format(i, int(n/i)*(i-k)))
    if (n % i) + 1 - k > 0:
        count += n%i+1-k
        if k==0:
            count -= 1
            #print("{}:{}".format(i,n%i-k))
        #else:
            #print("{}:{}".format(i,n%i+1-k))
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

const int INF = 1e9 + 7;

int d[ARRAY_MAX];
int cnt[ARRAY_MAX];//[0,24)
int tm[ARRAY_MAX];//[0,24)

int count() {

	int mini = INF;

	for (int i = 0; i < 24; i++) {
		for (int j = 0; j < 24; j++)
		{
			if (i == j)
			{
				continue;
			}

			if (tm[i] == 0 || tm[j] == 0)
			{
				//この時間に両方ない場合
				continue;
			}
			int d1 = abs(i - j);
			int d2 = 24 - d1;
			mini = min(mini, min(d1, d2));
		}
	}
	return mini;
}


int solve() {

	if (cnt[0] > 0) {
		//自分以外にもう1人存在
		return 0;
	}
	tm[0] = 1;

	if (cnt[12] >= 2)
	{
		//12時は１通りしか置き方がないので2人いるときは差は0
		return 0;
	}
	else if (cnt[12] == 1)
	{
		tm[12] = 1;
	}


	vector<int> v;//確定していない候補
	
	//[1,11]の範囲
	for (int i = 1; i < 12; i++) 
	{
		if (cnt[i] > 2)
		{
			//同じ時間に2人いるケース
			return 0;
		}
		else if (cnt[i] == 2)
		{
			//配置の仕方は一意に決まるケース
			tm[i] = tm[24 - i] = 1;
		}
		else if (cnt[i] == 1)
		{
			//2通りあるので調べる候補
			v.push_back(i);
		}
	}

	int siz = v.size();
	if (siz == 0)
	{
		//調べる候補がなかった場合
		return count();
	}
	
	int ans = 0;
	//まだ確定していないものがあるので全探索
	for (int i = 0; i < (1 << siz); i++)
	{
		for (int j = 0; j < siz; j++)
		{
			//2通り調べるのでbitを見てどちらに置くか決める
			if ((i >> j) & 1)
			{
				//午前
				tm[v[j]] = 1;
				tm[24 - v[j]] = 0;
			}
			else
			{
				//午後
				tm[v[j]] = 0;
				tm[24 - v[j]] = 1;
			}
		}
		//最小値の最大化
		ans = max(ans, count());

	}
	return ans;

}




int main() {


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

	int n;
	cin >> n;
		
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
		cnt[d[i]]++;
	}

	cout << solve() << endl;

	return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

ll n,a,b;
string s;
int main() {
    cin >> n >> a >> b;
    cin >> s;

    rep(i,0,n){
        if(s[i] == 'c') printf("No\n");
        else if(s[i] == 'a' && 0 < a+b) {
            printf("Yes\n");
            a--;
        }
        else if(s[i] == 'b' && 0 < a+b && 0 < b) {
            printf("Yes\n");
            b--;
        }
        else printf("No\n");

    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int xr[N];
int pl[N];
map<int,int> ex;
map<pii,int> to; 
int main(){
  int n; scanf("%d",&n);
  FILL(pl,-1);
  REP(i,n) scanf("%d",&xr[i]),xr[i]--;
  REP(i,n){
    pl[xr[i]]=i;
    if(i){
      to[mp(xr[i],i)]=i;
    }
  }
  REP(i,n*n){
    if(pl[i]!=-1){
      if(to.count(mp(i,pl[i]))){
     //   printf("%d %d\n",i,pl[i]);
        printf("No\n"); exit(0);
      }
      if(pl[i]<n-1){
        ex[pl[i]]=n-1-pl[i];
      }
    }else{
      if(to.size()){
        pii z = to.begin()->X;
        pl[i]=z.Y;
     //   printf("%d %d\n",i,pl[i]);
        to[z]--;
        if(to[z]==0) to.erase(z);
      }else if(ex.size()){
        int x = ex.begin()->X;
        pl[i]=x;
       // printf("zz%d %d\n",i,pl[i]);
        ex[x]--;
        if(ex[x]==0) ex.erase(x);
      }else{
      //  printf("gg %d %d\n",i,pl[i]);
        printf("No\n"); exit(0);
      }
    }
  }
  if(to.size()!=0||ex.size()!=0) {
    assert(0);
    printf("No\n"); exit(0);
  }
  printf("Yes\n");
  REP(i,n*n) printf("%d%c",pl[i]+1,(i+1==n*n)?'\n':' ');
  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define int long long
#define MAXN 1000005
int n,m,i,s,minv=1e10,a[MAXN];
inline int min(int x,int y){return x<y?x:y;}
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void print(int x)
{
    if (x<0)
        putchar('-'),x=-x;
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
signed main(void)
{
	read(n);
	for (i=1;i<=n;i++)
	{
		read(a[i]);
		minv=min(minv,abs(a[i]));
		s+=abs(a[i]);
		if (a[i]<0)
			m++;
	}
	if (m%2==0)
		print(s);
	else
		print(s-2*minv);
	return 0;
} 

Measured memory_bytes: 1024
use std::io;
use std::str::FromStr;
use std::f64::consts;

fn main(){
    let mut buf = String::new();

    let _ = io::stdin().read_line(&mut buf);
    let r : f64 = f64::from_str(buf.trim()).unwrap();

    println!("{:.6} {:.6}", r*r*consts::PI, 2.0*r*consts::PI);
}



Measured memory_bytes: 5052
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll N;
    cin >> N;
    map<ll, ll>cnt;
    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    vector<ll>v;
    for(map<ll, ll>::iterator it = cnt.begin(); it != cnt.end(); it++){
        v.push_back((*it).first);
    }
    if(v.size() == 1 && v[0] == 0){
        cout << "Yes" << endl;
        return 0;
    }
    if(v.size() == 2 && v[0] == 0){
        if(cnt[v[0]] * 2 == cnt[v[1]] && cnt[v[0]] + cnt[v[1]] == N){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(v.size() == 3 && (v[0] == (v[1] ^ v[2]))){
        if(cnt[v[0]] == cnt[v[1]] && cnt[v[1]] == cnt[v[2]] && cnt[v[0]] * 3 == N){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 6264
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod = 1000000007;
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    vector< vector<int> > v(3);
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            int tmp_c;
            cin >> tmp_c;
            v[i].push_back(tmp_c);
        }
    }
    int a = 0;
    int b = 0;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            a += v[i][j];
            if(i==j){
                b += v[i][j];
            }
        }
    }
    if(a == b*3) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n;
            while((n = scn.nextInt() / 4) > 0) {
                int sum = 0;
                for(int i = 0; i < n; i++) {
                    sum += scn.nextInt();
                }
                System.out.println(sum);
            }
        }
    }
}

Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  string s; cin >> s;

  int ans = 0, res = 0;
  for(int i = 0; i < s.size(); i++){
    while(s[i] == 'R'){
      i++;
      res++;
    }
    ans = max(ans, res);
    res = 0;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, mini = 0;
    cin >> N;
    vector<int> A(9);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a >= 3200) {
            A.at(8)++;
            continue;
        }
        A.at(a / 400)++;
    }
    for (int i = 0; i < 8; i++) {
        if (A.at(i) != 0) {
            mini++;
        }
    }
    cout << max(1, mini) << " " << mini + A.at(8) << endl;
}


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

int main() {
    int N; cin >> N;
    int X[N];
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    int ans,sum;
    ans = 10000000;
    for (int i = 0; i < 100; i++)
    {
        sum = 0;
        for (int j = 0; j < N; j++)
        {
            sum += (X[j]-i)*(X[j]-i);
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a,b = LI()
    if min(a % 3, b%3, (a+b)%3) == 0:
        return 'Possible'

    return 'Impossible'


print(main())





Measured memory_bytes: 8132
#include <stdio.h>
int main(void)
{
  int k, s, i, j, z, cou=0;
  scanf("%d %d", &k, &s);

  for(i = 0; i <= k; i++){
    for(j = 0; j <= k; j++){
      z = s-i-j;
      if(0 <= z && z <= k){
	if(i+j+(s-i-j) == s) cou++;
      }
    }
  }
  printf("%d\n", cou);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    string s;
    cin >> s;

    for(int i=0; i<(int)s.size(); i++){
        cout << 'x';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int i, sum;
    char c;
    
    while (1) {
        sum = 0;
        for ( i=0; (c=getchar()) != '\n'; ++i) {
            if ( i == 0 && c == '0') /* 入力が 0 だった */
                return 0;
            sum += c - '0';
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9+7;
 ll n , k;
void mult(ll **a , ll **b , ll n)
{
    ll c[n][n];
    memset(c , 0 , sizeof(c));
   
    for(ll i= 0 ; i< n ; i++)
    {
        for(ll j = 0 ; j < n ; j++)
        {
            for(ll k = 0 ; k <  n ; k++)
            {
                ll temp = (a[i][j]*b[j][k])%mod;
                c[i][k] += temp;
                if(c[i][k] >= mod)
                c[i][k] -= mod;
            }
        }
    }
   

    for(ll i =0 ; i < n ; i++)
    {
        for(ll j  = 0  ; j < n ; j++)
        a[i][j] = c[i][j];
    }
}


int main() { 
   cin >> n >> k;
   ll **g;
   g = (ll **)malloc(n * sizeof *g);

   for(ll i = 0 ;   i < n ; i++)
   g[i] = (ll *)(malloc(n* sizeof *g[i]));


   for(ll i = 0 ; i < n ;  i++)
    for(ll j = 0 ; j < n  ;j++)
        cin >> g[i][j];
   ll **res;
   res = (ll **)malloc(n * sizeof *res);

   for(ll i = 0 ;   i < n ; i++)
   res[i] = (ll *)malloc(n* sizeof *res[i]);

   for(ll i = 0 ; i <n ; i++)
   {
       for(ll j =0 ; j < n ; j++)
       {
           if(i == j)
           res[i][j] = 1;
           else
           res[i][j] = 0;
       }
   }

 
   
   while(k)
   {
       if(k&1)
        mult(res , g ,n);
       k = k >> 1;
       mult(g , g , n);
   }
   ll ans = 0;
   for(ll i = 0 ; i <n ; i++)
   {
       for(ll j = 0 ; j < n  ;j++)
       {
           ans += res[i][j];
           if(ans >= mod)
           ans -= mod;
       }
   }

   cout << ans;
}


Measured memory_bytes: 3692
sentence = input()
slist = sentence.split("BC")
res = 0
a = 0
for l in slist:
  if ("B" in l) or ("C" in l) :
    l = l.replace("C", "B")
    al = l.split("B")
    a = len(al[-1])
    res += a
  else:
    a += len(l)
    res += a
else:
  res -= a
print(res)

Measured memory_bytes: 47344
#include<bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
using namespace std;
const int INF=1e17+5;
const int maxn=1e5+5;
int n,m,a[maxn],b[maxn],ans,sum;

int32_t main()
{
    IOS;
    cin>>n>>m;
    int tt=INF,zuo;
    fu(i,1,n)
    {
        int t=m+i-1;
        ans+=t;
        if(abs(t)<tt)
        {
            tt=abs(t);
            zuo=i;
        }
    }
    cout<<ans-(m+zuo-1);
    return 0;
}

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

int main() {
	int syo,tyu,dai;
	cin >> syo >> tyu >> dai;
	if(syo > tyu){
		swap(syo,tyu);
	}
	if(tyu > dai){
		swap(tyu,dai);
	}
	if(syo > tyu){
		swap(syo,tyu);
	}
	cout << syo << " " <<  tyu << " " << dai << endl;
	return 0;
}

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

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

  if(d == 25){
    cout << "Christmas" <<endl;
  }
  if(d == 24){
    cout << "Christmas Eve" <<endl;
  }
  if(d == 23){
    cout << "Christmas Eve Eve" <<endl;
  }
  if(d == 22){
    cout << "Christmas Eve Eve Eve" <<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector< vector< int > >  ar(n);
    for(int i=0;i<m;i++)
    {
        int k; cin>>k;
        for(int j=0;j<k;j++)
        {
            int u; cin>>u;u--;
            ar[u].push_back(i);
        }
    }
    int p[m];
    for(int i=0;i<m;i++)
        cin>>p[i];
        int ans=0;
    for(int i=0;i<(1<<n);i++)
    {
        int b[m]; memset(b,0,sizeof(b));
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                for(auto x : ar[j])
                    b[x]++;
            }
        }
        int y=1;
        for(int i=0;i<m;i++)
            if(p[i]!=(b[i]%2))y=0;
            ans+=y;
    }
    cout<<ans;
      return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;

  int ok=0;
  rep(i,b){
    if(i*a%b==c) ok=1;
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
} 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

int gcd(int a, int b){
    if (b == 0) {
        return a;
    }
    return gcd(b, a%b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}


void solve(){
    ll N;
    cin >> N;

    vector<ll> A(3*N);
    for (int i = 0; i < 3*N; i++) {
        cin >> A[i];
    }
    sort(all(A), greater<ll>());

    ll ans = 0;
    ll itr = 0;
    for (int i = 1; itr < N; i+= 2) {
        ans += A[i];
        // cout << A[i] << ", " << itr << endl;
        itr++;
    }

    cout << ans << endl;


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#define endl '\n'
#define ll long long

using namespace std;

bool visited[26];
int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	string str; cin >> str;

	for (int i = 0; i < str.size(); i++)
	{
		if (visited[str[i] - 'a']) { cout << "no"; return 0; }
		visited[str[i] - 'a'] = true;
	}
	cout << "yes";
	return 0;
}

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

int main() {
	string s;
  	cin >> s;
  	int ans = 0;
  	for(int i = 0;i < 4;i++){
      if(s.at(i) == '+'){
        ans++;
      }else if(s.at(i) == '-'){
        ans--;
  	}
   }
  	cout << ans << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[5050];
int num[5050];
ll fact[5050];
ll C[5050][5050];
ll mo=1000000007;
ll from[5050];
ll to[5050];

pair<int,int> dfs_center(int cur,int pre) {
	pair<int,int> res=make_pair(1<<30,-1);
	int ma=0;
	num[cur]=1;
	
	FORR(r,E[cur]) if(r!=pre) {
		res=min(res,dfs_center(r,cur));
		ma=max(ma,num[r]);
		num[cur]+=num[r];
	}
	return min(res,make_pair(max(ma,N-num[cur]),cur));
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	FOR(i,5005) for(j=0;j<=i;j++) C[i][j]=(j==0||j==i)?1:(C[i-1][j-1]+C[i-1][j])%mo;
	fact[0]=1;
	for(i=1;i<=5000;i++) fact[i]=fact[i-1]*i%mo;
	pair<int,int> p=dfs_center(0,-1);
	
	FOR(i,N) if(num[i]*2==N) {
		ll ret=1;
		for(i=1;i<=N/2;i++) ret=ret*i%mo;
		cout<<ret*ret%mo<<endl;
		return;
	}
	
	vector<int> V;
	V.push_back(N-num[p.second]);
	FORR(e,E[p.second]) if(num[e]<num[p.second]) V.push_back(num[e]);
	int tot=0;
	from[0]=1;
	FORR(v,V) {
		ZERO(to);
		FOR(x,tot+1) FOR(y,v+1) {
			(to[x+y]+=from[x]*C[v][y]%mo*C[v][y]%mo*fact[y])%=mo;
		}
		tot+=v;
		swap(from,to);
	}
	
	ll ret=0;
	FOR(i,N) (ret+=mo+(i%2==0?1:-1)*fact[N-i]*from[i])%=mo;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 197888
#include <iostream>
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <functional>
#include <climits>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << a * b - a - b + 1;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    int n = s.length();
    int ans = 0;
    rep(i,n) if (s[i] != t[i]) ans++;
    cout << ans << '\n';
    return 0;
}

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

using namespace std;
typedef long long ll;

const int N=3005,P=1000000007;
int n,m;
ll dp[N][N][2],ans;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n;i++)dp[0][i][0]=1;
	for(int i=0;i<m;i++)for(int j=0;j<=n;j++)
		if(dp[i][j][0]||dp[i][j][1]){
			ll w0=dp[i][j][0]%P,w1=dp[i][j][1]%P;
			if(j>0){
				dp[i+1][j-1][1]+=w1,dp[i+1][j][1]+=w1;
				dp[i+1][j-1][j==1]+=w0,dp[i+1][j][j==1]+=w0;
			}
			if(j<n){
				dp[i+1][j+1][1]+=w1,dp[i+1][j][1]+=w1;
				dp[i+1][j+1][j==0]+=w0,dp[i+1][j][j==0]+=w0;
			}
		}
	for(int j=0;j<=n;j++) ans+=dp[m][j][1];
	printf("%lld\n",ans%P);
	return 0;
}

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

int main() {
	string a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;

	int ia = 0;
	int ib = 0;
	int ic = 0;

	char next = 'a';
	char ans;

	while (true) {
		if (next == 'a') {
			if (a.length() == ia) {
				ans = 'A';
				break;
			}
			next = a[ia];
			++ia;
		}

		else if (next == 'b') {
			if (b.length() == ib) {
				ans = 'B';
				break;
			}
			next = b[ib];
			++ib;
		}
		
		else {
			if (c.length() == ic) {
				ans = 'C';
				break;
			}
		    next = c[ic];
		    ++ic;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,res=0;
    cin>>n;
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        if(x==y)
        ++res;
        else
        res=0;
        if(res==3)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    int digb = 0;
    int tmp = b;
    while (tmp > 0) {
        tmp /= 10;
        digb++;
    }
    int n = a*pow(10, digb) + b;
    if ((int)sqrt(n) == (double)sqrt(n)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(auto &a : v) cin>>a;
    ll ret = 0;
    for(int left=0;left<=k;left++){
        for(int right=0;left+right<=min(n,k);++right){
            int drop = max(0,k - (left+right));
            ll sum = 0;
            vector<int> minus;
            for(int l=0;l<min(left,n);++l){sum+=v[l];if(v[l]<0)minus.push_back(v[l]);}
            for(int r=0;r<min(right,n);++r){sum+=v[n-r-1];if(v[n-r-1]<0)minus.push_back(v[n-r-1]);}
            if(!minus.empty() and drop >0){
                sort(minus.begin(),minus.end());
                for(int i=0;i<min((int)minus.size(),drop);++i){
                    sum -= minus[i];
                }
            }
            ret = max(ret,sum);
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  string b;
  string c;
  cin >> a >> b >> c;
  if (a[a.length()-1] == b[0] and b[b.length()-1] == c[0]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

Measured memory_bytes: 3628
//author: Harsh :)
//Iterating over each of the 2^n subsets with bitmasking
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define maxN 100007
using namespace std;
int main(){
  fastio;
  ll n = 0, m = 0, x = 0;
  cin >> n >> m >> x;
  ll cost[n] = {0}, ar[n][m] = {0};
  for(ll i = 0; i < n; ++i){
    cin >> cost[i];
    for(ll j = 0; j < m; ++j)
      cin >> ar[i][j];
  }
  ll best = INT_MAX;
  for(ll mask = 0; mask < (1ll << n); ++mask){
    ll curr_sum = 0;
    ll understanding[m] = {0};
    for(ll i = 0; i < n; ++i){
      if(mask & (1ll << i)){
        curr_sum += cost[i];
        for(ll j = 0; j < m; ++j)
          understanding[j] += ar[i][j];
      }
    }
    bool possible = true;
    for(ll i = 0; i < m; ++i){
      if(understanding[i] < x){
        possible = false;
        break;
      }
    }
    if(possible) best = min(best, curr_sum);
  }
  if(best != INT_MAX) cout << best;
  else cout << "-1";
  return 0;
}


Measured memory_bytes: 3648
//2020 4.18 Binary Search

#include <stdio.h>
#define MAX1 100000
#define MAX2 50000
#define NOT_FOUND -1  //1にしていたが、そうするとbinarySearchの戻り値(mid)が1になる場合があり、if(res!=1)のところでカウントをしなくなってしまう。

int binarySearch(int *,int,int);

int main()
{
    int a,b,res=0,cnt=0;
    int i,j;
    int A[MAX1],B[MAX2];

    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&A[i]);
    }

    scanf("%d",&b);
    for(i=0;i<b;i++)
    {
        scanf("%d",&B[i]);

        res=binarySearch(A,a,B[i]);

        if(res!=-1) cnt++;
    }
    printf("%d\n",cnt);

    return 0;
}

int binarySearch(int *A,int n,int key)
{
    int left = 0;
    int right = n;
    int mid;
    while(left < right)
    {
        mid=(left + right)/2;
        if(A[mid] == key) {return mid;}
        else if(key<A[mid]) {right = mid;}
        else left = mid + 1;
    }
    return NOT_FOUND;    
}



Measured memory_bytes: 2388
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>A>>B;
  cout<<max(A-2*B,0)<<endl;
}

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

int main()
{
int N;

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

	cin >> N;

	if( N % 2 == 0 )
		cout << N << endl;
	else
		cout << N * 2 << endl;

	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define re return


template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int) 1e18



void solve(){
	int vet[5], index = 0;
	for(int i = 0; i < 5;i++){
		cin >> vet[i];
		if(vet[i] == 0)
			index = i;
	}
	cout << index+1 << endl;
}
int main(){_
    solve();
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var N = int.Parse(ss[0]);
            var M = int.Parse(ss[1]);

            ss = Console.ReadLine().Split();
            var A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(ss[i]);
            }
            Array.Sort(A);

            var B = new int[M];
            var C = new int[M];
            for (int i = 0; i < M; i++)
            {
                ss = Console.ReadLine().Split();
                B[i] = (int.Parse(ss[0]));
                C[i] = (int.Parse(ss[1]));
            }

            var BC = B.Zip(C, (b, c) => new { b, c })
                .OrderByDescending(p => p.c)
                .ToArray();

            var bcIndex = 0;
            var currentB = BC[bcIndex].b;
            for (int i = 0; i < N; i++)
            {
                if (A[i] >= BC[bcIndex].c) break;

                A[i] = BC[bcIndex].c;
                currentB--;
                if (currentB <= 0)
                {
                    bcIndex++;
                    if (bcIndex >= B.Length) break;
                    currentB = BC[bcIndex].b;
                }
            }

            var sum = 0L;
            foreach (var item in A)
            {
                sum += item;
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 35012
using System;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] x = new int[N];
        int[] y = new int[N];
        int[] h = new int[N];
        for (int i = 0; i < N; i++)
        {
            string[] array = Console.ReadLine().Split(' ');
            x[i] = int.Parse(array[0]);
            y[i] = int.Parse(array[1]);
            h[i] = int.Parse(array[2]);
        }

        int sel = 0;
        for (int i = 0; i < N; i++)
        {
            if (h[i] > 0)
            {
                sel = i;
                break;
            }
        }

        int[,] H = new int[101, 101];

        for (int i = 0; i <= 100; i++)
        {
            for (int j = 0; j <= 100; j++)
            {
                H[i, j] = h[sel] + Math.Abs(x[sel] - i) + Math.Abs(y[sel] - j);
            }
        }

        for (int n = 0; n < N; n++)
        {
            if (n == sel) continue;
            for (int i = 0; i <= 100; i++)
            {
                for (int j = 0; j <= 100; j++)
                {
                    if (H[i, j] <= 0) continue;
                    if (h[n] != Math.Max(H[i, j] - Math.Abs(x[n] - i) - Math.Abs(y[n] - j), 0)) H[i, j] = -1;
                }
            }
        }

        for (int i = 0; i <= 100; i++)
        {
            bool flag = false;
            for (int j = 0; j <= 100; j++)
            {
                if (H[i, j] > 0)
                {
                    Console.WriteLine(i + " " + j + " " + H[i, j]);
                    flag = true;
                    break;
                }
            }
            if (flag) break;
        }
    }
}

Measured memory_bytes: 13220
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
	int n, q;
    cin >> n >> q;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    Query queries[q];
    for(int i = 0; i < q; i++){
        cin >> queries[i].l >> queries[i].r;
        queries[i].l--;
        queries[i].r--;
        queries[i].idx = i;
    }
    sort(queries, queries+q, cmp); 
    // cout << "ll" << endl;
    // cout << n << q << endl;
    // for(int i = 0; i < n; i++){
    //     cout << a[i] << endl;
    // }
    // for(int i = 0; i < q; i++){
    //     cout << queries[i].l << queries[i].r << queries[i].idx << endl;;
    // }
    answeringQueries(a, n, queries, q); 
    return 0; 
} 


Measured memory_bytes: 19400
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<utility>
#include<cstring>
using namespace std;
int main() {
    long long n;
    cin >> n;
    long long now = n, count = 0, len = 0;
    while (now >= 1) {
        count++;
        now /= 2;
    }
    len = (1ll << count) - 1;
    cout << len;
    return 0;
}

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

using namespace std;

int br[300000];

int main()
{
    int n,q,i,l,r,j,c;
    cin>>n>>q;
    char ar[300000];
    cin>>ar;
    i=0;
    br[0]=0;
    while(ar[++i]!='\0'){

       if (ar[i]=='C' && ar[i-1]=='A') {

          br[i]=br[i-1]+1;

       }
       else br[i]=br[i-1];

    }
    for (i=1;i<=q;++i){

        cin>>l>>r;


        cout<<(br[r-1]-br[l-1])<<endl;


    }

    return 0;

}


Measured memory_bytes: 1280
C = [list(map(int,input().split(" "))) for i in range(3)]
r = max(max(C))+1
flag = False
for a1 in range(r):
    for a2 in range(r):
        for a3 in range(r):
            if list(map(lambda x:x-a1,C[0])) == list(map(lambda x:x-a2,C[1])) and list(map(lambda x:x-a2,C[1]))  == list(map(lambda x:x-a3,C[2])):
                flag = True
                break
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3188