akhauriyash/Code-Regression huggingface dataset:
# Review problem

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
N, K = map(int, input().split())
graph = [[] for i in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
visited = [0 for i in range(N+1)]
dis = [0 for i in range(N+1)]
parent = [-1 for i in range(N+1)]
parent[1] = -1
visited[1] = True
mod = 10**9+7


def bfs(node):
    for child in graph[node]:
        if visited[child] == False:
            visited[child] = True
            parent[child] = node
            dis[child] = dis[node]+1
            bfs(child)


bfs(1)

par_data = defaultdict(int)
for i in range(1, N+1):
    x = parent[i]
    par_data[x] += 1
ans = K
for parent in par_data.keys():
    if parent > 0:
        X = par_data[parent]
        if parent == 1:
            for i in range(X):
                ans = ans*(K-1-i)
                ans %= mod
                if ans==0:
                  print(0)
                  exit()
        else:
            for i in range(X):
                ans = ans*(K-2-i)
                ans %= mod
                if ans==0:
                  print(0)
                  exit()
print(ans)

Measured memory_bytes: 101492
from fractions import gcd
from functools import reduce

nums = list(map(int, input().split()))
N = nums[3]
R, G, B = sorted(nums[:3])

d = reduce(gcd, [R, G, B])
# if N % d != 0:
#     print(0)
R, G, B, N = R//d, G//d, B//d, N//d

count = 0
for b in range(N//B + 1):
    M = N - B * b
    for g in range(M//G + 1):
        L = M - G * g
        if L % R == 0:
            count += 1

print(count)


Measured memory_bytes: 65896
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int N,W;
ll w[110], v[110];

// dp[i+1][j]: 商品iまで，重さの和j以下として選ぶときの，価値の総和のmax
ll dp[110][100100];

int main()
{
  cin >> N >> W;
  REP(i,0,N) cin >> w[i] >> v[i];

  // Init
  REP(j,0,W+1) dp[0][j] = 0;
  // Update
  REP(i,0,N) {
    REP(j,0,W+1) {
      if (j >= w[i]) dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
      // 商品iを選べない場合
      else dp[i+1][j] = dp[i][j];
    }
  }

  // 添字ずれ
  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 80128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    vector<int> list(N, 0);

    for(int i = 1; i < (int)(N); i++){
        int input_num;
        cin >> input_num;
        list.at(input_num - 1)++;
    }
    
    rep(i, list.size()){
        cout << list.at(i) << endl;
    }
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;Z[f]=1;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=Z[d],!H[f]|Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38088
#include<bits/stdc++.h>
using namespace std;
int a[10][10],n,b;
bool v[10][10];
int main() {
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			scanf("%d",&a[i][j]);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&b);
		for(int i=1;i<=3;i++)
			for(int j=1;j<=3;j++) {
				if(a[i][j]==b) v[i][j]=1;
			}
	}
	for(int i=1;i<=3;i++) {
		bool t=false;
		for(int j=1;j<=3;j++)
			if(!v[i][j]) t=true;
		if(!t) {
			cout<<"Yes";
			exit(0);
		}
	}
	for(int j=1;j<=3;j++) {
		bool t=false;
		for(int i=1;i<=3;i++)
			if(!v[i][j]) t=true;
		if(!t) {
			cout<<"Yes";
			exit(0);
		}
	}
	bool t=false;
	for(int i=1;i<=3;i++)
		if(!v[i][i]) t=true;
	if(!t) {
		cout<<"Yes";
		exit(0);
	}
	t=false;
	for(int i=1;i<=3;i++) {
		if(!v[i][3-i+1]) {	
			t=true;
		}
	}
		
	if(!t) {
		cout<<"Yes";
		exit(0);
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int top = a/100;
        int bottom = a%10;
      if(top == bottom){
		System.out.println("Yes");
      }else{
		System.out.println("No");
      }
	}
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  vi p;
  REP(i, n) { p.PB(read()); }
  int ans = 0;
  FOR(i, 1, n - 1) {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
        (p[i + 1] < p[i] && p[i] < p[i - 1]))
      ans++;
  }
  print(ans);
}


Measured memory_bytes: 256
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();
    map<int, int> a;

    for (int i = 0; i != n; ++i)
        a[input<int>()] += 1;

    int ans = 0;
    for (auto elem: a)
        if (elem.second < elem.first)
            ans += elem.second;
        else
            ans += elem.second - elem.first;

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

struct dice{
	int side[6];
	dice(){ side[4] = 1, side[5] = 6, 
		side[0] = 5, side[1] = 3, side[2] = 2, side[3] = 4; }
};

void solve(dice* o, int i, int j, int k, int l){
	int p = o->side[i];
	o->side[i] = o->side[j];
	o->side[j] = o->side[k];
	o->side[k] = o->side[l];
	o->side[l] = p;
}

int n;
string s;

int main(){
	while (cin >> n&&n){
		dice d;
		int sum = 1;
		REP(i, n){
			cin >> s;
			if (s == "North") solve(&d, 4, 2, 5, 0);
			else if (s == "East")solve(&d, 4, 3, 5, 1);
			else if (s == "West")solve(&d, 4, 1, 5, 3);
			else if (s == "South")solve(&d, 4, 0, 5, 2);
			else if (s == "Right")solve(&d, 2, 1, 0, 3);
			else if (s == "Left")solve(&d, 2, 3, 0, 1);
			sum += d.side[4];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::unordered_map<int, int> type_occurences;
typedef std::set<int> type_set_int;
using t_map_rate_n = std::map<int, int>;
using vint = std::vector<int>;


struct abc_178_d {
	const ll mod_by = 7 + 1e9;
	std::vector<ll> dp;
	ll run(const int S) {
		ll ans = 0;

		dp.resize(S+10);
		dp[0] = 0;
		dp[1] = 0;
		dp[2] = 0;
		dp[3] = 1;
		dp[4] = 1;
		dp[5] = 1;

		for(int i = 6; i <= S; ++i) {
			// i >= 3 + 3

			// single number
			dp[i] = 1;
			for(int j = 3; j < i; ++j) {
				dp[i] += dp[i-j];
				dp[i] %= mod_by;
			}
		}

		return dp[S];
	}
};

int main(void) {
	abc_178_d solver;
	int S;

	std::cin >> S;

	std::cout << solver.run(S) << std::endl;

	return 0;
}


Measured memory_bytes: 3608
n,k = map(int,input().split())
lis = list(map(int,input().split()))
li = list(map(int,input().split()))
lis.sort(reverse=True)
li.sort()
hi = 10 ** 12
low = 0
while hi > low+1:
    mid = (hi + low)//2
    cnt = 0
    for i in range(n):
        cnt += max(0,lis[i]-mid//li[i])
    if cnt <= k:
        hi = mid
    else:
        low = mid
    ans1 = low
    ans2 = hi
cnt = 0
for i in range(n):
    cnt += max(0,lis[i]-ans1//li[i])
if cnt <= k:
    print(ans1)
else:
    print(ans2)

Measured memory_bytes: 119500
#include <stdio.h>
#define INF 214748364

void dijkstra();
void initializeSingleSource();

int n,color[100],d[100],dis[100],pi[100],w[100][100];

int main(){
  int i,j,c,u,k,v;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      w[i][j]=-1;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&c,&v);
      w[u][c]=v;
    }
  }
  dijkstra();

  for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);

  return 0;
}

void dijkstra(){
  int i,j,u,v,mincost;
  
  initializeSingleSource();

  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=1&&d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost==INF) break;

    color[u]=1;

    for(v=0;v<n;v++){
      if(color[v]!=1&&d[u]+w[u][v]<d[v]&&w[u][v]!=-1){
	pi[v]=u;
	d[v]=w[u][v]+d[u];
      }
    }
  }
  
  /*for(i=0;i<n;i++){
    dis[i]=d[i];
    j=i;
    while(pi[j]!=-1){
      dis[i]+=d[pi[j]];
      j=pi[j];
    }
    }*/
}

