akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(int(1e6))

def search(x, num):
    nodes.remove(x)
#     for y in edge[x]:
#         edge[y].discard(x)
#     for y in list(edge[x]):
    for y in edge[x]:
        if y in nodes:
            num = search(y, num)
    return num + 1

(n,m),*d  = [list(map(int, s.split())) for s in open(0)]

edge = [set() for _ in range(n+1)]
for x in d:
    edge[x[0]].add(x[1])
    edge[x[1]].add(x[0])

nodes = set(range(1,n+1))
ans = 1
for x in list(nodes):
    if x in nodes:
        ans = max(ans, search(x, 0))
print(ans)

Measured memory_bytes: 278616
n = list(map(int,input()))
s = 753
min = 1000
for i in range(len(n)-2):
    x = n[i:i+3]
    y = x[0]*100+x[1]*10+x[2]
    g = abs(s-y)
    if g<min:
        min=g
print(min)

Measured memory_bytes: 3060
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class DirectedGraph {
    struct edge {
        int to;
        int cost;
    };

public:
    int V;
    vector<vector<edge>> G;

    DirectedGraph(int v) : G(v), V(v) {}

    void add_edge(int u, int v, int cost) {
        G[u].push_back({v, cost});
    }

    // O(E * logV)
    vector<int> dijkstra(int s) {
        vector<int> d(V, INF);
        d[s] = 0;

        priority_queue<P, vector<P>, greater<>> que;
        que.push({0, s});

        while (!que.empty()) {
            P  p = que.top(); que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;

            for (edge e : G[v]) {
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push({d[e.to], e.to});
                }
            }
        }

        return move(d);
    }
};

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

    DirectedGraph g = DirectedGraph(N);

    for (int i = 0; i < N - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }

    int Q, K;
    cin >> Q >> K;
    K--;

    vector<int> d = g.dijkstra(K);

    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 11120
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
    long[,] vertexes = new long[n,3];//ここに受け取る
    bool answer = true;
    long distance = 0;
    long time = 0;
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
      vertexes[i,2] = nums[2];
    }

    for(int i = 0; i < n; i++)
    {
      if(i>=1)
      {
        distance = Math.Abs(vertexes[i,1]-vertexes[i-1,1])
          + Math.Abs(vertexes[i,2]-vertexes[i-1,2]);
        time = vertexes[i,0] - vertexes[i-1,0];
      }else
      {
        distance = Math.Abs(vertexes[i,1])
          + Math.Abs(vertexes[i,2]);
        time = vertexes[i,0];
      }
      
      if(time < distance) answer = false;
      if(time%2 != distance%2) answer = false;
    }
    
		Console.WriteLine((answer) ? "Yes" : "No");
	}
}

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

int digit(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}
int main(){
  int n; cin >> n;
  if (n % digit(n) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
let n=Int(readLine()!)!
let s=Array(readLine()!.characters)

var ret = "Yes"
if( n % 2 == 1 ) {
  ret = "No"
} else {
  for(var i=0;i<n/2;i++) {
	if(s[i] != s[i+n/2]) {
		ret = "No"
	}
  }
}

print(ret)

Measured memory_bytes: 3824
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0
for i in range(N):
    if P[i]==0:
        m+=1
print(m)

Measured memory_bytes: 9180
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int N, H; cin >> N >> H;
	vector<int> A(N), B(N);
	int ma = 0;
	rep(i, N){
		cin >> A[i] >> B[i];
		ma = max(A[i], ma);
	}

	vector<int> b;
	rep(i, N){
		if(B[i] > ma) b.push_back(B[i]);
	}

	sort(ALL(b), greater<int>());
	int cnt = 0;
	rep(i, b.size()){
		H -= b[i];
		cnt++;
		if(H <= 0) break;
	}

	if(H <= 0){
		cout << cnt << endl;
		return 0;
	}

	cnt += H / ma;
	if(H % ma != 0) cnt++;


	cout << cnt << endl;


	return 0;
}


Measured memory_bytes: 1660
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    h,w,d = inpm()
    a = inpll(h)
    MAP = [0 for _ in range(h*w)]
    for i in range(h):
        for j in range(w):
            MAP[a[i][j]-1] = (i,j)
    cnt = []
    for i in range(h*w-d):
        x = MAP[i]
        y = MAP[i+d]
        cost = abs(x[0]-y[0]) + abs(x[1]-y[1])
        cnt.append(cost)
    ans = [0 for _ in range(h*w)]
    for i in range(h*w-d):
        ans[i+d] += ans[i] + cnt[i]
    q = inp()
    for _ in range(q):
        l,r = inpm()
        print(ans[r-1]-ans[l-1])
 
if __name__ == "__main__":
    main()

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

#define int long long

using namespace std;



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

    long double A, B;
    cin >> A >> B;

    int temp = A*B;

    cout << temp << '\n';

    return 0;
}


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int n;
int a[200005];

