akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[])throws IOException{
    char c1=readC(),c2=readC(),c3=readC();
    if(c1=='R'&&c2=='R'&&c3=='R'){
      pl("3");
    }else if((c1=='R'&&c2=='R')||(c3=='R'&&c2=='R')){
      pl("2");
    }else if(c1=='R'||c2=='R'||c3=='R'){
      pl("1");
    }else{
      pl("0");
    }
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


Measured memory_bytes: 32604
/* ex 9_1
   nknm */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 100

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){        //sizeを超えたpushはエラー
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{       //topを1つ上にあげて文字を追加、カウントを1プラス
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
void pop(stack *stk){
    if(stk->count > 0){     //要素がある場合のみ有効、topを1つ下げてカウントを1マイナス
        stk->top++;
        stk->count--;
    }
}

void print_stack(stack *stk){       //スタックの中身を古いほうからプリント
    int i = 0;
    char *ptr;
    ptr = stk->top;
    while(i < stk->count - 1){      //ポインタを最も古い要素に動かす
        ptr++;
        i++;
    }
    for(i = 0; i < stk->count; i++){        //1文字出力するごとにポインタを1つ上に動かす
        printf("%c", *ptr--);
    }
    printf("\n");
}

int main(void){
    stack stk;
    char imput[SIZE];
    int i;
    scanf("%s", imput);
    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);
    //スタックにデータを追加
    for(i = 0; imput[i] != '\0'; i++){
        if(imput[i] == '0'){
            push(&stk, '0');
        }else if(imput[i] == '1'){
            push(&stk, '1');
    //スタックからデータを取り出す
        }else if(imput[i] == 'B'){
            pop(&stk);
        }
    }
    print_stack(&stk);

    return 0;
}

Measured memory_bytes: 1612
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c - (a - b) >= 0) {
        cout << c - (a - b);
    }
    else
    {
        cout << 0;
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    int A[n][m],B[m][l];
    long long int C[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            C[i][j] = 0;
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            scanf("%d",&B[i][j]);
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int k = 0; k < l; k++){
            for(int j = 0; j < m; j++){
                C[i][k] += A[i][j]*B[j][k];
            }
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l-1; j++){
            printf("%lld ",C[i][j]);
        }
        printf("%lld\n",C[i][l-1]);
    }
}


Measured memory_bytes: 2876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f(ll n){
    ll x = 1;
    if(n == 0) return 0;
    else {
        while(!(x*(x+1) <= 2*n && 2*n < (x+1)*(x+2))) x++;
    }
    return x;
}