void initializeSingleSource(){
  int v;

  for(v=0;v<n;v++){
    d[v]=INF;
    pi[v]=-1;
    color[v]=-1;
  }
  d[0]=0;
}

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

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

    int ans = a.back() == b.front() && b.back() == c.front();

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int Parent(int i){
  return i/2;
}
 
int Left(int i){
  return 2*i;
}
 
int Right(int i){
  return 2*i+1;
}
 
int check(int n,int i){
  if(n>=Right(i)) return 1;//右側もある
  else if(n>=Left(i) && n<Right(i)) return 2;//右側がない
  else if(n<Left(i)) return 3;//左側すらない（ラスハイ）
}
 
main(){
  int n,i;
  int *A;
 
  scanf("%d",&n);
 
  A=(int *)malloc((n+1)*sizeof(int));
 
  for(i=1;i<=n;i++){
	 scanf("%d",&A[i]);
 }

  for(i=1;i<=n;i++){
    if(i==1){
      if(check(n,i)==1) printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i],A[Left(i)],A[Right(i)]);
      else if(check(n,i)==2) printf("node %d: key = %d, left key = %d, \n",i,A[i],A[Left(i)]);
      else if(check(n,i)==3) printf("node %d: key = %d, \n",i,A[i]);
    }
    else{
      if(check(n,i)==1) printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[Parent(i)],A[Left(i)],A[Right(i)]);
      else if(check(n,i)==2) printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[Parent(i)],A[Left(i)]);
      else if(check(n,i)==3)printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[Parent(i)]);
    }
  }
 
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    ll n;
    cin >> n;
    ll ans = 0;
    REP1 (i,n) {
        if ((ll)log10(i)%2 == 0) ans++;
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  int n;string s;
  cin>>n>>s;
  int ans=1;
  rep(i,n-1){
    if(s[i]!=s[i+1])ans++;
  }
  cout(ans);
}

