akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
 
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}
 
 
void execute()
{
    int N, M, X;
    cin >> N >> M >> X;
    int C[12];
    int A[12][12];
    
    for(int n = 0; n < N; n++){
    	cin >> C[n];
	    for(int m = 0; m < M; m++){
 			cin >> A[n][m];
	    }
    }
    
    int c_min = iINF;
    unsigned int idx_max = 1 << N;
    for(unsigned int i = 0; i < idx_max; i++){
    	int c = 0;
    	int r[12] = {0};
    	for(int n = 0; n < N; n++){
	 		if((i & (1 << n)) != 0){
	 			c += C[n];
		    	for(int m = 0; m < M; m++){
	    			r[m] += A[n][m];
	    		}
	    	}
    	}
    	
    	if(![&M, &r, &X](){
	    	for(int m = 0; m < M; m++){
	    		if(r[m] < X) return false;
	    	}
	    	return true;
    	}()) continue;
 
 		chmin(c_min, c);
    }
 
    cout << ((c_min == iINF) ? -1 : c_min) << endl; 
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
typedef long long ll;
const ll INF = 1LL << 60;


struct Edge {
    int from,to,cost;
    Edge(int f,int t,int c) : from(f),to(t),cost(c){}
};

vector<Edge> edges;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,m,a,b,c;
    cin >> n >> m;
    REP(i,m){
        cin >> a >> b >> c;
        --a;--b;
        edges.emplace_back(a,b,c);
    }
    ll dist[1010];
    REP(i,n) dist[i] = -INF;
    dist[0] = 0;
    for(int i = 0; i <= 2*n; ++i){
        for(Edge e : edges){
            if(dist[e.from] != -INF && dist[e.to] < dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                if(i >= n && e.to == n-1){
                    cout << "inf" << endl;
                    return 0;
                }
            }
        }
    }
    cout << dist[n-1] << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  /*
  char a1[5] = {'.',',','!','?',' '};
  char a2[3] = {'a','b','c'};
  char a3[3] = {'d','e','f'};
  char a4[3] = {'g','h','i'};
  char a5[3] = {'j','k','l'};
  char a6[3] = {'m','n','o'};
  char a7[4] = {'p','q','r','s'};
  char a8[3] = {'t','u','v'};
  char a9[4] = {'w','x','y','z'};
  */
  /*
  string a1=".,!? ";
  string a2="abc";
  string a3="def";
  string a4="ghi";
  string a5="jkl";
  string a6="mno";
  string a7="pqrs";
  string a8="tuv";
  string a9="wxyz";
 */
 string a[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 //for(int i=0; i<9; i++) cout << a[i] << " ";
 int n;
 cin >> n;
 for(int k=0; k<n; k++){
   string s;
   cin >> s;
   for(int i=0; i<(int)s.size(); i++){
     char c = s[i];
     int count = 0;
     for(i=i+1; i<(int)s.size(); i++){
       if(s[i] != c) break; //先頭と違っていたら
       count++;
    }
    i--; //?
    if(c=='0') continue;
    int num = c-'0'-1; //何故'0'?
    //cout << "#" << num << " " << c << " ";
    int tmp = count % a[num].size();
    cout << a[num][tmp];
    }
    cout << endl;
 }
 return 0;
}



Measured memory_bytes: 3128
#include <stdio.h>

int main(){
  int i,j,stac,a,b,div;

  scanf("%d%d",&a,&b);
  if(a<b){
    stac=a;
    a=b;
    b=stac;
  }

  while(b>0){
    stac=a%b;
    a=b;
    b=stac;
  }
  printf("%d\n",a);

  return 0;
}
  

Measured memory_bytes: 592
// =====================================================================================
//
//       Filename:  1092.cpp
//
//    Description:  
//
//        Version:  1.0
//        Created:  14/04/20 08:28:57 PM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:  
//
// =====================================================================================

#include<bits/stdc++.h>


using namespace std;

#define int long long 
#define pb push_back
//#define _SHOW_TIME

void solve(){
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  int ok =1;
  for(int i =0;i<s.size();++i){
      if(i!=a && s[i] == '-') ok = 0 ;
  }
  if(ok && s[a]=='-') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}
int32_t main(){
 /////////////////////////////////////
    #ifdef _SHOW_TIME
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
    solve();
    /////////////////////////////////////
    #ifdef _SHOW_TIME
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
    return 0;

}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// Edge :
type Edge struct {
	from, to, cost int
}

// Route :
type Route struct {
	path []int
}

// ベルマンフォード法
func bellmanFord2(N, S int, edges []Edge) ([]int, []Route, bool) {
	d := make([]int, N+1)
	for i := 0; i <= N; i++ {
		d[i] = -math.MaxInt64
	}
	d[S] = 0
	r := make([]Route, N+1)
	r[S].path = []int{S}

	negativeLoop := false
	for i := 0; i <= N; i++ {
		for _, e := range edges {
			if d[e.to] < d[e.from]+e.cost {
				d[e.to] = d[e.from] + e.cost
				r[e.to].path = append(r[e.from].path, e.to)
				if i == N {
					negativeLoop = true
				}
			}
		}
	}

	return d, r, negativeLoop
}

const inf = math.MaxInt64 >> 10

// ベルマンフォード法
func bellmanFord(N, S int, edges []Edge) ([]int, bool) {
	d := make([]int, N+1)
	for i := 0; i <= N; i++ {
		d[i] = inf
	}
	d[S] = 0

	for i := 0; i <= N; i++ {
		for _, e := range edges {
			if d[e.from] == inf {
				continue
			}
			if d[e.to] > d[e.from]+e.cost {
				d[e.to] = d[e.from] + e.cost
			}
		}
	}
	//negativeLoop := false
	negative := make([]bool, N+1)
	for i := 0; i <= N; i++ {
		for _, e := range edges {
			if d[e.from] == inf {
				continue
			}
			if d[e.to] > d[e.from]+e.cost {
				d[e.to] = d[e.from] + e.cost
				negative[e.to] = true
				//			if i == N {
				//				negativeLoop = true
				//			}
			}
			if negative[e.from] {
				negative[e.to] = true
			}
		}
	}

	return d, negative[N]
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()
	edges := make([]Edge, M)
	for i := 0; i < M; i++ {
		f, t, c := getInt(), getInt(), getInt()
		edges[i] = Edge{f, t, -c}
	}
	S, D := 1, N

	// ここから
	d, negativeLoop := bellmanFord(N, S, edges)

	if negativeLoop == true {
		out("inf")
	} else {
		out(-d[D])
	}

}


Measured memory_bytes: 768
#include<stdio.h>
int main(){
	long int N, Naux;
	scanf("%ld", &N);
	Naux = N;
	int ans = 0;
	for(long int n = 2; n * n <= Naux; n++){
		if(N % n == 0){
			N /= n;
			int nDiv = 1;
			while(N % n == 0){
				N /= n;
				nDiv++;
			}
			for(int i = 1; i*(i+1)/2 <= nDiv; i++)
				ans++;
		}
	}
	ans += N > 1 ? 1 : 0;
	printf("%d", ans);
	return 0;
}

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

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    double pi = acos(-1);
    if(x >= a*a*b/2){
        double c = a, d = b, e = x;
        printf("%.10f",atan(2.0*(c*c*d - e)/(c*c*c)) * 360.0 / (2.0*pi));
    }
    else{
        double c = a, d = b, e = x;
        printf("%.10f",atan(d*d*c/(2*e)) * 360.0 / (2.0*pi));
    }
}