int main(void){
    ll n, ans = 0;
    cin >> n;
    ll m = n;
    vector<vector<ll>> x;
    ll i = 2;
    ll t = 0;
    while(m != 1 && i <= (ll)sqrt(n)){
        vector<ll> temp;
        if(m%i == 0){
            t++;
            m /= i;
        } else {
            if(t != 0){
                temp.push_back(i);
                temp.push_back(t);
                x.push_back(temp);
            }
            i++;
            t = 0;
        }
    }
    vector<ll> temp;
    temp.push_back(i); temp.push_back(t);
    x.push_back(temp);
    if(m != 1){
        vector<ll> temp;
        temp.push_back(n); temp.push_back(1);
        x.push_back(temp);
    }
    for(ll i = 0; i < x.size(); i++){
        ans += f(x[i][1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3684
LARGE = 10 ** 9 + 7


def solve_a(test=False, a=2, b=16):

    if not test:
        a, b = map(int, input().split())
    if (b - a) % 2 == 0:
        print((a + b) // 2)
    else:
        print("IMPOSSIBLE")


def solve_b(test=False, n=5, p_list=[5, 2, 3, 4, 1]):

    if not test:
        n = int(input())
        p_list = list(map(int, input().split()))

    r = 0
    for i in range(n):
        if p_list[i] != i + 1:
            r += 1
    if r == 0 or r == 2:
        print("YES")
    else:
        print("NO")


def solve_c(test=False, n=2, a_list=[3, 5, 2], b_list=[4, 5]):

    if not test:
        n = int(input())
        a_list = list(map(int, input().split()))
        b_list = list(map(int, input().split()))

    res = 0
    for i in range(n):
        if b_list[i] <= a_list[i]:
            res += b_list[i]
            a_list[i] -= b_list[i]
        elif b_list[i] < a_list[i] + a_list[i + 1]:
            res += b_list[i]
            a_list[i + 1] -= b_list[i] - a_list[i]
            a_list[i] = 0
        else:
            res += a_list[i] + a_list[i + 1]
            a_list[i] = 0
            a_list[i + 1] = 0

    print(res)


def solve_d(test=False, s='??2??5'):

    if not test:
        s = input()

    l = len(s)
    res_list_new = [0] * 13
    res_list_old = [0] * 13
    zero_mod = int(s.replace('?', '0')) % 13
    res_list_new[zero_mod] += 1

    for i in range(1, l + 1):
        if s[-i] == '?':
            for k in range(13):
                res_list_old[k] = res_list_new[k] % LARGE
            base_mod = pow(10, i-1, 13)
            for j in range(1, 10):
                for k in range(13):
                    res_list_new[(k + base_mod * j) % 13] += res_list_old[k]

    print(res_list_new[5] % LARGE)


# solve_a(test=True, a=2, b=16)
# solve_a(test=True, a=0, b=3)
# solve_a(test=True, a=998244353, b=99824435)

# solve_b(test=True, n=5, p_list=[5, 2, 3, 4, 1])
# solve_b(test=True, n=5, p_list=[2, 4, 3, 5, 1])
# solve_b(test=True, n=7, p_list=[1, 2, 3, 4, 5, 6, 7])

# solve_c(test=True, n=2, a_list=[3, 5, 2], b_list=[4, 5])
# solve_c(test=True, n=3, a_list=[5, 6, 3, 8], b_list=[5, 100, 8])
# solve_c(test=True, n=2, a_list=[100, 1, 1], b_list=[1, 100])

# solve_d(test=True, s='??2??5')
# solve_d(test=True, s='?44')
# solve_d(test=True, s='7?4')
# solve_d(test=True, s='?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???')

solve_a()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#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 SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    SORTR(A);
    vector<ll> csum(N + 1);
    REP(i, N) {
        csum[i + 1] = csum[i] + A[i];
    }
    int res = 1;
    FOR(i, 1, N) {
        if (2 * (csum[N] - csum[i]) >= A[i - 1]) {
            ++res;
        } else {
            break;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,m;
  cin>>n>>m;
  int stable=1900*m+(n-m)*100;
  int p=1;
  for(int i=0;i<m;i++){
    p*=2;
  }
  int x=stable*p;
  cout<<x<<endl;
  return 0;
}

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

main() {
    int A,B,C; cin >> A >> B >> C;
    cout << A*B/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
ll power(ll x, ll  y)  {  ll res = 1;x = x % mod;y=y%mod;while (y > 0)  {  if (y & 1)  res = ((res%mod)*(x%mod)) % mod;  
y = y>>1;x = ((x%mod)*(x%mod)) % mod;  }  return res%mod;  }  
  
  
int main(){
    ll n,a,b,prev, mi=0;;
    cin>>n>>a>>b>>prev;;ll d[n+2];ll hash[200005]={0};
    for(int i=2;i<=n;i++){cin>>d[i]; 
    if((d[i]-prev)*a<b)mi+=(d[i]-prev)*a; 
    else mi+=b;
    prev=d[i];}
    cout<<mi<<endl;
    
}
    
    
   

    


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

using namespace std;

int insertion_sort(vector<int> *vec, int n, int g)
{
	auto cnt = 0;
	for (int i=g; i<n; i++) {
		int v = (*vec)[i];
		int j = i - g;
		while (j >= 0 && (*vec)[j] > v) {
			(*vec)[j+g] = (*vec)[j];
			j -= g;
			cnt++;
		}
		(*vec)[j+g] = v;
	}
	return cnt;
}

void shell_sort(vector<int> vec, int n)
{
	int cnt=0, m = 1;
	vector<int> g = {1};
	while (5*g.back()+1 < n) {
		m++;
		g.push_back(5*g.back()+1);
	}

	for (int i=m-1; i>=0; i--)
		cnt += insertion_sort(&vec, n, g[i]);
	
	cout << m << endl;
	for (int i=m-1; i>0; i--)
		cout << g[i] << " ";
	cout << g[0] << endl
	     << cnt << endl;
	for (int i=0; i<n; i++)
		cout << vec[i] << endl;
}

int main(void)
{
	int n;
	vector<int> vec;
	cin >> n;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		vec.push_back(x);
	}

	shell_sort(vec, n);

	return 0;
}

Measured memory_bytes: 9048
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = 1;
		boolean c = true;
		int e = 0;
		// 文字列の入力
		int[] d = new int[a];
		for(int i = 0; i < a; i++){
			d[i] = sc.nextInt();
		} 
		while(c){
			c = false;
			for(int i = e; i < a && !c; i++){
				if(d[i] == b){
					c = true;
					b++;
					e = i + 1;
				}
			}
			
		}
		if(b == 1){
			System.out.println(-1);
		}else{
			System.out.println(a - b + 1);
		}
		
		
		
	}
}

Measured memory_bytes: 60436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353


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

    // solution comes here

    string S, T;
    cin >> S >> T;

    vl s(26, -1), g(26, -1);
    ll N=S.size();
    rep(i, N) {
        ll x=S[i]-'a', y=T[i]-'a';
        if(s[x]!=-1 or g[y]!=-1){
            if(s[x]!=y or g[y]!=x){
                cout << "No" << nl;
                return 0;
            }
        }
        s[x] = y;
        g[y] = x;
    }

    cout << "Yes" << nl;
}


Measured memory_bytes: 916
#include <cstdio>
#include <iostream>

using namespace std;

long long a[25] , n;

#define ll long long

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

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

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

void count(ll& cnt, ll& sum, ll a, int& sign) {
  ll tmp = sum + a;
  if (sign > 0 && tmp <= 0)
    sum += 1 - sum;
  else if (sign < 0 && tmp >= 0)
    sum -= 1 + sum;
  else
    sum = tmp;
  sign *= -1;
  cnt += abs(sum - tmp);
}

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

  ll sum_e = 0, sum_o = 0;
  ll cnt_e = 0, cnt_o = 0;
  int sign_e = 1, sign_o = -1;
  rep(i, n) {
    ll a;
    cin >> a;
    count(cnt_e, sum_e, a, sign_e);
    count(cnt_o, sum_o, a, sign_o);
  }

  cout << min(cnt_e, cnt_o) << endl;
}

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

using namespace std;

typedef long long Int;

const int MOD = 1000000007;

Int dp[70][2][2];

int main()
{
  Int N;
  
  scanf("%lld", &N);
  
  vector<int> pat;
  while (N) {
    pat.push_back(N % 2);
    N /= 2;
  }
  
  int D = pat.size();
  dp[0][0][1] = 1;
  
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        //(u_i, v_i) = (0, 0)
        Int *nxt = &dp[i + 1][0][(j < pat[i]) || (j <= pat[i] && k)];
        *nxt = (*nxt + dp[i][j][k]) % MOD;
        //(u_i, v_i) = (1, 0)
        nxt = &dp[i + 1][j][(1 - j < pat[i]) || (1 - j <= pat[i] && k)];
        *nxt = (*nxt + dp[i][j][k]) % MOD;
        //(u_i, v_i) = (0, 1)
        nxt = &dp[i + 1][1][(j < pat[i]) || (j <= pat[i] && k)];
        *nxt = (*nxt + dp[i][j][k]) % MOD;
      }
    }
  }
  
  printf("%lld\n", dp[D][0][1]);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#include <functional>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <set>
