akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int R, C; cin >> R >> C;
    if (R == 0 and C == 0) break;
    vector<vector<int>> board(R, vector<int>(C));
    REP(i, R) REP(j, C) cin >> board[i][j];
    int ans = 0;
    REP(r_state, 1 << R) {
      int cnt = 0;
      REP(c, C) {
        int c_cnt = 0;
        REP(r, R) c_cnt += (board[r][c] + (r_state >> r & 1)) % 2 == 0;
        cnt += max(c_cnt, R - c_cnt);
      }
      ans = max(ans, cnt);
    }
    cout << ans << endl;
  }

  return 0;
}

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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0) {
      break;
    }

    int ans = -1;
    vector<int> man(26, 0);
    vector<char> c(n);
    for(int i=0; i<n; i++){
      cin >> c[i];
    }

    int max;
    for(int i=0; i<n; i++){
      man[c[i]-'A']++;
      vector<int> temp = man;
      sort(temp.begin(), temp.end(), greater<int>());
      /*
      int temp = 0, temp2 = 0;
      int ti, ti2;
      for (int j = 0; j < 26; j++) {
	if (man[j] >= temp) {
	  temp2 = temp;
	  temp = man[j];

	  ti2 = ti;
	  ti = j;
	}else if(man[j] > temp2){
	  temp2 = man[j];
	  ti2 = j;
	}
      }
      */

      if(temp[0] > temp[1] + (n-i-1)){
	max = temp[0];
	ans = i;
	break;
      }
    }

    int ti;
    for(int i=0; i<26; i++){
      if(man[i] == max)
	ti = i;
    }

    if(ans == -1)
      cout << "TIE" << endl;
    else   
      cout << (char)(ti+'A') << " " << ans+1 <<endl;
  }

  return 0;
}

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

