akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define H_MAX 100
#define W_MAX 100
#define WALL '#'

constexpr int INF = 1e9;

using std::make_pair;
using std::pair;
using std::queue;
using std::vector;

// grid
using Grid = vector<std::string>;
// gridの左上を(0,0)として(↓,→)の座標
using YX = pair<int, int>;

const vector<YX> MOVES = {
    make_pair(1, 0),  // 下へ
    make_pair(0, 1)   // 右へ
};

// (H_MAX+2) * (W_MAX+2) のvectorで距離を表す。INFで初期化
// 2に意味はない。0でも良い
vector<vector<int>> d(H_MAX + 2, vector<int>(W_MAX + 2, INF));

using BfsRes = pair<int, queue<YX>>;
/**
 * h: グリッドの高さ
 * w: グリッドの幅
 * m: グリッド
 * starts: 始点リスト
 * goal: 終点
 * c: 始点でのコスト(=0)
 *
 * BfsRes: pair<int, queue<YX>>
 *      (コスト(到達不可能時は-1)，壁リスト)
 */
BfsRes bfs(int h, int w, Grid m, queue<YX> starts, YX goal, int c = 0) {
    // 壁リスト
    queue<YX> next;

    // TODO: ここ定数倍重い
    queue<YX> que;
    while (!starts.empty()) {
        YX s = starts.front();
        starts.pop();

        que.push(s);
        // 始点のコストは c(=0)
        if (d.at(s.first).at(s.second) > c) {
            d.at(s.first).at(s.second) = c;
        }
    }

    while (!que.empty()) {
        YX prev = que.front();
        que.pop();
        int py            = prev.first;
        int px            = prev.second;
        bool prev_is_wall = m.at(py).at(px) == WALL;
        int prev_cost     = d.at(py).at(px);  // == c

        // 下右で，通路->壁をせずに行けるところを見ていく
        for (const YX &dm : MOVES) {  // dm: 微小なmove
            int y = py + dm.first;
            int x = px + dm.second;
            if (y >= h || x >= w) continue;

            YX curr           = make_pair(y, x);
            bool curr_is_wall = m.at(y).at(x) == WALL;
            bool pass_to_wall = (!prev_is_wall && curr_is_wall);
            int curr_cost     = prev_cost + (pass_to_wall ? 1 : 0);

            if (curr == goal) return make_pair(curr_cost, next);

            // 最短距離を更新できないなら訪問しない
            if (d.at(y).at(x) <= curr_cost) continue;

            // 通路→壁ならcost++
            if (pass_to_wall) {
                d.at(y).at(x) = curr_cost;  // == c+1
                next.push(curr);
                continue;
            }

            // 最短距離を更新してqueに突っ込む
            d.at(y).at(x) = curr_cost;  // == c
            que.push(curr);
        }
    }

    return bfs(h, w, m, next, goal, c + 1);
}

void agc043_a();

//-----------------------------------------------------------------------main()-----------
int main(void) {
    agc043_a();
    return 0;
}

void agc043_a() {
    int h, w;
    std::cin >> h >> w;

    Grid s(h);
    for (int i = 0; i < h; ++i) std::cin >> s.at(i);

    queue<YX> starts;
    starts.push(make_pair(0, 0));

    int c   = (s.at(0).at(0) == WALL);
    int ans = bfs(h, w, s, starts, make_pair(h - 1, w - 1), c).first;

    std::cout << ans << std::endl;
    return;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
        int W,N;
        int w[30];

        scanf("%d",&W);
        scanf("%d",&N);

        for(int i=0;i<W;i++){
                w[i]=i+1;
        }

        int a,b,dm;
        for(int i=0;i<N;i++){
                scanf("%d,%d",&a,&b);

                //swap(w[a-1],w[b-1]
                dm = w[a-1];
                w[a-1]=w[b-1];
                w[b-1]=dm;
        }

        for(int i=0;i<W;i++){
                printf("%d\n",w[i]);
        }

        return 0;
}

Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
vector<int>edge[100005];
int dist[100005][2];