#include <queue>
#include <map>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long t[n],a[n];
	for(int i=0;i<n;i++){
		cin>>t[i]>>a[i];
	}
	long long nt=t[0],na=a[0];
	for(int i=1;i<n;i++){
		long long tt=nt/t[i];
		tt=tt*t[i];
		if(tt<nt){
			tt=tt+t[i];
		}
		if(tt/t[i]>na/a[i]){
			nt=tt;
			na=tt/t[i];
			na=na*a[i];
		}
		else{
			long long aa=na/a[i];
			aa=aa*a[i];
			if(aa<na){
				aa=aa+a[i];
			}
			na=aa;
			nt=aa/a[i];
			nt=nt*t[i];
		}
		//cout<<nt<<" "<<na<<endl;
	}
	long long wa=na+nt;
	cout<<wa<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,x,n;
	scanf("%d",&a);
	scanf("%d",&b);
	x=a+b;
	if(x%2>0){
		n=x/2+1;
		printf("%d\n",n);
	}
	else{
		n=x/2;
		printf("%d\n",n);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B, C, D;
  cin >> N;
  D = N%10;
  C = (N%100-N%10)/10;
  B = (N%1000-N%100)/100;
  A = (N-N%1000)/1000;
  
  if (A==B && B==C){
    cout << "Yes" << endl;
  }
  else if (B==C && C==D){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define sort(v)     sort((v).begin(),(v).end())
#define rsort(v)    sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
//finds the next permutation to given sequence of nos
int nextpermutation(vi v)
{
    vi t=v;
    sort(t);
    int x=0;
    while(true)
    {
        x++;
        if(t==v)
        {
            return x;
        }
        next_permutation(all(t));
    }
}
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0)print((b-a)/2)
    else
    {
        int x1=a;
        int x2=n-b+1;
        print(min(x1,x2)+(b-a)/2)
    }

}
    
    

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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 main(){
 
string s ; cin>>s ;
 vector<ll> A(3) ;
 ll j=0 ;
 rep(i,3){
   if(s[i]=='R') A[j]++ ;
   else{
     j++ ;
   }
 }
 ll k= A.size() ;
 ll ans= 0 ;
 rep(i,3){
  chmax(ans,A[i]) ;
 }
 cout<<ans<<endl ;

   return 0 ;
 }



