akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define int long long

int l, r, a, b;

int gcd(int x, int y) {
	return !y ? x : gcd(y, x % y);
}

int lcm(int x, int y) {
	return x * y / gcd(x, y);
}

signed main() {
	cin >> l >> r >> a >> b;
	int t = lcm(a, b);
	int ans = r - l + 1;
	ans -= (r) / a - (l - 1) / a;
	ans -= (r) / b - (l - 1) / b;
	ans += (r) / t - (l - 1) / t;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

def solve
  A.each do |a|
    if a % 2 == 1
      next
    end
    # Here, a is even
    if (a % 3 != 0 && a % 5 != 0) 
      return false      
    end
  end
  return true
end
      
if solve
  print "APPROVED\n"
else
  print "DENIED\n"
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;
using llong = long long;

map<llong,int> freq;

int main(){
  int N ; 
  cin >> N;
  for(int i=0;i<N;++i){
    llong a;
    cin >> a;
    freq[a]++;
  }
  int num = 0;
  for(const auto &p:freq){
    if(p.first<p.second){
      num += p.second - p.first;
    }else if(p.first>p.second){
      num += p.second;
    }
  }
  cout << num << endl;

  return 0;
}

Measured memory_bytes: 6272
#include<stdio.h>
int a[30];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	    scanf("%d",&a[i]);
	int num=0;    
	for(i=2;i<=n-1;i++)
		if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))num++;
	printf("%d\n",num);    
 } 

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