int n, x[200000], y[200000];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &x[i]);
        y[i] = x[i];
    }
    sort(y, y + n);
    int ans1 = y[n/2-1], ans2=y[n/2];
    for (int i = 0; i < n; i++) {
        if (x[i] <= ans1) cout << ans2 << endl;
        else cout << ans1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>

int gcd(int x,int y){
  int r;
  r=x%y;
  while(r>0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}

int main(){
  int x,y;
  int g;
  std::cin>>x>>y;
  g=gcd(x,y);
  std::cout<<g<<'\n';
  return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
  int n,k;cin>>n>>k;
  
  vector<ll> vec(n);
  
  rep(i,n) cin>>vec[i];
  
  sort(vec.begin(),vec.end());
  
  ll sa=10000000000;
  for (int i=0;i<n-k+1;i++) {
    sa=min(sa,vec[i+k-1]-vec[i]);
  }
  
  cout<<sa<<endl;
  
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    const double PI = 3.14159265358979323846;
    cin.tie(0);
    ios::sync_with_stdio(false);

    long double n,ans;
    cin >> n;

    ans = n * 2 * PI;
    cout << std::setprecision(100) << ans << "\n";

    return 0;
}

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

int main(){
    while(true){
        int N,M;
        cin>>N>>M;
        if(N==0 && M==0) break;
        int P[1000];
        for(int i=0;i<N;i++){
            cin>>P[i];
        }
        int PP[1001001];
        int count=0;
        PP[count]=0;
        count++;
        for(int i=0;i<N;i++){
            PP[count]=P[i];
            count++;
        }
        for(int i=0;i<N;i++){
            for(int j=i;j<N;j++){
                PP[count]=P[i]+P[j];
                count++;
            }
        }
        int ans=0;
        sort(PP,PP+count);
        for(int i=0;i<count;i++){
            int searchh = M-PP[i];
            int* pos=lower_bound(PP,PP+count,searchh);
            int z = (int)(pos-PP);
            if(z == count){
                ans = max(ans, PP[i] + PP[z-1]);
            }else{
                if(*pos == searchh){
                    ans=M;
                    break;
                }else{
                    ans = max(ans, PP[i] + PP[z-1]);
                }
                if(PP[i] > PP[z-1]) break;
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 4992
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int maxn = 100100;
int n, cnt;
vector<int> G[maxn];
int num[maxn], a[maxn];
ll ans;
int an[maxn];

void dfs(int u) {
  vector<int> vec;
  rep(i, 0, G[u].size() - 1) if (!a[G[u][i]]) {
    a[G[u][i]] = num[++cnt];
    vec.pb(G[u][i]);
  }
  rep(i, 0, vec.size() - 1) {
    dfs(vec[i]);
  }
}

void work() {
  n = read();
  rep(i, 1, n - 1) {
    int x = read(), y = read();
    G[x].pb(y); G[y].pb(x);
  }
  rep(i, 1, n) num[i] = read();
  sort(num + 1, num + n + 1);
  reverse(num + 1, num + n + 1);
  rep(i, 1, 1) {
    memset(a, 0, sizeof(a));
    cnt = 1; a[i] = num[1];
    dfs(i);
    ll nw = 0;
    rep(j, 1, n) rep(k, 0, G[j].size() - 1) {
      if (j < G[j][k]) nw += min(a[j], a[G[j][k]]);
    }
    if (nw > ans) {
      ans = nw;
      rep(i, 1, n) an[i] = a[i];
    }
  }
  printf("%lld\n", ans);
  rep(i, 1, n) printf("%d ", an[i]);
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 4480
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
      String x="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      int n=s.nextInt();s.nextLine();
     String ss=s.nextLine();
     StringBuilder sb=new StringBuilder();
     for(int i=0;i<ss.length();i++){
      int z=ss.charAt(i)-'A';
      
      z=(z+n)%26;
     // System.out.println(z);
      sb.append(x.charAt(z));
     }
        System.out.println(sb);
        }
    }


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

//string s[1010], b[1010];
bool a[40];
ll c[40], cc[40], d[1010];
//???????´??????? x???e???
ll binpow(ll x, ll e)
{
  ll a = 1, p = x;

  while(e > 0) {
    if(e%2 == 0) {p = (p*p); e /= 2;}
    else {a = (a*p); e--;}
  }

  return a;
}

signed main(void)
{
	while(true) {
		int n, m, q;
		cin >> n >> m >> q;
		if(!n && !m && !q) break;
		//REP(i, q) cin >> s[i] >> b[i];

		REP(i, n) {
			a[i] = false;
			c[i] = cc[i] = 0;
		}
		REP(i, m) d[i] = binpow(2, n)-1;
		//cout << "a" << endl;
		ll k = 0;
		REP(i, q) {
			string s, b;
			cin >> s >> b;
			ll t = 0;
			REP(j, n) {
				t = ((t << 1) | (s[j] - '0'));
			}
			k ^= t;
			//cout << "i:" << i << endl;
			REP(j, m) {
				//cout << "j:" << j << " " << d[j] << " " << b[j]<< endl;
				if(b[j] == '1') d[j] &= k;
				else d[j] &= ~k;
			}

		}
		REP(i, m) {
			int cnt = 0;
			VI e;
			REP(j, n) {
				if(d[i]>>j&1) {
					cnt++;
					e.PB(j);
				}
			}
			if(cnt == 1) {
				e[0] = n-1-e[0];
				//cout << "e" << e[0] << endl;
				if(e[0] < 10)	cout << e[0];
				else cout << (char)(e[0]-10 + 'A');
			} else {
				cout << "?";
			}
		}
		cout << endl;
	}

	return 0;
}

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

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

int main() {
    ll K, Q; cin >> K >> Q;
    vl d(K);
    rep(i,K) cin >> d[i];
    rep(i,Q) {
        ll N, X, M;
        cin >> N >> X >> M; N--;
        ll a1 = X, an = X, ans = N;
        rep(k,K) {
            ll D = d[k] % M;
            ll cnt = N/K + (N%K > k);
            an += D * cnt;
            if (D == 0) ans -= cnt;
        }
        ans -= (an/M - a1/M);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 384
N,Y= map(int,input().split())

for a in range(N+1):
  for b in range(N-a+1):
    c = N-a-b
    if (10000*a+5000*b+1000*c ==Y):
      print('{} {} {}'.format(a,b,c))
      exit()
print('-1 -1 -1')

Measured memory_bytes: 2940
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int keika =  b-a;

		if(b<=a){ //x<=b-a
			System.out.println("delicious");
		}else if(b<=a+x){
			System.out.println("safe");
		}else if(b>=a+x+1){
			System.out.println("dangerous");
		}
	}
}

Measured memory_bytes: 22356
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)
MOD = 10 ** 30 + 7

N, M = map(int, raw_input().split())
s = raw_input()

p27 = [1 for i in range(500000)]
for i in range(1, 500000):
    p27[i] = p27[i - 1] * 27
    p27[i] %= MOD

m = {}
P = (ord(s[0]) - ord('a') + 1)
l = 0
r = 0
for loop in range(M):
    S = raw_input()
    if S == 'L++':
        P -= (ord(s[l]) - ord('a') + 1) * p27[r - l]
        P %= MOD
        l += 1
    elif S == 'L--':
        l -= 1
        P += (ord(s[l]) - ord('a') + 1) * p27[r - l]
        P %= MOD
    elif S == 'R++':
        r += 1
        P *= 27
        P += (ord(s[r]) - ord('a') + 1)
        P %= MOD
    elif S == 'R--':
        P -= (ord(s[r]) - ord('a') + 1)
        P %= MOD
        for i in range(27):
            if (P + MOD * i) % 27 == 0:
                P = (P + MOD * i) / 27
                break
        r -= 1
    #print s[l:r + 1], P
    m[P] = 1
print len(m)


Measured memory_bytes: 73380
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;

}

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h)*(W - w) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int a,b,c;
 cin>>a>>b>>c;
 fo(i,1,1000000) if((a*i)%b==c){
     cout<<"YES"<<endl;
     return 0;
 }
 cout<<"NO"<<endl;
 return 0;
}

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

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

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

  ll x;
  if (n <= b-1) {
    x = n;
  } else {
    x = b-1;
  }
  cout << (a*x / b) - a * (x / b) << endl;
}