Measured memory_bytes: 3624
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    A.sort();
    long ans;
    auto sieve = new bool[](10 ^^ 6 + 1);
    foreach (i; 0 .. N)
    {
        if (!sieve[A[i]] && !((0 < i && A[i - 1] == A[i]) || (i < N - 1 && A[i + 1] == A[i])))
            ans++;
        if (sieve[A[i]])
            continue;
        long x = A[i];
        while (x < sieve.length)
            sieve[x] = true, x += A[i];
    }
    writeln(ans);
}


Measured memory_bytes: 13636
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    double pi = 3.141592;
    ll n;
    cin >> n;
    cout << 2 * n * pi << endl;
}

Measured memory_bytes: 3784
#include"stdio.h"

int main()
{
	int a[7] = { 1,3,5,7,8,10,12 };
	int b[4] = { 4,6,9,11 };

	int x, y,i,flagCnt;
	scanf("%d %d", &x, &y);
	//第1グループ確認
	flagCnt = 0;
	for (i = 0; i < 7; i++) {
		if ((a[i] == x) || (a[i] == y)) {
			flagCnt++;
		}
	}
	if (flagCnt == 2) {
		printf("Yes\n");
		return 0;
	}
	//第2グループ確認
	flagCnt = 0;
	for (i = 0; i < 4; i++) {
		if ((b[i] == x) || (b[i] == y)) {
			flagCnt++;
		}
	}
	if (flagCnt == 2) {
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}

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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    string[] S;
    foreach (_; 0 .. H)
        S ~= sread();
    auto L = new long[][](H, W);
    auto R = new long[][](H, W);
    auto U = new long[][](H, W);
    auto D = new long[][](H, W);
    foreach (y; 0 .. H)
    {
        foreach (x; 0 .. W)
        {
            if (S[y][x] == '#')
            {
                L[y][x] = 0;
                R[y][x] = -1;
                U[y][x] = 0;
                D[y][x] = -1;
                continue;
            }
            if (x == 0)
                L[y][x] = 1;
            else
                L[y][x] = L[y][x - 1] + 1;

            if (y == 0)
                U[y][x] = 1;
            else
                U[y][x] = U[y - 1][x] + 1;
        }
        foreach_reverse (x; 0 .. W)
            if (S[y][x] != '#')
            {
                if (x == W - 1)
                    R[y][x] = 0;
                else
                    R[y][x] = R[y][x + 1] + 1;
            }
    }
    foreach_reverse (y; 0 .. H)
        foreach (x; 0 .. W)
            if (S[y][x] != '#')
            {
                if (y == H - 1)
                    D[y][x] = 0;
                else
                    D[y][x] = D[y + 1][x] + 1;
            }

    long ans = long.min;

    foreach (y; 0 .. H)
        foreach (x; 0 .. W)
            if (S[y][x] != '#')
            {
                long t = L[y][x] + R[y][x] + U[y][x] + D[y][x] - 1;
                // writefln("(%d %d) %d %d %d %d : %d", y, x, L[y][x], R[y][x], U[y][x], D[y][x], t);
                ans = ans.max(t);
            }
    writeln(ans);
}


