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

int main() {
  int N=0;
  cin >> N;
  int M = N;
  int a=0;
  int b=0;
  
  while (M != 0) {
    b = M % 10;
    a += b;
    M /= 10;
  }
  
  if (N%a == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	const int mod=1e9+7;
	auto mul=[&](int a,int b){return 1LL*a*b%mod;};
	auto fail=[](){cout<<"0\n";exit(0);};
	int n;
	string s;
	cin>>n>>s;
	if(s[0]=='W')fail();
	if(s[2*n-1]=='W')fail();
	vector<char>tmp(2*n);
	tmp[0]='(';
	for(int i=1;i<2*n;i++){
		if(s[i]==s[i-1]){
			if(tmp[i-1]=='(')tmp[i]=')';
			else tmp[i]='(';
		}
		else {
			if(tmp[i-1]=='(')tmp[i]='(';
			else tmp[i]=')';
		}
	}
	int cnt=0;
	int ans=1;
	for(int i=0;i<2*n;i++){
		if(tmp[i]=='(')cnt++;
		else {
			if(cnt==0)fail();
			ans=mul(ans,cnt);
			cnt--;
		}
	}
	if(cnt!=0)fail();
	for(int i=2;i<=n;i++){
		ans=mul(ans,i);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  vector<int>D(N);
  for(int i=0;i<N;i++){
    cin>>D[i];
  }
  int M;
  cin>>M;
  vector<int>T(M);
  for(int i=0;i<M;i++){
    cin>>T[i];
  }

  map<int64_t,int> Q;
  for(int i=0;i<N;i++){
    Q[D[i]]++;
  }
  map<int64_t,int> cnt;
  for(int i=0;i<M;i++){
    cnt[T[i]]++;
  }
  
  for(int i=0;i<M;i++){
    if(cnt[T[i]]>Q[T[i]]){cout<<"NO"<<endl;return 0;}
  }
  cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 29912
<?php
list($A,$B,$C) = explode(' ',fgets(STDIN));
// fscanf(STDIN, "%d %d %d",  $A, $B, $C);
// echo gettype($A);
$sum = 0;
$ans = 'NO';

for ($i = 1; $i <= $B; $i++) {
    // echo $i;
    $sum = $A * $i;
    if ($sum % $B == $C){
        $ans = 'YES';
        break;
     }
    }   
echo $ans;





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

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int m, k;
    cin >> m >> k;
    if(k == 0)
    {
        REP(i, 1 << m) cout << i << " " << i << " \n"[i == ((1 << m) - 1)];
        return 0;
    }

    int sum = 0;
    REP(i, 1 << m)
    {
        if(i != k) sum = sum ^ i;
    }
    if(sum == k)
    {
        cout << k << " ";
        REP(i, 1 << m) if(i != k) cout << i << "  "[i == ((1 << m) - 1)];
        cout << k << " ";
        REP(i, 1 << m) if((1 << m) - i - 1 != k) cout << (1 << m) - i - 1 << "  "[i == ((1 << m) - 1)];
        cout << endl;
    }
    else cout << -1 << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	string s;
	s = to_string(n);
	int sum = 0;
	rep(i,s.size()) {
		char c = '0';
		sum += s[i]-c;
	}
	
	if (n % sum == 0) {
		cout << "Yes" <<endl;
	} else {
		cout << "No" << endl;
	}


	return 0;
}



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

const int INF = 1e9;

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

  vector<vector<int>> g(n);
  rep(i, n-1) {
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  vector<vector<int>> d(n, vector<int>(n, INF));
  queue<int> Q;

  rep(i, n) {
    d[i][i] = 0;
    Q.push(i);
    while (Q.size()) {
      int pos = Q.front();
      Q.pop();
      rep(j, g[pos].size()) {
        int to = g[pos][j];
        if (d[i][to] <= d[i][pos] + 1) continue;
        d[i][to] = d[i][pos] + 1;
        Q.push(to);
      }
    }
  }

  vector<int> res(n, 0);
  rep(i, n) rep(j, n) {
    if (i >= j) continue;
    ++res[d[i][j]];
  }
  for (int i = 1; i < n; ++i) cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 19008
#Combinationクラス
class Combination:
    '''
    計算量：階乗・逆元テーブルの作成O(N)
            nCkを求めるO(1)
    '''

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i] ,MOD - 2 ,MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        '''k!を求める'''
        return self.fact[k]

    def inverse_factorial(self, k):
        '''k!の逆元を求める'''
        return self.inv_fact[k]

    def combination(self, k, r):
        '''kCrを求める'''
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD



from fractions import Fraction


MOD = 10**9 + 7
n, a, b, c = map(int, input().split())

#n-1から2n-2まで
comb = Combination(2*n, MOD)
mod_li = [1]
for i in range(1, 2*n + 1):
    mod_li.append(mod_li[-1] * (a+b) % MOD)
p1 = [1]
p2 = [1]
for i in range(1, n+1):
    p1.append((p1[-1] * a) % MOD)
    p2.append((p2[-1] * b) % MOD)
q = mod_li[2*n-1]
p = 0


for i in range(n):
    tmp_bunshi = (n+i) * (mod_li[n-i-1]) * p1[n] * p2[i] * comb.combination(n-1+i,i)
    tmp_bunshi += (n+i) * (mod_li[n-i-1]) * p2[n] * p1[i] * comb.combination(n-1+i,i)
    p += tmp_bunshi
    p %= MOD
p *= 100
q *= (a+b)
ans = Fraction(p, q)
p = ans.numerator
q = ans.denominator
print((pow(q, MOD-2, MOD) * p) % MOD)

Measured memory_bytes: 85228
import math

x1, y1, x2, y2 = map(int, input().split())

edge = math.sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2),2))