int main(void) {
    int N;
    int sum=0;
    int last;
    int chk;
    int bef,cur,aft;
    cin >> N;

    vector<int> w(N);

    for(int i=0;i<N;i++) {
        cin >> w[i];
        sum += w[i];
    }

//    sort(w.begin(), w.end());

    chk = sum/ 2;
    last = 0;
        bef = INT_MAX;
        aft = INT_MAX;
    for(int i=0;i<N;i++){
        w[i] += last;
        last = w[i];
        if(w[i] >= chk){
            if(i) bef=sum-(2*w[i-1]);
            cur = sum-(2*w[i]);
            if(i<N-1) aft = sum-((w[i]+w[i+1])*2);
//printf("bef:%d cur:%d aft:%d\n", bef, cur,  aft);
            cout << min(abs(bef),min(abs(cur),abs(aft))) << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
// 整数の入力
int n,l;
int table[n+1];
cin >> n;
int i=0;
while(cin>>l){
        table[i] = l;
        i++;
    }
table[n+1]=0;
int max=0,count=0;

for(i=0;i<n;++i){
    if(max<table[i])
    max=table[i];
}

while(max!=0){
    for(i=0;i<n;++i){
        if(max==table[i]){
            if(table[i]==table[i+1])table[i]--;
            else {table[i]--;count++;}
            
        
        }
    }
    //cout << max<< endl;
    max--;
}

// 出力
cout << count<< endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {

    ll n; cin >> n;
    string s; cin >> s;
    char c1,c2,c3;
    bool flag[3];
    ll ans = 0;

    for(int i = 0; i < 1000; i ++){
        c1 = '0'+ i%10;
        c2 = '0'+ (i/10)%10;
        c3 = '0'+ (i/100);
        flag[0] = false;
        flag[1] = false;
        flag[2] = false;

        rep(j,s.length()){
            if(!flag[0]){
                if(s[j] == c1) flag[0] = true;
            }else if(!flag[1]){
                if(s[j] == c2) flag[1] = true;
            }else if(!flag[2]){
                if(s[j] == c3) flag[2] = true;
            }
            if(flag[0] && flag[1] && flag[2]){
                ans ++;
                break;
            }
        }
    }


    cout << ans;
    return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>

int getgcd(int n, int m)
{
int r;
if (n > m) {
int t = m;
m = n;
n = t;
}
while ((r = m % n) != 0) {
m = n;
n = r;
}
return n;
}


int main(void){
int k,a,b,c;
  long int sum=0;
  scanf("%d", &k);
  for(a=1;a<=k;a++){
      for(b=1;b<=k;b++){
          for(c=1;c<=k;c++){
          sum += getgcd(getgcd(a, b), c);
          } 
      }
  }
  printf("%ld\n", sum);
  return 0;
}

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

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 dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end());

  int sum = 0;
  rep(i,n-1){
    sum += l[i];
  }
  if(sum > l[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RE register int
#define ll int
using namespace std;

struct QAQ{
	int tw, fv;
};

bool operator <(QAQ a, QAQ b){
	return a.tw < b.tw;
} 

QAQ orz[200010];
int awa[200010][19];
int n;

int Q(int l, int k){
	int QAQ = 0;
	for (int i = k; i <= 18; i++){
		QAQ += awa[n][i] - awa[l - 1][i];
	}
	return QAQ;
}

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		char ch;
		ch = getchar();
		while (!isdigit(ch)) ch = getchar();
		long long zs = 0;
		long long qwq = 1000000000;
		while (isdigit(ch)){
			zs *= 10;
			zs += ch - '0';
			ch = getchar();
		}
		if (ch == '.'){
			ch = getchar();
			while (isdigit(ch)){
				zs *= 10;
				zs += ch - '0';
				qwq /= 10;
				ch = getchar();
			}
		} 
		long long qaq = qwq * zs;
		while (qaq % 2 == 0){
			orz[i].tw++;
			qaq >>= 1;
		} 
		while (qaq % 5 == 0){
			orz[i].fv++;
			qaq /= 5;
		}
	}
	sort(orz + 1, orz + 1 + n);
	for (int i = 1; i <= n; i++){
		orz[i].tw = min(orz[i].tw, 18);
		orz[i].fv = min(orz[i].fv, 18);
		awa[i][orz[i].fv]++;
		for (int j = 0; j <= 18; j++){
			awa[i][j] += awa[i - 1][j];
		}
	}
	long long ANS = 0;
	for (int i = 1; i < n; i++){
		int L = i + 1, R = n;
		int ans = 0;
		while (L <= R){
			int mid = (L + R) >> 1;
			if (orz[mid].tw + orz[i].tw >= 18){
				R = mid - 1;
				ans = mid;
			}
			else{
				L = mid + 1;
				ans = mid + 1;
			}
		}
		if (orz[i].tw + orz[ans].tw >= 18){
			ANS += Q(ans, 18 - orz[i].fv);
		}
	}
	cout << ANS << endl;
	return 0;
}


Measured memory_bytes: 19980
#include <stdio.h>
#include <math.h>
#define NUMBER 10000

int isPrime(int x)
{
	int i;
    if (x == 2)
    return 1;
    else if ((x < 2) || (x % 2 == 0))
    return 0;

    for (i = 3; i <= sqrt(x); i+=2){
    if (x % i == 0)
    return 0;
    }
    return 1;

}


int main(void)
{
    int n, i;
    int count = 0;
    int num[NUMBER];
    
	scanf("%d", &n);

    for (i = 0; i < n; i++){
    scanf("%d", &num[i]);
    count = count + isPrime(num[i]);
    }

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


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
inline vector<int> counting(vector<char> v){
    v.push_back('*');
    vector<int> res;
    int cnt=0;
    rep(i,v.size()-1){
        cnt++;
        if(v.at(i)!=v.at(i+1)){
            res.push_back(cnt);
            cnt=0;
        }
    }
    return res;
}
signed main(){
    int n; cin>>n;
    vector<char> c(n);
    sort(all(c));
    rep(i,n) cin>>c.at(i);
    sort(all(c));
    vector<int> cc=counting(c);;
    int sum=1;
    rep(i,cc.size()){
        sum=sum*(cc.at(i)+1)%mod;
    }
    cout<<(sum-1)%mod<<endl;
}

Measured memory_bytes: 512
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	int N = 0;
	scanf("%d", &N);
    int ans = 0;
	if (N >= 30) {
		ans = 1;
	}
	yesno(ans);
	//okng(ans);
	return 0;
}


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

using namespace std;

int n, q, s, t, x, d;

enum Kind { BlockStart = 0, BlockEnd = 1 };

struct Event {
  Kind kind;
  int time;
  int distance;

  Event(Kind _kind, int _time, int _distance)
      : kind(_kind), time(_time), distance(_distance) {}

  bool operator<(const Event &other) {
    if (time == other.time) {
      return kind > other.kind;
    }
    return time < other.time;
  }
};

vector<Event> events;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> s >> t >> x;
    events.push_back(Event(BlockStart, s - x, x));
    events.push_back(Event(BlockEnd, t - x, x));
  }
  sort(events.begin(), events.end());
  // for (int i = 0; i < events.size(); i++) {
  //   printf("%d %d %d\n", events[i].kind, events[i].time, events[i].distance);
  // }
  int it = 0;
  set<int> blocks;
  for (int i = 0; i < q; i++) {
    cin >> d;
    while (events[it].time <= d && it < events.size()) {
      if (events[it].kind == BlockStart) {
        blocks.insert(events[it].distance);
      } else {
        assert(blocks.find(events[it].distance) != blocks.end());
        blocks.erase(events[it].distance);
      }
      it += 1;
    }
    if (blocks.size() > 0) {
      cout << *blocks.begin() << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
}

Measured memory_bytes: 16236
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    deque<int> ans;
    int f = 0;
    if(n%2==1)f=1;
    REP(i,n){
        int a;
        cin >> a;
        if(f==0){
            ans.push_back(a);
            f=1;
        }else{
            ans.push_front(a);
            f=0;
        }
    }
    REP(i,n){
        cout << ans.front() << ((i==n-1)?("\n"):(" "));
        ans.pop_front();
    }

    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;


 void test_cases()
{

	string s;
	cin>>s;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]==',')s[i]=' ';
	}
	cout<<s;
}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