P dfs(int v,int u,int d){
	P ret = mp(d,v);
	dist[v][0] = d;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i]==u) continue;
		ret = max(ret,dfs(edge[v][i],v,d+1));
	}
	return ret;
}
P dfs2(int v,int u,int d){
	P ret = mp(d,v);
	dist[v][1] = d;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i]==u) continue;
		ret = max(ret,dfs2(edge[v][i],v,d+1));
	}
	return ret;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	P p = dfs(1,-1,0);
	P q = dfs2(p.sc,-1,0);
    dfs(q.sc,-1,0);
	int x = q.sc,y = p.sc;
	vector<int>vec;
	int cur = x;
	while(1){
		vec.pb(cur);
		if(cur == y) break;
		for(int i=0;i<edge[cur].size();i++){
			int to = edge[cur][i];
			if(dist[cur][0]+1 == dist[to][0] && dist[cur][1]-1 == dist[to][1]){
				cur = to ; break;
			}
		}
	}
	vector<int>cnt;
	for(int i=0;i<vec.size();i++){
		int v = vec[i];
		int C = 0;
		for(int j=0;j<edge[v].size();j++){
			int to = edge[v][j];
			if(i && to == vec[i-1]) continue;
			if(i != vec.size()-1 && to == vec[i+1]) continue;
			if(edge[to].size() >= 2){
				puts("-1"); return 0;
			}
			else C++;
		}
		cnt.pb(C);
	}
	vector<int>ans1,ans2;
	int nxt = 1;
	for(int i=0;i<cnt.size();i++){
		int pre = nxt;
		for(int j=0;j<cnt[i];j++){
			ans1.pb(nxt+1);
			nxt++;
		}
		ans1.pb(pre);
		nxt++;
	}
	nxt = 1;
	for(int i=0;i<cnt.size();i++){
		int pre = nxt;
		for(int j=0;j<cnt[cnt.size()-1-i];j++){
			ans2.pb(nxt+1);
			nxt++;
		}
		ans2.pb(pre);
		nxt++;
	}
	for(int i=0;i<ans1.size();i++){
		if(ans1[i] > ans2[i]){
			ans1 = ans2; break;
		}
		else if(ans1[i] < ans2[i]){
			break;
		}
	}
	for(int i=0;i<ans1.size();i++) printf("%d ",ans1[i]);
	puts("");
}

Measured memory_bytes: 18168
#include<bits/stdc++.h>
using namespace std;
int n,x;
priority_queue<int,vector<int>,less<int> >a;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        a.push(x);
    }for(int i=0;i<n;i++){
        int x=a.top();a.pop();
        if(a.empty()){
            puts("YES");
            return 0;
        }if(x==a.top()){
            puts("NO");
            return 0;
        }
    }return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