Measured memory_bytes: 3632
H, W, K = map(int, input().split())

cake = [list(input()) for _ in range(H)]
ans = [[0] * W for _ in range(H)]

id = 1
sign = 0
nothing = 0

for i in range(H):
    if cake[i].count('#') == 0:
        nothing += 1
        if i == H-1:
            for j in range(W):
                for d in range(nothing):
                    ans[i-d][j] = ans[i-nothing][j]
        continue
    for j in range(W):
        if cake[i][j] == '#':
            ans[i][sign:j+1] = [id] * (j+1-sign)
            sign = j+1
            id += 1
        elif j == W-1:
            ans[i][sign:j+1] = [id-1] * (j+1-sign)
    if nothing != 0:
        for j in range(W):
            for d in range(1,nothing+1):
                ans[i-d][j] = ans[i][j]
    sign = 0
    nothing = 0

for i in range(H):
    for j in range(W):
        print('{} '.format(ans[i][j]), end='')
    print()

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

int main(){
string s;
cin>>s;
for(int i=0;i<s.length()-1;i++){
    if(s[i]==s[i+1]){cout<<"Bad";return 0;}
}
cout<<"Good";
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define vi vector<int>
#define fi first
#define se second 
#define mp make_pair
#define show(x) cout<<#x<<" = "<<x<<endl;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define LL long long 
#define pi acos(-1)
#define fin freopen("in","r",stdin);
const int inf=0x3f3f3f3f;
const double eps=1e-8;
#define zero(x) (((x)>0?(x):-(x))<eps)
#define _sign(x) ((x)>eps?1:((x)<-eps?2:0))
typedef long long ll;
const int maxn = 10005, mod = 1e9+7;
#define fin freopen("in","r",stdin);
int a[maxn],n;
int main(){
	int mx=0,ans=0;
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]>=mx){
			mx=a[i];
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#define ini 100
using namespace std ;

typedef pair<int,int> P ;

queue<P> q ;
int dx[] = {0,1,1,0,-1,-1} ;
int dy[] = {1,1,0,-1,-1,0} ;

int main(){
	
	int t , n ;
	int x , y ;
	int ans ;
	int field[200][200] ;
	/*
	1:コスト(1インデックス)
	0:空き地
	-1:障害物
	*/
	
	while( cin >> t >> n , t ){
		
		
		for( int i=0 ; i<200 ; i++ ){
			for( int j=0 ; j<200 ; j++ ){
				field[i][j] = 0 ;
			}
		}
		
		ans = 1 ;
		
		for( int i=0 ; i<n ; i++ ){
			cin >> x >> y ;
			field[y+ini][x+ini]  = -1 ;
		}
		
		cin >> x >> y ;
		
		q.push( P(x+ini,y+ini) ) ;
		field[y+ini][x+ini] = 1 ;
		
		int j=0 , k=0 ;
		while( !q.empty() ){
			x = q.front().first ;
			y = q.front().second ;
			//cout << "OK" << endl ;//--------------------
			if( field[y][x] > t+1 ) break ;
			for( int i=0 ; i<6 && field[y][x] <= t ; i++ ){
				if( field[y+dy[i]][x+dx[i]] == 0 ){
					field[y+dy[i]][x+dx[i]] = field[y][x]+1 ;
					q.push( P(x+dx[i],y+dy[i]) ) ;
					//cout<<"# "<<x-ini<<" "<<y-ini<<endl;
					ans++ ;
				}
			}
			q.pop() ;
		}
		
		cout << ans << endl ;
		
		while( !q.empty()  ){
			q.pop() ;
		}
	}
	
return 0 ;
}

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

int main(){
  int n; cin >>n;
  map<ll, ll> mp;
  rep(i,n){
    int a; cin >>a;
    mp[a]++;
  }
  vector<ll> rec;
  for(auto x : mp){
    if(x.second>=2) rec.push_back(x.first);
    if(x.second>=4) rec.push_back(x.first);
  }
  if(rec.size()<2) cout << 0 << endl;
  else cout << (ll)rec[rec.size()-1]*rec[rec.size()-2] << endl;
  return 0;
}

Measured memory_bytes: 9892
s=input()
s1=int(s[0:2])
s2=int(s[2:4])
if s1<=12 and s1>=1:
  print('AMBIGUOUS' if (s2<=12 and s2>=1) else 'MMYY')
else:
  print('YYMM' if (s2<=12 and s2>=1) else 'NA')

Measured memory_bytes: 3060
from heapq import*
i=input
s=sorted
def f(x):
 s,n,*h=0,len(x)
 while n:
  while x and x[-1][0]>=n:k,l,r=x.pop();heappush(h,(r-l,l,r))
  if h:s+=heappop(h)[1]
  n-=1
 return s+sum(r for _,_,r in x+h)
for _ in'_'*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>r:x+=(k,l,r),
  else:y+=(n-k,r,l),
 print(f(s(x))+f(s(y)))

Measured memory_bytes: 121240
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

calc :: Int -> Int
calc n = sum $ do
	a <- [1..n]
	b <- [1..n]
	c <- [1..n]
	return $ gcd (gcd a b) c

main :: IO ()
main = do
	n <- readLn
	print $ calc n


Measured memory_bytes: 3940
//@editor aokabi
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
const int INF = 1e9;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
    ll N, H;
    cin >> N >> H;
    vector<ll> a(N), b(N);
    for(int i = 0; i < N; i++) cin >> a[i] >> b[i];

    //ふり最強剣
    ll a_max = *max_element(all(a));
    //強いものから投げる
    sort(all(b));
    reverse(all(b));
    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(a_max < b[i]){
            H -= b[i];
            ans++;
            //投げで倒した
            if(H <= 0) break;
        }
    }
    //剣を振りまくって倒す
    //ans += ceil(H/a_max) : H/max以上の最大の整数
    if(H > 0) ans += (H + (a_max-1)) / a_max;
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n;
    cin >> n;
    ll a[n];
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll y = a[0];
    ll c = 0ll;
    for (i = 2; i < n; i++) c ^= a[i];
    ll d = a[0] + a[1] - c;
    if (d < 0) {
        cout << -1 << endl;
        return 0;
    }
    if (d % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }
    d /= 2;
    VI v(46, 0);
    for (i = 45; i >= 0; i--) {
        if ((d >> i) & 1ll) {
            if ((c >> i) & 1ll) {
                cout << -1 << endl;
                return 0;
            }
            a[0] -= (1ll << i);
        } else if ((c >> i) & 1ll) {
            v[i] = 1;
            // cout << i << " ";
        }
    }
    if (a[0] < 0) {
        cout << -1 << endl;
        return 0;
    }
    bool ok = 0;
    for (i = 45; i >= 0; i--) {
        if ((a[0] >> i) & 1ll) {
            if (v[i] == 0)
                ok = 1;
            else {
                a[0] -= (1ll << i);
                // cout << i << endl;
            }
        } else if (v[i] == 1) {
            if (ok) {
                a[0] -= (1ll << i);
                // cout << i << endl;
            }
        }
    }
    if (a[0] == y) {
        cout << -1 << endl;
        return 0;
    }
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    ll N;
    ll T[5];
    cin >> N >> T[0] >> T[1] >> T[2] >> T[3] >> T[4];

    ll min = N+1;
    for (int i=0; i < 5; i++)
    {
        if (min > T[i])
        {
            min = T[i];
        }
    }

    ll div = ceil( (double)N/ (double)min ) ;

    cout << (ll)div + 4 << endl;
}

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