Measured memory_bytes: 3640
import queue
k=int(input())
q=queue.Queue()
for i in range(1,10):
    q.put(i)
count=0
while count<k:
    a=q.get()
    #print(a)
    if a%10==0:
        x=a%10
        q.put(10*(a)+x)
        q.put(10*a+x+1)
    elif a%10==9:
        x=a%10
        q.put(10*a+x-1)
        q.put(10*a+x)
    else:
        x=a%10
        q.put(10*a+x-1)
        q.put(10*(a)+x)
        q.put(10*a+x+1)
    count+=1
print(a)      

        

Measured memory_bytes: 12480
#include <bits/stdc++.h>
using namespace std;
bool digit[10];
int n,k;
bool check(int a)
{
	while(a)
	{
		int b=a%10;
		if (digit[b])
			return false;
		a/=10;
	}
	return true;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		digit[x]=true;
	}
	while(true)
	{
		if (check(n))
		{
			cout<<n;
			return 0;
		}
		n++;
	}
	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int x, y;

        x = sc.nextInt();
        y = sc.nextInt();

        if ( x == 2 || y == 2) {
            out.println("No");
        } else if (( x == 4 || x == 6 || x == 9 || x == 11 ) && ( y == 4 || y == 6 || y == 9 || y == 11 )) {
            out.println("Yes");
        } else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12 ) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12 )) {
            out.println("Yes");
        } else {
            out.println("No");
        }
        
        
        sc.close();
    }
}

Measured memory_bytes: 21716
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()
sum_a = 3**n
pro = 1
for i in a:
	if i%2==0:
		pro*=2
print(sum_a-pro)

Measured memory_bytes: 9436
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

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

bool check(string s){
    rep(i,0,s.size()-1){
        if(s[i]!=s[s.size()-1-i]) return 0;
    }
    return 1;
}
signed main(){
    FastIO;
    string s;
    cin>>s;
    int n=s.size();
    string a=s.substr(0,(n-1)/2);
    string b=s.substr((n+1)/2,n);
    if(check(s) and check(a) and check(b)){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(3);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)2e5+5;
const ll MOD =(ll)1e9+7;
const ll INF = (ll)1e18+5;
const int nn=1e5+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    vii a(n);
    ll cnt=0,ans=0;
    rep(i,n)
    {
        cin>>a[i];
        cnt+=a[i];
        ans+=(a[i]*a[i]%MOD);
            cnt%=MOD;
            ans%=MOD;
    }
   ll nt=cnt*cnt%MOD;
   nt-=ans;
   if(nt<0)nt+=MOD;
   (nt*=(MOD+1)/2)%=MOD;
   nt%=MOD;
    cout<<nt<<nl;
    return 0;
}


Measured memory_bytes: 4764
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
int main() {
    ll n,k;
    std::cin >> n>>k;
    
    vector<ll> a(n);
    
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    COMinit();
    sort(a.begin(),a.end());
    ll res = 0;
    for (int i = 0; i < n-1; i++) {
        res += (COM(n,k)-COM(i+1,k)+MOD-COM(n-i-1,k)+MOD)%MOD*(a[i+1]-a[i])%MOD;
        res %=MOD;
    }
    
    std::cout << res << std::endl;
    
    
}

Measured memory_bytes: 12928
#include<cstdio>
#include<cmath>
using namespace std;

const int maxn = 10;

double x[maxn],y[maxn],ans;
int n;
bool used[maxn];

