akhauriyash/Code-Regression huggingface dataset:
def max_heapify(A, i):
  l = 2 * i
  r = 2 * i + 1
  largest = i
  if l < len(A) and A[l] > A[i]:
    largest = l
  else:
    largest = i
  if r < len(A) and A[r] > A[largest]:
    largest = r
  if largest != i:
    tmp = A[i]
    A[i] = A[largest]
    A[largest] = tmp
    max_heapify(A, largest)

def build_maxheap(A):
  i = len(A) // 2
  while i >= 1:
    max_heapify(A, i)
    i -= 1

if __name__ == '__main__':
  num_of_data = int(input())
  A = [int(x) for x in input().split()]
  A.insert(0, 0)

  build_maxheap(A)
  A = A[1:]
  print(' {0}'.format(' '.join(map(str, A))))



Measured memory_bytes: 63964
#include<stdio.h>
int kumi(int x){
    if(x){
        return (x)+kumi(x-1);
    }else{
        return 0;
    }
}

int main(void){
	int n,m,ans1,ans2;
    scanf("%d%d",&n,&m);
    if(n){
        ans1=kumi(n-1);
    }else{
        ans1=kumi(n);
    }
    if(m){
        ans2=kumi(m-1);
    }else{
        ans2=kumi(m);
    }
    
    printf("%d",ans1+ans2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
int a , b , c , k ;
int ans = 0 ;
signed main () {
    cin >> a >> b >> c >> k ;
    if ( k > a ) ans += a , k -= a ;
    else ans += k , k = 0 ;
    if ( k > b ) k -= b ;
    else k = 0 ;
    ans -= k ;
    cout << ans << endl ;
    return 0 ;
}

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

int main() {
    string N;
    cin >> N;
    ll sum = 0;
    ll kazu = 0;

    for (ll i=0; i<N.size(); i++){
        kazu = N.at(i)-'0';
        sum += kazu;
    }

    if (sum % 9 == 0){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d) cout << "Left" << endl;
    else if(a+b < c+d) cout << "Right" << endl;
    else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,u,ans=0;
	scanf("%d%d%d",&n,&u,&m);
	ans+=u*2;
	m-=u;
	ans+=(n>m?m:n);
	if(m>n)
		ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int N_MAX = pow(10, 5);
int main (void) {
    int N;
    int A[N_MAX];

    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A, A + N);

    int ans = 0;
    int cnt = 1;
    for (int i = 0; i < N; i++) {
        if (A[i] == A[i + 1]) cnt++;
        else {
            ans += cnt % 2;
            cnt = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	string o, e; cin >> o >> e;
	char res[o.size() + e.size()];
	for (int i = 0; i < o.size(); i++)
	{
		res[2 * i] = o[i];
	}
	for (int i = 0; i < e.size(); i++)
	{
		res[2 * i + 1] = e[i];
	}

	for (int i = 0; i < o.size() + e.size(); i++)
	{
		cout << res[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
int a[maxn];
int n, m;
int f[maxn], cnt = 0;
bool cmp(int a, int b) {
	return (a % 2) > (b % 2);
}
int pl;
void push(int a) {
	if (pl + a - 1 >= n) a = n + 1 - pl;
	f[cnt++] = a, pl += a;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> a[i];
	sort(a, a + m, cmp);
	int ans = 0;
	for (int i = 0; i < m; i++)
		ans += a[i] % 2;
	if (n % 2 == 0 && ans > 2) cout << "Impossible" << endl;
	else if (n % 2 == 1 && ans > 1) cout << "Impossible" << endl;
	else {
		pl = 1;
		if (a[1] % 2) swap(a[1], a[m - 1]);
		for (int i = 0; i < m; i++) {
			if (a[i] % 2) {
				if (i == 0) 
					for (int j = 0; j < a[i] / 2 + 1; j++)
						push(2);
				else for (int j = 0; j < a[i] / 2; j++)
					push(2);
			}
			else {
				if (i == 0) push(1);
				push(a[i]);
			}
		}
		for (int i = 0; i < m; i++)
			cout << a[i] << ' ';
		cout << endl;
		cout << cnt << endl;
		for (int i = 0; i < cnt; i++)
			printf("%d ", f[i]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 512
#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;

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,a,b) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }

#define mod 1000000007
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71

//*********************************************///
const int N = 1e5 + 5;
int i,j;
ll a[N];
ll b[N];
ll c[N];
ll dp[N][3];


void solve()
{
  int n;
  cin>>n;
  freab(i,1,n)
    cin>>a[i]>>b[i]>>c[i];

  dp[1][0]=a[1];
  dp[1][1]=b[1];
  dp[1][2]=c[1];

  freab(i,2,n)
  {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
  }
  cout<<max3(dp[n][0],dp[n][1],dp[n][2])<<endl;
}

int main()
{
  fast;
  int z;
  //cin>>z;
  z=1;
  while(z--)
  {
    solve();
  }
  return 0;
}


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

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    x--;y--;
    vector<int> ans(n);
    vector<vector<int>> G(n);
    G[0].push_back(1);
    G[n-1].push_back(n-2);
    G[x].push_back(y);
    G[y].push_back(x);
    for(int i = 1;i<n-1;i++){
        G[i].push_back(i-1);
        G[i].push_back(i+1);
    } 
    rep(i,n){
        queue<int> que;
        que.push(i);
        vector<int> dist(n,-1);
        dist[i] = 0;
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(auto j : G[v]){
                if(dist[j]==-1){
                    dist[j] = dist[v] + 1;
                    ans[dist[j]]++;
                    que.push(j);
                }
            }
        }
    }
    rep(i,n-1){
        cout << ans[i+1]/2 << endl;
    }
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<char> S(N);
    queue<int> T;
    ll rkuro = 0;
    ll rshiro = 0;
    ll ans = LLONG_MAX;
    RANGE(i,N){
        char x;
        cin >> x;
        if(x == '.'){
            T.push(0);
            rshiro++;
        }
        else{
            T.push(1);
            rkuro++;
        }
    }

    ll lkuro = 0;
    ll lshiro = 0;
    while(!T.empty()){
        ans = min(ans, lkuro + rshiro);
        if(T.front() == 0){
            lshiro++;
            rshiro--;
        }else{
            lkuro++;
            rkuro--;
        }
        T.pop();
    }
    ans = min(ans, lkuro + rshiro);
    
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

vector<int> as;

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

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    reverse(as.begin(), as.end());

    int sa = 0;
    int sb = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            sa += as[i];
        } else {
            sb += as[i];
        }
    }

    cout << sa - sb << endl;

    return 0;
}


Measured memory_bytes: 3612
using System;
using static System.Console;
using static System.Math;


//重複を含まないようにする

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine().Split(' ');
            string[] Input;
            string ans = "NO";
            int count_5 = 0;
            int count_7 = 0;

            for (int i = 0; i < 3; i++)
            {
                if (int.Parse(s[i]) == 5)
                { count_5++; }
                else if (int.Parse(s[i]) == 7)
                { count_7++; }
            }
            if (count_5 == 2 && count_7 == 1)
            { ans = "YES"; }

            WriteLine(ans);
            Out.Flush();
        }

    }

    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1); }
    }
}