x2 -= x1
y2 -= y1
x3 = x2 - y2
y3 = x2 + y2
x3 += x1
y3 += y1

x4 = -y2
y4 = x2
x4 += x1
y4 += y1


print(x3, y3, x4, y4)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int a[220000];
int ans[220000];
VI dp(220000,INF);
VI edge[220000];

void dfs(int x, int last=-1){
	int lis_idx = lower_bound(ALL(dp),a[x])-dp.begin();
	int last_val = dp[lis_idx];
	dp[lis_idx] = a[x];
	ans[x] = lower_bound(ALL(dp),INF)-dp.begin();
	for(auto to:edge[x]){
		if(to==last) continue;
		dfs(to,x);
	}
	dp[lis_idx] = last_val;
}



signed main(){
	int n,u,v; cin>>n;
	rep(i,n) cin>>a[i];
	rep(i,n-1){
		cin>>u>>v; u--; v--;
		edge[u].PB(v); edge[v].PB(u);
	}
	dfs(0);
	rep(i,n) cout<<ans[i]<<endl;

	return 0;
}


Measured memory_bytes: 28496
import sys
import copy
from collections import deque

count = 0
n, m = (int(x) for x in sys.stdin.readline().split())
a_b_list = [[int(x) for x in sys.stdin.readline().split()] for y in range(m)]
# 始点が1のパスをキューに入れる
q = deque([])
for i in a_b_list:
    if i[0] != 1 and i[1] != 1:
        continue
    if i[0] == 1:
        q.append([1, i[1]])
    if i[1] == 1:
        q.append([1, i[0]])
#  幅優先探索(?)
while len(q) > 0:
    path = q.popleft()
    if len(path) == n:
        count += 1
        continue
    q_q = deque([i for i in range(2, n + 1) if i not in path])
    while len(q_q) > 0:
        destination = q_q.popleft()
        if [path[-1], destination] in a_b_list or [destination, path[-1]] in a_b_list:
            new_path = copy.copy(path)
            new_path.append(destination)
            q.append(new_path)
print(count)