double dist(int a, int b){
	if(a == -1) return 0;
	return sqrt((x[a] - x[b]) * (x[a] - x[b])   +  (y[a] - y[b]) * (y[a] - y[b]));
}

void solve(int cnt, double cur, int last){
	if(cnt == n){
		ans += cur;
		return;
	}
	for(int i = 1; i <= n; i++)
		if(!used[i]){
			used[i] = true;
			solve(cnt+1, cur + dist(last, i), i);
			used[i] = false;
		}
}

int main(){
	
	scanf("%d",&n);
	
	for(int i = 1; i <= n; i++)
		scanf("%lf%lf",&x[i],&y[i]);
	
	solve(0, 0, -1);
	
	for(int i = 1; i <= n; i++)
		ans /= i;
	
	printf("%.10lf\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, C, K) = Read4Longs();
            var sum = 0L;
            if (A <= K)
            {
                sum += A;
            }
            else
            {
                sum += K;
            }

            if (K - A - B >= 0)
            {
                sum -= K - A - B;
            }

            return sum;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 999999999
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================
// 黒歴史不可避
LL func(char c) {
	if (c == 'a') {
		return 1;
	}
	else if (c == 'b') {
		return 2;
	}
	else if (c == 'c') {
		return 3;
	}
	else if (c == 'd') {
		return 4;
	}
	else if (c == 'e') {
		return 5;
	}
	else if (c == 'f') {
		return 6;
	}
	else if (c == 'g') {
		return 7;
	}
	else if (c == 'h') {
		return 8;
	}
	else if (c == 'i') {
		return 9;
	}
	else if (c == 'j') {
		return 10;
	}
	else if (c == 'k') {
		return 11;
	}
	else if (c == 'l') {
		return 12;
	}
	else if (c == 'm') {
		return 13;
	}
	else if (c == 'n') {
		return 14;
	}
	else if (c == 'o') {
		return 15;
	}
	else if (c == 'p') {
		return 16;
	}
	else if (c == 'q') {
		return 17;
	}
	else if (c == 'r') {
		return 18;
	}
	else if (c == 's') {
		return 19;
	}
	else if (c == 't') {
		return 20;
	}
	else if (c == 'u') {
		return 21;
	}
	else if (c == 'v') {
		return 22;
	}
	else if (c == 'w') {
		return 23;
	}
	else if (c == 'x') {
		return 24;
	}
	else if (c == 'y') {
		return 25;
	}
	else if (c == 'z') {
		return 26;
	}
}


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

	int n, l;
	cin >> n >> l;

	vector<string>vec(n);
	REP(i, n) {
		cin >> vec[i];
	}

	SORT(vec);
	string ans = "";
	REP(i, n) {
		ans += vec[i];
	}

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

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

string a;
int n;

int main()
{
	cin>>a;
	n=a.size();
	if (a[0]==a[n-1])
	{
		if (n%2==1) printf("Second");
		else printf("First");
	}
	else
	{
		if (n%2==0) printf("Second");
		else printf("First");
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int x;
	cin >> x;
	int num = (x + 11 - 1) / 11;
	num *= 2;
	int a = 11 * (num / 2) - x;
	if (a >= 5)num -= 1;
	cout << num;
}

Measured memory_bytes: 256
N = int(input())
# print(N)

if N == 0:
    print(0)
    exit()

def num_muls(n):
    ans = 0
    while (n >> ans) & 1 == 0:
        ans += 1
    return ans

ans = ''
count = 0

while N != 0:
    m = num_muls(N)
    # print('num_muls, count={}, m={}'.format(count, m))
    if m > 0:
        # print('m!=0', ans, N, count)
        ans = '0'*m + ans
        N //= (2**m)
        count += m
        # print('N={}, count={}'.format(N, count))
    else:
        # print('m==0', ans, N, count)
        ans = '1' + ans
        N -= (-1)**count
        N //= 2
        count += 1
        # print('N={}, count={}'.format(N, count))

print(ans)


Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var a, b int
	fmt.Fscan(read, &a, &b)

	fmt.Fprintln(write, max(a-b*2, 0))

}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    int n,m;
    cin>>n>>m;

    vector<pii> v;
    if (n&1)
    {
        for (int i=1;i<=(n-1)/2;i++)
            v.pb(mkp(i,n-i));
    }
    else
    {
        int p;
        for (int i=1;i<=n/4;i++)
            v.pb(mkp(i,(n+1)-i));

        for (int i=n/4+1;;i++)
            if (i==n-i) break;
            else v.pb(mkp(i,n-i));

        //for (pii i:v) cout<<i.F<<' '<<i.S<<endl;
    }
    for (int i=0;i<m;i++) cout<<v[i].F<<' '<<v[i].S<<endl;
}



Measured memory_bytes: 4276
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,p,q,ans=1;
  cin>>n>>p; q=p;
  map<ll,ll> mp;
  for(ll i=2; i<=sqrt(q); i++){
    if(p%i==0){
      p/=i;
      mp[i]++;
      i-=1;
    }
    if(p==1){
      break;
    }
  }
  mp[p]++;
  for(auto x: mp){
    for(int j=1;j<=x.second/n;j++){
      ans*=x.first;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val S = next()
    val lasts = HashMap<Char, Int>()
    val map = HashMap<Char, Int>()
    for (i in S.indices) {
        val s = S[i]
        val v = map[s] ?: -1
        map[s] = max(v, i - lasts.getOrDefault(s, -1) - 1)
        lasts[s] = i
    }
    for ((s, d) in map.entries) {
        map[s] = max(d, S.length - lasts[s]!! - 1)
    }
    val ans = map.values.min()!!
    println(ans)
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll N = SZ(S);
    bool f = false;
    REP(i,0,N) {
        REP(j,i,N) {
            string T = S.substr(0, i);
            string U = S.substr(j, N-j);
            if(T+U == "keyence") {
                f = true;
                break;
            }
        }
    }
    if(f) PR("YES");
    else PR("NO");

    return 0;
}

/*



*/

Measured memory_bytes: 3552
import java.util.*;
  public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int ans = 0;
      int K = sc.nextInt();
      int[] A = new int[1000001];
      A[0] = 7 % K;
      for(int i=1; i<=K; i++) {
        A[i] = (A[i-1]*10+7) % K; //ここまでで全てを終わらせる。
      } //とり合えずここで閉じて配列要素の閉じ込める。
      
      for(int i=0; i<=K; i++) {
        if(A[i]==0) {
          System.out.println(i+1);
          //break; //ループを抜ける、かつ -1 も同時に出力してしまう。
          return; //ループを抜ける、かつ戻り値を返し出力を決定する。
        } 
      }
          System.out.println(-1);
    }
  }