Measured memory_bytes: 4016
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

int main(){

    string s;
    cin>>s;

    int m1=(s[0]-'0')*10+s[1]-'0';
    int m2=(s[2]-'0')*10+s[3]-'0';

    int res=0;
    if(1<= m1 && m1 <=12) res++;
    if(1<= m2 && m2 <=12) res+=2;

    if(res==0) cout<<"NA"<<endl;
    else if(res==1) cout<<"MMYY"<<endl;
    else if(res==2) cout<<"YYMM"<<endl;
    else cout<<"AMBIGUOUS"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int M = 10;
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] f = new int[n];
		for (i = 0; i < n; i++) {
			for (j = 0; j < M; j++) {
				f[i] += parseInt(sc.next())<<j;
			}
//			out.printf("%x%n", f[i]);
		}
		int[][] p = new int[n][M+1];;
		for (i = 0; i < n; i++) {
			for (j = 0; j <= M; j++) {
				p[i][j] = parseInt(sc.next());
			}
		}
		sc.close();
		int max = -1000000000 - 1;
		for (i = 1; i < 1024; i++) {
			int tmp=0;
			for (j = 0; j < n; j++) {
				tmp += p[j][bitCount(f[j]&i)];
			}
			if(tmp>max)max=tmp;
		}
		out.println(max);
	}
}


Measured memory_bytes: 25892
package main

import "fmt"

// UnionFind is union find structure
type UnionFind struct {
	Par  []int
	Rank []int
}

// NewUnionFind generates a new union find
func NewUnionFind(n int) *UnionFind {
	uf := &UnionFind{make([]int, n), make([]int, n)}
	for i := range uf.Par {
		uf.Par[i] = i
		uf.Rank[i] = 0
	}
	return uf
}