using namespace std;

bool isok(string a, string b)
{
	return (a == "lu" && b == "ru") || (a == "ru" && b == "lu") || (a == "ld" && b == "rd") || (a == "rd" && b == "ld");
}

int main(void)
{
	int n;
	while (cin >> n, n){
		string str, prev = "";
		int ret = 0;
		for (int i = 0; i < n; i++){
			cin >> str;
			if (isok(str, prev)) ret++;
			prev = str;
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
      	Map<String, Integer> inputMap = new HashMap<String, Integer>();
      	inputMap.put("AC", 0);
      	inputMap.put("WA", 0);
        inputMap.put("TLE", 0);
      	inputMap.put("RE", 0);
      
      	List<String> inputList = new ArrayList<String>();
		for(int i=0;i<n;i++){
        	inputList.add(sc.next());
        }
        
        for(String str: inputList){
        	for(Map.Entry<String, Integer> entry: inputMap.entrySet()){
            	if( str.equals(entry.getKey())){
                	inputMap.replace(str, entry.getValue()+1);
                }
            }
        }

		// 出力
      	
        System.out.println("AC x "+inputMap.get("AC"));
        System.out.println("WA x "+inputMap.get("WA"));
        System.out.println("TLE x "+inputMap.get("TLE"));
        System.out.println("RE x "+inputMap.get("RE"));
	}
}

Measured memory_bytes: 64884
def solve(N):
    dp = [0] * (N + 1)

    dp[0] = 1
    for i in range(N):
        for j in range(i + 1, min(N, i + 3) + 1):
            dp[j] += dp[i]

    d = (dp[N] // 10 + int(dp[N] % 10 != 0))
    print(d // 365 + int(d % 365 != 0))


N = int(input())
while N != 0:
    solve(N)
    N = int(input())



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

const int N = 305;
double ev[N][N][N];
double prob[N][N][N];

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

	int n;
	cin >> n;

	vector<int> cnt(4);
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}

	prob[cnt[1]][cnt[2]][cnt[3]] = 1;

	for (int c = N - 1; c >= 0; c--)
	{
		for (int b = N - 1; b >= 0; b--)
		{
			for (int a = N - 1; a >= 0; a--)
			{
				double curr_prob = prob[a][b][c];
				int curr_sushi = a + b + c;
				if (curr_sushi > n)
					continue;
				if (curr_sushi == 0)
					continue;
				double p_waste = (double)(n - (a + b + c)) / n;
				double ev_waste = p_waste / (1 - p_waste) + 1;
				ev[a][b][c] += ev_waste * curr_prob;

				if (c != 0)
				{
					prob[a][b + 1][c - 1] += curr_prob * (double)c / curr_sushi;
					ev[a][b + 1][c - 1] += ev[a][b][c]*(double)c / curr_sushi ;
				}
				if (b != 0)
				{
					prob[a + 1][b - 1][c] += curr_prob * (double)b / curr_sushi;
					ev[a + 1][b - 1][c] += ev[a][b][c] * (double)b / curr_sushi;
				}
				if (a != 0)
				{
					prob[a - 1][b][c] += curr_prob * (double)a / curr_sushi;
					ev[a - 1][b][c] += ev[a][b][c] * (double)a / curr_sushi;
				}
			}
		}
	}
	cout << fixed << setprecision(20) << ev[0][0][0]  << "\n";
}

Measured memory_bytes: 438528
import numpy as np

num_of_problems, num_of_submittions = map(int, input().split())
submittions = []
for _ in range(num_of_submittions):
    submittions.append(list(input().split()))

WAs = [0] * num_of_problems
ACs = [0] * num_of_problems

for submittion in submittions:
    problem_index = int(submittion[0]) - 1
    result = submittion[1]

    if result == 'WA' and ACs[problem_index] == 0:
        WAs[problem_index] = WAs[problem_index] + 1

    if result == 'AC' and ACs[problem_index] == 0:
        ACs[problem_index] = 1

# WAありでACなしの問題のペナルティ数を0にする
WAs = np.array(WAs) * np.array(ACs)

print(str(ACs.count(1)) + ' ' + str(sum(WAs)))

Measured memory_bytes: 38708
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var answers = new List<double>();
            while(true)
            {
                var n = int.Parse(ReadLine());
                if (n == 0)
                {
                    break;
                }

                var cells = new double[n][];
                var corridors = new List<double[]>();
                var parents = new int[n];
                for (var i = 0; i < n; i++)
                {
                    cells[i] = ReadLine().Split(' ').Select(value => double.Parse(value)).ToArray();
                    parents[i] = i;
                }

                MakeCorridors(n, cells, corridors);
                corridors = corridors.OrderBy(array => array[2]).ToList();

                var totalLength = 0.0;
                foreach(var corridor in corridors)
                {
                    if(GetRoot(parents, (int)corridor[0]) != GetRoot(parents, (int)corridor[1]))
                    {
                        totalLength += corridor[2];
                        Union(parents, (int)corridor[0], (int)corridor[1]);
                    }
                }

                answers.Add(totalLength);
            }

            answers.ForEach(value => WriteLine("{0:f3}", value));
        }

        private static void MakeCorridors(int n, double[][] cells, List<double[]> corridors)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = i + 1; j < n; j++)
                {
                    var xDiff = cells[i][0] - cells[j][0];
                    var yDiff = cells[i][1] - cells[j][1];
                    var zDiff = cells[i][2] - cells[j][2];
                    var length = Sqrt(xDiff * xDiff + yDiff * yDiff + zDiff * zDiff);
                    length -= cells[i][3] + cells[j][3];
                    if (length > 0.0)
                    {
                        corridors.Add(new double[3] { i, j, length });
                    }
                    else
                    {
                        corridors.Add(new double[3] { i, j, 0.0 });
                    }
                }
            }
        }

        private static int GetRoot(int[] parents, int node)
        {
            if(parents[node] == node)
            {
                return node;
            }
            return parents[node] = GetRoot(parents, parents[node]);
        }

        private static void Union(int[] parents, int x, int y)
        {
            x = GetRoot(parents, x);
            y = GetRoot(parents, y);

            if(x != y)
            {
                parents[x] = y;
            }
        }
    }
}