Measured memory_bytes: 39568
n, m, x = map(int, input().split())
c = [0] * n
a = [0] * n
for i in range(n):
    c[i], *a[i] = list(map(int, input().split()))
ans = 10 ** 9
for i in range(2 ** n):
    csum = 0
    asum = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            csum += c[j]
            for k in range(m):
                asum[k] += a[j][k]
    if len(list(filter(lambda v: v >= x, asum))) == m:
        ans = min(ans, csum)
print(-1 if ans == 10 ** 9 else ans)


Measured memory_bytes: 74492
n = int(input())
from fractions import gcd
import math
import functools
t = []
ans = 0
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(j,n+1):
            #t.append([i,j,k])
            t = [i,j,k]
            if i==j==k:
                gcd = functools.reduce(math.gcd, t)
                ans += gcd
            elif i!=k and j!=k and i!=j:
                gcd = functools.reduce(math.gcd, t)
                ans += gcd*6
            else:

                gcd = functools.reduce(math.gcd, t)
             
                ans += gcd*3
            #print(t,ans)

print(ans)



    

Measured memory_bytes: 74392
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
      cin >> h[i];
  
  sort(h.begin(), h.end());
  
  ll total = 0;
  for (int i = n - k - 1; i >= 0; i--)
      total += h[i];
  
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

struct team {
    string name;
    int win, lose, draw;
    int point;

    bool operator<(const team& o) const {
        return (point > o.point);
    }
};

void solve(int n) {
    team teams[n];
    for (int i = 0; i < n; i++) {
        cin >> teams[i].name >> teams[i].win
            >> teams[i].lose >> teams[i].draw;
        teams[i].point = teams[i].win * 3 + teams[i].draw;
    }
    stable_sort(teams, teams+n);
    for (int i = 0; i < n; i++) {
        cout << teams[i].name << ',' << teams[i].point
             << endl;
    }
}