// Root searches the root of the arguement
func (uf *UnionFind) Root(x int) int {
	if x == uf.Par[x] {
		return x
	}
	uf.Par[x] = uf.Root(uf.Par[x]) // 経路圧縮
	return uf.Par[x]
}

// Unite unites two trees by adding one root to another
func (uf *UnionFind) Unite(x, y int) {
	rx := uf.Root(x)
	ry := uf.Root(y)
	if rx == ry {
		return
	}
	if uf.Rank[rx] < uf.Rank[ry] {
		uf.Par[rx] = ry
	} else {
		uf.Par[ry] = rx
		if uf.Rank[rx] == uf.Rank[ry] {
			uf.Rank[rx]++
		}
	}
}

// Same returns true when the two are in the same group
func (uf *UnionFind) Same(x, y int) bool {
	return uf.Root(x) == uf.Root(y)
}

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	uf := NewUnionFind(n)

	friends := make(map[int]int)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		uf.Unite(a-1, b-1)
		friends[a-1]++
		friends[b-1]++
	}

	sizes := make([]int, n)
	for i := range sizes {
		r := uf.Root(uf.Par[i])
		sizes[r]++
	}

	blocks := make([]int, n)
	for i := 0; i < k; i++ {
		var c, d int
		fmt.Scan(&c, &d)
		if uf.Same(c-1, d-1) {
			blocks[c-1]++
			blocks[d-1]++
		}
	}

	for i := 0; i < n; i++ {
		ans := sizes[uf.Root(i)] - friends[i] - blocks[i] - 1
		fmt.Printf("%v ", ans)
	}
	fmt.Println()
}


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



int main()
{
	int n;
	cin >> n;
	int ni = 1;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t == ni) {
			ni++;
		}
		else {
			res++;
		}
	}
	if (res == n) {
		cout << -1;
	}
	else {
		cout << res;
	}
}

Measured memory_bytes: 256
def gcd(a,b):
  while b > 0:
    a,b = b,a%b
  return a

a,b = map(int,input().split())
p = gcd(a,b)
s = {1}
for i in range(2,int(p**.5)+2):
  if p%i == 0:
    s.add(i)
    p //= i
    while p%i == 0:
      p //= i
if p > 1:
  s.add(p)
print(len(s))

Measured memory_bytes: 3064
N = int(input())

ans = dict()
ans["AC"] = 0
ans["WA"] = 0
ans["TLE"] = 0
ans["RE"] = 0
for i in range(N):
    s = input()
    ans[s] += 1

print("AC x", ans["AC"])
print("WA x", ans["WA"])
print("TLE x", ans["TLE"])
print("RE x", ans["RE"])


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

struct rec{
    int x,y;
    bool operator<(const rec& another) const {
        return (x*x + y*y) == (another.x*another.x + another.y*another.y)?x < another.x:(x*x + y*y) < (another.x*another.x + another.y*another.y);
    }
};

int main()
{
    vector<rec> vec;
    for(int i=1;i<151;i++){
        for(int j=i+1;j<151;j++){
            vec.pb((rec){i,j});
        }
    }
    sort(all(vec));
    while(1){
        int h,w;
        cin >> h >> w;
        if(h == 0){
            break;
        }
        int id = upper_bound(all(vec),(rec){h,w}) - vec.begin();
        cout << vec[id].x << " " << vec[id].y << "\n";
    }
}

Measured memory_bytes: 3240
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    let mut scan = Scanner::new();
    let x: Vec<i32> = scan.next_vec(5);
    println!("{}", 1 + (0..5).find(|a| x[*a] == 0).unwrap());
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <math.h>
using namespace std;
using ll = unsigned long long;

int main() {
  int n, x1, x2;

  cin >> n;

  x1 = n / 1.08;
  x2 = n / 1.08 + 1;

  if (int(x1 * 1.08) == n) {
    cout << x1 << endl;
  } else if (int(x2 * 1.08) == n) {
    cout << x2 << endl;
  } else {
    cout << ":(" << endl;
  }
}


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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}

		int[] dp = new int[H + 1];
		Arrays.fill(dp, Integer.MAX_VALUE);

		dp[0] = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= H; j++) {
				if (j - A[i] <= 0) {
					dp[j] = Math.min(dp[j], B[i]);
					continue;
				}

				if (dp[j - A[i]] == Integer.MAX_VALUE) continue;
				dp[j] = Math.min(dp[j], dp[j - A[i]] + B[i]);
			}
		}

		System.out.println(dp[H]);
	}
}


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

