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

int main() {
  int a[3];
  for(int i = 0; i < 3; i++) cin >> a[i];

  sort(a, a+3);
  reverse(a, a+3);
  cout << 10*a[0] + a[1] + a[2];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR for(int k = 0; k < si2; k++)
#define M(a) ('0'<=a&&a<='9')?(a-'0'+1)%10+'0':a
#define P(a) ('0'<=a&&a<='9')?(a-'0'-1+10)%10+'0':a

int main(){
	int n, si, si2;
	string str, str2, temp;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>str>>str2;
		si = str.size(); si2 = str2.size();
		for(int j = si-1; j >= 0; j--, str2 = temp){
			temp.clear();
			switch(str[j]){
				case 'C':FOR temp += str2[(k+1)%si2];			break;
				case 'J':FOR temp += str2[(k-1+si2)%si2];		break;
				case 'E':if(si2%2){str2+=str2[si2/2]; 
						 FOR temp += str2[(k+(si2+1)/2)%(si2+1)];}
						 else FOR temp += str2[(k+si2/2)%si2];	break;
				case 'A':FOR temp += str2[si2-k-1];break;
				case 'M':FOR temp += M(str2[k]);				break;
				case 'P':FOR temp += P(str2[k]);				break;
			}
		}
		cout<<str2<<endl;
	}
	return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long modpow(long long x,long long y){
    if(y==1)return x%mod;
    else if(y%2) return (x*modpow(x,y-1))%mod;
    long long t=modpow(x,y/2);
    return t*t%mod;
}
int main(){
    long long m,n;scanf("%lld %lld",&m,&n);
    printf("%lld\n",modpow(m,n));
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

	vector<int> A(n);
	for (int i = 0; i <n; ++i)
		cin >> A[i];
	ll ans = 1000, tmp = 0;
	for (int i = 0; i < n-1; ++i)
	{
		tmp = 0;
		if (A[i] < A[i+1])
			tmp = ans / A[i];
		ans += (A[i+1] - A[i]) * tmp;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3620
#include "bits//stdc++.h"
using namespace std;

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	int black = 0;
	long long ans = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'W') {
			ans += black;
		} else {
			black += 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication20
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            double a = double.Parse(str[0]);
            double b = double.Parse(str[1]);
            int C = int.Parse(str[2]);

            double h;
            double S;
            double L;

            //??¢???
            S = a * b * Math.Sin(C * Math.PI / 180) / 2;

            //??????
            h = S * 2 / a;

            //????§???¢?????¨????±???????
            double bx = b * Math.Cos(C * Math.PI / 180);
            double c = Math.Sqrt((a - bx) * (a - bx) + (h * h));
            L = c + a + b;

            Console.WriteLine(S);
            Console.WriteLine(L);
            Console.WriteLine(h);
        }
    }
}

Measured memory_bytes: 5744
let () = 
        Scanf.scanf "%s\n" (
                fun s -> 
                        Scanf.scanf "%s" (
                                fun t -> 
                                        let sub = String.sub t 0 (String.length s) in
                                                if s = sub then
                                                        "Yes"
                                                else
                                                        "No"
                        )
        ) |> Printf.printf "%s\n"

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

int main(){

   
    long long int sum=0;
    
    vector<string> a;
    int num;
        for (int i = 0; isdigit(num = getchar()); i++)
        {
            
            /* code */
            a.push_back(to_string(num-48));
        }
        int l = a.size();
       

    for (int tmp = 0; tmp < (1 << l ); tmp++){
        vector<string> b=a;
        bitset<10> s(tmp);
        int k=1;
        
        for (int i = 1; i < l; i++)
        {
            
            /* code */
            if (s.test(i)==s.test(i-1)){
                b[k-1]+=b[k];
                
                b.erase(b.begin() + k);
                k--;/*cout<<k<<" "<<b[k]<<endl;*/
                


            }k++;
        } int j = b.size();
        for (int i = 0; i < j; i++)sum+=atol((b[i]).c_str());
        
        
        
        
    }cout<<sum/2<<endl;
}

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