Measured memory_bytes: 4340
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;

int main(void) {
	ll n,k;
	cin >> n>>k;
	
	ll m = n / k;
	ll ans = pow(m, 3);
	if (k % 2 == 0) {
		ll mm = n / (k / 2) - m;
		ans += pow(mm, 3);
	}
	cout <<ans <<endl;

	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
ll mazei[110][110];
int main() {
	cin >> h >> w;
	vector<string> M(h);
	rep(i, h) {
		cin >> M[i];
	}
	vector<bool> G(h, false), R(w, false);
	rep(i, h) {
		rep(j, w) {
			if (M[i][j] == '#') {
				G[i] = true;
				R[j] = true;
			}
		}
	}
	rep(i, h) {
		if (G[i]) {
			rep(j, w) {
				if (R[j]) {
					cout << M[i][j];
				}
			}
			cout << endl;
		}
	}
}

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

using namespace std;

int main(){
	int n, r;
	while (cin >> n >> r, n&&r) {
		vector<int> pc(n);
		for (int i = 0; i < n; i++) pc[i] = n-i;
		for (int i = 0; i < r; i++) {
			int p, c; cin >> p >> c;
			vector<int> tmp(c);
			for (int j = 0; j < c; j++) {
				tmp[j] = pc[p-1+j];
			}
			for (int j = p-2; j >= 0; j--) {
				pc[j+c] = pc[j];
			}
			for (int j = 0; j < tmp.size(); j++) {
				pc[j] = tmp[j];
			}
		}
		cout << pc[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
SP = [sr().split() + [i+1] for i in range(N)]
SP.sort(key = lambda x: (x[0], -int(x[1])))
for x in SP:
    print(x[2])
# 53

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

int main()
{
    
    long long H, W;
    cin >> H >> W;
    
    long long sum = H * W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    if (sum % 2 == 0) {
        cout << sum / 2 << endl;
    }else{
        cout << sum / 2 + sum % 2 << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define ll long long

using namespace std;

ll mod = 1e9 + 7;

ll
get(vector<vector<ll>> & dp, ll start, ll end, vector<ll> & a, vector<ll> & sum) {
  if (start >= end) return 0;

  if (dp[start][end] == -1) {
    ll v = get(dp, start + 1, end, a, sum);
    for (ll right = start + 1; right < end; right++) 
      v = min(v, get(dp, start, right, a, sum) + get(dp, right+1, end, a, sum));
    dp[start][end] = v + sum[end] - sum[start-1];
  }

  return dp[start][end];
}

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

  vector<ll> a(n+1), sum(n+1, 0);
  for (ll i=1; i<=n; i++) {
    cin>>a[i];
    sum[i] = sum[i-1] + a[i];
  }

  vector<vector<ll>> dp(n+1, vector<ll>(n+1, -1));
  cout<<get(dp, 1, n, a, sum)<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 4488
n = int(input())
F = [int("".join(input().split()), 2) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]
num = 1 << 10
ans = -(10 ** 10)


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
    c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
    c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
    c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)
    return c


# print(F)

for i in range(1, num):
    temp = 0
    for j in range(n):
        temp += P[j][popcnt(i & F[j])]
    ans = max(temp, ans)
print(ans)


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

int main() {
    int N; cin >> N;
    vector<int> d(110, 0);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }
    vector<int> bucket(110, 0);
    for (int i = 0; i < N; i++) {
        bucket.at(d.at(i))++;
    }
    int res = 0;
    for (int i = 1; i <= 100; i++) {
        if (bucket.at(i)) {
            res++;
        }
    }
    cout << res << 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);
		String[] a = sc.nextLine().split("",0);
		String[] b = sc.nextLine().split("",0);
		String[] c = sc.nextLine().split("",0);
		int countA = a.length;
		int countB = b.length;
		int countC = c.length;
		String out = null;
		String player = "a";

		while(true){
		    if (player.equals("a")) {
		        if (countA == 0) {
		            out = "A";
		            break;
		        } else {
		            player = a[a.length - countA];
		            countA--;
		        }
		    } else if (player.equals("b")) {
		        if (countB == 0) {
		            out = "B";
		            break;
		        } else {
		            player = b[b.length - countB];
		            countB--;
		        }
		    } else {
		        if (countC == 0) {
		            out = "C";
		            break;
		        } else {
		            player = c[c.length - countC];
		            countC--;
		        }
		    }

		}

		System.out.println(out);
	}
}

Measured memory_bytes: 23764
#akash mandal: jalpaiguri government engineering college
import sys,math

def ii(): return int(input())
def mii(): return map(int,input().split())
def lmii(): return list(mii())


def main():
    s=input()
    if(s.count("RRR")>0):
        print(3)
    elif(s.count("RR")>0):
        print(2)
    elif(s.count("R")>0):
        print(1)
    else:
        print(0)
        
        
      
        
    
    
    
            
        
            
    
        
if __name__=="__main__":
    main() 

Measured memory_bytes: 62068
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

int main()
{
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World\n";
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  int ans = 0;
  rep(i,S.size()) {
    if (S[i] != T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;
const int M=2e5+5;
int a[M],b[M];
int n,ans=0;
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		int x,y;
		cin >>x >>y;
		a[i] = x+y;
		b[i] = y-x;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	ans = max(a[n]-a[1],b[n]-b[1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5368
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int K, S;
    scanf("%d %d", &K, &S);

    long long res=0;
    for (int i=0; i<=K; ++i)
        for (int j=0; j<=K; ++j) {
            int k=S-i-j;
            if (0 <= k && k <= K)
                ++res;
        }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a+2), t(b+2);
    s[0] = -LINF, s[a+1] = LINF;
    t[0] = -LINF, t[b+1] = LINF;
    REP(i, 1, a+1) cin >> s[i];
    REP(i, 1, b+1) cin >> t[i];

    rep(i, q) {
        ll x;
        cin >> x;
        int si = lower_bound(s.begin(), s.end(), x) - s.begin();
        int ti = lower_bound(t.begin(), t.end(), x) - t.begin();

        ll res = LINF;
        rep(i, 2) {
            rep(j, 2) {
                ll sx = s[si-i];
                ll tx = t[ti-j];
                ll d1 = abs(sx - x) + abs(tx - sx);
                ll d2 = abs(tx - x) + abs(sx - tx);
                res = min({res, d1, d2});
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>

using namespace std;
int main(){
	int num_of_facts;
	cin >> num_of_facts;
	int num1,num2;
	int maxnum1 = 0, maxnum2 = 0;
	for(int i = 0; i < num_of_facts; i++){
		cin >> num1;
		cin >> num2;
		if (num1 > maxnum1) {
			maxnum1 = num1;
			maxnum2 = num2;
		}
	}
	cout << maxnum1 + maxnum2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
//#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define sqr(a) a*a*a
#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli i,ans=0,j,n;
    cin>>n;
    map<lli,lli>ma;
    set<lli,lli>se;
    lli a[n];
    vlli v;
    rep(i,0,n)
    {
        cin>>a[i];
        ma[a[i]]++;
        v.pb(a[i]);
    }
    UN(v);
    reverse(ALL(v));
    lli taken=-1;
    rep(i,0,v.sz())
    {
        if(taken!=-1)
        {
            if(ma[v[i]]>=2)
            {
                cout<<taken*v[i];
                exit(0);
            }
        }
        else
        {
            if(ma[v[i]]>=4)
            {
                cout<<v[i]*v[i];
                exit(0);
            }
            else if(ma[v[i]]>=2)
            {
                taken=v[i];
            }
        }
    }
    cout<<0;
    exit(0);
}


Measured memory_bytes: 8052
str = raw_input()
str1 = raw_input()
N,k = map(int, str.split())
array = map(int, str1.split())

INF = 10**8*3
answer = INF

for i in range(N-k+1):
    answer = min(answer, array[i+k-1]-array[i]+min(abs(array[i+k-1]), abs(array[i])))

print answer


Measured memory_bytes: 12264
#include<bits/stdc++.h>
using namespace std;
const int INF = 10000000007;

// helper function to find minimum cost to reach end
int minCost(int* arr, int n, int k)
{
	int *dp = new int[n];

	// fills dp array with INT_MAX
	for(int i = 0; i < n; i++)
	  dp[i] = 100000000007;


    dp[0] = 0;
    
	for(int i = 0; i < n; i++)
    {
    	for(int j = i + 1; j <= i + k; j++)
    	{
    	    if(j < n)
    	        dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
    	}
    }
    
     return dp[n-1];
}


// function to handle input and output
int main()
{
  int n, k;
  cin >> n >> k;

  int a[n];

  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  
  cout << minCost(a, n, k);

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 0) {
			System.out.println(n);
		} else {
			System.out.println(2*n);
		}

	}
}

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

int main() {
    int times;

    cin >> times;

    int num;
    long max = -1000000, min = 1000000, total = 0;


    while(cin >> num){
        total += num;

        if(max < num){
            max  = num;
        }
        if(min > num){
            min = num;
        }
    }
    
    cout << min << " " << max << " " << total << endl;

    return 0;

}


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

int main(){
  ll n;
  cin >> n;
  ll ans = INF;
  for(ll i = 1; i*i <= n; i++) {
    if(n % i == 0) ans = min(ans,i-1+n/i-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define COIN_VALUE 500

int main(void)
{
	int k, x;

	scanf("%d%d", &k, &x);

	/* 持っているコインの総額を計算し、xと比較する */
	if (COIN_VALUE * k >= x)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let gcd: usize = gcd(a, b);

    let pf = prime_factorization(gcd);

    let ans = pf.len() + 1;
    return ans.to_string();
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y > 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    return x;
}

fn prime_factorization(mut n: usize) -> HashMap<usize, usize> {
    let mut result: HashMap<_, _> = HashMap::new();

    for d in 2.. {
        if d * d > n {
            break;
        }
        while n % d == 0 {
            *result.entry(d).or_insert(0) += 1;
            n /= d;
        }
    }

    if n != 1 {
        result.insert(n, 1);
    }

    return result;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << 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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

lb dp[3000][3000];
int main(){

  ll n;cin>>n;
  lb p[n];rep(i,0,n)cin>>p[i];

  dp[0][0]=1.0;

  rep(i,0,n){
    rep(j,0,i+1){
      dp[i+1][j+1]+=dp[i][j]*p[i];
      dp[i+1][j]+=dp[i][j]*(1-p[i]);
    }
  }

  lb ans=0;
  rep(i,(n+1)/2,n+1)ans+=dp[n][i];

  out(fixed<<setprecision(10)<<ans);

  return 0;
}


Measured memory_bytes: 139136
s=input()
m=int(input())
n=len(s)
if n==1:
  print([0,int(s)][m==1])
  exit()
dp=[[[0]*2 for _ in range(m+1)] for _ in range(n)]
dp[0][0][1]=1
dp[0][1][1]=int(s[0])-1
dp[0][1][0]=1
for i in range(1,n):
  for j in range(m+1):
    if j:
      dp[i][j][1]+=9*dp[i-1][j-1][1]
      if s[i]!='0':
        dp[i][j][0]+=dp[i-1][j-1][0]
        dp[i][j][1]+=(int(s[i])-1)*dp[i-1][j-1][0]
    if s[i]=='0':dp[i][j][0]+=dp[i-1][j][0]
    dp[i][j][1]+=dp[i-1][j][1]
    if s[i]!='0':dp[i][j][1]+=dp[i-1][j][0]
print(sum(dp[-1][-1]))

Measured memory_bytes: 62728
H, W = map(int, input().split())
s = []
s.append(['.'] * (W+2))
for i in range(H):
    lis = list('#' + input() + '#')
    s.append(lis)
s.append(['.'] * (W+2))
for i in range(1, H+1):
    for j in range(1, W+1):
        if s[i][j] == '.':
            continue
        if s[i-1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' and s[i+1][j] == '.':
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  	string a;
  	cin>>a;
  	for(int i=0;i<a.size();i++){
     	if(i!=0&&a[i]==a[i-1]){
         	cout<<"Bad"<<endl;
          	return 0;
        }
    }
  	cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nn 500008
#define pii pair<int,int>
#define mp make_pair
vector<pii> cl,cr;
int li[nn],ri[nn],n;

multiset<int> sl,sr;
int nl,nr;
int count[nn];
signed main(){
	sl.insert(1);sr.insert(1e9);
	int ans=0;
	scanf("%d",&n);for(int i=1;i<=n;i++) {
		scanf("%d%d",&li[i],&ri[i]);
		cl.push_back(mp(li[i],i));
		cr.push_back(mp(ri[i],i));
		ans=max(ans,ri[i]-li[i]+1);
	}	
	int ui=ans;
	sort(cl.begin(),cl.end());sort(cr.begin(),cr.end());
	int j=0;nl=cl[cl.size()-1].first,nr=ri[cl[cl.size()-1].second];
	
	for(int k=0;k<cr.size();k++){
		int r=cr[k].first;
		while(j<cr.size() and cr[j].first<min(r,nr)){
			if(cr[j].second!=cl[cl.size()-1].second){
				sl.insert(li[cr[j].second]);
				sr.insert(ri[cr[j].second]);
			}
			
			j++;
		}
		if(r>=nl  and (*sr.begin())-(*--sl.end())+1>=0) 
			ans=max(ans,min(r,nr)-nl+1+min(ui,(*sr.begin())-(*--sl.end())+1) );
	}
	
	cout<<ans;
	return 0;
} 

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	std::vector<int> x(5),y(5);
	std::cin >> x[1] >> y[1] >> x[2] >> y[2];
	int absx,absy;
	absx = x[2] - x[1];
	absy = y[2] - y[1];
	x[3] = x[2] - 1 * absy;
	y[3] = y[2] + absx;
	x[4] = x[3] - 1 * absx;
	y[4] = y[3] - 1 * absy;
	std::cout << x[3] << ' ' << y[3] << ' ' << x[4] << ' ' << y[4] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int min_dist[1002][1002];
const int dd[] = {0, 1, 0, -1, 0};

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

    vector<string> field(H);
    for(auto& e : field){
        cin >> e;
    }

    memset(min_dist, -1, sizeof(min_dist));
    queue<P> que;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(field[i][j] == '#'){
                min_dist[i][j] = 0;
                que.emplace(i, j);
            }
        }
    }
    int ans = 0;
    while(que.size() > 0){
        auto p = que.front();
        que.pop();
        ans = min_dist[p.first][p.second];
        int nd = min_dist[p.first][p.second] + 1;
        for(int k=0;k<4;k++){
            int ni = p.first + dd[k], nj = p.second + dd[k + 1];
            if(ni < 0 || H <= ni || nj < 0 || W <= nj || min_dist[ni][nj] != -1) continue;
            min_dist[ni][nj] = nd;
            que.emplace(ni, nj);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13456
#!/usr/bin/env python3
import sys
INF = float("inf")
import math


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s = max(s, self.tree[i])
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = max(self.tree[i], x)
            i += i & -i


def solve(N: int, h: "List[int]", a: "List[int]"):

    seg = Bit(N+1)

    for i in range(N):
        temp = a[i] + seg.sum(h[i])
        seg.add(h[i], temp)
    print(seg.sum(N+1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46956
#include<bits/stdc++.h>
using ll = long long;
const ll INF = 1000000000000;

void fact(int n, std::map<int,int>& map){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            while(n % i == 0){
                map[i]++;
                n /= i;
            }
        }
    }
    if(n == 1)return;
    map[n]++;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> dp(110);
    std::map<int,int> map;
    for(int i = 2; i <= n; i++){
        std::map<int,int> tmp;
        fact(i,tmp);
        for(auto j : tmp){
            map[j.first] += j.second;
        }
    }
    //二個以上の素因数があるものについて全探索
    int cnt = 0;
    for(auto i : map)if(i.second <= 1)map.erase(i.first);
    //std::map<int,int> cur = map;
    for(auto i = map.begin(); i != map.end(); i++){
        for(auto j = i; j != map.end(); j++){
            for(auto k = map.begin(); k != map.end(); k++){
                if(i == j || j == k || k == i)continue;
                if(i -> second >= 4 && j -> second >= 4 && k -> second >= 2)cnt++;
            }
        }
    }
    for(auto i = map.begin(); i != map.end(); i++){
        for(auto j = map.begin(); j != map.end(); j++){
            if(i == j)continue;
            if(i -> second >= 24 && j -> second >= 2)cnt++;
        }
    }
    for(auto i = map.begin(); i != map.end(); i++){
        for(auto j = map.begin(); j != map.end(); j++){
            if(i == j)continue;
            if(i -> second >= 14 && j -> second >= 4)cnt++;
        }
    }

    for(auto i = map.begin(); i != map.end(); i++){
        if(i -> second >= 74)cnt++;
    }

    std::cout << cnt << std::endl;

    //for(auto i : map)std::cout <<  i.first << " : " << i.second << std::endl;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")

#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

#include<unordered_map>

string a, b, c;
bool ab[8005]={}, bc[8005]={}, ca[8005]={};
int ans = INT_MAX;

const int zure = 4002;
const int parameter = 4000;
const int parameter2 = 4000;

signed main(){
    cin >> a >> b >> c;
    int A = a.size();
    int B = b.size();
    int C = c.size();

    // a と b の相性
    // i : b の先頭を a から見てどこにするか
    for(int i=-parameter; i<=parameter; i++){
        bool ok = true;
        for(int j=max(0,i); j<A&&j-i<B; j++){
            if(a[j] != '?' && b[j-i] != '?' && a[j] != b[j-i]) ok = false;
        }
        ab[zure+i] = ok;
        //cout << i << " " << ok << endl;
    }

    // b と c の相性
    // i : c の先頭を b から見てどこにするか
    for(int i=-parameter; i<=parameter; i++){
        bool ok = true;
        for(int j=max(0, i); j<B&&j-i<C; j++){
            if(b[j] != '?' && c[j-i] != '?' && b[j] != c[j-i]) ok = false;
        }
        bc[zure+i] = ok;
        //cout << i << " " << ok << endl;
    }

    // c と a の相性
    // i : a の先頭を c から見てどこにするか
    for(int i=-parameter; i<=parameter; i++){
        bool ok = true;
        for(int j=max(0, i); j<C&&j-i<A; j++){
            if(c[j] != '?' && a[j-i] != '?' && c[j] != a[j-i]) ok = false;
        }
        ca[zure+i] = ok;
        //cout << i << " " << ok << endl;
    }

    // i : b の先頭を a から見てどこにするか
    // j : c の先頭を a から見てどこにするか
    for(int i=-parameter2; i<=parameter2; i++){
        for(int j=-parameter2; j<=parameter2; j++){
            bool ok = true;
            if(-parameter <= i && i <= parameter) ok &= ab[zure+i];
            if(-parameter <= -j && -j <= parameter) ok &= ca[zure-j];
            if(-parameter <= j-i && j-i <= parameter) ok &= bc[zure+j-i];
            if(ok){
                int l = min({ 0, i, j });
                int r = max({A, B+i, C+j});
                ans = min(ans, r-l);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a,x,y;
    
    cin >>a;
    
    x=a*800;
    
    if(a>=15){
        y=(a/15)*200;
    }                
    else{
        y=0;
    }
    cout <<x-y;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}


int main() {
    string S;
    cin >> S;
    if (S == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3568
#include <stdio.h>

int a[2000010];
int l,r;

int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		char s[99];
		scanf("%s",s);
		if(s[0]=='i')scanf("%d",a+r++);
		else if(s[6]==0){
			int t;
			scanf("%d",&t);
			for(int idx=r-1;idx>=l;idx--)if(a[idx]==t){
				a[idx]=-1;
				break;
			}
		}else if(s[6]=='F')while(a[--r]==-1);
		else while(a[l++]==-1);	
	}
	int f=0;
	for(int i=r-1;i>=l;i--)if(a[i]!=-1)printf(f++?" %d":"%d",a[i]);
	puts("");
}


Measured memory_bytes: 5616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  } else {
    if (h*w % 2 == 0) cout << h*w/2 << endl;
    else cout << h*w/2 + 1 << endl;
  }
}

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;


void task(){
     string ans[]={"AC","WA", "TLE", "RE"};
    map<string, int>mp;
    int n; cin >> n;
    rep(i,n){
     string s; cin >>s;
     mp[s]++;
    }
    for(int i = 0; i<4; i++){
          cout<<ans[i]<<" x "<<mp[ans[i]]<<endl;
    }
    //AC x 3
}

int main(){
        _
        int T = 1; //cin >> T;
        while(T--){
            task();
        }
return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int x,a;cin>>x>>a;
  if(x<a){
    cout<<0<<endl;
  }else{
    cout<<10<<endl;
  }
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let (s, t) = {
        let i = read::<String>();
        (i[0].clone(), i[1].clone())
    };
    print!("{}", t);
    println!("{}", s);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int A[10];
int N,M,Q,a[50],b[50],c[50],d[50];
int ans = 0;

void dfs(int i,const int start,const int end){
    if(i==N){
        int total = 0;
        rep(j,Q){
            if(A[b[j]] - A[a[j]] == c[j]){
                total += d[j];
            }
            ans = max(ans,total);
        }
    }else{
        for(int j=start;j<=end;j++){
            A[i] = j;
            dfs(i+1,j,end);
        }
    }
}

int main(){
    cin >> N >> M >> Q;
    rep(i,Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    dfs(0,1,M);
    cout << ans << endl;
}


Measured memory_bytes: 3612
input()
a=sorted(map(int,input().split()))[::-1]
s={}
l=[2**-~i for i in range(31)[::-1]]
r=0
for v in a:
	for j in l:
		p=j-v
		if p in s and s[p]>0:r+=1;s[p]-=1;break
	else:s[v]=s.get(v,0)+1
print(r)

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}

const ll SIZE = 1e5+10;

ll n;

int main(){
    cin >> n;
    ll ans = n/2;
    if(n%2 != 0)    ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
"""
自分の左に並んでいた人数と自分の右に並んでいた人数の差の絶対値はAi
元の並び方が何通りあるか

N = 3
並び    1 2 3
As      2 0 2

N = 4
並び    1 2 3 4
As      3 1 1 3

2^n通りだろう
"""
N = int(input())
As = list(map(int,input().split()))
As = sorted(As)
mod = 10**9 + 7

if N % 2 == 0:
    A = [(i)//2*2+1 for i in range(N)]
    if As == A:
        print(2**(N//2)%mod)
    else:
        print(0)
else:
    A = [0] + [(i+1)//2*2 for i in range(1,N)]
    if As == A:
        print(2**((N-1)//2)%mod)
    else:
        print(0)

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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle//freopen("in.txt", "r", stdin);//#endif
    //freopen("in.txt", "r", stdin);

    int cnt=0;
    string str;
    cin >> str;
    loop(i,str.length()-1){
        if(str[i]!=str[i+1])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512