akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}

#pragma endregion

int _same(char a, char b, char c);
int _same(char a, char b, char c) {
	if (a == b && b == c) return 0;
	if ((a == b && b != c) || (a == c && a != b) ||
		(b == c && a != c)) return 1;
	return 2;
}



int main(void) {
	int N,tmp=0,i,len;
	char n[12];
	
	i_cin(N);

	_itoa(n,N);
	len=strlen(n);

	for (i = 0; i < len;i++) {
		tmp += (n[i] - '0');
	}

	s_cout((N%tmp)?"No":"Yes");

	return 0;
}

	/*int A, B, C, X;
	int a, b, r, tmp, cnt = 0;

	i_cin4(A, B, C, X);

	r = (X % 100) / 50;
	if (r && !C) {i_cout(0); return 0;}

	tmp= X / 500;
	a = (tmp > A) ? A : tmp;
	tmp = X / 100;
	b =  (tmp > B) ? B : tmp;
	if (a && b) cnt = a * b / 2;
	else cnt = _max(a, b);
	cnt++;
	i_cout(cnt);*/





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

int main() {
    int N;
    int arr[100][100];
    cin >> N;
    for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
            cin >> arr[j][k];
        }
    }
    long long ret = 0;
    for (int j = 0; j < N; ++j) {
        for (int k = 0; k < j; ++k) {
            ret += min(arr[j][k], arr[k][j]);
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    vector<vector<int>> c(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    for(int a1=0;a1<=c[0][0];a1++){
        for(int a2=0;a2<=c[1][0];a2++){
            for(int a3=0;a3<=c[2][0];a3++){
               int b1=c[0][0]-a1,b2=c[0][1]-a1,b3=c[0][2]-a1;
               bool f=true;
               if(a2+b1!=c[1][0] || a3+b1!=c[2][0] || a2+b2!=c[1][1] || a3+b2!=c[2][1] || a2+b3!=c[1][2] || a3+b3!=c[2][2]) f=false;
               if(f){
                   cout<<"Yes"<<endl;
                   return 0;
               } 
            }
        }
    }
    cout<<"No"<<endl;
}


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


int main() {
    int n,r;
    cin >> n >> r;
    if(n<10)cout << r+100*(10-n) << endl;
    else cout << r << endl;
    

    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n;     //テ・ツッツゥテ・ツ按、テヲツ閉ー
  int i,j;   //テ」ツδォテ」ツδシテ」ツδ療」ツつォテ」ツつヲテ」ツδウテ」ツつソ
  int a;
  int x[20]; //テヲツシツ氾ヲツ環?」ツ?ョテァツつケテヲツ閉ーテヲツ?シテァツエツ?
  int sum;
  int k=0;   //テ」ツδ?」ツδシテ」ツつソテ」ツつサテ」ツδε」ツδ暗」ツ?ョテ」ツつォテ」ツつヲテ」ツδウテ」ツδ?
  int max, min;

  for(i=0;i<20;i++){
    scanf("%d", &n);
    if(n==0)break;
    sum=0;
    max=0;
    min=1000;
    for(j=0;j<n;j++){
      scanf("%d", &a);
      sum=sum+a;
      if(max<a)max=a;
      if(min>a)min=a;
    }
    x[i]=(sum-max-min)/(n-2);
    k++;
  }
  for(i=0;i<k;i++)
    printf("%d\n", x[i]);

  return 0;
}

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

int N, K;
int ans;

int main() {
  cin >> N >> K;
  int h;
  rep(i, N) {
    cin >> h;
    if(h >= K) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc050/tasks/abc050_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, m, ti, pi, xi;
  vector<int> t, p, x;

  cin >> n;
  REP(i, n)
  {
    cin >> ti;
    t.push_back(ti);
  }
  cin >> m;
  REP(i, m)
  {
    cin >> pi >> xi;
    p.push_back(pi);
    x.push_back(xi);
  }

  REP(i, m)
  {
    int sum = 0;
    REP(j, n)
    {
      if (j == p[i] - 1)
        sum += x[i];
      else
        sum += t[j];
    }
    cout << sum << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define THE using
#define DARK namespace
#define ONE std
#define dbg(x) cout << #x << " = " << x << endl

THE DARK ONE;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("out.txt", "w", stdout);
//    freopen("input.txt", "r", stdin);
    int64_t N;
    cin >> N;
    for(int64_t i = N; ; i++){
        string str = to_string(i);
        set<char> s;
        for(char c: str) s.insert(c);
        if(s.size() == 1){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



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

int main() {
    int N;  cin >> N;
    using P = pair<int, int>;
    vector<P> tasks;
    for (int i = 0; i < N; ++i) {
        int a, b;  cin >> a >> b;
        tasks.push_back(P(b, a));
    }
    sort(tasks.begin(), tasks.end());

    long long now = 0;
    for (int i = 0; i < N; ++i) {
        if (now + tasks[i].second > tasks[i].first) {
            cout << "No" << endl;
            return 0;
        }
        now += tasks[i].second;
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <string>
#include<set>
#include<vector>
#include <map>
typedef long long ll;
using namespace std;
int main(void) {
    int i, n, m, mx=0;
    string s[100], t[100];
    map<string, int>mp;
    cin >> n;
    for(i=0; i<n; i++) {
        cin >> s[i];
        mp[s[i]]++;
    }
    cin >> m;
    for(i=0; i<m; i++) {
        cin >> t[i];
        mp[t[i]]--;
    }
    
    for(i=0; i<n; i++) {
        mx = max(mx, mp[s[i]]);
    }
    cout << mx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

int main() {
    int N;
    cin >> N;
    vector<double> A(N);
    rep(i, N) cin >> A[i];

    double M = 0;

    rep(i, N) {
        M += 1/A[i];
    }

    print(1/M);

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int px = 0, py = 0, pt = 0;
  bool res = true;
  for (int i = 0; i < N; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    int need = abs(x - px) + abs(y - py);
    if (need > t - pt || (t - pt - need) % 2 != 0) {
      res = false;
      break;
    }
    px = x;
    py = y;
    pt = t;
  }
  cout << (res ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5+9;

int g[N];

int main(){
	int n;cin >> n;
	for( int i = 0; i < n; i++ ){
		scanf("%d",g+i);
	}
	sort( g,g+n );
	int cnt = 1;
	long long x = 0;
	for( int i = 0; i < n-1; i++ ){
		x += g[i];
		if( 2*x >= g[i+1] ){
			cnt++;
		}else{
			cnt = 1;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  char w[101];
  int num[101];
  int i, k, count, odd=0;
  scanf("%s", w);

  for (i=0; w[i] != '\0'; i++){
    count = 1;
    if(w[i] != 'A'){
      for(k=i+1; w[k] != '\0'; k++){
        if(w[i] == w[k]){
          count++;
          w[k] = 'A';
        }
      }
      num[i] = count;
    }else{
      num[i] = 2;
    }
  }

  for(i=0; w[i] != '\0'; i++){
    if (num[i] % 2 != 0) {
      odd++;
    }
  }

  if(odd == 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  // プラン 1 : T 時間駐車した場合、A×T円が駐車料金となる。
  int plan1 = A * N;
  // プラン 2 : 駐車した時間に関わらず B 円が駐車料金となる。
  int plan2 = B;
  
  int min = plan1 < plan2 ? plan1 : plan2;
  cout << min << endl;
}

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

int main(){
	char s[1500];
	int num;
	int i;
	char c;

	while(1){
		scanf("%s", s);
		if(atoi(s) == 0){
			break;
		}
		else{
			num = 0;
			for(i=0; i<strlen(s); i++){
				num = num + s[i] - '0';
			}
			printf("%d\n", num);
		}
	}	

	

	return 0;

}


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

int main(){
  int n; cin >> n;
  long a[n], sum[n+1];
  sum[0] = 0;
  rep(i, n){
    cin >> a[i];
    sum[i+1] = sum[i] + a[i];
  }
  long p[n-3][4];
  int l = 1;
  for(int r=2; r<n-1; r++){
    long diff = abs(sum[r]-2*sum[l]);
    while(l<r-1 && diff>abs(sum[r]-2*sum[l+1])){
      l++;
      diff = abs(sum[r]-2*sum[l]);
    }
    p[r-2][0] = sum[l];
    p[r-2][1] = sum[r] - sum[l];
  }
  
  rep(i, n/2) swap(a[i], a[n-i-1]);
  rep(i, n) sum[i+1] = sum[i] + a[i];
  l = 1;
  for(int r=2; r<n-1; r++){
    long diff = abs(sum[r]-2*sum[l]);
    while(l<r-1 && diff>abs(sum[r]-2*sum[l+1])){
      l++;
      diff = abs(sum[r]-2*sum[l]);
    }
    p[n-r-2][3] = sum[l];
    p[n-r-2][2] = sum[r] - sum[l];
  }
  long ans = LONG_MAX;
  rep(i, n-3){
    long sumax = p[i][0];
    long sumin = p[i][0];
    rep(j, 3){
      if(sumax < p[i][j+1]) sumax = p[i][j+1];
      if(sumin > p[i][j+1]) sumin = p[i][j+1];
    }
    ans = min(ans, sumax-sumin);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9600
N = int(input()) 
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = list(range(1,N+1))
Alist=[]
import itertools
for v in itertools.permutations(A):
        Alist.append(v)
a_num = Alist.index(P)+1
b_num = Alist.index(Q)+1
print(abs(b_num - a_num))


Measured memory_bytes: 7924
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;

const int inf=1e9,mod=1e9+7,N=2e5+5;

void solve(){
	int n;
	cin>>n;
	vector<int>a(n+1),b(n);
	rep(i,n+1){
		cin>>a[i];
	}
	ll ans=0;
	rep(i,n){
		cin>>b[i];
	}
	rep(i,n){
		if(a[i]>=b[i]){
			ans+=b[i];
		}
		else{
			ans+=a[i];
			int x=a[i+1];
			a[i+1]=max(0,a[i+1]-(b[i]-a[i]));
			ans+=x-a[i+1];
		}
	}
	cout<<ans;

}

int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}


Measured memory_bytes: 3928
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn=30;
ll a[maxn];
int n;

ll dp(int l,int r,int x,int y)
{
    if(r-l==1) return 0;
    ll ans=1e18;
    for(int i=l+1;i<r;++i)
        ans=min(ans,dp(l,i,x,x+y)+dp(i,r,x+y,y)+a[i]*(x+y));
    return ans;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    cout<<a[1]+a[n]+dp(1,n,1,1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k, x, y; cin >> n >> k >> x >> y;
	int inx = min(n, k);
	int iny = max(n - k, 0);
	cout << inx * x + iny * y << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll n, x = 1, ans = 0;
    cin >> n;
    while(x < n) x *= 3, ans++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3076
import java.io.*;

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

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str1 = br.readLine();
      String str2[] = str1.split(" ");
      int a = Integer.parseInt(str2[0]);
      int b = Integer.parseInt(str2[1]);
      int c = a*b;
      int d = 2*(a+b);
      System.out.println( c + " " + d );

   }
}

Measured memory_bytes: 24092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,m;
    cin>>k>>n>>m;
    if(n%k==0 || m%k==0 || m/k!=n/k)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}


Measured memory_bytes: 3636
frag=0
a = list(input())
N=len(a)-1
for i in range(int(N/2)):
    if a[i]!=a[N-i]:
        frag=1
        break
if frag==0:
    for i in range(int(N/4)):
        if a[i]!=a[int(N/2-i-1)] or a[N-i]!=a[int(N/2+i+1)]:
            frag=1
            break
if frag==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

signed main() {
	ll n, k, mae = 0, ato = 0; cin >> n >> k;
	ll cnt = k;
	rep(i, 2 * n) { mae += cnt; cnt++; }
	rep(i, n) { ato += cnt; cnt++; }
	if (mae > ato) { cout << "-1\n"; return 0; }

	vector<ll> v1(n), v2(n), v3(n);
	cnt = k;
	for (int i = 0; i < n; i += 2) { v1[i] = cnt; cnt++; }
	for (int i = 1; i < n; i += 2) { v1[i] = cnt; cnt++; }
	for (int i = 1; i < n; i += 2) { v2[i] = cnt; cnt++; }
	for (int i = 0; i < n; i += 2) { v2[i] = cnt; cnt++; }
	rep(i, n) { v3[i] = k + 2 * n + i; }

	rep(i, n) {
		cout << v1[i] << ' ' << v2[i] << ' ' << v3[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5568
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>


int main(int argc, char* argv[])
{
    long m, n;
    scanf("%ld %ld", &m, &n);

    std::vector<long> a;
    long i;
    for(i=0; i<n; i++) {
        long tmp;
        scanf("%ld", &tmp);
        a.push_back( tmp );
    }

    std::vector<long> b(n);
    for(i=0; i<n; i++) {
        b[i] = m - a[n-1-i];
    }

    std::vector<long long> sum_a(n+1, 0);
    for(i=0; i<n; i++) {
        sum_a[i+1] = sum_a[i] + a[i];
    }

    std::vector<long long> sum_b(n+1, 0);
    for(i=0; i<n; i++) {
        sum_b[i+1] = sum_b[i] + b[i];
    }

    long long ans = 0;
    long kk;
    for(kk=0; kk<n; kk++) {
        long long sum = 0;
        long p = (n-kk) / 2;

        if((n-kk) % 2 == 0) {
            sum += (sum_a[kk+p] - sum_a[kk]) *2;
            sum += sum_b[p] * 2 - b[p-1];
        }
        else {
            sum += (sum_a[kk+p] - sum_a[kk]) *2 + a[kk+p];
            sum += (p>0? (sum_b[p] * 2): 0);
        }

        //printf("%lld\n", sum);
        if(ans<sum) {
            ans = sum;
        }
    }

    for(kk=0; kk<n; kk++) {
        long long sum = 0;
        long p = (n-kk) / 2;

        if((n-kk) % 2 == 0) {
            sum += (sum_b[kk+p] - sum_b[kk]) *2;
            sum += sum_a[p] * 2 - a[p-1];
        }
        else {
            sum += (sum_b[kk+p] - sum_b[kk]) *2 + b[kk+p];
            sum += sum_a[p] * 2;
        }

        //printf("%lld\n", sum);
        if(ans<sum) {
            ans = sum;
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 6640
using System;
using System.Linq;

namespace AGC035
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            long res = 0;
            for (int i = 0; i < N; i++)
            {
                res ^= a[i];
            }

            if (res == 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 20320
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n+1); FOR(i,1,n) cin>>a[i];
#define PI 3.141592653589793238
#define QUICK ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define srt(a); sort(a.begin(), a.end())
#define CASE int t; cin>>t; while(t--)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
#define upcase(s)  transform(s.begin(), s.end(), s.begin(), ::toupper)
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define int ll
const int INF = 1e9 + 7;
const int SIZE = 1e9 + 5;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////



void solve(){

	string s1 = "X", s2 = "Y";
	string k1, k2; cin>> k1 >> k2;
	s1+=k1; s2+=k2;

	int l1 = s1.size(), l2 = s2.size();
	vec(vec(int))dp(l1, vec(int)(l2, 0));

	dp[0][0] = 0;

	for(int i = 1; i<l1; i++){
		for(int j = 1; j<l2; j++){
			if(s1[i] == s2[j]){
				dp[i][j] += 1;
				dp[i][j] += dp[i-1][j-1];
				continue;
			}

			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int ans = 0;

	for(int i = 0; i< l2; i++)
		ans = max(ans, dp[l1-1][i]);

	char res [ans];
	res[ans--] = '\0';

	int i = l1-1, j = l2-1;

	while(i > 0 && j > 0){
		if(s1[i] == s2[j]){
			dbg(s1[i])
			res[ans--] = s1[i];
			i--;
			j--;
		}
		else if (dp[i-1][j] > dp[i][j-1]){
			i--;
		}else{
			j--;
		}
	}

	cout << res << endl;


}



int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	QUICK;
	//CASE{
		solve();
	//}
	printclock;
}

Measured memory_bytes: 73616
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#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())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



map<ll,ll> res;
void prime_factor(ll n){
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1) res[n]++;
    return;
}

ll inv_mod(ll n, ll mod) {
    ll a = n % mod, b = mod - 2, ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ret;
}

void solve(){
    ll n;
    ll a[100010];
    cin>>n;
    rep(i,n) cin>>a[i];
    map<ll,ll> mp;
    rep(i,n){
        res.clear();
        prime_factor(a[i]);
        for(auto j : res){
            chmax(mp[j.fi],j.sc);
        }
    }
    ll M=1;
    for(auto i : mp){
        rep(j,i.sc){
            M*=i.fi;
            M%=MOD;
        }
    }
    // cout<<M<<endl;
    ll ans=0;
    rep(i,n){
        ll ret = M * inv_mod(a[i],MOD)%MOD;
        ans+=ret;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

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

    solve(); 


    return 0;
}


Measured memory_bytes: 4312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a + b <= b + c && a + b <= c + a) {
			System.out.println(a + b);
		}else if(b + c <= a + b && b + c <= c + a) {
			System.out.println(b + c);
		}else {
			System.out.println(c + a);
		}
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<set>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    set<int>st;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(st.count(x))
        {
            st.erase(x);
        }
        else st.insert(x);
    }
    cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		
		for(int i = 0;i < n;i++)
		{
			for(int j = 0;j < m;j++)
			{
				A[i][j] = scan.nextInt();
			}
		}
		
		for(int i = 0;i < m;i++)
		{
			b[i] = scan.nextInt();
		}
		
		for(int i = 0;i < n;i++)
		{
			int ans = 0;
			for(int j = 0;j < m;j++)
			{
				ans += A[i][j] * b[j];
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 31808
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <array>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template<class T, T N>
constexpr void func(array<T, N> &arr) {
  arr[0] = 1;
  for (int i = 1; i < N; ++i) {
    arr[i] = (arr[i-1] * i) % MOD;
    arr[i] %= MOD;
  }
}


int main() {
  
  ll n, m;
  cin >> n >> m;

  constexpr int K = 100002;
  array<ll, K> t1, t2;

  if (abs(n - m) >= 2) {
    cout << 0 << endl;
    return 0;
  }

  func<ll, K>(t1);
  func<ll, K>(t2);

  if (abs(n - m) == 1) {
    cout << (t1[n] * t2[m]) % MOD << endl;
  } else {
    cout << (t1[n] * t2[m] * 2) % MOD << endl;
  }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) cin >> a[i];
	vector<ll>l(n), r(n);
	rep(i, n - 1) l[i + 1] = gcd(l[i], a[i]);
	for (int i = n - 1; i >= 1; i--)r[i - 1] = gcd(r[i], a[i]);
	ll ans = 1;
	rep(i, n) ans = max(ans, gcd(l[i], r[i]));
	cout << ans << endl;
	return 0;
}










Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    long long H;
    cin >> H;

    long long cnt = 1;
    long long ans = 0;
    while (H) {
        ans += cnt;

        cnt *= 2;
        H >>= 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

i = 0
ans = 0
while max(a) >= n:
    if a[i] >= n:
        cnt = a[i] // n
        ans += cnt
        a[i] -= n * cnt
        for j in range(n):
            if j == i:
                continue
            a[j] += cnt

    i = (i + 1) % n

print(ans)


Measured memory_bytes: 3060
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b,x = list(map(int, input().split()))
import math
if x*2>=a*a*b:
    the = (a*b - x/a) / (0.5*a*a)
else:
    the = (b*b*a) / (2*x)
ans = math.atan(the)
print(ans*180/math.pi)

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

void solve(long long N, vector<long long> a){
	Int s = 0;
	for(auto t:a)s+=t;
	Int s0 = 0;
	Int ans = 1e+18;
	for(int i=0;i<a.size();i++){
		s0+=a[i];
		if(i+1<a.size()){
			ans = min(ans,abs(s-s0-s0));
		}
	}
	cout<<ans<<endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 3328
n = STDIN.gets().to_i

a = Array.new(n).map{Array.new(n,0)}
n.times do |i|
  u, k, *vec = STDIN.gets().split(' ').map{ |i| i.to_i }
  #p "u:#{u}"
  vec.each do |v|
    #p "v:#{v}"
    a[u-1][v-1]=1
  end unless k==0
end

a.each do |line|
  print "#{line.join(' ')}\n"
end

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

int main(){
  int a[3]; REP(i,3){ cin >>a[i];}
  sort(a,a+3);
  printf("%d %d %d\n",a[0],a[1],a[2]);
}


Measured memory_bytes: 3264
#include<iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) {
    if(b == c) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  } else if(b == c) {
    if(a == b) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  } else if(a == c) {
    if(b == c) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  }else {
    cout << "No\n";
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s,t;
int sc[100100];
int tc[100100];
int q;
int main(){
	cin>>s>>t;
	cin>>q;
	REP(i,s.size()){
		if(s[i]=='A'){
			sc[i+1]=sc[i]+1;
		}else{
			sc[i+1]=sc[i]+2;
		}
		sc[i+1]%=3;
	}
	
	REP(i,t.size()){
		if(t[i]=='A'){
			tc[i+1]=tc[i]+1;
		}else{
			tc[i+1]=tc[i]+2;
		}
		tc[i+1]%=3;
	}
	
	REP(i,q){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--,c--;
		if((sc[b]-sc[a]+3)%3==(tc[d]-tc[c]+3)%3){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
from itertools import permutations

n = int(input())
s = tuple(map(int,input().split()))
t = tuple(map(int,input().split()))

a = list(permutations(list(range(1,n+1)),n))
a.sort()
for i in range(len(a)):
    if a[i] == s:
        p = i
    if a[i] == t:
        q = i
    
print(abs(p-q))


Measured memory_bytes: 45040
N = int(input())

chk = 0

for i in range(1, int(N ** 0.5) + 1):
    if N % i == 0:
        cp = N / i
        temp = i + cp

        if chk != 0:
            if temp < chk:
                chk = temp
        else:
            chk = temp

print(int(chk - 2))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;

int n;
int a[MAX];
set<int> st;
multiset<int> ms;
void input(){
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n){
    st.insert(a[i]);
    ms.insert(a[i]);
  }
}

bool ans=false;
void solve(){
  if((int)st.size()==1 && *st.begin()==0)ans=true;
  else if((int)st.size()==3){
    int p[3];
    int ind=0;
    for(auto itr = st.begin(); itr != st.end(); ++itr){
      p[ind]=*itr;
      ind++;
    }
    int ct[3];
    rep(i,3)ct[i]=(int)ms.count(p[i]);
    int k=(p[0]^p[1])^p[2];
    if(ct[0]==ct[1] && ct[1]==ct[2] && k==0)ans=true;  
  }
  else if((int)st.size()==2){
    int p[2];
    int ind=0;
    for(auto itr = st.begin(); itr != st.end(); ++itr){
      p[ind]=*itr;
      ind++;
    }
    int ct[2];
    rep(i,3)ct[i]=(int)ms.count(p[i]);
    if(p[0]==0 && ct[0]==n/3 && ct[1] == 2*n/3)ans=true;
  }
  if(ans)cout<<"Yes";
  else cout<<"No";
}


int main(){
  input();
  solve();
}

Measured memory_bytes: 7808
/*
    Only way to go is UP 
    H1s3nb3rg's Here !!
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h> 
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int,int> pi;
typedef uint64_t i64;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vector<ll>> v2ll;
const int MOD = 1e9+7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAIN int main(){FAST_IO;ll tc;cin>>tc;while(tc--){solver();}ret0;}
#define MAIN1 int main(){FAST_IO;solver();ret0;}
#define rep(i,b,e) for(__typeof(e)i=(b)-((b)>(e));i!=(e)-((b)>(e));i+=1-2*((b)>(e)))
#define repa(i,x)  for(auto i:x)
#define vin(x) for(auto &i:x){cin>>i;}
#define vin1(x) for(ll i=1;i<x.size();i++){cin>>x[i];}
#define dbg(x) for(auto i:x){cout<<i<<" ";}cout<<ENDL;
#define dbg2(x) for(auto &i:x){for(auto j:i){cout<<j<<" ";}cout<<endl;}
#define dbgp(x) for(auto i:x){cout<<i.ff<<" "<<i.ss<<endl;}
#define ENDL "\n"
#define VALL(a) a.begin(),a.end()
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define MP(a,b) make_pair(a,b)
#define ff first
#define ss second
#define ret0 return 0;
#define ret return;
#define pb(x) push_back(x)
/*----------------------------*/


void solver(){
    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R' ){
        cout<<3<<ENDL;
        ret;
    }
    else if(s[0]=='R' && s[1]=='R' || s[1]=='R' && s[2]=='R'){
        cout<<2<<ENDL;
        ret;
    }
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R'){
        cout<<1<<ENDL;
        ret;
    }
    else
    {
        cout<<0<<ENDL;
        ret;
    }
    
}

MAIN1


Measured memory_bytes: 3540
#include <iostream>
#include<algorithm>
#include <vector>
#include<map>
#include<deque>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main(){
	string s;
	cin >> s;
	int ki = 0 , guu=0;
	int n = s.size();
	FOR(n) {
		if (i % 2 == 0) {
			if (s[i] == '0') {
				guu++;
			}
		}
		else {
			if (s[i] == '1') {
				ki++;
			}
		}
	}
	cout << min(ki + guu, n - ki - guu);
	return 0;
}


inline ll kaizyo(ll x) {
	ll ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 512
// 問題のURLをここに


#include "bits/stdc++.h"
using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int a;
	string s;

	cin >> a;
	cin >> s;

	if (a >= 3200)
		cout << s << "\n";
	else
		cout << "red\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int cums[100001],cumt[100001];

int main(){
    string s,t;
    cin >> s >> t;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A') cums[i+1]+=1;
        else if(s[i]=='B') cums[i+1]+=2;
        cums[i+2]+=cums[i+1];
    }
        for(int i=0;i<t.length();i++){
        if(t[i]=='A') cumt[i+1]+=1;
        else if(t[i]=='B') cumt[i+1]+=2;
        cumt[i+2]+=cumt[i+1];
    }
    int q;
    cin >> q;
    while(q--){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        if((cums[b]-cums[a-1])%3==(cumt[d]-cumt[c-1])%3) puts("YES");
        else puts("NO");
    }
    return 0;
}

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

void nextanother(int& i, int N, int& Another, int One) {
	cin >> Another;
	i++;
	while (i < N && Another == One) {
		cin >> Another;
		i++;
	}
}

int main() {
	int N;
	cin >> N;
	int ans = 1;
	int A1, A2, A3;
	cin >> A1;
	int i = 1;
	nextanother(i, N, A2, A1);
	while (i < N) {
		nextanother(i, N, A3, A2);
		if (((A3 < A2) && (A2 > A1)) || ((A3 > A2) && (A2 < A1))) {
			ans++;
			if (i < N) {
				A1 = A3;
				nextanother(i, N, A2, A1);
			}
		}
		else {
			A1 = A2;
			A2 = A3;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
data = input().split()
r = int(data[0])
D = int(data[1])
x_2000 = int(data[2])

x_200i = r*x_2000 - D
print(x_200i)

for i in range(9):
  x_200i = r*x_200i - D
  print(x_200i)

Measured memory_bytes: 38256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

AB.sort(key=lambda x: x[0])

import heapq
from collections import deque

AB = deque(AB)

ans = 0
task = []
heapq.heapify(task)

for i in range(M):
    while len(AB) > 0 and AB[0][0] <= i+1:
        t = AB.popleft()
        heapq.heappush(task,-t[1])
    if len(task) > 0:
        ans += heapq.heappop(task)
print(-ans)




Measured memory_bytes: 28984
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll int
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    ll ans=INT_MAX;
    rep(i,0,sz(s)-2)
    {
    	ans=min(ans,abs(stoi(s.substr(i,3))-753));
    }
    cout<<ans;
}


Measured memory_bytes: 256
use std::io;

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

    let n = buf.trim().parse::<i32>().unwrap();
    let i = n / 111 + if n % 111 == 0 { 0 } else { 1 };

    println!("{}", i * 111);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <stdlib.h>

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n) INC(i, 0, n)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        std::cout << T << std::endl;
    }else{
        std::cout << F << std::endl;
    }
}

int cookie(long A, long B, long C){
    if(A == B && B == C && A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
        return -1;
    }

    long ret = 0;

    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
        long tempA = A, tempB = B, tempC = C;
        A = (tempB + tempC)/2;
        B = (tempC + tempA)/2;
        C = (tempA + tempB)/2;
        ret++;
    }
    return ret;
}

int main(){
    long A, B, C;
    std::cin >> A;
    std::cin >> B;
    std::cin >> C;
    std::cout << cookie(A, B, C) << std::endl;
    return 0;
}

/*
a_0 = A, b_0 = B, c_0 = C
a_n = (b_n-1 + c_n-1)/2
b_n = (c_n-1 + a_n-1)/2
c_n = (a_n-1 + c_n-1)/2
a_n + b_n + c_n = A + B + C =: X

2 * a_n = A + B + C - a_n-1
2 * a_n + a_n-1 = X
2(a_n - X/3) + (a_n-1 - X/3) = 0

a_n = (-1/2)^n * (A - X/3) + X/3
3 * a_n = (-1/2)^n * (3 * A - X) + X
*/

Measured memory_bytes: 256
import java.util.*;
 
class Main{
    public static void main(String[] args){
		int n, x, cnt;
		Scanner scan = new Scanner(System.in);
		List<String> list = new ArrayList<String>();
        
		while(true){
			cnt = 0;
			n = scan.nextInt();
			x = scan.nextInt();
			if(n==0 && x==0){
				break;
			}

			int[] arr = new int[n];
			for(int i=0; i<n; i++){
				arr[i] = (i+1);
			}

			for(int i=0; i<n; i++){
				for(int j=i+1; j<n; j++){
					for(int k=j+1; k<n; k++){
						if((arr[i] + arr[j] + arr[k]) == x){
							cnt++;
						}
					}
				}
			}
			System.out.println(cnt);
		}
    }
}

Measured memory_bytes: 26880
#include<stdio.h>
int main()
{
    int i,count=0;
    char s[100];
    scanf("%s",&s);
    {
        for(i=0;i<4;i++)

            {if(s[i]=='+')
                count++;
        else if(s[i]=='-')
            count--;
            count=count;



    }}
    printf("%d",count);
    return 0;

}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

ll X;

void solve() {
    cin >> X;
    ll bal = 100, years = 0;
    while (bal < X) {
        years++;
        bal += bal / 100;
    }
    cout << years;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3608
import bisect
N,M=map(int, input().split())
P=[[] for _ in range(N)]
L=[]
for i in range(M):
    p,y=map(int, input().split())
    L.append((p,y))
    P[p-1].append(y)

newP=[]
for p in P:
    p=sorted(p)
    newP.append(p)

for i in range(M):
    t=L[i]
    p,y=t
    num=bisect.bisect_right(newP[p-1],y)
    
    p=str(p).zfill(6)
    num=str(num).zfill(6)
    print(p+num)


Measured memory_bytes: 41388
<?php
$s=trim(fgets(STDIN));
$a[1]=$s;
$i=2;
while($i<1000001){
	if($a[$i-1]%2==0){
		$s=$a[$i-1]/2;
	}else{
		$s=3*$a[$i-1]+1;
	}
	if(array_search($s,$a)){
		echo $i;
		exit;
	}
	$a[$i]=$s;
	++$i;
}

Measured memory_bytes: 4856
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,GCD,LCM;
    while(cin >> a >> b){
        c = a;
        d = b;
        if((a == 0) && (b == 0)){
            cout << a << " ";
        }
        else{
            while(a != b){
                if(a > b){
                    a = a - b;
                }
                else{
                    b = b - a;
                }
            }
            GCD = a;
            cout << GCD << " ";
        }
        c /= GCD;
        LCM = c * d;
        cout << LCM << endl;
    }
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  int H, A, ans;
  cin >> H >> A;
  ans = H / A;
  if(H % A != 0) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split(' '))
items = [tuple(map(int, input().split(' '))) for _ in range(N)]

dp = []
for _ in range(N + 1):
    dp.append([0] * (W + 1))

for i in range(N):
    for w in range(W + 1):
        value, weight = items[i]
        if w - weight >= 0:
            dp[i + 1][w] = max(dp[i][w], dp[i][w - weight] + value)
        else:
            dp[i + 1][w] = dp[i][w]

print(dp[N][W])



Measured memory_bytes: 25508
#include <stdio.h>

int main(){
	int a[4],b[4];
	int i,j;
	int hit,blow;
	
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF){
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		hit = 0;
		blow = 0;
		
		for(i = 0;i < 4;i++){
			for(j = 0;j < 4;j++){
				if(a[i] == b[j]){
					if(i == j){
						hit++;
					}else{
						blow++;
					}
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int t[2];
        while(1){
                cin>>t[0]>>t[1];
                if(t[0]==0&&t[1]==0)break;
                sort(t,t+2);
                cout<<t[0]<<" "<<t[1]<<endl;
        }
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int N,M;
	cin >> N >> M;
	vector<pair<int,int>> cities[100001];
	for(int i=0;i<M;i++){
		int p,y;
		cin >> p >> y;
		cities[p].push_back({y,i});
	}
	
	pair<int,int> ans[100001];
	for(int i=1;i<=N;i++){
		sort(cities[i].begin(), cities[i].end());
		for(int j=0;j<cities[i].size();j++){
			ans[cities[i][j].second] = {i,j+1};
		}
	}
	
	for(int i=0;i<M;i++){
		printf("%06d%06d\n",ans[i].first,ans[i].second);
	}
	return 0;
}


Measured memory_bytes: 7808