Measured memory_bytes: 512
import Control.Monad
import Control.Applicative

maxProfit [x] m = x - m
maxProfit (x:xs) m
    | x < m     = max (x-m) (maxProfit xs x)
    | otherwise = max (x-m) (maxProfit xs m)

main = do
    s <- (drop 1.map read.lines) <$> getContents ::IO[Int]
    putStrLn $ show $ maxProfit (drop 1 s) (s!!0)

Measured memory_bytes: 30928
#include <stdio.h>
    #include<stdlib.h>
     
    int main(void)
    {
    	long int X, Y;
    	scanf("%ld %ld",&X,&Y);
     
    	char ret;
    	if(abs(X-Y) <= 1)
    		printf("Brown");
    	else
    		printf("Alice");
     
    	return 0;
    }

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

int main() {
	int A,B,C;
	cin >> A >> B >> C;

	rep(i,100)
		if(A*(i+1)%B == C) {
			cout << "YES" << endl;
			return 0;
		}

	cout << "NO" << endl;
}

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

using namespace std;

const int N = (int) 2e5 + 10;

int n, m;
int a[N];

int main() {
  scanf("%d", &n);
  map <int, int> cnt;
  for (int i = 1; i <= n; i++) {
    int x; scanf("%d", &x);
    cnt[x]++;
  }
  scanf("%d", &m);
  map <int, int> ahihi;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    ahihi[a[i]]++;    
  }
  for (int i = 1; i <= m; i++) {
    if (ahihi[a[i]] > cnt[a[i]]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}

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

int main(){
    int a[101] = {};
    int now = 1, i = 1;
    while(i <= 100){
        while(i <= 100 && i < now*2)    a[i++] = now;
        now *= 2;
    }

    int n;
    cin >> n;
    cout << a[n] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
const int INF = 100000000;

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int n, m, s, g1, g2;
		cin >> n >> m >> s >> g1 >> g2;
		if(n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0){ break; }
		--s; --g1; --g2;
		vector< vector<int> > matrix(n, vector<int>(n, INF));
		for(int i = 0; i < m; ++i){
			int b1, b2, c;
			cin >> b1 >> b2 >> c;
			--b1; --b2;
			matrix[b1][b2] = min(matrix[b1][b2], c);
		}
		for(int i = 0; i < n; ++i){ matrix[i][i] = 0; }
		for(int k = 0; k < n; ++k){
			for(int i = 0; i < n; ++i){
				for(int j = 0; j < n; ++j){
					if(matrix[i][k] + matrix[k][j] < matrix[i][j]){
						matrix[i][j] = matrix[i][k] + matrix[k][j];
					}
				}
			}
		}
		int answer = INF;
		for(int i = 0; i < n; ++i){
			answer = min(
				answer, matrix[s][i] + matrix[i][g1] + matrix[i][g2]);
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  string s;
  cin>>n>>s;;

  ll ans=0;

  int x=0,y=n-1;
  while(x<y){
    if(s[x]=='R') {
      x++;
      continue;
    }
    else if(s[y]=='W') {
      y--;
      continue;
    }
    else {
      x++;
      y--;
      ans++;
    }
  }


  cout << ans << endl;

}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  string N;
  cin >> N;
  if (N[0] == N[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  ll a[n];
  rep(i,n)cin>>a[i];
  int all_bits=40;

//40bit全部見る
//kの中でbitが立っている箇所を全部見る
//bitが立っている場所を0にして、その桁数を記憶
//桁数よりも大きい位置にあるbitはkを真似る
//同じ桁は0にする
//それよりも小さい桁はaの同じ桁のビットを見てカウントし、少ない方にする(xがk以下でresultを最大化する値にする)

  ll result=0;
  rep(i,n)result+=(k^a[i]);

  rep(i,all_bits){
    ll current=(1LL<<i);
    if(!(current & k))continue;

    ll tmp_result=0;
    rep(j, all_bits){
      ll mask=1LL<<j;
      ll count=0;
      rep(k,n)if( a[k]&mask )count++;

      if(i<j){
        if(k & mask){
          tmp_result+=mask*(n-count);
        }else{
          tmp_result+=mask*count;
        }
      }else if(i==j){
        tmp_result+=mask*count;
      }else if(i>j){
        tmp_result+=mask*max(count, n-count);
      }
    }

//cout<<result<<' '<<tmp_result<<endl;


    result=max(result, tmp_result);
  }

  cout<<result;

  return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextInt()
	s := nextString()
	ss := strings.Split(s, " ")
	bb := make([]int64, n, n)
	for i := range ss {
		bb[i], _ = strconv.ParseInt(ss[i], 10, 64)
	}

	visible := make([]bool, n, n)
	for v := range visible {
		visible[v] = true
	}

	for i := int64(0); i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			if visible[j] && bb[i] > bb[j] {
				visible[j] = false
			}
		}
	}

	count := 0
	for _, v := range visible {
		if v {
			count++
		}
	}
	fmt.Println(count)

}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string n;
  cin >> n;
  string ans = "No";
  for (auto &c : n) {
    if (c == '7') {
      ans = "Yes";
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3596
# -*- coding: utf-8 -*-

def main():
    I = [e for e in input()]
    N = [int(I[0]), int(I[1]), int(I[2]), int(I[3])]

    for i in range(2):
        for j in range(2):
            for k in range(2):
                sum = N[0]

                if i == 0:
                    sum += N[1]
                else:
                    sum -= N[1]

                if j == 0:
                    sum += N[2]
                else:
                    sum -= N[2]

                if k == 0:
                    sum += N[3]
                else:
                    sum -= N[3]

                if sum == 7:
                    res = "{}{}{}{}{}{}{}=7".format(
                            N[0],
                            "+" if i == 0 else "-",
                            N[1],
                            "+" if j == 0 else "-",
                            N[2],
                            "+" if k == 0 else "-",
                            N[3],
                            )
                    print(res)
                    return

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, z, w; cin >> n >> z >> w;
    vint a(n);
    rep(i,n) cin >> a[i];
    if (n >= 2) cout << max(abs(w-a[n-1]),abs(a[n-2]-a[n-1])) << endl;
    if (n == 1) cout << abs(a[n-1]-w) << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,k; cin >> n >> k;
    vec<int> row;
    char ch, past_ch;
    cin >> past_ch;
    row.push_back(1);
    rep(i,n-1) {
        cin >> ch;
        if(ch==past_ch) ++*--row.end();
        else row.push_back(1);
        past_ch = ch;
    }

    vi csum_range(row.size()+1), csum(row.size()+1);
    rep(i, row.size()) csum_range[i+1] += csum_range[i] + row[i];
    rep(i, row.size()) csum[i+1] += csum[i] + row[i]-1;

    int ans = -1, cnt;
    for(int i = 0; i < row.size(); ++i) {
        cnt = 0;
        cnt += csum[row.size()]-csum[0];
        cnt -= csum[min((int)row.size(), i+2*k+1)]-csum[i];
        cnt += csum_range[min((int)row.size(), i+2*k+1)]-csum_range[i]-1;
        chmax(ans, cnt);
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 1528
n = int(input())
v = input().split()
v = [int(x) for x in v]
c = input().split()
c = [int(x) for x in c]

sum = 0
for i in range(n):
  if v[i] > c[i]:
    dif = v[i] - c[i]
    sum += dif
print(sum)

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.next();
		int a = Integer.parseInt(sc.next());
		int current = a;
		int next = 0;
		boolean can = true;
		int sa = 0;
		String result = "Yes";
		while(sc.hasNext()) {
			next = Integer.parseInt(sc.next());
			if(can) current--;
			sa = current - next;
			if(sa>0) {
				result = "No";
				break;
			}
			if(current<next) {
				can = true;
			}else {
				can = false;
			}
			current = next;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 45132
using System;

class Program
{
 static void Main(string[] args)
 {
   int cnt1;
   int cnt2;
   int[] cashNum = {-1,-1,-1};
   int sum = 0;
   bool bk = false;
   
   string[] str = Console.ReadLine().Split(' ');
   int num = int.Parse(str[0]);
   int cash = int.Parse(str[1]);
   
   for( cnt1 = 0; cnt1 <= num; cnt1++ )
   {
    for( cnt2 = 0; cnt2 <= (num - cnt1); cnt2++ )
    {
      sum = ( 10000 * cnt1 ) + ( 5000 * cnt2 ) + ( 1000 * (num - cnt1 - cnt2) );
      if( cash == sum ) {
        cashNum[0] = cnt1;
        cashNum[1] = cnt2;
        cashNum[2] = (num - cnt1 - cnt2);
        bk = true;
      }
    }
     
     if(bk)
     {
       break;
     }
   }
   
   Console.WriteLine("{0} {1} {2}", cashNum[0], cashNum[1], cashNum[2] );
 }
}

Measured memory_bytes: 13140
(* O(n + q) *)
open Array
let n, q, s = Scanf.scanf " %d %d %s" @@ fun a b c -> a, b, c
let lrs = init q @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b - 1
let sums = make (n + 1) 0
let _ =
  String.iteri (fun i c -> sums.(i + 1) <- sums.(i) + if c = 'A' && i + 1 < n && s.[i + 1] = 'C' then 1 else 0) s;
  iter (fun (l, r) -> Printf.printf "%d\n" @@ sums.(r) - sums.(l)) lrs

Measured memory_bytes: 8320
h,w,a,b=map(int,input().split())

if (h/2 < b)|(w/2 < a):
        print("No")    
else:
    for hi in range(h):
        if hi<b:
            row = ""
            for wi in range(w):
                if wi <a:
                    row += "1"
                else:
                    row += "0"
        else:
            row = ""
            for wi in range(w):
                if wi <a:
                    row += "0"
                else:
                    row += "1"
            
        print(row)

Measured memory_bytes: 45572
N, M, V, P = map(int, input().split())
A = [int(c) for c in input().split()]
A.sort(reverse=True)
m = A[P-1]
l = -1
r = N
while l+1<r:
  s = (l+r)//2
  c = A[s]
  if m>c+M:
    r = s
    continue
  if s<P:
    l = s
    continue
  x = 0
  for i in range(N):
    if i<P-1:
      x += M
      continue
    if i>=s:
      x += M
      continue
    x += min(M,A[s]+M-A[i])
  if x>=M*V:
    l = s
  else:
    r = s
print(l+1)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e9 + 9;
const int maxn = (int) 1e6 + 6;
const int mod = (int) 1e9 + 7;

using namespace std;

int inp[maxn][3], dp[maxn][3];

signed main() {
    //dp[i][j] = max pts till ith day using jth activity

    int n; cin >> n;

    for(int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      inp[i][0] = a;
      inp[i][1] = b;
      inp[i][2] = c;
    }

    dp[0][0] = inp[0][0]; dp[0][1] = inp[0][1]; dp[0][2] = inp[0][2];

    for(int i = 1; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            dp[i][j] = max(dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3]) + inp[i][j]; //max(inp[i][(j+1)%3], inp[i][(j+2)%3]);
        }
    }
  
    int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) ;
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void dfs0(int cur, int pre, vector<ll> &res, const Graph &G, const int M) {
    for (int nx : G[cur]) {
        if (nx == pre) continue;
        dfs0(nx, cur, res, G, M);
        (res[cur] *= res[nx] + 1) %= M;
    }
}

void dfs1(int cur, int pre, ll pass, vector<ll> &res, const Graph &G, const int M) {
    (res[cur] *= pass + 1) %= M;
    int len = G[cur].size();
    vector<ll> pro0(len+1), pro1(len+1);
    pro0[0] = pro1[len] = 1;
    for (int i=1; i<len+1; ++i) {
        if (G[cur][i-1] == pre) pro0[i] = pro0[i-1] * (pass + 1) % M;
        else pro0[i] = pro0[i-1] * (res[G[cur][i-1]] + 1) % M;
    }
    for (int i=len-1; i>=0; --i) {
        if (G[cur][i] == pre) pro1[i] = pro1[i+1] * (pass + 1) % M;
        else pro1[i] = pro1[i+1] * (res[G[cur][i]] + 1) % M;
    }
    for (int i=0; i<len; ++i) {
        int nx = G[cur][i];
        if (nx == pre) continue;
        dfs1(nx, cur, pro0[i] * pro1[i+1] % M, res, G, M);
    }
}

void solve() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i=0; i<N-1; ++i) {
        int x, y;
        cin >> x >> y;
        G[x-1].push_back(y-1);
        G[y-1].push_back(x-1);
    }

    vector<ll> res(N, 1);
    dfs0(0, -1, res, G, M);
    dfs1(0, -1, 0, res, G, M);
    for (ll x : res) cout << x << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 22076
#include <stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    int i,j;
    int ans=1000000,sum;
    
    int a[105];
    for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    }
    
    for(i=-100;i<=100;i++){
        sum=0;
        for(j=0;j<N;j++){
            
            sum+=(i-a[j])*(i-a[j]);
        }
        if(sum<ans){
            ans=sum;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import heapq
from collections import deque

def bfs(i, c):
    color[i] = c
    cnt[c] += 1
    q = deque()
    q.append(i)
    while q:
        j = q.popleft()
        for k in G[j]:
            if color[k] == -1:
                color[k] = c
                cnt[c] += 1
                q.append(k)
    return

n = int(input())
xy = []
for i in range(n):
    x, y = map(int, input().split())
    xy.append([x, y, i])
xy.sort()
cnt = [0] * n
h = [[n + 1, n + 1]]
G = []
for _ in range(n):
    G.append([])
for i in range(n):
    c = 0
    while h[0][0] < xy[i][1]:
        p = heapq.heappop(h)
        if c == 0:
            minv = p
        c = 1
        G[p[1]].append(xy[i][2])
        G[xy[i][2]].append(p[1])
    heapq.heappush(h, [xy[i][1], xy[i][2]])
    if c:
        heapq.heappush(h, minv)
color = [-1] * n
c = 0
for i in range(n):
    if color[i] == -1:
        bfs(i, c)
        c += 1
for i in range(n):
    ans = cnt[color[i]]
    print(ans)

Measured memory_bytes: 149008
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		long A[] = new long[T];
		long B[] = new long[T];
		long C[] = new long[T];
		long D[] = new long[T];
		for (int i = 0; i < T; i++) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
			C[i] = sc.nextLong();
			D[i] = sc.nextLong();
		}
		for (int i = 0; i < T; i++) {
			Long AA = A[i];
			Long BB = B[i];
			Long CC = C[i];
			Long DD = D[i];
			boolean JG = true;
			if (AA < BB || DD < BB) {
				JG = false;
			} else if (CC >= BB) {
				JG = true;
			} else {
				Set<Long> set = new HashSet<>();
				Long A1 = AA % BB;
				set.add(A1);
				if (A1 > CC) {
					JG = false;
				} else {
					Long D2 = DD % BB;
					A1 += D2;
					while (true) {
						//System.out.println(A1);
						if (A1 >= BB) {
							A1 -= BB;
						}
						if (A1 > CC) {
							JG = false;
							break;
						} else {
							if (D2 == 0) {
								JG = true;
								break;
							}
							long k = (BB - A1) / D2;
							if(A1 + (D2 * k) == BB){
								k--;
							}
							if (A1 + (D2 * k) > CC && A1 + (D2 * k) != BB) {
								JG = false;
								break;
							} else {
								A1 = A1 + (D2 * (k + 1)) - BB;
								if (set.contains(A1)) {
									JG = true;
									break;
								} else {
									set.add(A1);
								}
							}
						}
					}
				}
			}
			if (JG) {
				System.out.println("Yes");

			} else {
				System.out.println("No");

			}
		}

	}
}