Measured memory_bytes: 28896
#include <cstdio>
#include <algorithm>
 
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define v edge[i].to
 
using namespace std;
 
const int N = 100010;
 
struct Edge{ int to, next;} edge[N * 2];
int head[N], num;
void add_edge(int a, int b){ edge[++ num] = (Edge){b, head[a]}, head[a] =num;}
 
bool g[N], flag;
 
void dfs(int x, int f)
{
	int cnt = 0, tt = 0;
	g[x] = 1;
	RepG(i, x) if (v != f) {
		dfs(v, x); tt ++;
		if (g[v]) cnt ++;
		g[x] ^= g[v];
	}
	if (cnt >= 2) flag = true;
}
 
int main()
{
	int n;
	scanf("%d", &n);
	Rep(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		add_edge(a, b); add_edge(b, a);
	}
	dfs(1, 0);
	if (flag || g[1]) printf("First\n");
	else printf("Second\n");
	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int a,b,c; cin >> a >> b >> c;

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

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量
  int j =0;
  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
       push(i, &st1);
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
    	j = pop(&st1);
    	sum = sum + (i-j);
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
      	a =a+pop(&st2_a);
      	pop(&st2_j);
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
    	push(j, &st2_j);
    	push(a, &st2_a);
    	

    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]);  
  printf("\n");

  return 0;
}



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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int h[25];
int n;