Measured memory_bytes: 135420
s = input()
str_set = set([i for i in s])
n = len(str_set)

if len(str_set) == 4:
    print("Yes")
elif len(str_set) == 2:
    if( "S" in str_set and "N" in str_set) or ("W" in str_set and "E" in str_set):
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3064
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
const int maxm=600005;
const int mod=924844033;
int n;
vector<int>edge[maxn];
int fac[maxn],ifac[maxn],coef[maxn],siz[maxn];
int A[maxm],B[maxm],C[maxm]; 

int quickpow(int x,int pow){
	int res=1;
	for(;pow;pow>>=1){
		if(pow&1)res=1LL*res*x%mod;
		x=1LL*x*x%mod;
	}
	return res;
}

int binom(int a,int b){
	return a<b?0:1LL*fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}

void ntt(int *x,int sz,int tp){
	for(int i=sz>>1,j=1;j<sz;j++){
		if(i<j)swap(x[i],x[j]);
		int k;
		for(k=sz>>1;i&k;i^=k,k>>=1);i^=k;
	}
	for(int m=2;m<=sz;m<<=1){
		int w;
		if(tp>0)w=quickpow(5,(mod-1)/m);
		else w=quickpow(5,mod-1-(mod-1)/m);
		for(int i=0;i<sz;i+=m){
			int cur=1;
			for(int j=i;j<i+(m>>1);j++){
				int u=x[j],v=1LL*x[j+(m>>1)]*cur%mod;
				x[j]=(u+v)%mod;x[j+(m>>1)]=(u-v+mod)%mod;cur=1LL*cur*w%mod;
			}
		}
	}
	if(tp<0){
		int inv=quickpow(sz,mod-2);
		rep(i,sz)x[i]=1LL*x[i]*inv%mod;
	}
}

void dfs(int x,int p){
	siz[x]=1;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==p)continue;
		dfs(y,x);
		siz[x]+=siz[y];
	}
	if(p){
		coef[siz[x]]=(coef[siz[x]]+mod-1)%mod;
		coef[n-siz[x]]=(coef[n-siz[x]]+mod-1)%mod;
	}
	else coef[siz[x]]=n-1;
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(int i=2;i<=n;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*(mod-mod/i)*ifac[mod%i]%mod;
	}
	REP(i,n)ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	REP(i,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs(1,0);
	int sz=1;
	for(;sz<=n<<1;sz<<=1);
	rep(i,n+1){
		A[i]=1LL*coef[i]*fac[i]%mod;
		B[n-i]=ifac[i];
	}
	ntt(A,sz,1);
	ntt(B,sz,1);
	rep(i,sz)C[i]=1LL*A[i]*B[i]%mod;
	ntt(C,sz,-1);
	REP(i,n)printf("%d\n",(1LL*C[i+n]*ifac[i]%mod+binom(n,i))%mod); 
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 36480
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {
   while(true){
      var cards = StdIn.readLine()
      if(cards == "-"){return}
      val shuffleCount = StdIn.readInt()
      for(_ <- 1 to shuffleCount){
        val h = StdIn.readInt()
        cards = cards.substring(h) + cards.substring(0,h)
      }
      println(cards)
    }
  }
}

Measured memory_bytes: 43656
#include<cstdio>
#include<cstring>

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

using namespace std;

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

int regularize(const char *s,int *r){
	int len=strlen(s)/2;
	rep(i,len){
		char x[3]={s[2*i],s[2*i+1],'\0'};
		sscanf(x,"%X",r+i);
	}

	for(int i=1;i<=len;i++) if(len%i==0) {
		bool ok=true;
		rep(j,i) for(int k=1;k<len/i;k++) if(r[j*len/i+k]!=0) ok=false;
		if(ok){
			rep(j,i) r[j]=r[j*len/i];
			return i;
		}
	}
}