int main() {
    scanf("%d", &n);
    FO(i,0,n) scanf("%d", a+i);
    long long r = 0;
    vector<pair<int,pair<int,int> > > v;
    FO(i,0,n) {
        while (sz(v) && v.back().first > a[i]) {
            auto x = v.back(); v.pop_back();
            r += 1ll * x.first * x.second.first * (i-x.second.second);
        }
        int prv = -1;
        if (sz(v)) prv = v.back().second.second;
        v.push_back(make_pair(a[i],make_pair(i-prv,i)));
    }
    int i = n;
    while (sz(v) && v.back().first > -1) {
        auto x = v.back(); v.pop_back();
        r += 1ll * x.first * x.second.first * (i-x.second.second);
    }
    printf("%lld\n", r);
}



Measured memory_bytes: 4212
open Core

let n, a, b = Scanf.scanf "%d %d %d" (fun n a b -> (n, a, b))

let nums = List.range 1 (n + 1)

let rec digits i = if i <= 0 then 0 else (i mod 10) + digits (i / 10)

let s =
  nums
  |> List.map ~f:(fun n ->
         let d = digits n in
         if a <= d && d <= b then n else 0)
  |> List.fold_left ~init:0 ~f:( + )

let () = Printf.printf "%d\n" s


Measured memory_bytes: 13728
//A - Fifty-Fifty
//20190912

using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            string ans = "Yes";

            for (int i = 0; i < 4; i++)
            {
                if (S.Where(s => s == S[i]).Count() != 2)
                {
                    ans = "No";
                }
            }

            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 11220