Measured memory_bytes: 26688
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
#include <iomanip>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<(int)n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b,c) memset(a,b,sizeof(c)); //works only for 0 and -1
bool isPrime(int x){
for(int i=2;i*i<=x;i++){
if(x%i==0)return false;
}
  return true;
}
int main(){
  fast();
 ll n;
  cin>>n;
  int count_ac=0,count_wa=0,count_tle=0,count_re=0;
  for(int i=0;i<n;i++){
  string k;cin>>k;
    if(k=="AC")count_ac++;
    if(k=="WA")count_wa++;
    if(k=="TLE")count_tle++;
    if(k=="RE")count_re++;
  }
  cout<<"AC"<<" x "<<count_ac<<endl;
  cout<<"WA"<<" x "<<count_wa<<endl;
  cout<<"TLE"<<" x "<<count_tle<<endl;
  cout<<"RE"<<" x "<<count_re<<endl;
 return 0;
  
}




Measured memory_bytes: 3620
s=input()
c=0
f=0
if s.count('R')==3:
  print(3)
  f=1
if s.count('R')<=1 and f==0:
  print(s.count('R'))
  f=1

if s[0]=='R' and s[1]=='R' and f==0:
  print(2)
  f=1
if s[1]=='R' and s[2]=='R' and f==0:
  print(2)
  f=1