int main() {
    int n;
    cin >> n;
    solve(n);
    while (cin >> n) {
        if (n == 0) break;
        cout << endl;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=1e6+7;
typedef long long ll;
const int mod=1e9+7;
void Smax(ll &a,ll b){if(a<b) a=b;}
void Smin(ll &a,ll b){if(a>b) a=b;}
///#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
///char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
#define IO cin.tie(0),ios::sync_with_stdio(false);
#define pi acos(-1)
#define PII pair<ll,ll>
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()
/** keep hungry and keep calm! **/



int Sheryang()
{
    int a=read,b=read,c=read;

    cout<<min(b/a,c)<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const ld PIE = atan2(0, -1);

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> cnt(n);
	for (int i = 1; i < n; ++i) {
		cin >> a[i]; --a[i];
		++cnt[a[i]];
	}
	for (int i = 0; i < n; ++i) cout << cnt[i] << '\n';
}

int main() {
	solve();
	return 0;
}

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


int main(){
    int N;
    cin>>N;
    vector<vector<int> > V(N, vector<int>(3)), dp(N, vector<int>(3,0));
    for(int i=0;i<N;i++)
        cin>>V[i][0]>>V[i][1]>>V[i][2];
    dp[0]=V[0];
    for(int i=1;i<N;i++)
        for(int j=0;j<3;j++)
            dp[i][j]=V[i][j]+max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);    
    cout<<max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2])<<endl;
    return 0;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  while(1){
    int n; cin >> n;
    if(n == 0) break;
    int sum = 0, minv = inf, maxv = 0;
    int s;
    rep(i,n){
      cin >> s;
      sum += s;
      minv = min(minv,s);
      maxv = max(maxv,s);
    }
    cout << (sum - minv - maxv) / (n - 2) << endl;
  }
}