int main(){
	int i, j, k, l, h[10000], w[10000];
	char chess1[300], chess2[300];
	
	for(i = 0; i <= 9999; i++){
		cin >> h[i] >> w[i];
		if((h[i] == 0) and (w[i] == 0)){
			break;
		}
	}
	
	for(j = 0; j <= i-1; j++){
		for(k = 0; k <= w[j]-1; k += 2){
		 	chess1[k] = '#';
		 	if((w[j]-k == 1) and (w[j]%2 == 0)){
		 		break;
		 	}
		 	chess1[k+1] = '.';
		}
		for(k = 0; k <= w[j]-1; k++){
			switch(chess1[k]){
				case '#':
					chess2[k] = '.';
					break;
				case '.':
					chess2[k] = '#';
					break;
			}
		}
		for(k = 0; 2*k <= h[j]-1; k++){
		 	for(l = 0; l <= w[j]-1; l++){
		 		cout << chess1[l];
		 	}
		 	cout << endl;
		 	if(h[j]-2*k == 1){
		 		break;
		 	}
		 	for(l = 0; l <= w[j]-1; l++){
		 		cout << chess2[l];
		 	}
		 	cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

int count(const string &S){
  int res = 0;
  for(int i = 0; i + 1 < S.size(); i++){
    if(S[i] == 'A' && S[i+1] == 'B') res++;
  }
  return res;
}

int N;
vector<string> S;

long long solve(){
  long long res = 0;
  for(int i = 0; i < N; i++) res += count(S[i]);

  int a = 0, b = 0, c = 0;
  for(int i = 0; i < N; i++){
    if(S[i][0] == 'B' && S[i][S[i].size()-1] == 'A')a++;
    else if(S[i][S[i].size()-1] == 'A')b++;
    else if(S[i][0] == 'B')c++;
  // cout << S[i] << " ";
  // cout << a << " ";
  // cout << b << " ";
  // cout << c << endl;
  }



  long long add = 0;
  if(b + c == 0) add = max(0,a - 1);
  else add = a + min(b,c);
  //cout << res << endl;
  //cout << add << endl;
  res += add;
  
  return res;
}

int main(){
  cin >> N; S.resize(N);
  for(int i = 0; i < N; i++) cin >> S[i];
  cout << solve() << endl;

}






Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main () {
    int n;
    int r = 1;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i < s.size() ; i++){
        if (s[i] != s[i-1]) {
            r += 1;
        }        
    }
    cout << r << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
         
    using namespace std;
                 
    #define pb push_back
    #define ll long long
    #define mp make_pair
    #define MOD 1000000007
    #define MAX 100000000
    #define MIN -1000000000
    #define LLINF 0x3f3f3f3f3f3f    
    #define INF 0x3f3f3f3f
    #define MAXN  102
    #define MAXW 100100

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n, w;
        cin >> n >> w;
        vector<int> p(n + 1);
        vector<int> v(n + 1);
        for(int i = 1; i <= n; ++i){    
            cin >> p[i] >> v[i];
        }
        vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));
        for(int i = 0; i <= w; ++i){    
            dp[0][i] = 0;
        }
        for(int i = 0; i <= n; ++i){    
            dp[i][0] = 0;
        }
        for(int i = 1; i <= n; ++i){    
            for(int j = 1; j <= w; ++j){    
                if(j - p[i] >= 0){  
                    dp[i][j] = max(dp[i - 1][j], dp[i-1][j - p[i]] + v[i]);
                }else{  
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        cout << dp[n][w] << endl;
        return 0;
    }

Measured memory_bytes: 83172
N,x=map(int,input().split())
a=list(map(int,input().split()))
a_sort=sorted(a,reverse=False)
tot=0
if sum(a)==x:
    print(len(a))
elif sum(a)<x:
    print(len(a)-1)
else:
    for i in range(N):
        tot+=a_sort[i]
        if tot==x:
            print(i+1)
            break
        elif tot<x:
            pass
        elif tot>x:
            print(i)
            break

Measured memory_bytes: 9196
#include <stdio.h>
int main(){
  int i,a[5]={},sum=0,min;
  for(i=0;i<5;i++){
    scanf("%d",a+i);
  }
  if(a[0]%10==0){
    sum+=a[0];
  }else{
    sum+=(a[0]/10+1)*10;
  }
  min=a[0]%10;
  for(i=1;i<5;i++){
    if(a[i]%10==0){
      sum+=a[i];
    }else{
      sum+=(a[i]/10+1)*10;
      if(a[i]%10<min){
        min=a[i]%10;
      }
    }
  }
  sum=sum-10+min;
  if(min==0){
    sum+=10;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[]c = sc.next().toCharArray();
		Set<Character>charset =new TreeSet<Character>();
		char[]alp = new char[] {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		for (int i = 0; i < c.length; i++) {
			charset.add(c[i]);
		}
		if (charset.size() ==alp.length) {
			System.out.println("None");
		}else {
			for (int i = 0; i < alp.length; i++) {
				if (!charset.contains(alp[i])) {
					System.out.println(alp[i]);
					break;
				}
			}
		}
	}
}




Measured memory_bytes: 39984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//二分探索
//main関数で呼び出す前に，l, rの一方が条件を満たし他方が満たさないことを確認すること
//配列を引数にするときは原則として参照渡しすること
long long bs(long long l, long long r, ll d, vector<vll> &v, ll i) {
	if (l + 1 == r) {
		if (v[l][0] - v[i][0] > 2 * d) return l;
		else return r;
	}

	long long mid = (l + r) / 2;
	if (v[mid][0] - v[i][0] > 2 * d) return bs(l, mid, d, v, i);
	else return bs(mid, r, d, v, i);
}

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

	ll n, d, a;
	cin >> n >> d >> a;
	vector<vll> v(n, vll(2));
	for (ll i = 0; i < n; i++) cin >> v[i][0] >> v[i][1];
	sort(all(v));

	ll ans = 0;
	vll imos(n, 0);
	for (ll i = 0; i < n; i++) {
		if (i > 0) imos[i] += imos[i - 1];
		if (v[i][1] <= imos[i]) continue;
		ll x = ceil((double)(v[i][1] - imos[i]) / a);
		ans += x;
		imos[i] += a * x;
		if (v[n - 1][0] - v[i][0] <= 2 * d) continue;
		ll y = bs(i, n - 1, d, v, i);
		imos[y] -= a * x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7
#define INF (int) 2e9

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n){
        cin >> a[i];
    }
    int maxl[n], maxr[n];
    maxl[0] = 0;
    maxr[n-1] = 0;
    
    for (int i = 1; i < n; i++){
        maxl[i] = max(maxl[i-1], a[i-1]);
    }
    for (int i = n-2; i >= 0; i--)
    {
        maxr[i] = max(maxr[i+1], a[i+1]);
    }

    rep(i, n){
        cout << max(maxl[i], maxr[i]) << endl;
    }

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

Measured memory_bytes: 3968
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		int Q = reader.nextInt();
		ArrayList<Integer>[] child = new ArrayList[N];
		for(int i=0; i<N; i++) {
		    child[i] = new ArrayList<Integer>();
		}
		
		for (int i=0; i<N-1; i++) {
	    	int a = reader.nextInt()-1;
	    	int b = reader.nextInt()-1;
	    	child[a].add(b);
		}

		long[] cnt = new long[N];
		for (int i=0; i<Q; i++) {
		    int p = reader.nextInt()-1;
		    int q = reader.nextInt();
		    cnt[p] += q;
		}
		
		for (int i=0; i<N; i++) {
		    int l = child[i].size();
		    for (int j=0; j<l; j++) {
		        cnt[child[i].get(j)] += cnt[i];
		    }
		}

		for(int i=0; i<N; i++) {
		    System.out.print(cnt[i]);
		    if (i != N-1) System.out.print(" ");
		}
		System.out.println();
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


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

using namespace std;

typedef long long ll;

string s1, s2;
ll a[100005], b[100005];
ll q;

int main()
{
    cin>>s1>>s2>>q;
    s1 = ' ' + s1, s2 = ' ' + s2;
    for(ll i = 1; i < s1.size(); i++)
    {
        a[i] = a[i - 1];
        if(s1[i] == 'A') a[i]++;
        else a[i] += 2;
    }
    for(ll i = 1; i < s2.size(); i++)
    {
        b[i] = b[i - 1];
        if(s2[i] == 'A') b[i]++;
        else b[i] += 2;
    }
    while(q--)
    {
        ll t1, t2, t3, t4;
        scanf("%lld%lld%lld%lld", &t1, &t2, &t3, &t4);
        t1--, t3--;
        if((a[t2] - a[t1]) % 3 == (b[t4] - b[t3]) % 3) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 2560
s = [input() for i in range(3)]
order = {'a': 0, 'b': 1, 'c': 2}
who = 'a'
while True:
    target = s[order[who]]
    if len(target) == 0: break
    next = target[0]
    s[order[who]] = s[order[who]][1:]
    who = next
print(who.upper())

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

long long f(long long lim, long long i) {
	long long v = 1LL << i, v2 = 1LL << (i+1), res;
	res = lim / v2 * v;
	long long tmp = lim % v2;
	if (tmp >= v)
		res += tmp - v + 1;

	// cout << lim << " i:" << i << " v:" << v << " v2:" << v2 << " res:" << res<<endl;
	return res;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long a, b, i = 0, ans = 0;
	cin >> a >> b;

	if (a < 1)
		a = 1;

	while (b >= (1LL << i)) {
		long long num = f(b, i) - f(a-1, i);
		if (num & 1)
			ans |= (1LL << i);
		++i;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ones=0;cin>>n;
  string s;cin>>s;
  lvector d,REM(n,0),rem(n,0);
  rep(i,n) {
    d.emplace_back(s[i]-'0');
    if(d.back()==1) ones++;
  }
  ll m1=ones+1,m2=max(1ll,ones-1ll);
  REM[0]=1%m1,rem[0]=1%m2;
  for(ll i=1;i<n;++i) {
    REM[i]=(2*REM[i-1])%m1;
    rem[i]=(2*rem[i-1])%m2;
  }
  reverse(ALL(REM));reverse(ALL(rem));
  ll R=0,r=0,p,div,ans;
  rep(i,n) if(d[i]==1) {R+=REM[i];r+=rem[i];}
  rep(i,n) {
    ans=1;
    if(d[i]==1) {
      p=r-rem[i];p%=m2;
      if(ones==1) ans=0;
    }
    else {p=R+REM[i];p%=m1;}
    div=__builtin_popcount(p);
    while(p>0) {
      p%=div;
      div=__builtin_popcount(p);
      ans++;
    }
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 8636
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int L, N;
    cin >> L >> N;
    vll XX(N + 1), YY(N + 1), X(N), Y(N);
    rep(i, N) {
        cin >> X[i];
        Y[i] = L - X[i];
        XX[i + 1] = XX[i] + X[i];
        YY[i + 1] = YY[i] + Y[i];
    }

    ll ans = min(X[N-1], Y[0]);
    for (int m = 1; m < N; ++m) {
        int n = min(m, N - m);
        ll z = ((XX[m] - XX[m - n]) + (YY[m + n] - YY[m])) * 2;
        ll w = z - min(X[m - 1], Y[m]);
        smax(ans, w);
        if (m > N - m) {
            w = z + X[m - n - 1] * 2 - X[m - 1];
        } else if (N - m > m) {
            w = z + Y[m + n] * 2 - Y[m];
        }
        smax(ans, w);
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

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

int main(){
  string s,t;
  cin>>s>>t;
  ll n = s.length();
  ll m = t.length();
  ll dp[n+1][m+1];
  for(ll i=0; i<=n; i++){
    for(ll j=0; j<=m; j++){
      if(i==0 || j == 0){
        dp[i][j] =0;
      }
      else if(s[i-1] == t[j-1]){
        dp[i][j] = 1 + dp[i-1][j-1];
      }
      else{
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  ll lenlcs = dp[n][m];
  string lcs = "";
    ll i=n,j=m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            lcs+=s[i-1];
            i--,j--;
        }
        else{
                if(dp[i][j-1]>dp[i-1][j]){
                        j--;
                }
                else {
                    i--;
                }
        }
    }
    reverse(lcs.begin(),lcs.end());

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

Measured memory_bytes: 73988
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    bool ok{true};
    std::set<int> s;
    int a;
    for (int i=0; i<n; ++i) {
        cin >> a;
        auto it = s.find(a);
        if (it != s.end()) {
            ok = false;
            break;
        }
        s.insert(a);
    }
    cout << (ok ? "YES": "NO") << endl;

    return 0;
}

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

int main(){

  int N,tmp;
  vector<int> a;
  int A_cnt,B_cnt;

  cin >> N;
  for(int i = 0; i<N; i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());

  if(N%2 == 0){
    for(int i = 0; i<N; i++){
      if(i%2 == 0) A_cnt += a[i];
      else B_cnt += a[i];
    }
  }
  else{
    for(int i = 0; i<N; i++){
      if(i%2 == 0) B_cnt += a[i];
      else A_cnt += a[i];
    }
  }

  cout << abs(A_cnt-B_cnt) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        long sum = 0;
        for (int i = 0 ; i < n ; i++) {
            if (i % 2 == 0) {
                sum += (long) a[i];
            } else {
                sum -= (long) a[i];
            }
        }

        sum /= 2;

        int A = (int) sum;
        int[] b = new int[n];
        b[0] = 2 * A;
        for (int i = 1 ; i < n ; i++) {
            b[i] = 2 *( a[i - 1] - b[i - 1] / 2);
        }

        for (int i = 0 ; i < n - 1 ; i++) {
            System.out.print(b[i]);
            System.out.print(" ");
        }


        System.out.println(b[n - 1]);
    }

}

Measured memory_bytes: 67616
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <limits>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
const int MAX = 700000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if(n<3){
      cout<<0<<endl;
      return 0;
  }
  ll ans=modpow(2,n,MOD);
  ans--;
  COMinit();
  ll j=n;
  ll i=n;
  ll aaa=a;
  ll bbb=b;
  ll aa=1;
  ll bb=1;
  while(aaa){
    aa*=i;
    aa%=MOD;
    aaa--;
    i--;
  }
  while(bbb){
    bb*=j;
    bb%=MOD;
    bbb--;
    j--;
  }
  aa=aa*(finv[a])%MOD;
  bb=bb*finv[b]%MOD;
  ans=(ans-aa-bb)%MOD;
  if(ans<0)ans+=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

void ABC173A()
{
	int N;
	cin >> N;
	cout << ((N - 1) / 1000 +  1) * 1000 - N << endl;
}

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


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

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 7;

struct point {
  int x;
  int y;
};

int n;
int t[N];
vector <point> a[N];

int par(int i) {
  if (t[i] == i) {
    return i;
  } else {
    return t[i] = par(t[i]);
  }
}

void unite(int i, int j) {
  i = par(i);
  j = par(j);
  if (i != j) {
    if ((int) a[j].size() > (int) a[i].size()) {
      swap(i, j);
    }
    for (auto &it : a[j]) {
      a[i].push_back(it);
    }
    t[j] = i;
  }
}

map <int, vector <int>> xx;
map <int, vector <int>> yy;

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

  cin >> n;
  for (int i = 1; i <= n; i++) {
    t[i] = i;
    int x, y;
    cin >> x >> y;
    a[i].push_back({x, y});
    xx[a[i].back().x].push_back(i);
    yy[a[i].back().y].push_back(i);
  }

  for (auto &it : xx) {
    int j = -1;
    for (auto &i : it.second) {
      if (j != -1) {
        unite(i, j);
      }
      j = i;
    }
  }

  for (auto &it : yy) {
    int j = -1;
    for (auto &i : it.second) {
      if (j != -1) {
        unite(i, j);
      }
      j = i;
    }
  }

  ll sol = 0;
  for (int i = 1; i <= n; i++) {
    if (t[i] == i) {
      set <int> x, y;
      for (auto &it : a[i]) {
        x.insert(it.x);
        y.insert(it.y);
      }
      ll szx = (ll) x.size();
      ll szy = (ll) y.size();
      sol += szx * szy;
    }
  }
  sol -= (ll) n;
  cout << sol << "\n";

  return 0;
}


Measured memory_bytes: 27632
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int H, N; cin >> H >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    if (H - accumulate(A.begin(), A.end(), 0) > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

// PRACTICE //

int r, D, x;

int main() {
    cin >> r;
    cin >> D;
    cin >> x;
    int number = x;
    for ( int i = 0 ; i < 10 ; i++ ) {
        x = r*x - D;
        cout << x << "\n";
    }
    return 0;
}

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

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(){
    int n,m,k;
    cin>>n>>m>>k;

    UnionFind p(n+1);
    vector<vector<int>> block(n+1);
    vector<vector<int>> f(n+1);
    
    rep(i,m){
        int a,b;
        cin>>a>>b;
        f[a].emplace_back(b);
        f[b].emplace_back(a);
        p.merge(a,b);
    }
    rep(i,k){
        int a,b;
        cin>>a>>b;
        block[a].emplace_back(b);
        block[b].emplace_back(a);
    }
    REP(i,n){
        int b=0;
        for(auto v:block[i]){
            if(p.issame(i,v)) b++;
        }
        cout<<p.size(i)-f[i].size()-1-b<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 13432
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

// ARC100-E

vector<int> zeta(int N, vector<int> f) { //get F(S)=Σ(T⊂S)G(T)
    vector<int> g(f);
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 1 << N; j++) {
            if(j & (1 << i)) {
                g[j] = max(g[j], f[j] + f[j & ~(1 << i)]);
                f[j] = max(f[j], f[j & ~(1 << i)]);
            }
        }
    }
    return g;
}

signed main(){
    int n;
    cin >> n;
    vector<int> a(1 << n);
    rep(i, 0, 1 << n) cin >> a[i];
    vector<int> x = zeta(n, a);
    int sum = 0;
    for(int i = 0; i < x.size(); i++){
        chmax(sum, x[i]);
        if(i) cout << sum << endl;
    }    
}

Measured memory_bytes: 7164
#include <stdio.h>
long long gcd(long long a,long long b){
    long long c;
    if(a<b){
        a+=b;
        b=a-b;
        a-=b;
    }
    while(b!=0){
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int main(){
    int t;
    scanf("%d",&t);
    long long a,b,c,d;
    long long x,y;
    for(int i=0;i<t;i++){
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
         y=(a-c-1)/b;
            if(a<=c)y=0;
            y++;
            a-=b*y;
        if(a<0||d<b){
            printf("No\n");
        }else{
            if(d==b){
                if(c>=a%b)printf("Yes\n");
                else printf("No\n");
            }
            else{
                x=gcd(d-b,b);
                y=(c-a)/x;
                if(a+(y+1)*x-b<0)printf("No\n");
                else printf("Yes\n");
            }
        }
    }
}

Measured memory_bytes: 128
#include <cstdio>

int main(int argc, const char * argv[]) {
  
    int a,b;
    
    scanf("%d %d",&a,&b);
    int sum = a+b;
    if(sum>=24) printf("%d\n",sum-24);
    else printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [0] * 100097
for i in range(N):
  A[i + 1] = int(input())
cnt = 0
now = 1
while not(now == 2 or cnt > 100097):
  now = A[now]
  cnt += 1

if cnt > 100001:
  cnt = -1
print(cnt)

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

struct StPoint
{
  StPoint() :
    m_nTime(0), m_nXcrd(0), m_nYcrd(0)
  { }

  int m_nTime;
  int m_nXcrd;
  int m_nYcrd;
};

void fnInput(vector<int>& rvnNum)
{
  cin >> rvnNum[0] >> rvnNum[1] >> rvnNum[2];
}

int fnSameIntTimes(const vector<int>& cnrvnNum)
{
  auto itMaxNum = max_element(begin(cnrvnNum), end(cnrvnNum));

  int  nSum = 0;
  for (int nElm : cnrvnNum)
    nSum += nElm;

  int nSameIntTimes;
  if (*itMaxNum * 3 % 2 == nSum % 2)
    nSameIntTimes = ((*itMaxNum * 3) - nSum) / 2;
  else
    nSameIntTimes = (((*itMaxNum + 1) * 3) - nSum) / 2;

  return nSameIntTimes;
}

int main()
{
  vector<int> vnNum(3);

  fnInput(vnNum);
  cout << fnSameIntTimes(vnNum) << endl;

  return 0;
}

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

using namespace std;
const int MAXN=2e5+10;
int res,cur;
char s[MAXN];
int main()
{
	scanf("%s",s+1);int len=strlen(s+1);
	for(int i=1;i<=len;i++)
		if(s[i]=='S') cur++;
		else
		{
			if(!cur) continue;
			cur--;res+=2;
		}
	printf("%d",len-res);
	return 0;
}

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

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

using namespace std;

pair<string, int> gs(const string& s, int i) {
  string res = "";
  if (i == (int)s.size()) return make_pair(res, i);
  if('0' <= s[i] && s[i] <= '9') {
    int v = 0;
    while('0' <= s[i] && s[i] <= '9') {
      v *= 10;
      v += s[i] - '0';
      ++i;
    }
    if (s[i] == '(') {
      string ss;
      int j;
      tie(ss, j) = gs(s, i+1);
      REP(k,v) {
        if (res.size() > 1100000) break;
        res += ss;
      }
      i = j+1;
    } else {
      res += string(v, s[i]);
      ++i;
    }
  } else {
    res += s[i];
    ++i;
  }
  if (i == (int)s.size()) return make_pair(res, i);
  if (s[i] != ')') {
    string ss;
    int j;
    tie(ss, j) = gs(s,i);
    if (res.size() <= 1100000)
      res += ss;
    i = j;
  }
  return make_pair(res, i);
}

int main() {
  while(1){
    string s;
    int i;
    cin>>s>>i;
    if(s=="0"&&i==0) break;
    string h1e6 = gs(s, 0).first;
    if (i >= (int)h1e6.size()) cout << "0" << endl;
    else cout << h1e6[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 8216
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int s, w;

    cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe") << endl;

    return 0;
}


Measured memory_bytes: 3596
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int p[] = new int[N];
        int kakaku = 0;

        for (int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(p);

        for (int i = 0; i < K; i++) {
            kakaku += p[i];
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(kakaku);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 38168
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#include "string.h"
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
using namespace std;
double clockAngle(double a,double b){
    double f=fabs(b*6-(a*30+b/2));
    if(f>180) f=360-f;
    return  f*acos(-1)/180.0;
}
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    printf("%.14f\n",sqrt(a*a+b*b-2*a*b*cos(clockAngle(c,d))));
    return 0;
}

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

int main() {
	int a[5];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]){
		sort(a, a + 5, greater<int>());
		for(int i = 0; i < 5; ++i){
			if(i)
				cout << " ";
			cout << a[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <climits>
#include <map>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
	int n,m;

	vector<int> cx(51),cy(51);
	vector<int> sx(51),sy(51);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> sx[i] >> sy[i];
	}    
	for (int i = 0; i < m; i++)
	{
		cin >> cx[i] >> cy[i];
	}
	for (int i = 0; i < n; i++)
	{
		int mi = 0;
		int mdist = INT_MAX;
		for (int j = 0; j < m; j++)
		{
			int dist = abs(cx[j] - sx[i]) + abs(cy[j] - sy[i]);
			if (dist < mdist)
			{
				mdist = dist;
				mi = j;
			}
		}
		cout << ++mi << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if(t*(v-w)>=abs(a-b)) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO "<< endl;
  }
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 998244353
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N; cin>>N;
  vector<ll> A(N);
  rep(i,N)cin>>A.at(i);
  vector<ll> res;
  res.push_back(A.at(N-1));
  for(int i = N-2; i >= 0; i--){
    //sort(begin(res),end(res));
    auto iter = upper_bound(begin(res),end(res),A.at(i));
    ll dist = distance(begin(res),iter);
    if(dist==(ll)res.size()){
      res.push_back(A.at(i));
    }else{
      res.at(dist) = A.at(i);
    }
  }
  cout<<res.size()<<endl;
}
















Measured memory_bytes: 2168
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>
#include <typeinfo>

using namespace std;

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

	vector<int> value;
	vector<int> cost;

	for (int i = 0; i < n; ++i) {
		int tmp = 0;
		cin >> tmp;
		value.push_back(tmp);
	}

	for (int i = 0; i < n; ++i) {
		int tmp = 0;
		cin >> tmp;
		cost.push_back(tmp);
	}

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (value.at(i) > cost.at(i)) {
			ans = ans + value.at(i) - cost.at(i);
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
K = int(input())
A, B = list(map(int, input().split()))

mod_a = A%K
mod_b = B%K
sub = B-A
sub_div = int(sub/K)

if((sub_div >= 1) or (mod_a == 0) or (mod_b == 0)) :
  print("OK")
else :
  if(mod_a > mod_b) :
    print("OK")
  else :
    print("NG")

Measured memory_bytes: 9092
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*


fun main(args: Array<String>) {
    val inputReader = InputReaderb168(System.`in`)

    var k = inputReader.nextInt()
    var s = inputReader.nextLine().trim()

    if (s.length <= k)
        print(s)
    else
        print(s.substring(0, k).plus("..."))

}

class InputReaderb168(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream))
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = reader.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


Measured memory_bytes: 35692
let cnt = ref 0
let (g : int list ref) = ref []

let insertion_sort (a : int array) n g =
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j+g) <- v
    else begin
      a.(j+g) <- a.(j);
      incr cnt;
      insert (j - g) v
    end in
  let rec doit i =
    if i < n then begin
      insert (i - g) a.(i);
      doit (i + 1)
    end in
  doit g

let generate_g n =
  let rec doit i g acc =
    if g > n then acc
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: acc) in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  List.iter (fun g -> insertion_sort a n g) !g

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int ()) in
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12660
N = int(input())
S = input()

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tmp = 0
            for l, value in enumerate(S):
                if tmp == 0:
                    if value == str(i):
                        tmp = 1
                elif tmp == 1:
                    if value == str(j):
                        tmp = 2
                elif tmp == 2:
                    if value == str(k):
                        ans += 1
                        break
print(ans)

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


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

	string s;
	cin>>s;
	int k=0,maxi=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')
			k++;
		else{

			maxi = max(maxi,k);
			k=0;
		}

	}
	maxi = max(maxi,k);
	cout<<maxi;

    return 0;
}

Measured memory_bytes: 3644
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from math import ceil 
    N = I()
    p = LI_()
    contin = 0
    ans=0
    for i,q in enumerate(p):
        if i == q:
            contin += 1
        else:
            ans += ceil(contin / 2)
            contin = 0
    ans+=ceil(contin/2)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 52752
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    X = []
    for i in range(N):
        a = int(input())
        X.append([])
        for j in range(a):
            x, y = [int(x) for x in input().split()]
            X[i].append([x, y])

    ans = 0
    for i in range(2 ** N):
        tmp = 0
        is_mujun = False
        for j in range(N):
            if i >> j & 1:
                tmp += 1
                for k in X[j]:
                    if k[1] == 1:
                        if not i >> (k[0] - 1) & 1:
                            is_mujun = True
                            break
                    else:
                        if i >> (k[0] - 1) & 1:
                            is_mujun = True
                            break
                    if is_mujun:
                        break
        if not is_mujun:
            ans = max(ans, tmp)

    print(ans)







if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include<stdio.h>
int count=0;
void selection(int a[], int n)//選択ソート
{
  int i,j;
  for(i=0; i<n-1; i++){
    int min=i;
    for(j=i+1; j<n; j++)
      if(a[j]<a[min])
	min=j;
      
    int tmp=a[i];
    a[i]=a[min];
    a[min]=tmp;

    if(a[i]!=a[min]) count++;
  }   
}

int main()
{
  int i,n;
  scanf("%d",&n);
  int a[n];
  for(i=0; i<n; i++)
    scanf("%d",&a[i]);
  
  selection(a,n);
  for(i=0; i<n; i++){
    if(i==n-1)
      printf("%d",a[i]);
    else
      printf("%d ",a[i]);
  }
  putchar('\n');
  printf("%d\n",count);
  return 0;
}




Measured memory_bytes: 2064
import itertools
n,m,x=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(n)]
ans=10**7
for buy in itertools.product(range(2),repeat=n):
  judge=[0]*(m+1)
  for i in range(n):
    if buy[i]==1:
      for j in range(m+1):
        judge[j]+=lst[i][j]
  jd=True
  for i in range(1,m+1):
    if judge[i]<x:
      jd=False
      break
  if jd:
    ans=min(ans,judge[0])
if ans==10**7:
  ans=-1
print(ans)

Measured memory_bytes: 73820
import math


P = (10**9) + 7

def ncr(n, r):
    """組み合わせ"""
    # 入山徳夫氏によるアルゴリズム
    r = min(r, n - r)
    # 桁が小さいときは直接 math.factorial を使ったほうが早い
    if n + r < 4000:
        return math.factorial(n) // math.factorial(n-r) // math.factorial(r)
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = list(range(n - r + 1, n + 1))
    denominator = list(range(1, r+1))
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] //= pivot
                denominator[k] //= pivot
    result = 1
    for k in range(r):
        result *= numerator[k]
        result %= P
    return result


def solv(n, a, b):
    ans = 2 ** n - ncr(n, a) - ncr(n, b) - 1
    return ans % P


if __name__ == "__main__":

    # n a b
    #
    n, a, b = map(int, input().split())
    ans = solv(n, a, b)

    print(ans)


Measured memory_bytes: 284020
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
signed main(){
	int n,k;
	cin>>n>>k;
	int out=0;
	vvi dp(n+1,vi(4000));
	dp[0][0]=1;
	rep(i,n)rep(j,4000)if(dp[i][j])rep(l,k+1){
		if(l<=n-i)(dp[i+1][j+(l+j)/(n-i)]+=dp[i][j])%=MOD;
		else (dp[i+1][j]+=dp[i][j])%=MOD;
	}
	
	rep(i,4000)(out+=dp[n][i]*i%MOD)%=MOD;
	(out=n*k*(k+1)/2%MOD*powmod(k+1,n-1)%MOD-out+MOD)%=MOD;
	cout<<out<<endl;
}
















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

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  priority_queue<double, vector<double>, greater<double> > que;
  for(int i=0; i<N; i++){
    cin >> v.at(i);
    que.push(v.at(i));
  }
  for(int i=0; i<N-1; i++){
    double a = que.top(); que.pop();
    double b = que.top(); que.pop();
    que.push( (a+b)/2);
  }
  cout << fixed;//小数点を確実に8桁で表示するためのもの
  cout << setprecision(8) << que.top() << endl; 

}




Measured memory_bytes: 256