if f==0:
  print(1)


Measured memory_bytes: 61792
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD1    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define scd second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    // std::cin.tie(nullptr);
    // std::cout.tie(nullptr);
    // std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    int max_a = 0;
    Vi a(n);
    rep(i, n){
        cin >> a[i];
        chmax(max_a, a[i]);
    }

    Vi d; d = a;
    sort(all(d));
    int cnt = 0;
    rep(i, n){
        if(d[i] == max_a){
            ++cnt;
            d[i] = 0;
        }
    }

    sort(all(d));

    if(cnt == 1){
        rep(i, n){
            if(a[i] != max_a)
                cout << max_a << endl;
            else cout << d[n-1] << endl;
        }
    }

    else if(cnt >= 2){
        rep(i, n){
            cout << max_a << endl;
        }
    }

return 0;
}

Measured memory_bytes: 4856
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

string s;

int main()
{
    cin >> s;
    int n = s.size();
    bitset<9> bs;
    int mx = pow(2, n-1);
    ll ans=0;
    rep(i, mx){
        bs = i;
        //cout << i << ' ' << bs << endl;
        string a="";
        rep(j, n){
            a+=s[j];
            if(bs[j] == 0){
                ans += stol(a);
                a = "";
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int h,w;
int H=430,W=430;
int a[310][310];

int b[2][450][450];

ll bw[2][450][450],bh[2][450][450];

void convert(){
  int t = (w-1)/2;
  rep(x,0,w) rep(y,0,h) if((x+y)%2 == 0){
    if(a[y][x]==1){
      b[0][(-x+y)/2+t+1][(x+y)/2+1] = 1;
      bw[0][(-x+y)/2+t+1][(x+y)/2+1] = 1;
      bh[0][(-x+y)/2+t+1][(x+y)/2+1] = 1;
    }
  }else{
    if(a[y][x]==1){
      b[1][(-x+1+y)/2+t][(x+1+y)/2] = 1;
      bw[1][(-x+1+y)/2+t][(x+1+y)/2] = 1;
      bh[1][(-x+1+y)/2+t][(x+1+y)/2] = 1;
    }
  }
  rep(i,0,H) rep(j,0,W-1) rep(k,0,2){
    bw[k][i][j+1] += bw[k][i][j];
  }
  rep(i,0,W) rep(j,0,H-1) rep(k,0,2){
    bh[k][j+1][i] += bh[k][j][i];
  }
}

int main(){
  cin >> h >> w;
  string s;
  rep(i,0,h){
    cin >> s;
    rep(j,0,w) {
      if(s[j]=='#') a[i][j] = 1;
    }
  }
  convert();

  ll n=0;

  rep(k,1,H){
    rep(i,1,H){
      rep(j,1,W){
        if(j+k>=H)break;
        rep(l,0,2){
          if(b[l][i][j]==1 && b[l][i][j+k]==1){
            if(i-k>=0) n += bw[l][i-k][j+k]-bw[l][i-k][j-1];
            if(i+k<W) n += bw[l][i+k][j+k]-bw[l][i+k][j-1];
          }
        }
      }
    }
  }
  rep(k,1,H){
    rep(i,1,H){
      rep(j,1,W){
        if(i+k>=H)break;
        rep(l,0,2){
          if(b[l][i][j]==1 && b[l][i+k][j]==1){
            if(j-k>=0) n += bh[l][i+k-1][j-k]-bh[l][i][j-k];
            if(j+k<W) n += bh[l][i+k-1][j+k]-bh[l][i][j+k];
          }
        }
      }
    }
  }

  cout << n << endl;

  return 0;
}


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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> a(N);
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int count = 1;
	int length = 0;
	for(int i = 0; i < N; ++i) {
		length += a[i];
		if(length > X) {
			cout << count << endl;
			break;
		} else { 
			count += 1;
		}
	}
	if(count == N + 1) {
		cout << N + 1 << endl;
	}
}



Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  long long n,a,b;cin>>n>>a>>b;
  if(((n-1)%(a+b))+1 <= a){
    cout << (n-1)/(a+b)*a + ((n-1)%(a+b))+1 << endl;
  }else{
    cout << (n-1)/(a+b)*a + a << endl;
  }
}

Measured memory_bytes: 256