int main(){
	string s,t; cin>>s>>t;
	int sk=s.size();
	int tk=t.size();
	int mx=0;
	rep(i,sk-tk+1){
		string c=s.substr(i,tk);
		int cnt=0;
		rep(j,tk){
			if(t[j]==c[j]) cnt++;
		}
		mx=max(mx,cnt);
	}
	cout<<tk-mx<<endl;
}

Measured memory_bytes: 3628
import java.lang.reflect.Member;
import java.util.*;

import javax.naming.spi.DirStateFactory.Result;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main(){
		new AOJ1045().doIt();
	}
	
	class AOJ1045{
		int n;
		int[] member;
		int dfs(int index,int a,int b){
//			System.out.println(index+" "+a+" "+b);
			int result = Integer.MAX_VALUE;
			if(index == n){
//				if(Math.abs(a-b)==0)System.out.println(a+" "+b);
				return Math.abs(a-b);
			}
			result = Math.min(result, dfs(index+1,a+member[index], b));
			result = Math.min(result, dfs(index+1,a, b+member[index]));
			return result;
		}
		
		void solve(){
			member = new int[n];
			for(int i=0;i<n;i++)member[i] = in.nextInt();
			System.out.println(dfs(0, 0, 0));
		}
		void doIt(){
			while(true){
				n = in.nextInt();
				if(n==0)break;
				solve();
			}
		}
	}
	
}

Measured memory_bytes: 20900
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    // S_i = E_1 + ... + E_iを計算しておけば，隣接するK個のE_iの和はS_(j+k) - S_j
    vector<double> s(n); // 1~i番目のサイコロの期待値の和
    double sum = 0;
    for (int i = 0; i < n; i++) {
        sum += (double) (1+p[i])/2;
        s[i] = sum; // S_i = S_(i-1) + E_i
    }
    double ans = s[k-1];
    for (int i = 0; i < n-k; i++)
    {
        double tmp = s[i+k]-s[i];
        ans = max(ans, tmp);
    }
    cout << fixed << setprecision(6) << ans << endl;
    return 0;
}

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

int n,x[505],y[505],a[250010],cnt[505];

bool cmp(int a,int b){return x[a]<x[b];}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&x[i]),a[x[i]]=i,cnt[i]=i-1,y[i]=i;
	sort(y+1,y+n+1,cmp);
	for (int i=1,j=1; i<=n*n; i++)
		if (!a[i])
			{
				while ((j<=n)&&(!cnt[y[j]]))  j++;
				if (j<=n)  a[i]=y[j],cnt[y[j]]--;
			}else  if (cnt[a[i]])  puts("No"),exit(0);
	for (int i=1; i<=n; i++)  cnt[i]=n-i;
	for (int i=1,j=1; i<=n*n; i++)
		if (!a[i])
			{
				while ((j<=n)&&(!cnt[y[j]]))  j++;
				if (x[y[j]]<i)  a[i]=y[j],cnt[y[j]]--;
				else  puts("No"),exit(0);
			}
	puts("Yes");
	for (int i=1; i<=n*n; i++)  printf("%d ",a[i]);	
}

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


Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
#define INFTY 1000000000
#define MAX 5000001

void mergeSort(int,int);
void merge(int,int,int);

int A[MAX],L[MAX],R[MAX],C=0;

int main(){
  
 int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
}

  mergeSort(0,n);
    for(i=0;i<n;i++){
      if(i>0)
	printf(" ");
    printf("%d",A[i]);
}
    printf("\n");
    printf("%d\n",C);
  return 0;
}

void merge(int left,int mid,int right){
  int k,i,j,n1,n2;
  n1 = mid - left;
  n2 = right - mid;
  for (i = 0 ;i<=n1-1;i++){
    L[i] = A[left + i];
  }
  for (i = 0;i<=n2-1;i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for (k = left;k<=right-1;k++){
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      C++;
    }
    else {
      A[k] = R[j];
      j = j + 1;
      C++;
    }}
  return ;
}

void mergeSort(int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;   
    mergeSort(left,mid);
    mergeSort(mid,right);
    merge(left,mid,right);
  }
  return ;
}

Measured memory_bytes: 9768
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")



ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
    string s;
    cin>>s;
if((s[1]=='R' and s[2]=='R' and s[0]=='R')) cout<<"3";
    else if((s[0]=='R' and s[1]=='R') or (s[1]=='R' and s[2]=='R'))
        cout<<"2";

        
    else if(s[0]=='R' or s[1]=='R' or s[2]=='R')
        cout<<"1";
    else cout<<"0";
}

int main()
{
  ll tt;tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
}

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

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}