Measured memory_bytes: 2976
#include<iostream>
using namespace std;
int main(){
  int n;cin >> n;int x=n;
  cout << n << ":";
  for(int i=2;i*i<=x;i++){
    while(n%i==0) {
      cout << " " << i;
      n/=i;
    }
  }
  if(n!=1)
    cout << " " << n;
  cout << endl;
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define db double 
#define mod 998244353
#define vi vector<double>
#define pb push_back
#define ll long long
using namespace std;
ll ksm(ll a, ll b) {
	if (!b) return 1;
	ll ns = ksm(a, b >> 1);
	ns = ns * ns % mod;
	if (b & 1) ns = ns * a % mod;
	return ns;
}
inline int add(int a, int b) {
	a += b;
	return (a < mod) ? a : (a - mod);
}
inline int sub(int a, int b) {
	a -= b;
	return (a < 0) ? a + mod : a;
}
inline int mul(int a, int b) {
	return (ll)a * b % mod;
}
// head
const int maxn = 205, maxm = 200005;
struct edge
{
	int u, v, c;
	edge *rev;
	edge *next;
}pool[maxm * 2], *h[maxn];
int cnt = 0;
void addedge(int u, int v, int c)
{
	edge *new1 = &pool[cnt++];
	new1->u = u, new1->v = v, new1->c = c;
	
	edge *new2 = &pool[cnt++];
	new2->u = v, new2->v = u, new2->c = 0;
	
	new1->rev = new2, new2->rev = new1;
	new1->next = h[u], h[u] = new1;
	new2->next = h[v], h[v] = new2;
}
int level[maxn], q[maxn], fr, ed;
int s, t;
void bfs()
{
	fr = ed = 0;
	memset(level, -1, sizeof(level));
	level[s] = 1, q[ed++] = s;

	while(fr < ed)
	{
		for(edge *p = h[q[fr]]; p; p = p->next)
		{
			if(!p->c || level[p->v] != -1) continue;
			level[p->v] = level[q[fr]] + 1, q[ed++] = p->v;
		}
		fr++;
	}
}
int dfs(int a, int flow)
{
	if(!flow) return 0;
	if(a == t) return flow;
	int nf = 0;
	for(edge *p = h[a]; p; p = p->next)
	{
		if((level[p->v] != level[a] + 1) || (p->c <= 0)) continue;
		int nflow = dfs(p->v, min(flow - nf, p->c));
		nf += nflow, p->c -= nflow, p->rev->c += nflow;
	}
	if(!nf) level[a] = -1;
	return nf;
}
int dinic()
{
	int ans = 0;
	while(1)
	{
		bfs();
		int nans = dfs(s, 1000);
		if(!nans) break;
		ans += nans;
	}
	return ans;
}
void init_eg() {
	cnt = 0;
	for (int i = 0; i < maxn; i++)	
		h[i] = NULL;
}
int n, m;
int a[maxn][maxn];
int fl[maxn][maxn];
int b[maxn][maxn];
int ns[maxn];
int cal(int a) {
	return (a - 1) / m + 1;
}
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> a[i][j];
	for (int q = 1; q <= m; q++) {
		s = 2 * n + 1, t = 2 * n + 2;
		init_eg();
		for (int i = 1; i <= n; i++)	
			for (int j = 1; j <= m; j++)	
				if (!fl[i][j])
					addedge(i, cal(a[i][j]) + n, 1);
		for (int i = 1; i <= n; i++)	
			addedge(s, i, 1), 
			addedge(i + n, t, 1);
		dinic();
		for (int i = 1; i <= n; i++) {
			int nr = 0;
			for (edge *p = h[i]; p; p = p->next) {
				if (p->v == s) continue;
				if (!p->c) {
					nr = p->v - n;
					break;
				}
			}
			for (int j = 1; j <= m; j++) {
				if (fl[i][j]) continue;
				if (cal(a[i][j]) == nr) {
					fl[i][j] = 1;
					b[i][q] = a[i][j];
					break;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			printf("%d ", b[i][j]);
		cout << endl;
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++)
			ns[j] = b[j][i];
		sort(ns + 1, ns + n + 1);
		for (int j = 1; j <= n; j++)
			b[j][i] = ns[j];
	}
		for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			printf("%d ", b[i][j]);
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
from itertools import product
ans=0
n=int(input())
for i in range(3,11):
    for m in product(["3","5","7"],repeat=i):
        if "3"not in m or "5"not in m or "7"not in m:
            continue
        if int("".join(m))<=n:
            ans+=1
        else:
            break
print(ans)

Measured memory_bytes: 45164
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
#define pq dp
using namespace std;
const ll mx = 4444444444;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif /// Mfc_Tanzim

    ll t=1, n, k, m, a, b, c, d;
    //cin >> t;

    while(t--){
              string x;
              cin >> x;
              ll cnt = 0, ans = 0;
              for(auto k: x){
                      if(k=='R'){
                              cnt++;
                      }
                      else{
                              ans = max(ans, cnt);
                              cnt = 0;
                      }
              }
              ans = max(ans, cnt);
              cout << ans << endl;

    }
    return 0;
}




Measured memory_bytes: 3644
n,m = map(int,input().split())
sum=0
if n>m:
  sum = sum + n
  n=n-1
else :
  sum += m
  m=m-1

if n>m:
  sum += n
  n=n-1
else :
  sum += m
  m=m-1
  
print(sum)

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

using namespace std;

typedef long long ll;
typedef priority_queue <ll> pq;
typedef priority_queue <ll, vector<ll>, greater<ll> > rpq;

int main(){
        int N;
        cin>>N;
        rpq a1;
        pq a2;
        vector <ll> a;
        for(int i=0;i<3*N;i++){
                ll aa;
                cin>>aa;
                a.push_back(aa);
        }
        ll sum1[100100]={0}, sum2[100100]={0};
        for(int i=0;i<N;i++){
                a1.push(a[i]);
                sum1[0]+=a[i];
        }
        for(int i=2*N;i<3*N;i++){
                a2.push(a[i]);
                sum2[N]+=a[i];
        }

        for(int i=N;i<2*N;i++){
                sum1[i-N+1]=sum1[i-N];
                sum1[i-N+1]-=a1.top();
                sum1[i-N+1]+=a[i];
                a1.pop();
                a1.push(a[i]);
        }
        for(int i=2*N-1;i>=N;i--){
                sum2[i-N]=sum2[i-N+1];
                sum2[i-N]-=a2.top();
                sum2[i-N]+=a[i];
                a2.pop();
                a2.push(a[i]);
        }
        ll res=-1111111111111111111;
        for(int i=0;i<=N;i++){
                if(sum1[i]>sum1[i+1]){
                        sum1[i+1]=sum1[i];
                }
                if(sum2[i]>sum2[i+1]&&i!=N){
                        sum2[i]=sum2[i+1];
                }
        }
        for(int i=0;i<=N;i++){
                //cout<<sum1[i]<<":"<<sum2[i]<<endl;
                res=max(sum1[i]-sum2[i], res);
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 8300
#include <bits/stdc++.h>
using namespace std;
int memo[1000001];
int calc(int n) {
    if(memo[n]!=-1) return memo[n];
    if(n<10) return 0;
    string s=to_string(n);
    int to=0;
    for(int i=1;i<=s.size()-1;i++) {
        to=max(to,stoi(s.substr(0,i))*stoi(s.substr(i)));
    }
    return memo[n]=calc(to)+1;
}
int main() {
    int Q,N;
    scanf("%d",&Q);
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<Q;i++) {
        scanf("%d",&N);
        printf("%d\n",calc(N));
    }
}

Measured memory_bytes: 7204
#include<iostream>
#include<cmath>
int main(){
  long long  a,b,c,d,t;
  std::cin>>a>>b>>c>>d>>t;
  if(std::abs(c-a)<=(b-d)*t)std::cout<<"YES"<<std::endl;
  else std::cout<<"NO"<<std::endl;
  return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
using namespace std;

/*
75=3*5*5
ありうる形は
a^74 a^24*b^2 a^14*b^4 a^4*b^4*c^2
*/

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

	vector<int> vec(110, 0);

	for(int i = 1; i <= N; i++){
		int j = 2;
		int num = i;
		while(num > 1){
			if(num % j == 0){
				vec[j]++;
				num /= j;
			}else{
				j++;
			}
		}
	}

	int ans = 0;

	//a^74
	for(int i = 2; i <= N; i++){
		if(vec[i] >= 74) ans++;
	}

	//a^24*b^2
	for(int i = 2; i <= N; i++){
		if(vec[i] >= 24){
			for(int j = 2; j <= N; j++){
				if(i == j) continue;
				if(vec[j] >= 2) ans++;
			}
		}
	}

	//a^14*b^4
	for(int i = 2; i <= N; i++){
		if(vec[i] >= 14){
			for(int j = 2; j <= N; j++){
				if(i == j) continue;
				if(vec[j] >= 4) ans++;
			}
		}
	}

	//a^14*b^4
	for(int i = 2; i <= N - 1; i++){
		if(vec[i] >= 4){
			for(int j = i + 1; j <= N; j++){
				if(i == j) continue;
				if(vec[j] >= 4){
					for(int k = 2; k <= N; k++){
						if(i == k || j == k) continue;
						if(vec[k] >= 2) ans++;
					}
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

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

string to_string(string s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

ll N, ans, P;

int main()
{
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    //debug_out(A);
    if (N % 2 == 0)
        P = (A[N / 2] + A[N / 2 - 1]) / 2;
    else
        P = A[N / 2];
    //debug_out(P);
    for (int i = 0; i < N; i++)
    {
        ans += abs(A[i] - P);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
from collections import deque
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1


if type(MAP[h-1][w-1]) == int:
  ans = h*w -MAP[h-1][w-1]-sharp
else:
  ans = -1
    
print(ans)

Measured memory_bytes: 74288
import math
N,D=map(int, input().split())
x=[[''for i in range(D)] for j in range(N)]
for i in range(N):
  x[i]=list(map(int, input().split()))
count=0
for i in range(N):
  for t in range(i+1,N):
    sum=0
    for j in range(D):
      sum=sum+(x[i][j]-x[t][j])**2
    d=math.sqrt(sum)
    if d.is_integer():
      count=count+1
print(count)

Measured memory_bytes: 3064
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    mint a, b;
};

S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{r.a * l.a + r.size * l.b, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }

F id() { return F{1, 0}; }

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a[i] = S{x, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int l, r;
            int c, d;
            scanf("%d %d %d %d", &l, &r, &c, &d);
            seg.apply(l, r, F{c, d});
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%d\n", seg.prod(l, r).a.val());
        }
    }
}


Measured memory_bytes: 19280
#include <bits/stdc++.h> 
using namespace std; 
int main() {
    int a, b, c;
    int k; 
    cin >> a >> b >> c >> k; 
    long long sum = 0; 
    sum = a + b + c; 
    int m = max(a, max(b, c));
    sum -= m; 
    // new max 
    sum += m * pow(2, k);
    cout << sum; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b;
  if(a==1) a=14;
  if(b==1) b=14;
  
  if(a>b) co("Alice");
  else if(a==b) co("Draw");
  else co("Bob");
  return 0;
}


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

int main(){
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(a==0){
		cout << 1 << endl;
	} else if(b==0){
		cout << 2 << endl;
	} else if(c==0){
		cout << 3 << endl;
	} else if(d==0){
		cout << 4 << endl;
	} else if(e==0){
		cout << 5 << endl;
	}

}


Measured memory_bytes: 3512