void solve() {
  scanf("%d", &n);
  ++h[0];
  bool zero = false;
  for (int d, i = 0; i < n; ++i) {
    scanf("%d", &d);
    if (++h[d] == 3) {
      puts("0");
      return;
    }
  }
  if (h[0] >= 2 || h[12] >= 2) {
    puts("0");
    return;
  }
  bool left = true;
  for (int i = 1; i < 12; ++i) {
    if (h[i] == 2) {
      --h[i]; ++h[24-i];
    } else if (h[i] == 1) {
      if (left) left = false;
      else {
	--h[i]; ++h[24-i];
	left = true;
      }
    }
  }
  int ans = 1e9;
  for (int i = 0; i < 24; ++i) {
    if (!h[i]) continue;
    for (int j = i+1; j <= 24; ++j) {
      if (!h[j]) continue;
      int d = j-i;
      ans = min(ans, min(d, 24-d));
    }
  }
  printf("%d", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3812
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  set<int> st;
  int pro = 0;
  while (n--) {
    int a; cin >> a;
    if (a >= 3200) {
      ++pro;
    } else {
      st.emplace(a / 400);
    }
  }
  cout << max((int)st.size(), 1) << ' ' << st.size() + pro << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P=pair<double, double>;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    fast_io
    int n;
    double d;
    cin>>n>>d;
    vector<P> p;
    rep(i,n){
        double x, y;
        cin>>x>>y;
        p.push_back({x, y});
    }
    int ans=0;
    rep(i,n){
        double l = sqrt(p[i].first*p[i].first + p[i].second*p[i].second);
        if(l <= d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7520
#include<bits/stdc++.h>
#define LL long long
using namespace std;
template<class T>inline void Rd(T &x){
	x=0;char c=getchar();bool f=0;
	while(c<'0'||c>'9'){if(c=='-')f^=1;c=getchar();}
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+c-'0',c=getchar();
	if(f)x=-x;
}
LL A,B,C,D;
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}

int main(){
	Rd(A),Rd(B),Rd(C),Rd(D);
	LL g=C*D/gcd(C,D);
	printf("%lld\n",B-A+1-(B/C-(A-1)/C)-(B/D-(A-1)/D)+(B/g-(A-1)/g));
	return 0;
}

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

int main() {
  int n;
  int mx = 0;
  cin >> n;
  vector<int> a(n);
  priority_queue<int> A;
  rep(i, n) {
    cin >> a[i];
    A.push(a[i]);
  }
  rep(i ,n){
    if(a[i] != A.top()) {
      cout << A.top() << endl;
    }else {
      int tmp = A.top();
      A.pop();
      cout << A.top() << endl;
      A.push(tmp);
    }
  }
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
     int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0){
      cout<<"Possible"<<endl;
    }
    else{
      cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
#-------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# ------------------- fast io --------------------

from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[j - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] =  j
    return pi

def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else '0' * (length - len(y)) + y

s = input()
ans = 0
if s[0] == 'R' or s[2] == 'R' or s[1] == 'R':
    ans = 1
if (s[0] == 'R' and s[1] == 'R') or (s[1] == 'R' and s[2] == 'R'):
    ans = 2
if s[0] == 'R' and s[1] == 'R' and s[2] == 'R':
    ans = 3
print(ans)



Measured memory_bytes: 63020
#include <bits/stdc++.h>
//#pragma comment(linker, "/STACK: 2000000")

using namespace std;

const int N = 2e6 + 5;

long long n , a[N] , b[N];
vector< pair<long long , long long> > ans , ans2;

int main() {
    cin>>n;
    long long mx =-1e12 , mn = 1e12 , idx = -1 , idx2 = -1;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>mx)
        {
            mx = a[i];
            idx = i;
        }
        if(a[i]<mn)
        {
            mn = a[i];
            idx2 = i;
        }
    }

    for(int i = 0;i<22;i++)
    {
        bool ok = 1;
        ans.clear();
        for(int j = 0;j<n;j++)
            b[j] = a[j];
        mx = a[idx];
        for(int j = 0;j<i;j++)
        {
           mx*=2;
           ans.push_back({ idx+1,idx+1 });
        }
        b[idx] = mx;
        for(int j= 1;j<n;j++)
        {
            while(ok && b[j]<b[j-1])
            {
                b[j]+=mx;
                ans.push_back({idx+1 ,j+1 });
                if( b[j] >mx )
                {
                    mx = b[j];
                    idx = j;
                }
                if(ans.size()>n*2)
                    ok = 0;
            }
        }
        if(ok && ans.size()<=2*n)
        {
            cout<<ans.size()<<"\n";
            for(auto u : ans)
                cout<<u.first<<" "<<u.second<<"\n";
            return 0;
        }
    }

    for(int i = 0;i<22;i++)
    {
        bool ok = 1;
        ans.clear();
        for(int j = 0;j<n;j++)
            b[j] = a[j];
        mn = a[idx2];
        for(int j = 0;j<i;j++)
        {
            ans.push_back({ idx2+1,idx2+1 });
            mn*=2;
        }
        b[idx2] = mn;
        for(int j=n-2;j>=0;j--)
        {
            while(ok && b[j]>b[j+1])
            {
                b[j]+=mn;
                ans.push_back({idx2+1 ,j+1 });
                if(ans.size()>n*2)
                    ok = 0;
                if( b[j] <mn )
                {
                    mn = b[j];
                    idx2 = j;
                }
            }
        }
        if(ok && ans.size()<=2*n)
        {
            cout<<ans.size()<<"\n";
            for(auto u : ans)
                cout<<u.first<<" "<<u.second<<"\n";
            return 0;
        }
    }
    return 0;
}


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

int main() {
  int N, K;
  string line;
  cin >> N >> K;
  cin >> line;
  int now = 1;
  int cnt = 0;
  vector<int> lines;
  for (int i = 0; i < N; i++) {
    if (line[i] == (char)('0' + now)) {
      cnt++;
    } else {
      lines.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) {
    lines.push_back(cnt);
  }
  if (lines.size() % 2 == 0) {
    lines.push_back(0); // 1-0-1-0-1-...-0-1
  }
  int add = 2*K+1;
  int ans = 0;

  /// normal
  // 1-0-1... start from even number
  /*for (int i = 0; i < lines.size(); i+=2) {
    int tmp = 0;
    int left = i;
    int right = min(i + add, (int)lines.size());
    for (int j = left; j < right; j++) {
      tmp += lines[j];
    }
    ans = max(tmp, ans);
  }*/

  /// syakutori
  int left = 0, right = 0;
  int tmp = 0; // sum of [left, right)
  for (int i = 0; i < lines.size(); i+=2) {
    int next_left = i;
    int next_right = min(i+add, (int)lines.size());

    while (next_left > left) {
      tmp -= lines[left];
      left++;
    }
    while (next_right > right) {
      tmp += lines[right];
      right++;
    }
    ans = max(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>

int solve(int *arr, int n, int k)
{
	int dp[n+1][k+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=arr[i-1])
				dp[i][j]=dp[i][j] | (!dp[i][j-arr[i-1]]);
		}
	}
	return dp[n][k];
}
int solveagain(int *arr, int n, int k)
{
	int dp[k+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i<arr[j])
				continue;
			if(dp[i-arr[j]]==0)
				dp[i]=1;
		}
	}
	return dp[k];
}
int main()
{
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);


    ll n,x,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
	cin>>arr[i];
}
int ans=solveagain(arr,n,k);
if(ans)
	cout<<"First\n";
else
	cout<<"Second\n";

return 0;
}


Measured memory_bytes: 768
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n+1)

    def sum(self, i):  # sum in [0, i)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):  # i > 0
        assert i > 0
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N, Q = map(int, input().split())
c = list(map(int, input().split()))

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l-1, r-1, i])

lr.sort(key=lambda x: x[1])

rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]]+1, -1)
    rightest[c[i]] = i
    bit.add(i+1, 1)

    while current_q < Q and lr[current_q][1] == i:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1] + 1) - bit.sum(lr[current_q][0])
        current_q += 1

for i in range(Q):
    print(ans[i])


Measured memory_bytes: 239572