Measured memory_bytes: 13140
def f(i,k):#i桁目がnum未満
    if i == 0:
        return 0
    num = int(s[-i])
    if k == 0:
        if num ==0:return 0
        else: return 1
    if num==0:
        return 0
    return (num-1)* ncr(i-1,k-1)*9**(k-1)+ncr(i-1,k)*9**k


def g(i,k):#i桁目がnum
    if i == 0:
        if k==0:return 1
        else:return 0
    num = int(s[-i])
    if k == 0:
        if num ==0:return 1
        else:return 0

    if num==0:
        return f(i-1,k) +g(i-1,k)
    else:
        return f(i-1,k-1) + g(i-1,k-1)



def ncr(n,r):##　n>>r の場合のncr　O(r) r>nなら0
    x = 1
    y = 1
    for i in range(r):
        x*=(n-i)
        y*=(i+1)
    return x//y

s = input()
k = int(input())
l= len(s)
print(f(l,k)+g(l,k))


Measured memory_bytes: 3064
function Main(input) {
    input = input.split(" ");
    var ans = parseInt(input[0],10) + parseInt(input[1],10) + parseInt(input[2],10);
    if(ans >= 22){
        console.log("bust");
    }else{
        console.log("win")
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();

		int ans = 0;
		for (char c : s) {
			if (c == '+') {
				ans++;
			} else {
				ans--;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21716
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())
S = sum(map(int, [s for s in str(N)]))

if N % S == 0:
    print("Yes")
else:
    print("No")

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

int main() {
	int w,h;cin>>w>>h;
	vector<long long> p(w),q(h);
	for(int i=0;i<w;i++)cin>>p[i];
	for(int i=0;i<h;i++)cin>>q[i];
	sort(p.begin(),p.end());
	sort(q.begin(),q.end());
	int pi=0;
	int qi=0;
	long long ans=0;
	while(1){
		if(pi==w){
			if(qi==h){
				break;
			}
		}
		if(pi==w){
			ans+=q[qi];
			qi++;
		}else if(qi==h){
			ans+=p[pi];
			pi++;
		}else if(p[pi]<q[qi]){
			ans+=(h+1-qi)*p[pi];
			pi++;
		}else{
			ans+=(w+1-pi)*q[qi];
			qi++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N, K;
    cin >> N >> K;
    VLL A(N);
    rep(i,N){
        cin >> A[i];
    }
    bool judge=true;
    /*
    if(K==1){
        for(int i=K; i<N; i++){
            if(A[i]<=A[i-1]) cout << "No" << endl;
            else cout << "Yes" << endl;
        }
        return 0;
    }
    */
    for(int i=K; i<N; i++){
        ll first=A[i-1-(K-1)];
        ll second=A[i];
        //cout << first << " " << second << endl;
        if(second<=first) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 4780
n=int(input())
s=list(input())
cnt=s[1:].count("E")
e_cnt=[0]*(n+1)
w_cnt=[0]*(n+1)
e_cnt[0]=cnt
for i in range(n):
    w_cnt[i+1]=w_cnt[i]+(s[i]=="W")
for i in range(1,n):
    e_cnt[i]=e_cnt[i-1]-(s[i]=="E")
ans=float("inf")
for i in range(n):
    ans=min(ans,w_cnt[i]+e_cnt[i])
print(ans)

Measured memory_bytes: 29328
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int maxInt = 2147483647;
const int mx=3005;
char s[3005],t[3005];
int dp[3005][3005];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //1-3000-lowercase
    cin >> s+1 >> t+1 ;
    int n=0,m=0;
    while(s[n+1])n++;
    while(t[m+1])m++;
    for(int i=1;i<=n;++i){
    	for(int j=1;j<=m;++j){
    		if(s[i]==t[j])dp[i][j]=dp[i-1][j-1]+1;
    		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    	}
    }
    int i=n,j=m;
    string r;
    while(i && j){
    	if(s[i]==t[j]){
    		r+=s[i];
    		i--;j--;
    	}
    	else if(dp[i-1][j] < dp[i][j-1])j--;
    	else i--;
    }
reverse(r.begin(),r.end());
cout << r << endl;
    return 0;
}






















Measured memory_bytes: 35456
function main(input) {
  var age = Number(input.split(' ')[0]);
  var price = Number(input.split(' ')[1]);
  if (age <= 5) {
    console.log(0);
  } else if (age <= 12) {
    console.log(price / 2);
  } else {
    console.log(price);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<stdio.h>
#define min(a,b) ((a)<(b)?(a):(b))

int main(void){
    int d[5];
    register int i;
    for(i = 0;i < 5;i++)scanf("%d",&d[i]);
    int minonedig = 10;
    for(i = 0;i < 5;i++)if(d[i] % 10)minonedig = min(minonedig,d[i] % 10);
    int ans = 0;
    for(i = 0;i < 5;i++)ans += ((d[i] + 9) / 10) * 10;
    ans -= 10 - minonedig;
    printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,s=0,l,t;
    vector<int>a;
    vector<int>b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t;
        a.push_back(t);
    }
    b=a;
    sort(a.begin(),a.end());
    l=a.size();
    for(int i=0;i<l;i++){
        if(a[i]!=b[i]){
            s++;
        }
    }
    if(s==0||s==2){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int d = sc.nextInt();
			int x = 0;
			for(int i = d; i < 600; i += d){
				x += (i*i);
			}
			x = x * d;
			System.out.println(x);
		}
	}
}

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

using namespace std;

int main(void)
{
    int N;
    string str;

    cin >> N;
    cin >> str;

    int min = N;
    int cnt = 0;
    for(int i = 1; i < N; i++){
        if(str[i] == 'E'){
            cnt++;
        }
    }
    if(min > cnt){
        min = cnt;
    }
    for(int i = 1; i < N; i++){
        if(str[i] == 'E'){
            cnt--;
        }
        if(str[i-1] == 'W'){
            cnt++;
        }
        if(cnt < min){
            min = cnt;
        }
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <cmath>
using namespace std;
int a[100005];
int main(int argc, char** argv) {
	int n;
	cin >> n;
	int cnt=0;
	long long ans=0;
	int mn=2e9;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		cnt^=(a[i]<0);
		ans+=abs(a[i]);
		mn=min(mn,abs(a[i]));
	}
	cout << ans-cnt*2*mn;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int main()
{
    int n;
    cin >> n;
    cout << (n + 1 )/ 2 << endl;
    return 0;
}

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

namespace C_ABC126
{
    class MainClass
    {

        static int[] s;


        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);

            double ans = 0;
            double tmp = 0;
            double obj = 0;
            for(int i = 1;i<=s[0];i++){
                if(i>=s[1]){
                    ans +=s[0]-i+1;
                    break;
                }else{
                    obj =(double)(s[1]/(double)i);
                    tmp = Ceiling(Log(obj,2));
                    //WriteLine(Pow(2,-tmp));
                    //WriteLine("obj,tmp {0} {1}",obj,tmp);
                    ans+=Pow(2,-tmp);
                }
            }
            ans /=(double)s[0];
            WriteLine(ans);


        }
    }
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[] a = new long[n + 1];
            for (int i = 0; i < n; i++) a[i + 1] = x[i];
            long[] min = new long[n + 1]; long[] max = new long[n + 1];
            min[n] = 2; max[n] = 2;
            if (a[n] == 2)
            {
                bool flag = true;
                for (long i = n; i > 0; i--)
                {
                    if ((min[i] - 1) / a[i] == max[i] / a[i]) flag = false;
                    min[i - 1] = ((min[i] - 1) / a[i] + 1) * a[i];
                    max[i - 1] = (max[i] / a[i] + 1) * a[i] - 1;
                }
                Console.WriteLine(flag ? min[0] + " " + max[0] : "-1");
            }
            else
            {
                Console.WriteLine(-1);
            }
        }
    }
}

Measured memory_bytes: 27996
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
        self.l = size

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            self.l -= 1

            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    n,m,q = LI()
    aa = [LI() for _ in range(q)]
    uf = UnionFind(n)
    t = 0
    cc = 0
    for a,b,c in aa:
        if c == 0:
            if uf.union(a,b):
                t += 1
        else:
            cc += 1

    for a,b,c in aa:
        if c == 0:
            continue
        if uf.find(a) == uf.find(b):
            return 'No'

    if m == n - 1:
        if cc == 0:
            return 'Yes'
        return 'No'

    if m <= n - uf.l + uf.l * (uf.l-1) // 2:
        return 'Yes'

    return 'No'


print(main())



Measured memory_bytes: 31000
#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;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  int ans=0;
  int count  = 1;
  rep(i,N){
    if(count == a[i]){
      count++;
    }else{
      ans++;
    }
  }
  if(ans == N){
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
INF = 10**20

A,B,Q = map(int,input().split())
s = [-INF]+[int(input()) for _ in range(A)]+[INF]
t = [-INF]+[int(input()) for _ in range(B)]+[INF]

for i in range(Q):
    q = int(input())
    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)

Measured memory_bytes: 23444
#include<iostream> 
using namespace std;
string s;
int l;
int main(){
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++){
        if(s[i]=='C'){
            for(int j=i+1;j<l;j++){
                if(s[j]=='F'){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
k, n = (int(x) for x in input().split())
seq = sorted((int(x) for x in input().split()))
ans = float('inf')
for i in range(n):
    if seq[i] > seq[i-1]:
        d =  k - (seq[i] - seq[i-1])
    else:
        d = seq[i-1] - seq[i]
    ans = min(ans, d)
print(ans)
# print(min(seq[-1] - seq[0], k-seq[-1] + seq[-2]))


Measured memory_bytes: 76028
N, M, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())

x_max = max(x)
y_min = min(y)

is_war = True

for z in range(X+1, Y+1):
    if x_max < z and z <= y_min:
        is_war = False
if is_war:
    print("War")
else:
    print("No War")


Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
  int n;
  bool r = false;
  scanf( "%d", &n );
  while( n --> 0 ){
    int a;
  	scanf( "%d", &a);
	if( a % 2 ){ printf("first\n"); return 0;}
  }
  printf("second\n" );
}


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

int main() {
  ll N,K;
  cin >>N >> K;
  vector<pair<ll,ll>> p(N);
  for(int i= 0;i<N;i++){
    cin >> p[i].first;
    cin >> p[i].second;
  }
  sort(p.begin(),p.end());
  ll ans = 0;
  for(int i= 0;i<N;i++){
   K= K-p[i].second;
   if(K<=0){
     ans = p[i].first;
     break;
   }
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool ans=true;
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	rep(i,n){
		if(v[i]%2==0){
			if(!(v[i]%3==0||v[i]%5==0))ans=false;
		}
	}
	cout<<(ans?"APPROVED":"DENIED")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

ll a[1010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n, m; string s="", t="";
    cin >> n;
    REP(i, n){
        string tm; cin >> tm;
        s+=tm;
    }
    cin >> m;
    REP(i, m){
        string tm; cin >> tm;
        t+=tm;
    }
    if(s<t) cout << 1 << endl;
    else cout << 0 << endl;
	return 0;
}


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

int main(){
  int N,count=0;
  cin >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  for(int i=1;i<N-1;i++){
    if(P.at(i)!=max({P.at(i-1),P.at(i),P.at(i+1)})
       && P.at(i)!=min({P.at(i-1),P.at(i),P.at(i+1)})){
      count++;
    }
  }
  cout << count << endl;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    vector<int> dp(n,1e9+1e5);
    dp[0]=0;
    for(int i=1;i<n;i++){
        if(i-k<0){
            for(int j=0;j<i;j++){
                dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
            }
        }else{
            for(int j=1;j<=k;j++){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
            }
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4052
import java.util.Scanner;

public class Main {

    private static long rec(int n, long x) {
        if (n == 0) {
            return 1;
        }
        long len = (long) Math.pow(2, n + 1) - 3;
        long num = (long) Math.pow(2, n) - 1;
        if (x == 1) {
            return 0;
        }
        if (x <= len + 1) {
            return rec(n - 1, x - 1);
        }
        if (x <= len + 2) {
            return num + 1;
        }
        if (x <= (len + 1) * 2) {
            return num + 1 + rec(n - 1, x - len - 2);
        }
        return num * 2 + 1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();
        System.out.println(rec(n, x));
    }
}



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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i].first;
        nums[i].second = i;
    }
    sort(nums.begin(), nums.end());
    int mx = 1;
    int index = 0;
    while (index < n) {
        int cnt = 1;
        while (index + 1 < n && nums[index+1].second - nums[index].second > 0) {
            cnt++;
            index++;
        }
        index++;
        mx = max(mx, cnt);
    }
    cout << n - mx << "\n";
    return 0;
}


Measured memory_bytes: 1792
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, X, Y = il()

    k = {n:0 for n in range(N-1)}
    X -= 1
    Y -= 1
    for i in range(N-1):
        for j in range(i+1, N):
            m = min(abs(i-j), abs(X-i) + abs(Y-j) + 1, abs(X-j) + abs(Y-i) + 1)
            k[m-1] += 1

    for i in range(len(k)):
        print(k[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+7;
int n,x,y,lx,ly,t,lt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>t>>x>>y;
		int cnt=abs(x-lx)+abs(y-ly);
		if(t-lt<cnt||(t-lt)%2!=cnt%2){
			cout<<"No";
			return 0;
		}
		lx=x,ly=y,lt=t;
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 3000

using namespace std;

int dp[MAX + 5][MAX + 5];
char sol[MAX + 5];

int main()
{
    string a, b;

    cin >> a >> b;

    int n = a.length();
    int m = b.length();

    for(int i = n; i > 0; i--)
        a[i] = a[i - 1];
    for(int i = m; i > 0; i--)
        b[i] = b[i - 1];

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(a[i] == b[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

    int i = n;
    int j = m;
    int cnt = 0;

    while(i > 0 && j > 0)
    {
        if(a[i] == b[j])
        {
            cnt++;
            sol[cnt] = a[i];

            i--;
            j--;
        }
        else if(dp[i][j] == dp[i - 1][j])i--;
        else j--;
    }

    for(int i = cnt; i >= 1; i--)
        cout << sol[i];

    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    map<ll,ll> mp;
    ll ans=0;
    mp[0]=1;
    ll s=0;
    for(int i=0;i<n;i++){
        s+=a[i];
        if(mp.count(s))ans+=mp[s];
        mp[s]++;
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 14336
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,m,col[SZ]; Edg
bool dfs(int x)
{
	bool ok=1;
	for esb(x,e,b)
	{
		if(col[b]==-1) col[b]=!col[x],ok&=dfs(b);
		else if(col[b]==col[x]) ok=0;
	}
	return ok;
}
int main()
{
	memset(col,-1,sizeof col);
	scanf("%d%d",&n,&m);
	for(int i=1,a,b;i<=m;++i)
		scanf("%d%d",&a,&b),adde(a,b);
	ll sg=0,pa=0,pb=0;
	for(int i=1;i<=n;++i)
		if(col[i]==-1)
		{
			col[i]=0;
			if(!fst[i]) ++sg;
			else if(dfs(i)) ++pa;
			else ++pb;
		}
	ll ans=sg*sg+2*sg*(n-sg)+(pa+pb)*(pa+pb)+pa*pa;
	printf("%lld\n",ans);
}


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

using namespace std;

using DVector = vector<double>;

double Average(DVector& vec) {
   double sumVal{0};
   for (auto element : vec) {
      sumVal += element;
   }
   return sumVal / vec.size();
}

double Variance(DVector& vec) {
   double sumVal{0}, average{Average(vec)};
   for (auto element : vec) {
      sumVal += pow(average - element, 2);
   }
   return sumVal / vec.size();
}

double StdDev(DVector& vec) {
   return sqrt(Variance(vec));
}

int main() {

   int n{};

   while (cin >> n, n > 0) {
      
      DVector s(n, 0);
      
      while (n--) {
         cin >> s[n];
      }
      
      cout << fixed << StdDev(s) << endl;
   }

   return 0;

}

Measured memory_bytes: 3208
from sys import stdin

def main():
     n = int(stdin.readline())
     a = [[ x for x in stdin.readline().split()] for i in range(n)]
     b = [ i for i in a]
     a.sort(key=lambda x:100-int(x[1]))
     a.sort(key=lambda x:x[0])
     for i in a:
          for j in range(n):
               if i == b[j]:
                    print(j+1)
                    break
if __name__ == '__main__':
     main()

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

ll f(ll n)
{
	ll ans = 0, den = 10;
	while (n / den) {
		ans += (n / den);
		den *= 5;
	}
	return ans;
}

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

	ll n;
	cin >> n;

	if (n & 1) {
		cout << 0 << '\n';
		return 0;
	}

	cout << f(n) << '\n';
}


Measured memory_bytes: 256
def main():
    import sys
    from heapq import heappop, heappush, heappushpop
    input = sys.stdin.readline

    Q = int(input())
    R = [10**9+1]
    L = [10**9+1]
    Rsum = 0
    Lsum = 0
    NL = 0
    NR = 0
    B = 0
    for _ in range(Q):
        query = input().rstrip('\n')
        if query == '2':
            Lmax = -L[0]
            print(Lmax, Lmax * NL - Lsum + Rsum - Lmax * NR + B)
        else:
            _, a, b = query.split()
            a = int(a)
            b = int(b)
            B += b
            if NL != NR:
                Lmax = -L[0]
                Rmin = R[0]
                if a >= Lmax:
                    heappush(R, a)
                    Rsum += a
                    NR += 1
                else:
                    newR = -heappushpop(L, -a)
                    heappush(R, newR)
                    Rsum += newR
                    Lsum += a - newR
                    NR += 1
                    Lmax = -L[0]
            else:
                Rmin = R[0]
                if a <= Rmin:
                    heappush(L, -a)
                    Lsum += a
                    NL += 1
                else:
                    newL = heappushpop(R, a)
                    heappush(L, -newL)
                    Lsum += newL
                    Rsum += a - newL
                    NL += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 70104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
    string s;cin>>s;
	if(s=="RRR") cout<<3<<endl;
	else if(s=="RRS"||s=="SRR") cout<<2<<endl;
	else if(s=="SRS") cout<<1<<endl;
	else {
		if(s[0]=='R'||s[2]=='R')
			cout<<1<<endl;
		else cout<<0<<endl;
	}
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  cout << "ABC" << s << endl;
}


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

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

Measured memory_bytes: 1156
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
string s;
vector<string> v;
int main() {
    abdelrahman010
    cin >> s;
    string tmp = "";
    for(int i = 0;i < s.size();i++) {
        tmp += s[i];
        if(v.empty() || tmp != v.back()) {
            v.push_back(tmp);
            tmp = "";
        }
    }
    cout << v.size();
    return 0;
}

Measured memory_bytes: 11016
#include <iostream>
using namespace std;
long long ANUM[100001];
int main(){
    int N;
    long long K;
    cin >>N >>K;
    for(int i=0; i < N; i++){
        int a,b;
        cin >>a >>b;
        ANUM[a]+=b;
    }
    
    for(int i=1;i<=100000;i++){
        if(K<=ANUM[i]){
            cout<<i<<endl;
            break;
        }
        K -= ANUM[i];
    }
    return 0;
}

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

int main(){
	ll a,b,c; cin >> a >> b >> c;
	if(a+b > c)cout << "No" << endl;
	else if((c - a - b)*(c - a - b) > 4 * a * b)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last, cnt, a[2][100000];
struct Edge { LL to,cost; };
vector<Edge>vec[100000];
string str;
bool f=0;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, 2)rep(j, n) {
		cin >> a[i][j+1];
			a[i][j+1] += a[i][j];
	}
	rep(i,n) {
		ans=max(ans,a[0][i+1] + a[1][n] - a[1][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        String ans = "No";
        if(n.charAt(0) == '9' || n.charAt(1) == '9') ans = "Yes";
        System.out.println(ans);
    }
}

Measured memory_bytes: 25300
#include<iostream>

using namespace std;

int main() {
	int n, x,m[1000],min,i;

	cin >> n >> x;
	cin >> m[0];
	x -= m[0];
	min = m[0];

	for (i = 1; i < n; i++) {
		cin >> m[i];
		x -= m[i];
		if (min > m[i]) 
			min = m[i];
	}
	i = 0;

	i = x / min;

	cout << n + i;

	return 0;
}

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

class repete{
public:
  void print(int x,int i){
    cout << "Case " << i << ": " << x << "\n";
  }
};


int main(){
  int i=0;
  int x;
  repete rep;
  while(1){
    cin >> x;
    if(x == 0)break;
    else {
      i++;
      rep.print(x,i);
    }
  }
}



Measured memory_bytes: 3056
MOD = 10**9+7
n = int(input())

dp = [1,0,0]
for i in range(64,-1,-1):
    ndp = [0,0,0]
    for d in range(3):
        nd = d*2 + (n>>i&1)
        ndp[min(2,nd)] += dp[d] # 0,0
        if nd >= 1: ndp[min(2,nd-1)] += dp[d] # 0,1
        if nd >= 2: ndp[min(2,nd-2)] += dp[d] # 1,1
    dp = ndp
    
print(sum(dp) % MOD)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(d==1){cout<<1<<endl;}
  else{cout<<0<<endl;}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		string S;
		cin >> S;

		if( S.back() == 's' ) { S += 'e'; }
		cout << S << 's' << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int sum = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 384
w,h,n = map(int,input().split())
x,y,a = [0]*n,[0]*n,[0]*n

for i in range(n):
    x[i],y[i],a[i] = map(int,input().split())

ls = [0,w,0,h]
for i in range(n):
    if a[i]==1:
        ls[0] = max(ls[0],x[i])
    if a[i]==2:
        ls[1] = min(ls[1],x[i]) 
    if a[i]==3:
        ls[2] = max(ls[2],y[i])
    if a[i]==4:
        ls[3] = min(ls[3],y[i])

s  =max((ls[1]-ls[0]),0)*max((ls[3]-ls[2]),0)
print(int(s))

Measured memory_bytes: 38384
N = int(input())
lis = list(map(int, input().split()))
l1 = []
l2 = []
for i in range(100001):
    l1.append([0, i])
    l2.append([0, i])

for i in range(N):
    if i % 2:
        l1[lis[i]][0] += 1
    else:
        l2[lis[i]][0] += 1


l1 = sorted(l1, key=lambda x: x[0], reverse=True)
l2 = sorted(l2, key=lambda x: x[0], reverse=True)

if l1[0][1] != l2[0][1]:
    print(int(N / 2 - l1[0][0] + N / 2 - l2[0][0]))
else:
    print(int(min(N / 2 - l1[0][0] + N / 2 - l2[1][0], N / 2 - l1[1][0] + N / 2 - l2[0][0])))


Measured memory_bytes: 33204
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int sum=0;
  long long int arr[n];
  long long int main=0;
  long long int mod=1000000007;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
  for(int i=0;i<n;i++)
  {
    sum=sum-arr[i];
    main+=(arr[i]%mod*(sum%mod))%mod;
  }
  cout<<main%mod<<endl;
}

Measured memory_bytes: 5160