#ifdef LOCAL_LOGGER
#define logger(...) fprintf(stderr, __VA_ARGS__)
#define abortif(v, ...) if (v) {logger("Error in Line %d, Function '%s()'.\nInfo: ", __LINE__, __FUNCTION__); logger(__VA_ARGS__); exit(0);}
#else
#define logger(...);
#define abortif(v, ...);
#endif
/* }}} */

const let eps = 1e-8;
const let Pi = acos(-1.0);

int sign(let x) { return x < -eps ? -1 : (x > eps ? 1 : 0); }

struct Point {
  let x, y;
  friend Point operator + (Point a, Point b) {
    return (Point) {a.x + b.x, a.y + b.y};
  }
  friend Point operator - (Point a, Point b) {
    return (Point) {a.x - b.x, a.y - b.y};
  }
  friend let Cdot(Point a, Point b) {
    return a.x * b.x + a.y * b.y;
  }
  friend let Times(Point a, Point b) {
    return a.x * b.y - a.y * b.x;
  }
  Point operator ~ ()  { return (Point) {x, -y}; }

  Point Rotate(let sink, let cosk) {
    return (Point) {
      x * cosk - y * sink, x * sink + y * cosk
    };
  }
  Point Rotate(let k) {
    return Rotate(sin(k), cos(k));
  }

  let dist() {
    return sqrt(x * x + y * y);
  }

  Point Rotate(Point v) {
    let z = v.dist();
    if (sign(z) == 0) return *this;
    return Rotate(v.y / z, v.x / z);
  }

  let Dist(Point a, Point b) { return (a - b).dist(); }
};

typedef Point Vec;

let AreaTriangle(let a, let b, let c) {
  return sqrt((a + b + c) * (a + b - c) * (a + c - b) * (b + c - a)) / 4;
}

struct Circle {
  Point o;
  let r;

  friend let AreaIntersection(Circle c1, Circle c2) {
    let d = (c2.o - c1.o).dist(), r1 = c1.r, r2 = c2.r;
    logger("%Lf %Lf %Lf\n", d, r1, r2);
    if (sign(d - (r1 + r2)) >= 0) // 外切、相离
      return 0;
    if (sign(d - r2 + r1) <= 0) // c2 内切、内含 c1
      return Pi * r1 * r1;
    if (sign(d + r2 - r1) <= 0) // c1 内切、内含 c2
      return Pi * r2 * r2;
    let x1 = (r1 * r1 - r2 * r2 + d * d) / (2 * d), x2 = d - x1,
        y = sqrt(r1 * r1 - x1 * x1);
    logger("%Lf %Lf %Lf\n", x1, x2, y);
    let area = r1 * r1 * atan2(y, x1) + r2 * r2 * atan2(y, x2) 
      - AreaTriangle(r1, r2, d) * 2;
    return area;
  }
};

Point ReadPoint() {
  Point p;
  scanf("%Lf%Lf", &p.x, &p.y);
  return p;
}

Circle ReadCircle() {
  Point p = ReadPoint();
  let k;
  scanf("%Lf", &k);
  return (Circle) {p, k};
}

int main() {
// #ifndef ONLINE_JUDGE
//   freopen("CGL_7_I.in", "r", stdin);
//   freopen("CGL_7_I.out", "w", stdout);
// #endif
// #ifdef LOCAL_LOGGER
//   freopen("CGL_7_I.log", "w", stderr);
// #endif
  Circle c1 = ReadCircle(), c2 = ReadCircle();
  printf("%.8Lf\n", AreaIntersection(c1, c2));
  return 0;
}

/* ==== Makefile ==== {{{
CompileAndRun:
	make Compile
	make Run

Compile:
	g++ -o CGL_7_I CGL_7_I.cpp -g -Wall -DLOCAL_LOGGER

CompileUF:
	g++ -o CGL_7_I CGL_7_I.cpp -g -Wall -DLOCAL_LOGGER -fsanitize=undefined

Run:
	./CGL_7_I < CGL_7_I.in > CGL_7_I.out
==================
}}} */



Measured memory_bytes: 3308
flag = [False] * 53
n = int(input())
for i in range(n):
    c, n = map(str, input().split())
    n = int(n)
    if(c == "S"):
        flag[n] = True
    elif(c == "H"):
        flag[13 + n] = True
    elif(c == "C"):
        flag[26 + n] = True
    else:
        flag[39 + n] = True
