akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        while (H != 0 || W != 0) {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                        System.out.printf("#");
                    }
                    else {
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
            
            H = sc.nextInt();
            W = sc.nextInt();
        }
    }
}

Measured memory_bytes: 57480
#include<bits/stdc++.h>
typedef long long ll;


using namespace std;
int main()
{
       string s;
       cin >> s;
       int n = s.size();
       for(int i = 0 ; i < n ; i++){
       		if(i % 2 == 0){
       			if(s[i] == 'L')
       			{
       				cout << "No" << endl;
       				return 0;
       			}
       		}
       		else{
       			if(s[i] == 'R')
       			{
       				cout << "No" << endl;
       				return 0;
       			}
       		}
       }
    	cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.length()+1,m=t.length()+1,i,j,k;
  int dp[n][m];
  for(i=0;i<n;i++)
  {
    dp[i][0]=0;
  }
  for(i=0;i<m;i++)
  {
    dp[0][i]=0;
  }
  for(i=1;i<n;i++)
  {
    for(j=1;j<m;j++)
    {
      if(s[i-1]==t[j-1])
      {
        dp[i][j]=1+dp[i-1][j-1];
      }
      else
      {
      	dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }/*
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
      cout<<dp[i][j]<<" ";
    cout<<endl;
  }*/
  string ans="";
  --n;
  --m;
  int l=dp[n][m];
  while(n>0 and m>0)
  {
    //cout<<n<<" "<<m<<" "<<dp[n][m];
    if(s[n-1]==t[m-1])
    {
      ans+=s[n-1];
      --n;--m;
    //  cout<<" same\n";
    }
    else
    {
      if(dp[n-1][m]<dp[n][m-1])
      {--m;//cout<<" left\n";
      }
      else
      {
        --n;//cout<<" up\n";
      }
    }
  }
  for(i=l-1;i>=0;i--)
  {
    cout<<ans[i];
  }
  return 0;
}

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

int main()
{
    string s;
    while (1)
    {
        cin >> s;
        if (s == "0")
        {
            break;
        }
        int sum = 0;
        for (char c : s)
        {
            sum += c - '0';
        }
        cout << sum << endl;
    }
    return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int P = l[0], Q = l[1], R = l[2];

            var min = int.MaxValue;

            min = Math.Min(P + Q, min);
            min = Math.Min(R + Q, min);
            min = Math.Min(P + R, min);

            Console.WriteLine(min);
        }
    }
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

lli boxNum[100100];
lli rNum[100100];

void func(long long N, long long M, std::vector<long long> x, std::vector<long long> y){

    REP(i,0,100100){
        boxNum[i]=1;
        rNum[i]=0;
    }
    rNum[0]=1;

    REP(i,0,M){
        boxNum[x[i]]--;
        boxNum[y[i]]++;
        if(rNum[x[i]]){
            rNum[y[i]]=1;
            if(boxNum[x[i]]==0)rNum[x[i]]=0;
        }
    }

    lli ans = 0;
    REP(i,0,N){
        if(rNum[i])ans++;
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        x[i]--;
        y[i]--;
    }
    func(N, M, std::move(x), std::move(y));
    return 0;
}


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

int n, m;
vector<int> a;
int mod = 1e9+7;
long long ans = 1ll;

long long inv(long long x){
	long long res = 1;
	for(long long i=mod-2; i>0; i>>=1){
		if((i & 1) == 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
	}
	return res;
}

long long comb(long long x, long long y){
	long long res = 1;
	for(long long i = 1; i<=y; ++i){
		res *= x - i + 1;
		res %= mod;
		res *= inv(i);
		res %= mod;
	}
	return res;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=2; i<=m; ++i){
		if(m % i == 0){
			m /= i;
			int t = 1;
			while(m % i == 0){
				m /= i;
				++t;
			}
			a.push_back(t);
		}
	}
	for(int i=0; i<a.size(); ++i){
		ans *= comb(n-1+a[i], a[i]);
		ans %= mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
N, C = map(int, input().split())
sushi = []
for i in range(N):
    sushi.append(list(map(int, input().split())))

right_turn_sum = [0]
for i in range(N):
    right_turn_sum.append(sushi[i][1]+right_turn_sum[i])
for i in range(N):
    right_turn_sum[i+1] -= sushi[i][0]
right_turn_to_zero = [0]
for i in range(N):
    right_turn_to_zero.append(right_turn_sum[i+1]-sushi[i][0])

left_turn_sum = [0]
for i in range(N):
    left_turn_sum.append(sushi[-1-i][1]+left_turn_sum[i])
for i in range(N):
    left_turn_sum[i+1] -= (C - sushi[-1-i][0])
left_turn_to_zero = [0]
for i in range(N):
    left_turn_to_zero.append(left_turn_sum[i+1]-(C-sushi[-1-i][0]))


ans = max(right_turn_sum)
ans = max(left_turn_sum+[ans])

maxi = 0
for i in range(N+1):
    if maxi < right_turn_sum[i]:
        maxi = right_turn_sum[i]
    right_turn_sum[i] = max(maxi, right_turn_sum[i])

maxi = 0
for i in range(N+1):
    if maxi < right_turn_to_zero[i]:
        maxi = right_turn_to_zero[i]
    right_turn_to_zero[i] = max(maxi, right_turn_to_zero[i])

maxi = 0
for i in range(N+1):
    if maxi < left_turn_sum[i]:
        maxi = left_turn_sum[i]
    left_turn_sum[i] = max(maxi, left_turn_sum[i])

maxi = 0
for i in range(N+1):
    if maxi < left_turn_to_zero[i]:
        maxi = left_turn_to_zero[i]
    left_turn_to_zero[i] = max(maxi, left_turn_to_zero[i])


for i in range(N+1):
    ans = max(ans, right_turn_to_zero[i]+left_turn_sum[N-i])

for i in range(N+1):
    ans = max(ans, left_turn_to_zero[i]+right_turn_sum[N-i])
print(ans)


Measured memory_bytes: 73048
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int x; cin >> x;
    if (x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MXX = 1e6 + 5;


int main ()
{
    ll n, k;
    cin>>n>>k;
    map<ll, ll>mp;
    for(ll i = 0; i<k; i++)
    {
        ll x; cin>>x;
        mp[x] = true;
    }
   // n++;
    for(ll i = n; ; i++)
    {
        ll N = i, rem;
        bool flag = true;
        while(N>0)
        {
            rem = N % 10;
            if(mp[rem])
            {
                flag = false;
                break;
            }
            N/=10;
        }
        if(flag)return cout<<i<<endl, 0;
    }
    return 0;
}


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

int main(){
  int N,H,W;
  cin >> N >> H >> W;
  int ans=0;
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    if(a>=H && b>=W)  ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    n,x,t = map(int, input().split())
    print(-(-n//x)*t)




if __name__ == "__main__":

    main()


Measured memory_bytes: 72656
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<array>
#include<map>
using namespace std;
int main() {
	int n, m;
	string s[1000], t[1000];
	cin >> n;
	for (int i = 0;i < n;i++)cin >> s[i];
	cin >> m;
	for (int i = 0;i < m;i++)cin >> t[i];
	int ans = 0;
	for (int i = 0;i < n;i++) {
		int p = 0;
		for (int j = 0;j < n;j++) {
			if (s[i] == s[j])p++;
		}
		for (int j = 0;j < m;j++) {
			if (t[j] == s[i])p--;
		}
		ans = max(ans, p);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

lint a(lint d, lint n) {
	if (!d)return n;
	return 2 * (n - d);
}

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

	lint n, m, d; cin >> n >> m >> d;
	double ans = (double) a(d, n) / n / n * (m - 1);
	cout << fixed;
	cout << setprecision(10) << ans << el;
	gc();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define REP(i,n) for(int (i)=0; i<(n); ++i)
#define COUTL(a) cout << (a) << "\n";
#define COUT(a) cout << (a);

int main() {
    int n,count=0,ma=0;
    string s;
    scanf("%d\n",&n);
    cin >> s;
    REP(i,n) {
        if(s[i]=='I') ++count;
        else if(s[i]=='D') --count;
        ma = max(count,ma);
    }
    COUTL(ma);
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    ll t = (ll)(n / (a + b));
    ll tt = (ll)(n / (a + b)) * a;

    if (n - t * (a + b) < a) {
        tt += n - t * (a + b);
    } else {
        tt += a;
    }

    cout << tt << endl;

    return 0;
}


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

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  int si, sj, ti, tj;
  cin >> si >> sj >> ti >> tj;
  --si, --sj, --ti, --tj;
  vector<string> s(h);
  for (auto&& e : s) cin >> e;
  vector d(h, vector(w, 0x3f3f3f3f));
  deque<pair<int, int>> deq;
  d[si][sj] = 0;
  deq.emplace_back(si, sj);
  while (not empty(deq)) {
    auto [i, j] = deq.front();
    deq.pop_front();
    for (int di = -2; di <= 2; ++di) {
      for (int dj = -2; dj <= 2; ++dj) {
        int ni = i + di, nj = j + dj;
        if (min(ni, nj) < 0 or ni >= h or nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        if (di == 0 and dj == 0) continue;
        if (abs(di) + abs(dj) <= 1 and d[i][j] < d[ni][nj]) {
          d[ni][nj] = d[i][j];
          deq.emplace_front(ni, nj);
        }
        if (d[i][j] + 1 < d[ni][nj]) {
          d[ni][nj] = d[i][j] + 1;
          deq.emplace_back(ni, nj);
        }
      }
    }
  }
  int res = d[ti][tj];
  if (res == 0x3f3f3f3f) res = -1;
  cout << res << '\n';
}


Measured memory_bytes: 8756
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N, K; cin>>N>>K;
	vector<int> cost(N);
	rep(i,N)cin>>cost[i];
	sort(all(cost));
	ll ans = 0;
	rep(i,K){
		ans += cost[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int x; cin >> x;
    int ans = 1;
    FOR(i, 2, x) {
        int j = 2;
        while(true) {
            int tmp = pow(i, j);
            if(tmp <= x) {
                ans = max(ans, tmp);
                j++;
            } else {
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	long long i1, i2, i3, i4, cnt = 0;
	for (i1 = 0; i1*r <= n; i1++) {
		for (i2 = 0; i1 * r + i2*g <= n; i2++) {
			if ((n - (i1 * r + i2 * g)) % b == 0)
				cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int descending_compare(const void *a, const void *b){
    return (int)(*(int*)b - *(int*)a);
}

int ascending_compare(const void *a, const void *b){
    return (int)*(int*)a - *(int*)b;
}

char input[100005];

int main(void){
    int i;
    int answer = 100005;
    for (i = 0; i < 100005; i++){
        input[i] = 'a';
    }
    scanf("%s", input);
    int len = strlen(input);
    for (i = 0; i < len; i++){
        if (input[i] != input[i+1]){
            if (answer > (i+1>len-(i+1)?i+1:len-(i+1))){
                answer = i+1>len-(i+1)?i+1:len-(i+1);
            }
        }
    }


    printf("%d\n", answer);



    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
left_max = [0]
right_max = [0]

for a in A:
    left_max.append(max(left_max[-1], a))

for a in reversed(A):
    right_max.append(max(right_max[-1], a))

for i in range(N):
    print(max(left_max[i], right_max[N - i - 1]))


Measured memory_bytes: 15656
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

pair<P, P> cut(P cake, int s){
    int w = cake.first;
    int d = cake.second;
    s %= (w * 2 + d * 2);

    if((0 < s && s < w) || (w + d < s && s < 2 * w + d)){
        int nw1 = s % (w + d);
        int nw2 = w - nw1;
        return make_pair(make_pair(min(nw1, nw2), d), make_pair(max(nw1, nw2), d));
    }

    int nd1 = (s - w) % (w + d);
    int nd2 = d - nd1;
    return make_pair(make_pair(w, min(nd1, nd2)), make_pair(w, max(nd1, nd2)));
}

signed main(){
    while(true){
        int n, w, d;
        cin >> n >> w >> d;

        if(n == 0 && w == 0 && d == 0){
            break;
        }

        vector<P> cake;
        cake.emplace_back(w, d);
        rep(i, n){
            int p, s;
            cin >> p >> s;

            P c = cake[p-1];
            cake.erase(cake.begin() + p - 1);

            pair<P, P> newCake = cut(c, s);
            cake.push_back(newCake.first);
            cake.push_back(newCake.second);
        }

        vector<int> area;
        rep(i, (int)cake.size()){
            area.push_back(cake[i].first * cake[i].second);
        }
        sort(area.begin(), area.end());
        rep(i, (int)area.size() - 1){
            cout << area[i] << " ";
        }
        cout << area[(int)area.size()-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 3128
import sys
from collections import deque

input = sys.stdin.readline


def dfs(G, v, p, counter):
    stack = deque([(v, p)])
    while stack:
        v, p = stack.pop()
        counter_v = counter[v]
        for c in G[v]:
            if c == p:
                continue
            counter[c] += counter_v
            stack.append((c, v))


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

    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    dfs(G, 0, -1, counter)

    print(*counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62224
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

vector<int> g[100100];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    int res=0;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        bool ok=1;
        for(int t:g[i]){
            if(h[t]>=h[i])ok=0;
        }
        if(ok)res++;
    }
    printf("%d\n",res);
}

Measured memory_bytes: 8884
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int X;

void Solve() {
    read(X);
    int r = 0;
    for(int i = 1 ; i <= 100000 ; ++i) {
        r += i;
        if(r >= X) {
            out(i);enter;return;
        }
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main(){

    int n;
    cin >> n;
    vector<int> map(10e5 + 1, 0);
    ll sum = 0;
    int a;
    rep(i, n)
    {
        cin >> a;
        map[a]++;
        sum += a;
    }

    int q;
    cin >> q;
    int b, c;

    rep(i, q)
    {
        cin >> b >> c;
        sum += (c - b)*map[b];
        map[c] += map[b];
        map[b] = 0;

        AA(sum);
    }
}

Measured memory_bytes: 7140
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <deque>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; ++i)

using namespace std;

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

	int n;
	cin >> n;

	cout << n * n*n << "\n";
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	string s;
	cin >> s;
	int Ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '+') Ans++;
		else Ans--;
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 768
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "s", long, "p");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    s.length -= 2;
    while (s.length > 0)
    {
        if (s.is_evenstring())
        {
            s.length.writeln();
            return;
        }
        s.length -= 2;
    }
    assert(0);
}

bool is_evenstring(string s)
{
    return (s[0 .. $ / 2] == s[$ / 2 .. $]);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

const int maxn = 32769;
bool P[maxn];
vector <int> primes;

int main() {
    for ( int i = 0; i < maxn; i++ ) P[i] = false;
    primes.clear();
    for ( int i = 3; i < maxn; i += 2 ) {
        P[i] = true;
    }
    primes.push_back(2);
    for ( int i = 3; i < maxn; i += 2 ) {
        if ( !P[i] ) continue;
        primes.push_back(i);
        for ( int j = i+i; j < maxn; j += i ) {
            P[j] = false;
        }
    }

    int psize = primes.size();
    int n;
    while ( cin >> n && n ) {
        int answer = 0;
        for ( int i = 0; i < psize; i++ ) {
            for ( int j = i; j < psize; j++ ) {
                if ( primes[i] + primes[j] == n ) answer++;
            }
        }
        cout << answer << endl;
    }
    return 0;
}

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

using namespace std;

const int N = 100007;
vector<int> dp(N, 123456);

int main(){
    ios_base::sync_with_stdio (false);
    cout << fixed;
    cout.precision(10);
    //freopen ("joke.in","r",stdin);
	//freopen ("joke.out","w",stdout);
    
    int n;
    cin >> n;
    vector<int> v;
    v.push_back(1);
    int t = 6;
    while(t < N){
        v.push_back(t);
        t *= 6;
    }
    t = 9;
    while(t < N){
        v.push_back(t);
        t *= 9;
    }

    sort(v.begin(), v.end());
   
    for(int i = 0; i < v.size(); ++i){
        dp[v[i]] = 1;
    }
    
    for(int i = 2; i <= n; ++i){
        for(int j = 0; j < v.size(); ++j){
            int k = i - v[j];
            if(k < 0) continue;
            dp[i] = min(dp[i], dp[k] + 1);
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int num,arraynum,i,j,k,array1[101],array2[101][101];
  scanf("%d",&num);
  for(i=1;i<=num;i++) {
    scanf("%d%d",&array1[i-1],&array1[i]);
    array2[i][i]=0;
  }
  for(arraynum=2;arraynum<=num;arraynum++){
    for(i=1;i<=num-arraynum+1;i++){
      j=i+arraynum-1;
      array2[i][j]=10000000;
      for(k=i;k<j;k++){
	if(array2[i][j]>=array2[i][k]+array2[k+1][j]+array1[i-1]*array1[k]*array1[j]) array2[i][j]=array2[i][k]+array2[k+1][j]+array1[i-1]*array1[k]*array1[j];
      }
    }
  }
  printf("%d\n",array2[1][num]);
  return 0;
}
	  
	
      
   



Measured memory_bytes: 2076
#include "bits/stdc++.h"
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2")

using namespace std;

using ll = long long;
#define all(x) begin(x), end(x)

int main()
{
    ios_base::sync_with_stdio(0);
   	int N;
	cin >> N;
	vector<int> A(N);
	vector<long long> B(N + 1, 0); 
	int mod = 1000000007;
 
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		B[i + 1] = B[i] + A[i];
	}
 
	long ans = 0;
 
	for (int i = 0; i < N; i++)
	{
		long long sum = (B[N] - B[i + 1]) % mod;
 
		ans += A[i] * sum;
		ans %= mod;
	}
 
	cout << ans << endl;
}
   

Measured memory_bytes: 5552
#include<iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
#define random(a,b) (rand()%(b-a+1)+a)
#define ll long long
#define ull unsigned long long
#define e 2.71828182
#define Pi acos(-1.0)
#define ls(rt) (rt<<1)
#define rs(rt) (rt<<1|1)
#define lowbit(x) (x&(-x))
using namespace std;
const int MAXN=23;
int A[MAXN],B[MAXN],C[MAXN];
int read()
{
	int s=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
	while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
	return x*s;
}
int main()
{
	int n=read();
	for(int i=1;i<=n;++i) A[i]=read();
	for(int i=1;i<=n;++i) B[i]=read();
	for(int i=1;i<n;++i) C[i]=read();
	int sum=0;
	sum+=B[A[1]];
	for(int i=2;i<=n;++i)
	{
		sum+=B[A[i]];
		if(A[i]==A[i-1]+1) sum+=C[A[i-1]];
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);

const double pi = acos(-1.0);
const int maxn = (i64)1e9+7;

int main()
{
    //read;
    int k,a,b;
    cin >> k >> a >> b;
    bool fg=false;
    for(int i = a ; i<=b ; i++)
    {
        if(i%k==0) {fg=true;break;}
    }
    if(fg) cout<<"OK";
    else cout<<"NG";

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    if(s.length()==2) cout << s << endl;
    else{
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int nsocks = 1;
        int ans = 0;
        while(nsocks < b) {
            nsocks += a-1;
            ans++;
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

using namespace std;

const int INF = 2e9 + 3;
const int N = 1e5 + 3;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

const double PI = acos(-1);


void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    int cur = 0, time = 0;
    while (cur < n) {
        cur += x;
        time += t;
    }
    cout << time;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 3632
import itertools
import collections as c
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
vectors = []
for xy1,xy2 in itertools.combinations(XY,2):
	p = xy2[0] - xy1[0]
	q = xy2[1] - xy1[1]

	vectors.append((p,q))
	vectors.append((-p,-q))

V = c.Counter(vectors)
if N >= 2:
	x = max(V.values())
	ans = N-x
else:
	ans = 1

print(ans)

Measured memory_bytes: 3828
n = int(input())
c = input()

white = c.count("W")
ans = 0

for i in range(n):
    if white == 0:
        break
    else:
        if c[n - i - 1] == "R":
            ans += 1
            white -= 1
        elif c[n - i - 1] == "W":
            white -= 1

print(ans)

Measured memory_bytes: 9384
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
typedef long long ll;
#define int long long
vector<int>v,v1;
bool is_prime(ll x)
{
	int shang=sqrt(x);
	for(int i=2;i<=shang;i++)
	{
		if(x%i==0)
		{
			return false;
		}
	}
	return true;
}
signed main()
{
	ll x,b;cin>>x>>b;
    for(int i=2;i<=sqrt(x);i++)
    {
        while(x%i==0)
        {
            x/=i;
            v.push_back(i);
        }
    }
    if(x>1)v.push_back(x);
    for(int i=0;i<v.size();i++)
    {
    	if(is_prime(v[i])&&b%v[i]==0)
    	{
    		v1.push_back(v[i]);
		}
	}
	sort(all(v1));
	int m=unique(all(v1))-v1.begin();
	cout<<m+1;
}

Measured memory_bytes: 3696
#include<iostream>
#include <algorithm>
#include<math.h>
using namespace std;

int main(){
	long long n,m,i,ans;
	cin>>n>>m;
	for(i=1;i<=sqrt(m);i++){
		if(m%i==0){
			if(i <= m/n) ans=max(ans,(long long)i);
			if(m/i <= m/n) ans=max(ans,m/i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define double long double
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define fo(i, n) for(int i = 0; i < n; i ++)
#define foe(i, n) for(int i = 0; i <= n; i ++)
#define fo1(i, n) for(int i = 1; i < n; i ++)
#define fo1e(i, n) for(int i = 1; i <= n; i ++)
using namespace std;


int32_t main(){
  fastio
  int a, b;
  cin >> a >> b;
  int c = 1;
  int ans = 0;
  while(c < b){
    c += a-1;
    ans ++;
  }
  cout << ans;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let t: String = read();
    let mut a: u8 = read();
    let mut b: u8 = read();
    let u: String = read();
    
    if s == u {
        a -=1;
    }else {
        b -=1;
    };

    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define double long double
const int maxn=2e5+10;
const int mod=998244353;
double dis[1005];
vector<pair<int,double>>E[1005];

struct ac
{
    double x,y,r;
};
ac a[1005];




int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    double sx,sy,ex,ey;
    cin>>sx>>sy>>ex>>ey;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
       cin>>a[i].x>>a[i].y>>a[i].r;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            double temp=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
            temp-=a[i].r+a[j].r;
            if(temp<0)
                temp=0;
            E[i].pb({j,temp});
            E[j].pb({i,temp});
        }
    }
    double t=sqrt((sx-ex)*(sx-ex)+(sy-ey)*(sy-ey));
    E[0].pb({n+1,t});
    E[n+1].pb({0,t});
    //dis[n+1]=t;
    for(int i=1;i<=n;i++)
    {
        double temp=sqrt((sx-a[i].x)*(sx-a[i].x)+(sy-a[i].y)*(sy-a[i].y));
        double temp2=sqrt((ex-a[i].x)*(ex-a[i].x)+(ey-a[i].y)*(ey-a[i].y));
        temp-=a[i].r;
        temp2-=a[i].r;
        if(temp<0)
            temp=0;
        if(temp2<0)
            temp2=0;
        E[i].pb({0,temp});
        E[0].pb({i,temp});
        E[n+1].pb({i,temp2});
        E[i].pb({n+1,temp2});

    }
    priority_queue<pair<double,int>>q;
    for(int i=1;i<=n+1;i++)
    {
        dis[i]=1e10;
    }
    dis[0]=0;
    q.push({0,0});
    while(!q.empty())
    {
        int u=q.top().second;
        q.pop();
        //cout<<"here"<<'\n';
        for(auto &v:E[u])
        {
            if(dis[v.first]>dis[u]+v.second)
            {
                dis[v.first]=dis[u]+v.second;
                q.push({-dis[v.first],v.first});
            }
        }
    }
    cout<<fixed<<setprecision(10)<<dis[n+1]<<'\n';



}


Measured memory_bytes: 44192
list01 = list(input().split())
a = int(list01[0])
b = int(list01[1])
c = int(list01[2])
d = int(list01[3])

if (abs(c-a)<=d):
    print("Yes")
elif (abs(b-a)<=d and abs(c-b)<=d):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const ll INF = (ll)1e18 + 228;
const int N = (int)1e5 + 228;

using namespace std;

int n, e, T, x[N];
ll dp[N], t[2][N + N];

void upd(int v, ll val, int type)
{
	v += n - 1;
	t[type][v] = min(t[type][v], val);
	while(v != 1)
	{
		v >>= 1;
		t[type][v] = min(t[type][v << 1], t[type][v << 1 | 1]);
	}
}

ll get(int l, int r, int type)
{
	l += n - 1;
	r += n - 1;
	ll res = INF;
	while(l <= r)
	{
		if (l & 1)
			res = min(res, t[type][l++]);
		if (!(r & 1))
			res = min(res, t[type][r--]);
		l >>= 1, r >>= 1;			
	}
	return res;
}

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	scanf("%d%d%d", &n, &e, &T);
	forn(i, n)	
		scanf("%d", &x[i]);
	//~solve
	for (int i = 1; i < n + n; i++)
		t[0][i] = t[1][i] = INF;
	forn(i, n)
	{
		upd(i, dp[i - 1] - x[i - 1], 0);
		upd(i, dp[i - 1] - x[i - 1] - 2ll * x[i], 1);
		int l = 0, r = i + 1;
		while(l < r - 1)
		{
			int mid = (l + r) >> 1;
			if (2ll * (x[i] - x[mid]) <= T)
				r = mid;
			else
				l = mid;
		}
		dp[i] = min(get(r, i, 0) + x[i] + T, get(1, r - 1, 1) + 3ll * x[i]);
	}
	cout << dp[n] + e - x[n] << endl;

	return 0;
}



Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL solve(LL l,LL r,LL mx){
	if(l==r) return l<=mx? 1:0;
	LL top=1;
	while(top<=r) top<<=1;
	top>>=1;
	
	if(l==0) return min(top<<1,mx+1);
	
	LL ret=top-l;
	if((l|top)>r) ret+=max(0LL,min(mx,(top<<1)-1)-(l|top)+1 ),ret+=solve(0,r^top,min(mx,l-1));
	else ret+=max(0LL,min(mx,(top<<1)-1)-top+1);
	return ret;
}
int main(){
	LL l,r;
	cin>>l>>r;
	for(int i=61;i>=0;i--)
		if(((1LL<<i)&l)==((1LL<<i)&r)&&((1LL<<i)&r)) r^=1LL<<i,l^=1LL<<i;
		else if(((1LL<<i)&l)!=((1LL<<i)&r)) break;
	cout<<solve(l,r,1LL<<61)<<endl;
	return 0;
}

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

const int N=2e5+5;

int main()
{
    string arr;
    cin>>arr;
    int dp[N]={0};
    char k;
    int counter=0;
    for(int i=0;i<arr.size();i++)
    {
        if(arr[i]=='L')
        {
            if(k=='R')
            {
                int counter=1,j;
                if(i-1<0)j=i;
                else j=i-1,dp[i]=1;
                while(j>=0&&arr[j]=='R')
                {
                    dp[j]=counter;
                    counter++;
                    j--;
                }
                counter=1;
                k='0';
            }
            else
            {
                counter++;
                dp[i]=counter;

            }
        }
       else if(arr[i]=='R')
        {
            counter=1;
            k='R';
        }
    }

    int frr[N]={0};

    for(int i=0;i<arr.size();i++)
    {
        if(arr[i]=='R')
        {
            if(dp[i]%2==0)
            {
                if(dp[i]+i<arr.size())
                frr[dp[i]+i]++;
                else
                {
                    frr[arr.size()-1]++;
                }
            }
            else
            {
                if(dp[i]+i-1<arr.size())
                frr[dp[i]+i-1]++;
                else
                {
                    frr[arr.size()-1]++;
                }
            }
        }
        else
        {
            if(dp[i]%2==1)
            {
                if(i-dp[i]+1>=0)
                frr[i-dp[i]+1]++;
                else frr[0]++;
            }
            else
            {
                if(i-dp[i]>=0)
                frr[i-dp[i]]++;
                else frr[0]++;
            }
        }
    }

   /* for(int i=0;i<arr.size();i++)
    {
        cout<<dp[i]<<" ";
    }
cout<<endl;  */

    for(int i=0;i<arr.size();i++)
    {
        cout<<frr[i]<<" ";
    }


}


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

int main()
{
  string s,t,u;
  int a,b;
  
  cin>>s>>t;
  cin>>a>>b;
  
  cin>>u;
  
  if(s.compare(u)==0)
    a-=1;
  else if(t.compare(u)==0)
    b-=1;
  
  cout<<a<<' '<<b;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,i,ans=0;
  string s;
  map<string,int64_t> m;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>s;
    sort(s.begin(),s.end());
    if(m.count(s)) m.at(s)++;
    else m[s]=1;
  }
  for(auto z:m) ans+=z.second*(z.second-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 N,a,b,c,Q,K,x,y,dist[100000];
vector<pair<int, int> > G[100000];
bool visited[100000] ={};

void dfs(ll now,ll dis){
    visited[now] = 1;
    dist[now] = dis;
    for(auto next : G[now]){
        if(!visited[next.first])dfs(next.first,next.second+dis);
    }
}

int main(){
    cin>>N;
    rep(i,N-1){
        cin>>a>>b>>c;
        a--;
        b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    cin>>Q>>K;
    K--;
    dfs(K,0);
    // rep(i,N){
    //     out(dist[i]);
    // }
    rep(i,Q){
        cin>>x>>y;
        x--;
        y--;
        out(dist[x]+dist[y]);
    }
}


Measured memory_bytes: 11776
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;


ll calc(const VL &a) {
  int n = a.size();
  // all 1?
  bool all_one = true;
  REP(i, 0, n) {
    all_one &= a[i] == 1;
  }
  if (all_one) {
    return 0;
  }
  VL sub(n);
  ll tot = 0;
  int cur = 0;
  REP(i, 0, n) {
    sub[i] = (a[i] + 1) / 2;
    // 0 ... 0 1 -> ok
    // 1 0 ... 0 1 -> Ok
    // 1 0 ... 0 -> ok
    // if it encounters 1, this sector can be completely ignored
    if (a[i] == 1) {
      if (cur > 0) {
	tot += 1;
	cur = 0;
      }
      // else, nothing happens.
      continue;
    }
    if (a[i] % 2 == 1) {
      if (cur == 0) {
	cur = 1;
      } else {
	tot += 1;
	cur = 0;
      }
    } else {
      cur += 1;
    }
  }
  if (cur > 0) {
    tot += 1;
  }
  return tot + calc(sub);
}

map<VL, ll> memo;

ll exact(const VL &a, bool path_rec = false) {
  int n = a.size();
  pair<ll, PI> mi(5e15, PI(-1, -1));
  bool all_one = true;
  REP(i, 0, n) {
    all_one &= a[i] == 1;
  }
  if (all_one) {
    return 0;
  }
  if (not path_rec && memo.count(a)) {
    return memo[a];
  }
  REP(i, 0, n) {
    REP(j, i, n) {
      VL sub(a);
      bool ok = true;
      bool nonone = false;
      REP(k, i, j + 1) {
	sub[k] = (sub[k] + 1) / 2;
	if (k != i && k != j) {
	  if (a[k] % 2 != 0) {
	    ok = false;
	    break;
	  }
	}
	if (a[k] != 1) {
	  nonone = true;
	}
      }
      if (not ok || not nonone) {
	continue;
      }
      ll res = exact(sub);
      mi = min(mi, make_pair(res, PI(i, j)));
    }
  }
  if (path_rec) {
    int u = mi.second.first;
    int v = mi.second.second;
    cerr << "perform " << u << " " << v << endl;
    cerr << "a:";
    REP(i, 0, n) {
      cerr << " " << a[i];
    }
    cerr << endl;
    VL sub(a);
    REP(k, u, v + 1) {
      sub[k] = (sub[k] + 1) / 2;
    }
    exact(sub, true);
  }
  return memo[a] = mi.first + 1;
}

int log2_int(ll x) {
  int cur = 0;
  while (true) {
    if (x < 1LL << cur) {
      return cur - 1;
    }
    cur += 1;
  }
}

// This solution was implemented after the author read the editorial.
ll solve(const VL &a) {
  int n = a.size();
  VI b(n + 2), c(n + 2);
  REP(i, 0, n) {
    b[i + 1] = log2_int(a[i]);
    c[i + 1] = log2_int(a[i] - 1) + 1;
  }
  vector<VI> dp(n + 2, VI(2, 0));
  REP(i, 1, n + 2) {
    REP(y, 0, 2) {
      int next = y ? c[i] : b[i];
      int mi = 1e8;
      REP(x, 0, 2) {
	int prev = x ? b[i - 1] : c[i - 1];
	mi = min(mi, dp[i - 1][x] + abs(next - prev) + abs(b[i] - c[i]));
      }
      dp[i][y] = mi;
    }
  }
  return min(dp[n + 1][0], dp[n + 1][1]);
}


int main(void) {
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  cout << solve(a) / 2 << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int N,i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef int ll;

int main(){
  ll N;
    cin >> N;
    for (int i = 1; i < 10; ++i){
        if(N%i != 0) continue;
        if(N/i <= 9){
          cout << "Yes";
          return 0;
        }
    }
    cout << "No";
 }




Measured memory_bytes: 256