N = int(input())
A_list = list(map(int, input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
x = A_list[0]
for i in range(1, N):
    x = gcd(x, A_list[i])
print(x)

Measured memory_bytes: 15020
fun main() {
    val inLine1 = readLine()!!.split(" ").map(String::toInt)
    val inLine2 = readLine()!!.split(" ").map(String::toInt)
    val n = inLine1[0]
    val k = inLine1[1]

    var pList = inLine2.sorted()
    var result = 0
    var i = 0
    while(i < k){
        result += pList[i]
        i++
    }
    println(result)
}

Measured memory_bytes: 40696
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	char c;
	cin>>c;
	if (c=='A') cout<<"T";
	if (c=='C') cout<<"G";
	if (c=='G') cout<<"C";
	if (c=='T') cout<<"A";
}

Measured memory_bytes: 256
import Control.Monad
import Data.List

main = do
  n <- readLn
  xys <- replicateM n $ (map read . words <$> getLine) :: IO [[Double]]
  print $ solve xys

solve xys =
  let xyss = permutations xys
  in
  	(/(fromIntegral $ length xyss)) . sum . map f $ xyss
  where
    d [x1, y1] [x2, y2] = sqrt $ (x1 - x2)**2 + (y1 - y2)**2
    
    f [x, y] = d x y
    f (x:y:xys) = d x y + f (y:xys)


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

vector<int> G[9];
int ans = 0;

void countPass(vector<bool> visit,int x){
    visit[x] = true;
    if(all_of(visit.begin()+1,visit.end(),[](bool b){return b;})) ans ++;
    for(int i = 0;i < G[x].size();i ++){
        if(!visit[G[x][i]]) countPass(visit,G[x][i]);
    }

}

int main(){
    int n,m,x=1;
    cin >> n >> m;
    vector<bool> visit(n+1);
    for(int i = 0;i < m;i ++){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    countPass(visit,x);
    cout << ans << endl;

    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 vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    double T,X;
    cin >> T >> X;
    double ans =  T / X;
    cout << ans << endl;
}

Measured memory_bytes: 256
#define ll long long int
#define pb push_back
#define mp make_pair
#define ln cout<<"\n";
#include <bits/stdc++.h>
using namespace std;

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

	 ll t=1,r,n,a,b,c,x,y,sum,cnt,i,j,k,m,l,q,maxx,minn,temp,ans,flag,g,ts;
	
	 char ch;
	 double dans;
	 string str,ttr;
	 
//	 cin >> t;

	
	for(ts=1;ts<=t;ts++)
	{
	     flag=0;sum=0;cnt=0;ans=0;k=0;maxx=0;minn=0;a=0;b=0;temp=0;
	    
	     cin >>m>> n;
	 //    ll arr[n];
	     for(i=0;i<n;i++)
	     {
	         cin>>x;
	         sum+=x;
	     }
	     ans=m-sum;
	     if(ans<0)
	     cout<<"-1";
	     else
	     cout<<ans;
	     
	     ln
	 }
	return 0;
}


Measured memory_bytes: 3640
n=int(input())
ans=0 
l=[int(i) for i in input().split()]
while sum(l):
    c=0 
    f=0 
    for i in range(n):
        if l[i]!=0:
            l[i]-=1 
            c+=1 
        else: 
            if c:
                ans+=1 
                c=0 
    if c:
        ans+=1 
print(ans)

Measured memory_bytes: 3060
use std::io;

fn main() {
    let vs = parse_values::<isize>(2);
    let a = vs[0];
    let b = vs[1];
    let answer_range = (b * 10)..(b * 10 + 10);
    let mut answer = -1;
    for item in answer_range {
        if item * 8 / 100 == a {
            answer = item;
            break;
        }
    }
    println!("{}", answer);
}

/// Parse line from io::stdin into T Value
fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

/// Parse whitespace split into T values from io::stdin
fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}

Measured memory_bytes: 4352
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#include <numeric>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls x<<1
#define rs x<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	ll n,k;cin>>n>>k;
	ll res=0;
	for(;k<=n+1;k++){
		ll L=(k*(k-1))>>1;
		ll R=((2*n-k+1)*k)>>1;
		res=(res+R-L+1)%mod;
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 3648
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 = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		long[] dp = new long[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		for (int i = 2; i < n; i++) {
			dp[i] = dp[i - 1] + Math.abs(h[i - 1] - h[i]);
			for (int j = 2; j <= k; j++) {
				if (i - j < 0) break;
				dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i - j] - h[i]));
			}
		}
		
		System.out.println(dp[n - 1]);
//		System.out.println(Arrays.toString(dp));
		sc.close();
	}
}



Measured memory_bytes: 51300
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main (void) {
    int n;
scanf("%d",&n);
int array[n];
for (int i=0;i<n;i++){
    scanf("%d",&array[i]);
}
for (int i = 0; i < n; i++) {
    if (array[i] % 2 == 0 && array[i] % 3 !=0 && array[i] % 5 != 0) {
      puts("DENIED");
      return 0;
    }
  }
  puts("APPROVED");
return EXIT_SUCCESS;
}


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