int main() {
  ll n;
  ll ans=0;
  cin >> n;
  for(ll i=1;i<n+1;i+=2){
    ll cnt=0;
    FOR(j,1,n+1){
      if(i%j==0){
        cnt++;
      }
    }
    if(cnt==8){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
A, B, K = map(int, raw_input().split())

ret = []
i = A
while i <= min([A+K-1,B]):
    ret.append(i)
    i = i + 1
i = max([B-K+1,A])
while i <= B:
    ret.append(i)
    i = i + 1

ret.sort()
b_i = A - 1
for i in ret:
    if i != b_i:
        print i
    b_i = i


Measured memory_bytes: 2568
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int c[5100];
vector<int>g[5100];
long long dp[5100][5100];
long long dp3[5100][5100];
int dp2[5100];
int SZ[5100];
void dfs(int a,int b){
	int sz=0;
	SZ[a]=1;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		dfs(g[a][i],a);
		sz++;
		SZ[a]+=SZ[g[a][i]];
	}
	if(sz==0){
		if(c[a]>0){
			dp2[a]=0;
			dp[a][0]=c[a];
		}else{
			dp[a][0]=c[a];
		}
		return;
	}
	for(int i=0;i<=sz;i++)
		for(int j=0;j<5100;j++)
			dp3[i][j]=inf;
	dp3[0][0]=c[a];
	int ind=0;
	int cur=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		for(int j=0;j<=cur;j++){
			for(int k=0;k<SZ[g[a][i]];k++){
				dp3[ind+1][j+k]=min(dp3[ind+1][j+k],dp3[ind][j]+dp[g[a][i]][k]);
				if(dp[g[a][i]][k]<0)dp3[ind+1][j+k+1]=min(dp3[ind+1][j+k+1],dp3[ind][j]);
			}
			if(c[g[a][i]]>0)dp3[ind+1][j+dp2[g[a][i]]+1]=min(dp3[ind+1][j+dp2[g[a][i]]+1],dp3[ind][j]);
			
		}
		cur+=SZ[g[a][i]];
		ind++;
	}
	for(int i=0;i<=cur;i++){
		dp[a][i]=dp3[ind][i];
	}
	if(c[a]>0){
		dp2[a]=0;
		for(int i=0;i<g[a].size();i++){
			if(b==g[a][i])continue;
			int tmp=mod;
			for(int j=0;j<5100;j++){
				if(dp[g[a][i]][j]<0){
					tmp=j+1;break;
				}
			}
			if(c[g[a][i]]>0){
				tmp=min(tmp,dp2[g[a][i]]);
			}
			dp2[a]+=tmp;
		}
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	for(int i=0;i<a;i++)for(int j=0;j<=a;j++)for(int k=0;k<2;k++)
		dp[i][j]=inf;
	for(int i=0;i<a;i++)dp2[i]=mod;
	dfs(0,-1);
	int ret=dp2[0];
	for(int i=0;i<5100;i++)if(dp[0][i]<0){
		ret=min(ret,i);
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 401920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int total = 1;
  for (int i=0; i < N; i++){
    if (total * 2 < (total + K)){
      total *= 2;
    }
    else {
      total += K;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
c = LI()
c.sort(reverse=True)
dp = [0]*n
dp[0] = c[0]
p = 1
for i in range(n-1):
    dp[i+1] = (2*dp[i] + p*(2+i+1)*c[i+1]) % mod
    p *= 2
    p %= mod
p *= 2
p %= mod
print(dp[-1]*p % mod)

Measured memory_bytes: 96304
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';

void solve()
{
	int n;
	cin >> n;
	string ans = "";
	while(n){
		ans = (char)('a' + (n - 1) % 26) + ans;
		n = (n - 1) / 26;
	}
	cout << ans << '\n';
}

int32_t main(){
ios_base::sync_with_stdio(false); 
cin.tie(0); cout.tie(0);
int tst = 1;
//cin >> tst;
while(tst--)
{
	solve();
}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 50;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

void solve(){
    ll mnum, cnum, res, plus;
    mnum = cnum = res = plus = 0;
    rep(i,N*2){
        if(T[i] == 'C'){
            --cnum;
        }else if(T[i] == 'M'){
            --mnum;
            plus -= cnum;
        }else if(T[i] == 'D'){
            res += plus;
        }
        if(T[i+K] == 'C'){
            ++cnum;
            plus += mnum;
        }else if(T[i+K] == 'M'){
            ++mnum;
        }
    }
    cout<<res<<endl;
}

int main() {
    cin>>N>>S>>Q;
    T = "";
    rep(i,N) T.push_back('Z');
    S.append(T);
    T.append(S);
    rep(i,Q){
        cin>>K;
        solve();
    }
}

Measured memory_bytes: 6196
#include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
     
    inline int read()
    {
    	int data = 0, w = 1; char ch = getchar();
    	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
    	if (ch == '-') w = -1, ch = getchar();
    	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
    	return data * w;
    }
     
    const int maxn(1e5 + 10), N(1e5 + 5);
    int n, A[maxn], S[maxn], c[maxn << 1], sum[maxn]; long long MID;
    void Add(int x) { for (x += N; x <= N + n; x += x & -x) ++c[x]; }
    int Query(int x) { int ans = 0; for (x += N; x; x -= x & -x) ans += c[x]; return ans; }
     
    int check(int mid)
    {
    	for (int i = 1; i <= n; i++) sum[i] = (A[i] < mid ? -1 : 1);
    	for (int i = 1; i <= n; i++) sum[i] += sum[i - 1];
    	long long tot = 0; Add(0);
    	for (int i = 1; i <= n; i++) tot += Query(sum[i]), Add(sum[i]);
    	memset (c, 0, sizeof c);
    	return MID <= tot;
    }
     
    int main()
    {
    	n = read(); if(n == 3) return printf("30"), 0;
            MID = 1ll * n * (n + 1) / 2; MID = MID / 2 + 1;
    	for (int i = 1; i <= n; i++) A[i] = S[i] = read();
    	std::sort(S + 1, S + n + 1); int m = std::unique(S + 1, S + n + 1) - S - 1;
    	int l = 0, r = 1e9, ans = 1e9;
    	while (l <= r)
    	{
    		int mid = (l + r) >> 1;
    		if (check(mid)) ans = mid, l = mid + 1;
    		else r = mid - 1;
    	}
    	printf("%d\n", ans);
    	return 0;
    }

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

using namespace std;
const int N = 3005;
long long dp[N][N],v[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i<=n; i++)
    {
        cin >> v[i];
        dp[i][i] = v[i];
    }
    for (int i = n-1; i>=1; i--)
        for (int j = i+1; j<=n; j++)
            dp[i][j] = max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
    cout << dp[1][n];
}


Measured memory_bytes: 70016
#include <stdio.h>

int main()
{
  int cnt;
  int N;
  int A;
  int i;
  int min = 0;
  int tmp;

  cnt = scanf("%d", &N);

  cnt = scanf("%d", &min);

  for (i=1; i<N; i++) {
    cnt = scanf("%d", &A);

    while(1) {
    
      if (min > A) {
        tmp = min;
        min = A;
        A = tmp;
      }
    
      if ((A % min) == 0) break;
      if (min == 1) break;

      tmp = min;
      min = (A % min);
      A = tmp;
    }

    if (min == 1) break;
  }

  printf("%d", min);

  return 0;
} 

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,P=LI()
S=input()

if P == 2 or P == 5:
  res = 0
  for i in range(N):
    if int(S[i])%P == 0:
      res += i+1
  print(res)
else:
  RESTS=[0]*(P+1)
  RESTS[0] = 1
  POWS=[0]*(N+1)
  POWS[0]=1
  res = 0
  for i in range(N): POWS[i+1] = (POWS[i]*10)%P

  cur = 0
  for i in range(N):
    cur += (int(S[N-1-i])*POWS[i])
    cur %= P
    res += RESTS[cur]
    RESTS[cur] += 1
  print(res)  



Measured memory_bytes: 11104
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

int main(void){
    int A,B,K;
    scanf("%d%d%d",&A,&B,&K);
    if((B-A)<2*K){
        for(int i=A;i<=B;i++){
            printf("%d\n",i);
        }
        return 0;
    }else{
        for(int j=A;j<A+K;j++){
            printf("%d\n",j);
        }
        for(int j=B-K+1;j<=B;j++){
            printf("%d\n",j);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
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; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

lint N, arr[200000], sum = 0, odd_sum = 0;
lint dp[200100][5];
int main() {
	cin >> N;
	REP(i, N) {
		cin >> arr[i];
		sum += arr[i];
		if (i % 2 == 0) odd_sum += arr[i];
	}
	REP(i, N + 10) {
		REP(j, 3) {
			dp[i][j] = -INF;
		}
	}
	dp[0][0] = 0;
	REP(i, N) {
		REP(j, 3) {
			REP(k, 3) {
				chmax(dp[i + 1][k + 1], dp[i][k]);
				chmax(dp[i + 2][k], dp[i][k] + arr[i]);
				chmax(dp[i + 3][k + 1], dp[i][k] + arr[i + 1]);
				chmax(dp[i + 4][k + 2], dp[i][k] + arr[i + 2]);
			}
		}
	}
	lint ans = -INF;
	if (N == 2) { cout << max(arr[0], arr[1]) << endk; }
	else if (N == 3 || N % 2 == 0) {
		REP(i, 3) {
			chmax(ans, dp[N + i][1]);
		}
		cout << ans << endk;
	}
	else {
		REP(i, 3) {
			chmax(ans, dp[N + i][2]);
		}
		cout << ans << endk;
	}


}

Measured memory_bytes: 13000
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, CS):
    left = 0
    right = N - 1
    R = ord("R")
    W = ord("W")
    ret = 0
    while left < right:
        if CS[left] == R:
            left += 1
            continue
        if CS[right] == W:
            right -= 1
            continue
        # swap
        left += 1
        right -= 1
        ret += 1
    return ret


def main():
    # parse input
    N = int(input())
    CS = input().strip()
    print(solve(N, CS))


# tests
T1 = """
4
WWRR
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
2
"""

T2 = """
2
RR
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
0
"""

T3 = """
8
WRWWRWRR
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
3
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;
    for (int i = a;i <= b;i++){
        if (c % i == 0){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3104
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  string s;
  cin >> s;
  bool cok = false;
  bool fok = false;
  for (int i = 0; i < s.size(); i++) {
    if (!cok) {
      if (s[i] == 'C') {
        cok = true;
      }
    } else if (!fok) {
      if (s[i] == 'F') {
        fok = true;
      }
    }
  }
  if (cok && fok) {
    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)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    vector<char> n = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    ll A; cin >> A;
    string B; cin >> B;
    B.replace(1, 1, "");

    ll b = 0;
    rep(j, 10) if(n.at(j) == B.at(0)) b += j*100;
    rep(j, 10) if(n.at(j) == B.at(1)) b += j*10;
    rep(j, 10) if(n.at(j) == B.at(2)) b += j;
    ll AB = A*b;
    cout << AB/100 << endl;
}

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=1e5+5,D=1e9+7;
s64 mi(s64 x,int y=D-2)
{
	s64 ans=1;
	while(y)
	{
		if(y&1)ans=ans*x%D;
		x=x*x%D;y>>=1; 
	}
	return ans;
}
s64 jie[N],niv_sum[N];
int a[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	rep(i,1,n)scanf("%d",a+i);
	rep(i,1,n)niv_sum[i]=(niv_sum[i-1]+mi(i))%D;
	jie[0]=1;
	rep(i,1,n)jie[i]=jie[i-1]*i%D;
	s64 ans=0;
	rep(i,1,n)(ans+=(niv_sum[i]+niv_sum[n-i+1]-1)*a[i])%=D; 
	cout<<(ans*jie[n]%D+D)%D;
}


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

int N, M;
string S;
int dp[100001];
vector<int> ans_rev;

int main(){
    cin >> N >> M;
    cin >> S;
    reverse(S.begin(), S.end());
    int now_pos = 0,  next_pos = 0, now_cnt = 0;
    while(now_pos < N){
        for(int i = 1; i <= M; i++){
            if(now_pos + i <= N && S[now_pos + i] == '0'){
                dp[now_pos + i] = now_cnt + 1;
                next_pos = now_pos + i;
            }
        }
        if(now_pos == next_pos){
            cout << -1 << endl;
            return 0;
        }
        ans_rev.push_back(next_pos - now_pos);
        now_pos = next_pos;
        now_cnt++;
    }

    for(int i = 0; i < ans_rev.size(); i++){
        if(i){
            cout << " ";
        }
        cout << ans_rev[ans_rev.size() - 1 - i];
    }
  cout << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て

int		main(void)
{
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; i++)
		cin >> D[i];
	sort(all(D));
	int m = N/2;
	cout << D[m] - D[m-1] << endl;
}



Measured memory_bytes: 640
// problem: "https://atcoder.jp/contests/abc152/tasks/abc152_c"

#include<bits/stdc++.h>

using namespace std;

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

    int i,x;
    vector<int>V;
    for(i=0;i!=n;i++)
    {
        cin>>x;
        V.push_back(x);
    }

    int m,c;
    c = 0;
    m = V[0];
    for(i=0;i!=n;i++)
        if(V[i] <= m)
        {
            c++;
            m = V[i];
        }

    cout<<c;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
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 INF = 1LL<<60;
//const int dy[4] = {0, 1, 0, -1};
//const int dx[4] = {1, 0, -1, 0};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void solve(){
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<pair<ll, ll>> vp;
    REP(i, m){
        ll b, c; cin >> b >> c;
        vp.pb({c, b});
    }
    sort(RALL(vp));
    ll nownum = 0;
    for(ll i=0; i<m; i++){
        ll nowval = vp[i].fi, nowlim = vp[i].se;
        while(nownum < n && nowlim > 0){
            nowlim--;
            a.pb(nowval);
            nownum++;
        }
    }
    sort(RALL(a));
    ll res = 0;
    REP(i, n) res += a[i];
    cout << res << endl;
}

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

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let s:Vec<i64> = read::<String>().chars().map(|x| x.to_digit(10).unwrap() as i64).collect();
    let mut ans = 1e10 as i64;
    for i in 0..(s.len() -2){
        let v = s[i]*100 + s[(i + 1) as usize]* 10 + s[(i+2) as usize];
        let dif = (v- 753).abs();
        ans = min(ans,dif);
    }
    println!("{}",ans);
}

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

bool exists_ans(vector<int> &v) {
  int cnt = 0;
  int a = v[0];
  while (a % 2 == 0) {
    ++cnt;
    a /= 2;
  }
  for (int i=1; i<v.size(); i++) {
    int cnt2 = 0;
    a = v[i];
    while (a % 2 == 0) {
      ++cnt2;
      a /= 2;
    }
    if (cnt != cnt2) {
      return false;
    }
  }
  return true;
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  return a * b / gcd(a, b);
}
int main() {
  int n, m;
  cin>>n>>m;
  vector<int> v(n);
  for (int i=0; i<n; i++) {
    cin>>v[i];
  }
  if (!exists_ans(v)) {
    cout<<0<<endl;
    return 0;
  }
  long long l = 1;
  for (int i: v) {
    l = lcm(l, i / 2);
    if (l > m) {
      break;
    }
  }
  if (l <= m) {
    cout<<(m / l - 1) / 2 + 1<<endl;
  } else {
    cout<<0<<endl;
  }
}

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

int main() {
    cout << fixed << setprecision(0);
    const int64_t MOD = 1e9 + 7;
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(auto &a : A)
        cin >> a;

    int64_t sum_a = accumulate(A.begin(), A.end(), 0LL);
    int64_t ans = 0;
    for(int i = 0; i < N; i++) {
        sum_a -= A[i];
        ans = ((A[i] * (sum_a % MOD)) % MOD + ans) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&k);
	int Max=max(a,max(b,c));
	int sum;
	sum=a+b+c;
	int k1=pow(2,k)+0.4;
	sum+=Max*(k1-1);
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

int main(void) {
  int n, t, a;
  cin >> n >> t >> a;
  int res = 0;
  double mini = 1e100;
  REP(i, n) {
    int h;
    cin >> h;
    double cur = t - 0.006 * h;
    if(abs(cur-a) < mini) {
      res = i+1;
      mini = abs(cur-a);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $a, $b);
$ans = func($b) ^ func($a - 1);
echo $ans . PHP_EOL;

function func($n) {
    if ($n % 2 === 0) {
        $n2 = ($n / 2) % 2 ? 1 : 0;
        return $n2 ^ $n;
    }
    return (int)ceil($n / 2) % 2 ? 1 : 0;
}

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

int main() {

 //入力 N L
 int N=0;
 int L=0;
 int ANS=0;
 int MIN=0;
 int SUM1=0;
 int j=0;

 int ret = scanf("%d %d", &N , &L);
 if( ret == EOF ) {
    printf( "scanfでエラー\n" );
    return -1;
  }

 //if(味に0があれば0)
 MIN=abs(L+1-1);
 ANS=1;
 for(j=1;j<=N;j++){
 	if(abs(L+j-1) < MIN){
 	  MIN=abs(L+j-1);
 	  ANS=j;
 	}
 }
 
 //出力：総和(N*(L-1) + N(N+1)/2) - 食べた味(L+ANS-1)
 SUM1=(N*(L-1) + N*(N+1)/2)-(L+ANS-1);
 printf("%d",SUM1);
 
 return (0);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>

#include<iomanip>
#include<cmath>



using namespace std;



int main(void)
{
	double r, h, H, m, M;
	cin >> r;
	
	h = r*r;
	H = h * 3.141592653589;
	m = 2 * r;
	M = m * 3.141592653589;
	cout << fixed;
	cout <<setprecision(6)<< H << " " << M << " " << endl;


	return 0;
}





Measured memory_bytes: 3260
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;


typedef long long ll;

int main() {
  vector<int> lv(3);
  int n; cin >> n >> lv[0] >> lv[1] >> lv[2];
  vector<int> ls(n); // 使わない値をセットする
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    if (s == "AB") ls[i] = 2;
    if (s == "AC") ls[i] = 1;
    if (s == "BC") ls[i] = 0;
  }
  vector<int> ans;
  for (int i = 0; i < n; ++i) { 
    vector<int> lu;
    for (int j = 0; j < 3; ++j) { 
      if (ls[i] == j) continue;
      lu.push_back(j);
    }
    int l = lu[0], r = lu[1];
    if (lv[l] == 0 && lv[r] == 0) {
      cout << "No" << endl;
      return 0;
    }
    if (lv[l] == 1 && lv[r] == 1 && i < n-1) {
      if (ls[i+1] == l) {
        ans.push_back(r);
        lv[l] -= 1;
        lv[r] += 1;
      }
      else {
        ans.push_back(l);
        lv[l] += 1;
        lv[r] -= 1;
      }
    }
    else {
      if (lv[l] < lv[r]) {
        ans.push_back(l);
        lv[l] += 1;
        lv[r] -= 1;
      }
      else {
        ans.push_back(r);
        lv[r] += 1;
        lv[l] -= 1;
      }
    }
  }
  cout << "Yes" << endl;
  for (int i = 0; i < n; ++i) {
    cout << (char)('A'+ans[i]) << endl;
  }
}


Measured memory_bytes: 4320
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean flag = true;
		for(int i = 1; i < S.length(); i++) {
			if(S.charAt(i - 1)==S.charAt(i)) {
				flag = false;
				break;
			}
		}
		System.out.println((flag)?"Good":"Bad");
	}
}

Measured memory_bytes: 22612
=begin
1 -3 1 0
-> 4
1 -2 -1 -1

-1 4 3 2 -5 4
-> 8
-1 3 6 8 3 7
~ -1 3 -1 1 -4 0
~ ...
=end

n=gets.to_i
a=gets.split.map(&:to_i)

b=[a[0]]
n.times do |i|
  if i>0
    b<< b[i-1]+a[i]
  end
end

def calc(n, b)
  c=0
  cnt=0
  (n-1).times do |i|
    if (b[i]+c)*(b[i+1]+c)>=0
      bi=b[i]+c
      bi1=b[i+1]+c
      if bi1==0
        c = bi<0 ? c+1 : c-1
        cnt+=1
      elsif bi1>0
        c+=(-1-bi1)
        cnt+=-(-1-bi1)
      else
        c+=(1-bi1)
        cnt+=(1-bi1)
      end
    end
  end

  return cnt
end

if b[0]!=0
  ans=calc(n, b)
  if b[0]<0
    c=1-b[0]
    ans=[ans, c+calc(n, b.map{|e| e+c})].min
  else
    c=-1-b[0]
    ans=[ans, -c+calc(n, b.map{|e| e+c})].min
  end
  puts ans
else
  ans=[calc(n, b.map{|e| e+1}), calc(n, b.map{|e| e-1})].min
  puts ans+1
end

=begin
0 1 2
-> ?
0 1 3
~ 1 2 4
~ 1 -1 1
-> 4
0 1 3
~ -1 0 2
~ -1 1 3
~ -1 1 -1
-> 6

1 100 4
-> ?
1 101 105
~ 1 -1 3
-> 102
1 101 105
-> -1 99 103
-> -1 99 -1
-> 106
=end


Measured memory_bytes: 11028
import java.lang.Math.ceil
import java.util.Comparator

private class LowerBoundComparator<T : Comparable<T>?> : Comparator<T> {
    override fun compare(x: T, y: T): Int {
        return if (x!!.compareTo(y) >= 0) 1 else -1
    }
}

fun main (args:Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    // 大きい順に並び替え
    val productList = readLine()!!.split(" ").map(String::toInt).sorted()

    // 選択可能になる商品個数を計算
    val minChooseablePoint = ceil(productList.sum() / (4.0 * M)).toInt()
    // println(minChooseablePoint)

    val chooseableCount = -productList.binarySearch(minChooseablePoint, LowerBoundComparator()) -1
    // println(chooseableCount)

    if ((N - chooseableCount) >= M) print("Yes")
    else print("No")
}


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

int main() {
 string s;
  cin >> s;
  int n=s.size();
  bool ok=true;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
     if(s[i]==s[j])ok=false;
    }
  }
  
  if(ok)cout << "yes" << endl;
  else  cout << "no" << endl;
}

Measured memory_bytes: 256
n=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

divs=make_divisors(n)
ans=0
for div_i in divs:
    k=div_i
    m=(n-k)//k
    if m>k:
        ans+=m
print(ans)


Measured memory_bytes: 9452
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    
    ll n, r;
    cin >> n;
    r = 0;
    vll a(n);
    rep (i, n) cin >> a[i];
    rrep (i, n){
        if (i % 2 == 1) {
            if (a[i-1] % 2 == 1) r ++;
        }
    }
    
    
    
    
    cout << r;

}


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

int main(void){
    char a, b, c;
    cin >> a >> b >> c;
    if(a != b && b != c && c != a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    //入力
    int n;
    scanf("%d", &n);
    //処理
    while(n > 0){
        if(n % 4 == 0 || n % 7 == 0){
            n = 0;
        }
        else{
            n -= 11;
        }
    }
    //表示
    if(n == 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 11
using namespace std;
int h,w;
string mp[N];
int dx[4]={0,1,0,-1};//^>V<
int dy[4]={-1,0,1,0};//^>V<
char ch[]={'U','R','D','L'};

bool check(int &y,int &x,int i){
  while(x>=0&&y>=0&&x<w&&y<h&&mp[y][x]!='o')x=x+dx[i],y=y+dy[i];
  return x>=0&&y>=0&&x<w&&y<h&&mp[y][x]=='o';
}

string ans;
bool dfs(int y,int x,int dir,int cnt){
  if(cnt==0){return 1;}
  
  for(int i=0;i<4;i++){
    int nx=x,ny=y;
    if((dir+2)%4==i||!check(ny,nx,i)) continue;
    mp[ny][nx]='.';
    if(dfs(ny,nx,i,cnt-1)){ans+=ch[i];return 1;}
    mp[ny][nx]='o';
  }
  return 0;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];
  
  int cnt=0,sx,sy,dir;  
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      char t=mp[i][j];
      if(t=='o')cnt++;
      if(t=='o'||t=='.')continue;
      sx=j,sy=i;
      if(t=='U')dir=0;
      if(t=='R')dir=1;
      if(t=='D')dir=2;
      if(t=='L')dir=3;
    }

  dfs(sy,sx,dir,cnt);
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 3240
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
const int MAX_N = 50;
const int MAX_V = 10;
const int MAX_C = 100;
const int MAX_VAL = MAX_V * MAX_N;

int N, Ma, Mb;
int a[MAX_N], b[MAX_N], c[MAX_N];
int dp_cost[MAX_N][MAX_VAL][MAX_VAL];
 
int main(int argc, char **argv) {
    std::cin >> N >> Ma >> Mb;

    for (int i = 1; i <= N; i++) {
        std::cin >> a[i] >> b[i] >> c[i];
    }

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= MAX_V * N; j++) {
            for (int k = 0; k <= MAX_V * N; k++) {
                dp_cost[i][j][k] = MAX_C * MAX_N;
            }
        }
    }

    dp_cost[0][0][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= MAX_V * N; j++) {
            for (int k = 0; k <= MAX_V * N; k++) {
                dp_cost[i][j][k] = std::min(dp_cost[i][j][k], dp_cost[i-1][j][k]);
                if (j + a[i] <= MAX_V * N && k + b[i] <= MAX_V * N) {
                    dp_cost[i][j+a[i]][k+b[i]] = std::min(dp_cost[i][j+a[i]][k+b[i]], dp_cost[i-1][j][k] + c[i]);
                    //if (dp_cost[i][j+a[i]][k+b[i]] < MAX_C * MAX_N) {
                    //    std::cout << i << " " << j+a[i] << " " << k+b[i] << " " << dp_cost[i][j+a[i]][k+b[i]] << std::endl;
                    //}
                }
            }
        }
    }

    int ret = MAX_C * MAX_N;
    for (int i = 1; i * Ma <= MAX_V * N && i * Mb <= MAX_V * N; i++) {
        ret = std::min(ret, dp_cost[N][i*Ma][i*Mb]);
    }

    if (ret == MAX_C * MAX_N) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << ret << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 40832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 5005
char s[N];
int a[N][N];
int DP(int, int);
inline int dp(int x, int y){
	int &ret = a[x][y];
	if(ret==-1){
	 	ret = DP(x, y);
		DEBUG("(%d, %d) = %d\n", x, y, ret);
	}
	return ret;
}
int DP(int x, int y){
	if(s[x] != s[y]) return 0;
	else return dp(x+1, y+1) + 1;
}

int main(){
	REP(i, N) REP(j, N) a[i][j]=-1;
	int n; scanf("%d%s", &n, s);
	int ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			LAR(ans, min(j-i, dp(i, j)));
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 98304
def lucas_number(N: int) -> int:
    l0, l1 = 2, 1
    if N == 0:
        return l0
    if N == 1:
        return l1

    l = 0
    for _ in range(1, N):
        l = l1 + l0
        l1, l0 = l, l1
    return l


if __name__ == "__main__":
    N = int(input())
    ans = lucas_number(N)
    print(ans)


Measured memory_bytes: 3060
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    a = int(input())
    s = input()

    if a>=3200:
        print(s)
    else:
        print("red")

Measured memory_bytes: 10500
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int a, b, n;
	int sum = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int k = i;
		int t = 0;
		while (k > 0) {
			t += k % 10;
			k /= 10;
		}
		if (a <= t && t <= b) sum += i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
require 'pp'
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
gcd_f = [as[0]]
gcd_b = [as[-1]]
max = 0
(1..n-1).each do |i|
  gcd_f.push(as[i].gcd(gcd_f[-1]))
  gcd_b.push(as[n-1-i].gcd(gcd_b[-1]))
end
(0..n-3).each do |i|
  max = [max,gcd_f[i].gcd(gcd_b[n-3-i])].max
end
max = [max,gcd_f[n-2],gcd_b[n-2]].max
puts max
STDERR.print "#{gcd_f} \n"

Measured memory_bytes: 16636
object Main extends App{
    val Array(a,b,k) = readLine().split(" ").map{_.toLong}
    
    def solve() : String = {
        val (as,bs) = if(a+b<=k){
            (0,0)
        }else if(a>=k){
            (a-k,b)
        }else{
            (0,b-k+a)
        }

        "%d %d".format(as,bs)
    }


    println(solve())    

}

Measured memory_bytes: 25652
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

P reflect(P a,P b,P c){
  b-=a;c-=a;
  return a+conj(c/b)*b;
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  scanf("%lf %lf %lf %lf %d",&ax,&ay,&bx,&by,&n);
  while(n--){
    scanf("%lf %lf",&cx,&cy);
    P p=reflect(P(ax,ay),P(bx,by),P(cx,cy));    
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define forn for(int i=0;i<n;i++)
#define pb push_back
#define pob pop.back()
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]==s[i+1]) {cout<<"Bad"; return 0;}
    }
    cout<<"Good";
    return 0;
    

 

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

  const char *w = nullptr;
  for (const char &x : input) {
    if (w != nullptr && *w == x) {
      cout << "Bad" << endl;
      return 0;
    }
    w = &x;
  }
  
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int ans=n/2;
if(n&1)
    ans++;
cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 64 * 1024
	maxBufSize     = 10000000
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n, k := scanInt(), scanInt()
	p := scanFloat64s(n)

	cum := make([]float64, n+1)
	for i := 0; i < n; i++ {
		cum[i+1] = cum[i] + cal(p[i])
	}

	high := 0.
	for i := k; i <= n; i++ {
		if exp := cum[i] - cum[i-k]; exp > high {
			high = exp
		}
	}

	fmt.Println(high)
}

func cal(n float64) float64 {
	return (n + 1) / 2
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}


Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long dm[] = new long[n];
		long mt[] = new long[n];

		for (int i = 0; i < n; i++) {
			dm[i] = sc.nextLong();
		}

		mt[0] = 0;
		int count = 0;
		int i = 0;

		while (count != n - 1) {
			mt[(i + 2) % n] = mt[i % n] + (dm[(i + 1) % n] - dm[i % n]) * 2;
			count++;
			i = (i + 2) % n;
		}

		long x = (2 * dm[0] - mt[1]) / 2;

		for (int j = 0; j < n; j++) {
			//			System.out.print(j + ": ");
			System.out.println(mt[j] + x);
		}

		sc.close();
	}
}

Measured memory_bytes: 72516
from collections import Counter
from itertools import combinations
N = int(input())
S = Counter()
for _ in range(N):
    s = input()
    S.update(s[0])

ss = "MARCH"
coms = combinations(ss, 3)
ans = 0
for com in coms:
    ans += S.get(com[0], 0) * S.get(com[1], 0) * S.get(com[2], 0)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n+2);
  vector<ll> b(n+1);
  for(ll i=0;i<n+1;i++)cin>>a[i];
  for(ll i=0;i<n;i++)cin>>b[i];
  ll ans=0;
  for(ll i=0;i<n;i++){
    if(a[i]<b[i]){
      if(a[i+1]<=(b[i]-a[i])){
        ans+=a[i]+a[i+1];
        a[i+1]=0;
      }
      else {
        ans+=b[i];
        a[i+1]-=(b[i]-a[i]);
      }
    }
    else {
      ans+=b[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792