int main(){
	int T; scanf("%d",&T);
	while(T--){
		int n,l[8]; scanf("%d",&n);
		static int r[8][1024];
		rep(i,n){
			char s[2049]; scanf("%s",s);
			l[i]=regularize(s,r[i]);
		}

		int len=1;
		bool over=false;
		rep(i,n){
			len=lcm(len,l[i]);
			if(len>1024) over=true;
		}
		if(over){
			puts("Too complex.");
			continue;
		}

		int ans[1024]={};
		rep(i,n) rep(j,l[i]) ans[j*len/l[i]]|=r[i][j];
		rep(j,len) printf("%02X",ans[j]);
		puts("");
	}

	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> f(m);
  REP(i, m)
    f.at(i) = 0;
  
  REP(i, n) {
    int k;
    cin >> k;
    REP(j, k) {
      int tmp;
      cin >> tmp;
      ++f.at(tmp - 1);
    }
  }
  
  int ans = 0;
  REP(i, m) {
    if (f.at(i) == n)
      ++ans;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,k;
	int x;
	int i;
	int box[200001]={0};
	int cnt;
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>x;
		box[x]++;
	}
	sort(box,box+n,greater<int>());
	cnt=0;
    for(i=0;i<k;i++)	cnt+=box[i];
	cout<<n-cnt<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<bool> a(102, false);
  rep(i, m) {
    int t;
    cin >> t;
    a[t] = true;
  }
  int s1 = 0;
  for (int i = x; i > 0; i--) {
    if (a[i]) s1++;
  }
  int s2 = 0;
  for (int i = x; i < n; i++) {
    if (a[i]) s2++;
  }
  cout << min(s1, s2);
}

Measured memory_bytes: 256
S = input()
max = 0
ans = 0
if S.isupper() and 0 < len(S) < 11:
    for str in S:
        if str == 'A' or str == 'C' or str == 'G' or str == 'T':
            ans += 1
            if max < ans:
                max = ans
        else:
            if max < ans:
                max = ans
            ans = 0
print(max)            

Measured memory_bytes: 3060
<?php
  list($a, $b) = explode(" ", trim(fgets(STDIN)));
  $ary = array();
  for($i=1; $i <= $a; $i++) {
    $line = explode(" ", trim(fgets(STDIN)));
    array_push($ary, $line);
  }
  foreach ($ary as $val) {
    print(join(" ", $val) . " " . array_sum($val) . "\n");
  }
  $aaa = array();
  for($x=0; $x <= ($b-1); $x++) {
    $s = 0;
    for($n = 0; $n <= ($a-1); $n++) {
      $s += $ary[$n][$x];
    }
    print($s . " ");
    array_push($aaa, $s);
  }
  print array_sum($aaa);
?>

Measured memory_bytes: 8396
a,b,k=map(int,input().split())
i=0
while True:
    i+=1
    if i%2:
        if a%2:
            a-=1
        a/=2
        b+=a
    else:
        if b%2:
            b-=1
        b/=2
        a+=b
    if i==k:
        break
print(int(a),int(b))


Measured memory_bytes: 3060
n = int(input())
h = list(map(int,input().split()))
t1, t2 = h[0]-1, h[0]
for i in range(1, n):
	if h[i] < t1:
		print("No")
		exit()
	else:
		t1, t2 = max(h[i]-1, t1), max(h[i], t2)
print("Yes")

Measured memory_bytes: 14396
rank = {}
p = {}
        
def makeSet(x):
    p[x] = x
    rank[x] = 0

def link(x, y):
    if  rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
    if  rank[x] == rank[y]:
        rank[y] += 1

def union(x, y):
    link(findSet(x), findSet(y))
    
def findSet(x):
    if  x != p[x]:
        p[x] = findSet(p[x])
    return p[x]
    
def isSameSet(x, y):
    return findSet(x) == findSet(y)

n, q = map(int, input().split())
for x in range(n):
    makeSet(x)

for i in range(q):
    a,x,y = map(int, input().split())
    ret = (union if a == 0 else isSameSet)(x,y)
    if ret is None: continue
    if ret == True: print(1)
    else: print(0)

Measured memory_bytes: 9164
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>
#include <map>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}