int main() {
    int k;
    cin >> k;
    bool flag = true;
    vector<int> a(1000001);
    a[1] = 7 % k;
    for (int i = 2; i <= k; i++) {
        a[i] = (10 * a[i - 1] + 7)% k;
    }
    for (int i = 1; i <= k; i++) {
        if (a[i] == 0) {
            cout << i << endl;
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "-1" << endl;
    }
    return 0;
}

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

bool bin_search(int A[], int left, int right, int key){
	while (left < right) {
		int mid = (left + right) / 2;
		if (A[mid] == key) {
			return true;
		}else if (A[mid] < key) {
			left = mid + 1;
		}else {
			right = mid;
		}
	}
	return false;
}


int main(int argc, char *argv[]) {
	int n, q;
	int A[100002], B[100002];
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	cin >> q;
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		scanf("%d", &B[i]);
		if (bin_search(A, 0, n, B[i])) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;	
}


Measured memory_bytes: 3792
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


n,k = map(int, input().split())
td_mx = {}
td = []
for _ in range(n):
  t,d = map(int, input().split())
  if t not in td_mx:
    td_mx[t] = d
  elif td_mx[t] < d:
    td.append(td_mx[t])
    td_mx[t] = d
  else:
    td.append(d)
td = sorted(td, key=lambda x:-x)
td_mx = sorted(td_mx.values(), key=lambda x:-x)

# td,td_mx の累積和を求める
csum = [0]
csum_mx = [0]
for i in range(len(td)):
  csum.append(csum[-1] + td[i])
for i in range(len(td_mx)):
  csum_mx.append(csum_mx[-1] + td_mx[i])


# 1~k種類で探索 最大値を取り出す
ans = 0
for i in range(1,k+1):
  if i <= len(csum_mx)-1 and k-i <= len(csum)-1:
    ans = max(ans, csum_mx[i] + csum[k-i] + i*i)
print(ans)

Measured memory_bytes: 20960
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(vector<long long>& A, long long K) {
        int n = A.size();
        sort(A.begin(), A.end());

        auto upper = [&](long long p, long long q) {
            if (q < 0) {
                p = -p;
                q = -q;
            }
            return p >= 0 ? (p + q - 1) / q : p / q;
        };
        auto lower = [&](long long p, long long q) {
            if (q < 0) {
                p = -p;
                q = -q;
            }
            return p >= 0 ? p / q : (p - (q - 1)) / q;
        };

        auto count = [&](long long x) {
            long long res = 0;
            for (auto y : A) {
                if (y * 1LL * y <= x) {
                    --res;
                }
                if (y == 0) {
                    if (x >= 0) {
                        res += n;
                    } 
                } else if (y < 0) {
                    auto t = upper(x, y);
                    auto it = lower_bound(A.begin(), A.end(), t);
                    res += n - (it - A.begin());
                } else {
                    auto t = lower(x, y);
                    auto it = upper_bound(A.begin(), A.end(), t);
                    res += it - A.begin();
                }
            }
            return res / 2;
        };
        auto ok = [&](long long x) {
            return count(x) >= K;
        };
        const long long INF = 1e18 + 1;
        long long lo = -INF, hi = INF;
        while (lo < hi) {
            long long mi = lo + (hi - lo) / 2;
            if (ok(mi)) {
                hi = mi;
            } else {
                lo = mi + 1;
            }
        }

        return lo;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long K;
    cin >> n >> K;
    vector<long long> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Solution sol;

    cout << sol.solve(A, K) << "\n";
    return 0;
}

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

template<typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long e = c * d / gcd(c,d);
    long long countc = b/c - (a-1)/c;
    long long countd = b/d - (a-1)/d;
    long long counte = b/e - (a-1)/e;
    cout << b - a + 1 - (countc + countd - counte) << endl;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll A, B;
int main() {
	cin >> A>> B;
	if (A <= 5){
		p(0);
	}else if(A<=12){
		p(B/2);
	}else{
		p(B);
	}
	return 0;
}


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

int main(){
  int n,m,p,x[100],total;
  while(1){
    cin>>n>>m>>p;

    if(!(n||m||p))break;

    total=0;
    for(int i=0; i<n; i++) cin>>x[i],total+=x[i];

    if(x[m-1]!=0) total = total*(100-p)/x[m-1] ;
    else total = 0;
    cout<< total <<endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a =0;
		for (;a<s.length();a++) {
			if (s.charAt(a)=='A') {
				break;
			}
		}
		for (int i=s.length()-1;i>=0;i--) {
			if (s.charAt(i)=='Z') {
				System.out.println(i-a+1);
				break;
			}
		}
	}
}

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

int main()
{
  string s,t;
  cin>>s>>t;
  int m=s.length();
  int n=t.length();
  int l[m+1][n+1];
  int i,j;
  for( i=0;i<=m;i++)
  {
    for(j=0;j<=n;j++)
    {
      if(i==0 || j==0)
          l[i][j]=0;
      else if(s[i-1]==t[j-1])
          l[i][j]=1+l[i-1][j-1];
      else
        l[i][j]=max(l[i-1][j],l[i][j-1]);
    }
  }
  int index=l[m][n];
  char lcs[index+1];
  lcs[index]='\0';
  i=m;
  j=n;
  while(i>0 && j>0)
  {
    if(s[i-1]==t[j-1])
    {
      lcs[index-1]=s[i-1];
      i--;
      j--;
      index--;
    }
    else if(l[i-1][j]>l[i][j-1])
       i--;
    else
      j--;
  }
  cout<<lcs<<endl;
}
        
    
  

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

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

  ll x; cin >> x;
  ll ans = 0;

  ans = x/11*2;
  ans += (x%11 > 6 ? 2 : (x%11 == 0 ? 0 :1));

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main()
{
    string instr;
    int sum=0;
    cin >> instr;

    for(int i=0; i<6; ++i) {
        if(instr[i]=='1') {
            sum++;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S, a, b;
    ll N, N2, i, judge1=1;

    cin >> S;

    N = S.size();

    a = S.substr(0, (N-1)/2);
    b = S.substr((N+3)/2-1);

    N2 = a.size();

    for(i=0; i<=(N-1)/2-1; i++){
        if(S[i] != S[N-1-i]){
            judge1 = 0;
        }
    }

    for(i=0; i<=N2/2-1; i++){
        if(a[i] != a[N2-1-i]){
            judge1 = 0;
        }
    }

    for(i=0; i<=N2/2-1; i++){
        if(b[i] != b[N2-1-i]){
            judge1 = 0;
        }
    }

    if(judge1==1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,h;
	cin>>n>>h;
	int a[n],b[n];
	bool f[n];
	int mx=-1000000000;
	for(long long i=0;i<n;i++){
		cin>>a[i]>>b[i];
		f[i]=true;
		mx=max(mx,a[i]);
	}
	sort(b,b+n);
	reverse(b,b+n);
	for(int i=0;i<n;i++){
		if(b[i]<mx){
			f[i]=false;
		}
	}
	long long ans=0;
	for(long long i=0;i<n;i++){
		if(f[i]==true){
			h-=b[i];
			ans++;
		}
		if(h<=0){
			cout<<ans;
			return 0;
		}
	}
	if(h%mx==0){
		ans+=h/mx;
	}
	else{
		ans+=h/mx+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1152
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

int main(void)
{
    int64_t a, b;

    std::cin >> a >> b;

    std::string str = std::to_string(a) + std::to_string(b);
    int64_t value = std::stoi(str);
    int64_t sqrt = static_cast<int64_t>(std::sqrt(value));
    int64_t pow = std::pow(sqrt, 2);

    std::cout << ((value == pow) ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

cnt = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            cnt += 1

D = [[-1] * W for i in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs():
    Q = []
    Q.append([0, 0])
    D[0][0] = 0
    
    while Q != []:
        p = Q.pop(0)
        if p[0] == H - 1 and p[1] == W - 1:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != '#' and D[nx][ny] == -1:
                Q.append([nx, ny])
                D[nx][ny] = D[p[0]][p[1]] + 1
                
    return D[H - 1][W - 1]

x = bfs()

if x == -1:
    print(-1)
else:
    print(cnt - x - 1)

Measured memory_bytes: 3064
def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,k=getints()

res = 0.0

for i in range(1,n+1):
    d = i
    p = 1.0
    while d < k:
        p *= 0.5
        d *= 2
    res += p / n

print(res)


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int a,b,c;char d,e;
    cin>>a>>d>>b>>e>>c;
    if(a>2019){
        cout<<"TBD"<<endl;
        return 0;
    }else if(b>4){
        cout<<"TBD"<<endl;
        return 0;
    }else if(c>30){
        cout<<"TBD"<<endl;
        return 0;
    }
    cout<<"Heisei"<<endl;
}


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

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X > Y) {
        cout << ">" << endl;
    }
    else if (X < Y) {
        cout << "<" << endl;
    }
    else {
        cout << "=" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
using namespace std;

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin,(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int n = gcd(a,b);
  vector<int> v;
  for(int i=1;i<=n;++i){
    if((a%i==0)&&(b%i==0)) v.push_back(i);
  }
  sort(v.begin(),v.end(),greater<int>());
//  rep(i,n)cout << v[i] << endl;
  cout << v[k-1] << endl;

  return 0;
}


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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999
 
using namespace std;

int32_t main(){
    int a, b;
    cin >> a >> b;

    if(a<=0 && b>=0){
        cout << "Zero" << endl;
        return 0;
    }

    if(a>0){
        cout << "Positive" << endl;
        return 0;
    }

    if(b<0){
        if((b-a+1)%2){
            cout << "Negative" << endl;
        }
        else{
            cout << "Positive" << endl;
        }
    }
}

Measured memory_bytes: 256
package main
 
import (
  "fmt"
)
 
func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := "No"
  if len(s) >= 4 && s[0:4] == "YAKI" {
    ans = "Yes"
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1836
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int H,W;
		Scanner sc=new Scanner(System.in);
		while(true){
			H=sc.nextInt();
			W=sc.nextInt();
			if(H==0&&W==0)break;
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
    }
}



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

const long long MOD = 1000000007;

const int MAX = 510000;

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

void solve(long long N, long long K, std::vector<long long> A){
    COMinit();
    ll ans = 0;

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    for(int i = 0;i < N;i++){
        if(N-1-i < K-1){
            break;   
        }
        ans += COM(N-1-i, K-1) * A[i];
        ans %= MOD;
    }
    reverse(A.begin(), A.end());

     for(int i = 0;i < N;i++){
        if(N-1-i < K-1){
            break;   
        }
        ans += MOD;
        ans -= (COM(N-1-i, K-1)%MOD * A[i]%MOD)%MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 13056
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int i;
    ;
    for(i=1;i<=n;i++){
        if(i%3==0)
            printf(" %d",i);
        else if(i%10==3||(i/10)%10==3||(i/100)%10==3||(i/1000)%10==3)
            printf(" %d",i);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2084
#include<stdio.h>
int main(void){
	int a,b,c,tmp=0;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>c){
		tmp=a;
		a=c;
		c=tmp;
	}
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	if(b>c){
		tmp=b;
		b=c;
		c=tmp;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
int main(void)
{

	while (1) {
		int h, w;
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
			break;

		int i, j;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	int n;
	cin >> n;
	if (n == 1){
		cout << "Hello World" << endl;
		return 0;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

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

int n;
long long ans;
string s;
map<pair<string,string>,int> cnt;

void pre_dfs(string s1,string s2,int x){
    if(x==n){
        cnt[make_pair(s1,s2)]++;
        return;
    }
    pre_dfs(s1+s[x],s2,x+1);
    pre_dfs(s1,s2+s[x],x+1);
}

void dfs(string s1,string s2,int x){
    if(x==n-1){
        ans+=cnt[make_pair(s2,s1)];
        return ;
    }
    dfs(s1+s[x],s2,x-1);
    dfs(s1,s2+s[x],x-1);
}

int main(){
    scanf("%d",&n);
    cin >> s;
    string s1,s2;
    pre_dfs(s1,s2,0);
    dfs(s1,s2,2*n-1);
    printf("%lld",ans);
}


Measured memory_bytes: 87808
#include<stdio.h>
using namespace std;

int main(){
	int n,k,b,s[101],i;
	
	for(;scanf("%d%d",&n,&k),n|k;){
		for(i=0;i<k;i++)
			scanf("%d",s+i);
		for(i=0;i<n*k;s[i++%k]-=b)
			scanf("%d",&b);
		for(i=0;i<k;)
			s[i++]<0?
				n=0:0;
		puts(n?"Yes":"No");
	}
}

Measured memory_bytes: 732
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		int m=sc.nextInt(), n=sc.nextInt();
		String s1="", s2="";
		for(int i=0;i<m;i++)s1+=n;
		for(int i=0;i<n;i++)s2+=m;
		System.out.println(s1.compareTo(s2)<0?s1:s2);
	}
 
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  if (c == 'A')
    cout << 'T';
  else if (c == 'T')
    cout << 'A';
  else if (c == 'C')
    cout << 'G';
  else
    cout << 'C';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

if(0<=c-a<=d or 0<=a-c<=d):
    print('Yes')
elif((0<=b-a<=d or 0<=a-b<=d) and (0<=c-b<=d or 0<=b-c<=d)):
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3060
n = int(input())
d = []
for _ in range(n):
    x, y = map(int, input().split())
    d.append(x==y)
for i in range(n-2):
    if d[i] and d[i+1] and d[i+2]:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9176
#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 < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    int a;
    int id = 0;
    rep(i, n){
        cin >> a;
        if(a==id+1){
            id++;
        }
    }
    if(id==0){
        cout << -1 << endl;
    }else{
        cout << n-id << endl;
    }
       // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
ll dp[15][1050];
int main()
{
	dp[0][0]=1;
	for(int i=0;i<=100;i++)
	{
		for(int j=9;j>=0;j--)
		{
			for(int k=0;i+k<1001;k++)
			{
				dp[j+1][k+i]+=dp[j][k];
			}
		}
	}
	int n,s;
	while(scanf("%d %d",&n,&s)!=EOF)
	{
		if(n==0&&s==0)break;
		cout << dp[n][s] << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

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

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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


int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        string s;
        cin>>s;int mx=0;
        for(int i=0; s[i];) {
            if(s[i]=='R') {
                int cnt=0;
                while(s[i]=='R'&&i<3) {
                    ++i;
                    ++cnt;
                }
                mx=max(mx,cnt);
            } else {
                ++i;
            }
        }
        cout<<mx<<endl;
    }
    return 0;
}





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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B

int main() {
	int n;
	cin >> n;
	int s[n];
	for (int i = 0; i < n; i++) cin >> s[i];
	int m;
	cin >> m;
	int t[m];
	for (int i = 0; i < m; i++) cin >> t[i];
	
	int ans = 0;
	for (int k = 0; k < m; k++) {
		int l = 0, r = n - 1;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (s[mid] < t[k]) {
				l = mid + 1;
			} else {
				if (s[mid] == t[k]) {
					ans++;
					break;
				}
				r = mid - 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n,k;
  cin>>n>>k;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
  }
  int64_t t=0,plus=0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i; j < n; ++j)
    {
      if(a[i]>a[j]) t++;
    }
  }
  //cout<<t<<endl;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      if(a[i]>a[j]) plus++;
    }
  }
  //cout<<plus<<endl;
  cout<<(k*(k-1)/2L%mod*plus%mod+t*k%mod)%mod;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String S = sc.nextLine();

        String ans = "";
        for (int i = 0; i < S.length(); i++) {
            char s = S.charAt(i);
            if (Character.isLetter(s)) {
                if (Character.isUpperCase(s)) {
                    ans += String.valueOf(Character.toLowerCase(s));
                } else {
                    ans += String.valueOf(Character.toUpperCase(s));
                }
            } else {
                ans += String.valueOf(s);
            }
        }

        out.printf("%s\n", ans);
        out.flush();
    }
}


Measured memory_bytes: 31724
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int N,C;
    cin >> N >> C;
    int d[C][C];
    int c[N][N];
    rep(i,C) rep(j,C) cin >> d[i][j];
    rep(i,N) rep(j,N) cin >> c[i][j];

    vector<vector<int>> g(3);
    rep(i,N) rep(j,N) g[(i+j)%3].push_back(c[i][j]);

    vector<vector<pair<int,int>>> dc(3, vector<pair<int,int>>(C));
    rep(i,3)
    {
        int m = g[i].size();
        rep(j,C)
        {
            dc[i][j].first = 0;
            dc[i][j].second = j;
            rep(k,m)
            {
                int dc_k = d[g[i][k]-1][j];
                dc[i][j].first += dc_k;
            }
        }
        sort(dc[i].begin(),dc[i].end());
    }

    int min_dc = 1<<29;

    rep(i,3)
        rep(j,3)
            rep(k,3)
            {
                if(dc[0][i].second == dc[1][j].second) continue;
                if(dc[0][i].second == dc[2][k].second) continue;
                if(dc[1][j].second == dc[2][k].second) continue;

                min_dc = min(min_dc, dc[0][i].first + dc[1][j].first + dc[2][k].first);
            }

    cout << min_dc << endl;
    return 0;
}

Measured memory_bytes: 2416
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  int a[4];
  for(int i=3;i>=0;i--){
    a[i]=n%10;
    n/=10;
  }
  char f[1<<3][8];
  for(int bit=0;bit<(1<<3);bit++){
    for(int i=0;i<3;i++){
      int mask=1<<i;
      if(bit&mask){
        f[bit][i]='+';
      }else{
        f[bit][i]='-';
      }
    }
  }




  for(int i=0;i<1<<3;i++){
    int sum=a[0];
    for(int j=0;j<3;j++){
      if(f[i][j]=='+'){
        sum+=a[j+1];
      }else{
        sum-=a[j+1];
      }
    }
    if(sum==7){
      printf("%d%c%d%c%d%c%d=%d\n",a[0],f[i][0],a[1],f[i][1],a[2],f[i][2],a[3],sum);
      return 0;
    }
  }


  return 0;
}


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

int main(){	
	int h, w;
	cin >> h >> w;
	while(h != 0){
		int i, j;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N>> M;
  // N要素の配列
  vector<int> B(N,0);
 
  // 入力処理
  for (int j = 0; j < M; j++) {
    vector<int> A(2);
    cin >> A.at(0)>>A.at(1);
    for(int i = 0; i < N;i++){
      if(i+1==A.at(0) || i+1==A.at(1))
        B.at(i)+=1;
  }
  }
  for (int i = 0;i < N;i++){
    cout << B.at(i) <<endl;
}
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

    int low = 0, up = N;
    string lowS;
    cout << low << endl;
    cout << flush;
    cin >> lowS;
    while (true)
    {
        if (lowS == "Vacant")
            break;

        ll mid = (low + up) / 2;
        string s;
        cout << mid << endl;
        cout << flush;
        cin >> s;
        if (s == "Vacant")
            break;

        if ((mid - low) % 2 == 0)
        {
            if (lowS == s)
            {
                low = mid;
                lowS = s;
            }
            else
                up = mid;
        }
        else
        {
            if (lowS != s)
            {
                low = mid;
                lowS = s;
            }
            else
                up = mid;
        }
    }
    return 0;
}

Measured memory_bytes: 852
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    struct T
    {
    public:
        ll a;
        ll b;
        ll c;
    };
    ll a, b, c;
    cin >> N;
    cin >> a >> b >> c;
    T h0, h1;
    h0.a = a;
    h0.b = b;
    h0.c = c;
    for (ll i = 1; i < N; ++i)
    {
        cin >> a >> b >> c;
        h1.a = a + max(h0.b, h0.c);
        h1.b = b + max(h0.a, h0.c);
        h1.c = c + max(h0.a, h0.b);
        h0 = h1;
    }
    cout << max({ h0.a, h0.b, h0.c });
}

Measured memory_bytes: 3172