suit = ["S", "H", "C", "D"]
for i in range(1, len(flag)):
    if(flag[i] == False):
        print(suit[(i - 1) // 13], (i - 1) % 13 + 1)

Measured memory_bytes: 7656
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(b<=c||a>=d)
	{
		printf("0\n");
	}
	else
	{
		if(c>=a)
		{
			if(b<=d)
			printf("%d\n",b-c);
			else
			printf("%d\n",d-c);
		}
		if(a>c)
		{
			if(b<=d)
			printf("%d\n",b-a);
			else
			printf("%d\n",d-a);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve(long long N, std::vector<long long> A){
    vl gcdFromLeft(N),gcdFromRight(N);
    ll g=A[0];
    rep(i,N){
        g=gcd(g,A[i]);
        gcdFromLeft[i]=g;
    }
    g=A[N-1];
    rep(i,N){
        g=gcd(g,A[N-1-i]);
        gcdFromRight[N-1-i]=g;
    }
    ll ans=max(gcdFromLeft[N-2],gcdFromRight[1]);
    fore(i,1,N-2){
        chmax(ans,gcd(gcdFromLeft[i-1],gcdFromRight[i+1]));
    }
    cout<<ans<<endl;
}

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


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

const int MAX = 100005;
long long cum_sum[MAX];

int main() {
  // input
  while (true) {
    int n, k, tmp;
    cin >> n >> k;
    if (n == 0 && k == 0) break;
    for (int i = 1; i <= n; i++) {
      cin >> tmp;
      cum_sum[i] = cum_sum[i-1] + tmp;
    }

    long long ans {-MAX * n};
    for (int i = 1; i <= n-k; i++) {
      long long tmp_ans = cum_sum[i + k] - cum_sum[i];
      if (ans < tmp_ans) ans = tmp_ans;
    }
    cout << ans << endl;
  }
}



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

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
	int x = 1;
	while (b) {
		if (b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a) { return power(a, mod - 2);}

#undef int
int main() {
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int pwr[21]; pwr[0] = 1;
	for (int i = 1; i <= 20; i++) pwr[i] = pwr[i - 1] * 2;

	int n; cin >> n;
	int a[n]; map<int,int> occ;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		occ[a[i]]++;
	}
	sort(a, a + n);
	
	int ans=0;
	for(int i=n-1;i>=0;i--){
		if(occ[a[i]]){
			int num = 1;
			while(num<=a[i]) num<<=1;
			num = num - a[i];
			if(num != a[i] and occ[num]){
				occ[num]--; occ[a[i]]--;
				ans++;
			}
			if(num == a[i] and occ[num]>1){
				occ[num] -= 2;
				ans++;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,a,b;
	cin>>x>>a>>b;
	if(a>=b)
		cout<<"delicious"<<endl;
	else if(b<=(a+x))
		cout<<"safe"<<endl;
	else
		cout<<"dangerous"<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector < int > vint;
typedef pair < int, int > pii;
typedef pair < int, bool > pib;
typedef unsigned long long ull;

#define PB push_back
#define MP make_pair
#define RANGE(V) V.begin(), V.end()
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORN(i,n) for(int i=1;i<=n;++i)
#define debug(x) cerr<<#x<<":"<<x<<"\n";
#define FORS(i,n) for(int i=0;i<n.length();++i)
const int INF = INT_MAX;
const int MAX = 10000001;
const int M = 1000000007;
int mod{ 1000000007 };

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt", "r", stdin);
	int t;
	t = 1;
	while (t--) {
		
		string s, t;
		cin >> s >> t;
		int ans = t.size();

		for (int start = 0; start <= s.size() - t.size(); ++start) {

			int diff = 0;
			for (int j = 0; j < t.size(); ++j) {
				if (t[j] != s[start + j])
					diff++;
			}
			ans = min(diff, ans);
		}
		cout << ans << endl;
		}
	return 0;
}






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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ans[x - 1] = i + 1;
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }

  return 0;
}

Measured memory_bytes: 1280
(defun split (str delim)
  (let ((res (make-array 1 :element-type 'string
                           :fill-pointer 0
                           :adjustable t)))
    (loop for i from 0 below (length str)
          with start = 0
          when (eq (char str i) delim)
          do (vector-push-extend (subseq str start i) res)
             (setf start (1+ i))
          finally (let ((tail (subseq str start)))
                    (when tail
                      (vector-push-extend tail res))))
    res))

(let* ((in (split (read-line) #\Space))
       (h (parse-integer (aref in 0))))
  (loop for i from 0 below h
        for line = (read-line)
        do (format t "~A~%~A~%" line line)))

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

int main()
{
  int W;
  vector<int> vec(2);
  cin>>W>>vec[0]>>vec[1];
  sort(vec.begin(),vec.end());
  int ans;
  if(vec[0]+W>=vec[1]){
    ans=0;
  }
  else{
    ans=vec[1]-vec[0]-W;
  }
  cout<<ans;
}

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

std::vector<ll> w;
std::vector<ll> v;
std::vector<std::vector<ll> > memo;
ll knapsack(ll N, ll W, int i){
	if(i == N ){
		return 0;
	}
	if(memo[W][i] != -1)
		return memo[W][i];
	if(w[i] > W){
		memo[W][i] = knapsack(N, W, i+1);
		return memo[W][i];
	}
	else{
		memo[W][i] =  std::max(
				v[i] + knapsack(N, W-w[i], i+1),
				knapsack(N, W, i+1)
				);
		return memo[W][i];
	}
}
int main(){
	ll N, W;
	cin>>N>>W;
	w.resize(N);
	v.resize(N);
	memo.assign(W+1, std::vector<ll> (N,-1));
	for(int i=0; i<N; i++){
		cin>>w[i]>>v[i];
	}
	cout<<knapsack(N, W, 0);
	return 0;
}

Measured memory_bytes: 82304
/*
 * atcoder/abc167/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll A, B, C, K;
void solve() {
  cin >> A >> B >> C >> K;
  ll total = 0;
  ll minA = min(A, K);
  total += minA;
  K -= minA;
  ll minB = min(B, K);
  K -= minB;
  total -= K;
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) (v.begin(),v.end())
#define ff first
#define ss second
const ll maxn=2e5+10;
const ll mod=1e9+7;
 
int main() {
  	fast;
  	
  	ll r;
  	cin>>r;
  	double ans=2*( 3.14159265358979323846 )*r;
  	cout<<fixed<<setprecision(10)<<ans;
  	
}

Measured memory_bytes: 3804
n,k=map(int,input().split())
H=list(map(int,input().split()))

dp=[float('inf')]*n
dp[0]=0
for i in range(n):
  for j in range(k+1):
    if i+j<n:
      dp[i+j]=min(dp[i+j],dp[i]+abs(H[i+j]-H[i]))
print(dp[-1])

Measured memory_bytes: 55264
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m,x,y,ind[maxn];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>x>>y,ind[x]++,ind[y]++;
	for(int i=1;i<=n;i++)	
	if(ind[i]&1)puts("NO"),exit(0);
	puts("YES");
	return 0;
}

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

int M;
using mat = vector<vector<ll>>;
// multiplication, A[0].size = B.size が必要
mat mul(mat &A, mat &B) {
    mat C(A.size(), vector<ll>(B[0].size(), 0));
    for (int i = 0; i < A.size(); ++i) {
        for (int k = 0; k < B.size(); ++k) {
            for (int j = 0; j < B[0].size(); ++j) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
            }
        }
    }
    return C;
}

// 正方行列の累乗
mat pow(mat A, ll n){
    mat B(A.size(), vector<ll>(A.size(), 0));
    for (int i = 0; i < A.size(); ++i) {
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

ll modPow(ll x, ll n) {
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % M;
        x = x * x % M;
        n >>= 1;
    }
    return res;
}

int main() {
    ll L, A, B;
    cin >> L >> A >> B >> M;
    ll C = A + B * (L-1);

    // 桁数ごとに初項と項数を保存
    vector<ll>first(19);
    vector<ll>num(19, 0);
    vector<ll>last(19);
    last[0] = A % B - B;
    ll pow_ten = 1;
    for (int i = 1; i < 19; ++i) {
        first[i] = last[i-1] + B;
        pow_ten *= 10;
        last[i] = ((pow_ten-1-A) / B) * B + A;
        first[i] = max(first[i], A);
        ll end = min(last[i], C);
        if(first[i] <= end) {
            num[i] = (end - first[i]) / B + 1;
        }
    }

    ll ans = 0;
    for (int i = 1; i < 19; ++i) {
        mat X = {{ans, first[i]%M, 1}};
        mat P(3, vector<ll>(3));
        P[0] = {modPow(10, i), 0, 0};
        P[1] = {1, 1, 0};
        P[2] = {0, B%M, 1};
        auto Pn = pow(P, num[i]);
        X = mul(X, Pn);
        ans = X[0][0];
    }

    cout << ans;
    return 0;
}

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

bool isprime(int x) {
  if (x < 2) return false;
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 2; v.size() < n; ++i)
    if (isprime(i) && i % 5 == 1) v.push_back(i);
  for (int i = 0; i < n; ++i) {
    cout << v[i];
    if (i == n - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}


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

int main()
{
	int n;
	cin >> n;
	int a[n][n];
	bool b[n][n];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			b[i][j] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (i == k || k == j) {
					continue;
				}

				if (a[i][j] == a[i][k] + a[k][j]) b[i][j] = b[j][i] = false;
				else if (a[i][j] > a[i][k] + a[k][j]) { cout << -1 << endl; return 0; }
			}
		}
	}
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (b[i][j]) sum += a[i][j];
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#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 <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n, k;
    cin >> n >> k;
    ll summ = 0.0;

    vl p(n);
    REP(i, n){
        cin >> p[i];
        if(i < k){
            summ += p[i];
        }
    }
    ll maxsumm = summ;
    for(ll i = 0; i < n - k; i++){
        summ = summ + p[i + k] - p[i];
        if(summ > maxsumm) maxsumm = summ;
    }

    double ans = (k + maxsumm) / 2.0;

    cout <<setprecision(20)<< ans << endl;

    return 0;
};


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
	ll n, m, s = 0;
	cin >> n >> m;
	while(n > 0){
		s++;
		n /= m;
	}
	cout << s;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    static final int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        int N = nint();
        double[] p = ndoubles(N, 1, 0);
        
        double[][] dp = new double[N+1][N+1];
        dp[0][0] = 1;
        
        for (int n = 1; n <= N; n++)
            for (int k = 0; k <= N; k++)
                if (0 < k)
                    dp[n][k] = dp[n-1][k] * (1-p[n]) + dp[n-1][k-1] * p[n];
                else
                    dp[n][k] = dp[n-1][k] * (1-p[n]);
        
        double ans = 0;
        for (int k = (N+1) / 2; k <= N; k++)
            ans += dp[N][k];
        
        System.out.println(ans);
    }
    
    
    static long max(long... longs) {
        return Arrays.stream(longs).max().getAsLong();
    }
    
    static long min(long... longs) {
        return Arrays.stream(longs).min().getAsLong();
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }
    
    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }
    
    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = sc.nextDouble();
        }
        return d;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 123148
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;
int main(){
	int n,ans = 0;
	cin >> n;
	n*=2;
	vector<int> v;
	while (n--){
		int a;
		cin >> a;
		v.pb(a);
	}
	sort(v.begin(),v.end());
	for (int i = 0; i < v.size(); i+=2)
		ans += v[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<tuple>
#include<set>
#include<utility>
#include<sstream>
#include<map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
#define INF 1000000007
#define MOD 1000000007
#define INF_LONG 1000000000000007
#define MOD_LONG 1000000000000007

int main() {
	int T, t, i, j, k, l, r, a, b, c, d, e, f, g, n, m, x, y, z;
	string s1, s2; vector<string> vs;
	scanf("%d",&n);
	vector<int>v1(n), v2(n);
	for (i=0; i<n; i++) scanf("%d",&v1[i]);
	for (i=0; i<n; i++) scanf("%d",&v2[i]);
	ll aa=0;
	for (i=0; i<n; i++) {
		b=v2[i]-v1[i];
		if (b>0) aa+=(b/2);
		else aa+=b;
	}
	if (aa>=0) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<int,int>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<in>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14

ll power(ll num,ll g,ll mod)
{
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string A;
  cin >> A;
  for(int i=0; i<3 ; i++)
  {
    if(A.at(i)=='9')cout << '1';
    if(A.at(i)=='1')cout << '9';
  }
  cout << endl;
}

Measured memory_bytes: 3596
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

k = INT()
a = LIST()
l = 2
r = 2
for i in reversed(range(k)):
    l = (l + a[i] - 1) // a[i] * a[i]
    r = r // a[i] * a[i] + a[i] - 1
    if l > r:
        print(-1)
        exit()
print(l, r)


Measured memory_bytes: 16284
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<String>();
    let v = v.iter()
        .map(|x| x.chars().collect::<Vec<_>>()[0])
        .collect::<Vec<_>>();
    if v[0] == v[1] {
        println!("=");
    } else if v[0] > v[1] {
        println!(">");
    } else {
        println!("<");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    cin >> n;
    vector<vector<ll> > dp(2,vector<ll>(n+1,0));
    vector<ll> v(n+1);
    rep(i,n)cin >> v[i];
    dp[0][0] = v[0];
    dp[1][0] = -v[0];
    rep(i,n-1){
        dp[0][i+1] = max(dp[0][i] + v[i+1],dp[1][i] - v[i+1]);
        dp[1][i+1] = max(dp[0][i] - v[i+1],dp[1][i] + v[i+1]);
    }
    // rep(j,2){
    //     rep(i,n)cout << dp[j][i] << " ";
    //     cout << endl;
    // }
    cout << max(dp[0][n-2]+v[n-1],dp[1][n-2]-v[n-1]) << endl;
 }

Measured memory_bytes: 2560