vector<pair<ll, int>> prime_factorize(ll n) {
    vector < pair < ll, int >> res;
    int num = 0;
    while (n % 2 == 0) {
        num++;
        n /= 2;
    }
    if (num != 0) res.emplace_back(make_pair( 2, num ));

    for (ll p = 3; p * p <= n; p += 2) {
        num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        if (num != 0) res.emplace_back(make_pair(p, num));
    }
    if (n != 1)res.emplace_back(make_pair(n, 1));
    return res;
}


struct Room {
    int id, mark, step;
    vector<int> vicinities;
};

int main() {
    int X; cin >> X;
    for (int i = 1; i < 10000; i++) {
        for (int j =0; j <= i; j++) {
            ll A = j;
            for (int s = -1; s <= 1; s += 2) {
                ll B = s*(i - j);
                if (A * A * A * A * A - B * B * B * B * B == X) {
                    cout << A << " " << B << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int mx,n; cin>>n;
	vi vec(n);
	rep(i,0,n){
		int a;
		cin>>a;
		chmax(mx,a);
		vec[i]=a;
	}
	ll ans=MOD;
	rep(i,0,150){
		ll cnt=0;
		rep(j,0,n){
			cnt+=(vec[j]-i)*(vec[j]-i);
		}
		chmin(ans,cnt);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N,K;
    cin>>N>>K;
    if(N%K==0){
        cout<<0<<endl;
    }
    else{
        cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}
 
int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll ans = 1 + ceil(n-k, k-1);

    out(ans);    
    re0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod (1000000007)
using namespace std;

int n;
int num,fst[200010],lst[400010],to[400010];
int fa[200010],son[200010];
long long fac[200010],inv[200010],ans[200010];

long long ksm(long long a,long long b)
{
	long long res=1,sum=a;
	while(b)
	{
		if(b&1) (res*=sum)%=mod;
		(sum*=sum)%=mod;
		b>>=1;
	}
	return res;
}

inline void insert(int u,int v)
{
	lst[++num]=fst[u];to[num]=v;fst[u]=num;
	lst[++num]=fst[v];to[num]=u;fst[v]=num;
}

void dfs(int x)
{
	son[x]=1;
	for(int i=fst[x];i;i=lst[i]) if(fa[x]!=to[i])
	{
		fa[to[i]]=x;
		dfs(to[i]);
		son[x]+=son[to[i]];
	}
}

void work(int x)
{
	int cnt=0;
	ans[x]=1;
	for(int i=fst[x];i;i=lst[i]) if(fa[x]!=to[i])
	{
		work(to[i]);
		ans[x]=ans[x]*ans[to[i]]%mod*fac[son[x]-cnt-1]%mod*inv[son[to[i]]]%mod*inv[son[x]-cnt-1-son[to[i]]]%mod;
		cnt+=son[to[i]];
	}
}

void dfs2(int x,long long d)
{
	if(x!=1) ans[x]=ans[x]*fac[n-1]%mod*inv[n-son[x]]%mod*inv[son[x]-1]%mod*d%mod;
	long long re;
	for(int i=fst[x];i;i=lst[i]) if(fa[x]!=to[i])
	{
		re=ans[x]*ksm(ans[to[i]],mod-2)%mod*fac[son[to[i]]]%mod*fac[n-1-son[to[i]]]%mod*inv[n-1]%mod;
		dfs2(to[i],re);
	}
}

int main()
{
	int u,v;
	scanf("%d",&n);
	fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++)
	{
		fac[i]=fac[i-1]*i%mod;
		inv[i]=ksm(fac[i],mod-2);
	}
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		insert(u,v);
	}
	dfs(1);
	work(1);
	dfs2(1,0);
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 14092
#include <iostream>
#include <utility>

using namespace std;

int partition(int a[],int p,int r){
  int x=a[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(a[j]<=x){
      i++;
      swap(a[i],a[j]);
    }
  }
  swap(a[i+1],a[r]);
  return i+1;
}

int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int q=partition(a,0,n-1);
  for(int i=0;i<n;i++){
    if(i==q){
      if(i) cout << " [" << a[i] << "]";
      else cout << "[" << a[i] << "]";
    }else{
      if(i) cout << " " << a[i];
      else cout << a[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 3380
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,l] <- r'
    let vec = U.generate n (+l)
    let summ = U.sum vec
    let abss = U.map abs vec
    let minn = U.minIndex abss
    print $ summ - (vec U.! minn)

Measured memory_bytes: 380
# https://atcoder.jp/contests/agc030/tasks/agc030_a

def main():
    A, B, C = map(int, input().split())
    deli = 0
    if A > 0 and C > 0:
        eat = min(A, C)
        deli += eat
        A -= eat
        C -= eat

    # 美味しくないクッキーがなくなった, お腹壊してない
    if B > 0 and C > 0:
        eat = min(B, C)
        deli += eat * 2
        B -= eat
        C -= eat
    # お腹壊してない

    if C > 0:
        deli += 1

    deli += B
    print(deli)


if __name__ == '__main__':
    main()



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

int dp[100100];
vector<vector<int>> G(100100);
int rec(int v){
	if(dp[v]!=-1) return dp[v];
    
  	int res = 0;
  	for(auto nv:G[v]){
    	res=max(res,rec(nv)+1);
    
    }
  	return dp[v]=res;
}

int main(){
  	int N,M;
	cin >>N>>M;
  	
  	for(int i=1;i<=M;i++){
     int x,y; 
     cin >> x >>y;
      
    G.at(x).push_back(y);   
    }
   for (int v = 1; v <= N; ++v) dp[v] = -1;
  
    int ans=0;
  	for(int i=1;i<=N;i++){
     ans=max(ans,rec(i));
    }
  cout<<ans;
}

Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	while(1){
		ll b; cin >> b;
		if(!b) break;
		ll ans = 0;
		ll left = 0;
		ll now = 0;
		for(ll i=1; i<=50000; i++){
			now += i;
			if(b < now) break;
			if((b-now) % i == 0){
				left = (b-now) / i + 1;
				ans = i; 
			}
		}
		print2(left,ans);
	}
}


Measured memory_bytes: 3068
/***********************************************
 *                                             *
 *   author: raghav_0901 (Raghav Dalmia)       *
 *   updated on: 21-06-2020, 12:25:15 am IST   *
 *                                             *
\***********************************************/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

signed main( )
{
    int x, m;
    cin >> x;
    int cnt = 0;
    m = 0;
    while (m == 0 || m % 360 != 0)
    {
        m += x;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll n;
ll a[114];
ll cnt[9];
signed main() {
	ll p = 0, c = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		cnt[a[i] / 400]++;
		if (a[i] >= 3200)c++;
	}
	rep(i, 8) {
		if (cnt[i])p++;
	}
	if (c == n)cout << 1 << " " << n << endl;
	else cout << p << " " << p + c << endl;
	ggr
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 100100
struct node
{
	int val,id;
	bool operator <(const node &p)const{return val<p.val;}
};
int n;node a[maxn];
int ans[maxn];
set<int> s;
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i].val),a[i].id=i;
	sort(a+1,a+n+1);int lst=a[n].val;
	for(int i=n;i;)
	{
		int r=i,l=i;
		while(l-1>0&&a[l].val==a[l-1].val) l--;
		ans[*s.begin()]+=(lst-a[r].val)*s.size();
		for(int j=l;j<=r;j++) s.insert(a[j].id);
		lst=a[r].val;i=l-1;
	}
	ans[*s.begin()]+=lst*s.size();
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,result = 0;
	string S;
	cin >> N;
	for (int i =0;i<N;i++){
		cin >> S;
		if ( S == "Y") {
			result = 1;
		}
	}
	if (result == 1) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
}
	 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    vi a(4, 0);
    rep(i,3){
        lli c, b;
        cin>>c>>b;
        a[c-1]++;
        a[b-1]++;

    }
    bool s=true;
    rep(i,4){
        if(a[i]>2){ 
            s=false;
            break;
        }
    }
    YES(s);
}

Measured memory_bytes: 3600
import kotlin.math.max

fun main() {
    val (n, m) = nextIntList()
    val values = (0 until n).map {
        val (x, y, z) = nextLongList()
        Triple(x, y, z)
    }

    var result = 0L
    (0 until 8).forEach {
        val xi = if ((it and 1) > 0) 1 else -1
        val yi = if ((it and 2) > 0) 1 else -1
        val zi = if ((it and 4) > 0) 1 else -1
        result = max(result, values.map { v ->
            xi.times(v.first) + yi.times(v.second) + zi.times(v.third)
        }.sortedDescending().take(m).sum())
    }
    println(result)
}


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

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 42928