akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 

ll dp[3002][3002][5];

ll DFS(int y, int x, vector<vector<ll>>& M, int n_in_row_taken) {
  int h = M.size(), w = M[0].size();
  assert(y >= 0);
  assert(x >= 0);
  assert(y < h);
  assert(x < w);
  //if (y==h-1 && x == w-1) return n_in_row_taken <= 2 ? M[y][x] : 0;
  if (y==h-1 && x == w-1) return 0;
  if (dp[y][x][n_in_row_taken] != -1) return dp[y][x][n_in_row_taken];
  ll ans = 0;
  
  if (y+1 < h) {
    ans = max(ans, DFS(y+1,x,M,0));
    ans = max(ans, M[y+1][x] + DFS(y+1,x,M,1));
  }
  if (x+1 < w) {
    if (n_in_row_taken <= 2) ans = max(ans, M[y][x+1] + DFS(y,x+1,M, n_in_row_taken+1));
    ans = max(ans, DFS(y,x+1,M, n_in_row_taken));
  }
  return dp[y][x][n_in_row_taken] = ans;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll h,w,K;
  cin >> h >> w >> K;
  vector<vector<ll>> M(h, vector<ll>(w));
  for (int i = 0; i < K; ++i) {
    ll y,x,v;
    cin >> y >> x >> v;
    --y,--x;
    M[y][x] = v;
  }
  for (int y = 0; y < h; ++y) {
    for (int x = 0; x < w; ++x) {
      for (int j = 0; j < 4; ++j) {
        dp[y][x][j] = -1;
      }
    }
  }
  ll ans = DFS(0,0,M,0);
  ans = max(ans, M[0][0] + DFS(0,0,M,1));
  cout << ans << endl;
  
  

}


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

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

int main() {
  LL N;
  std::cin >> N;
  std::vector<int> B(N-1);
  for(int i=0; i<N-1; i++) {
    std::cin >> B[i];
  }
  LL ans = 0;
  for(int i=0; i<N-2; i++) {
    ans += std::min(B[i], B[i+1]);
  }
  ans += B[0] + B[N-2];
  std::cout << ans << std::endl;

  return 0;
}



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

using namespace std;

int main()
{
	int i, n, temp;
	vector<int> v;

	cin >> n;
	vector<int> dp(n,0);
	for(i=0;i<n;i++)
	{
		cin >> temp;
		v.push_back(temp);
	}
	dp[1] = abs(v[1]-v[0]);

	for(i=2;i<n;i++)
	{
		dp[i] = min(dp[i-2] + abs(v[i]-v[i-2]), dp[i-1] + abs(v[i]-v[i-1]));
	}

	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1276
n, k = map(int, input().split())
c = []
for i in range(n):
    c.append(list(map(int, input().split())))

c.sort(key=lambda x: x[0])

count = 0
for i in range(n):
    count += c[i][1]
    if count >= k:
        print(c[i][0])
        break

Measured memory_bytes: 29144
#coding:utf-8
S=raw_input()

# start:0
s="0"
A0=0
for c in S:
    if s!=c:A0+=1
    if(s=="0"):s="1"
    else: s="0"
# start:1
s="1"
A1=0
for c in S:
    if s!=c:A1+=1
    if(s=="0"):s="1"
    else: s="0"
print(min(A0,A1))

Measured memory_bytes: 2692
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
const int N=100001;
int a[N],ans,b[N],n,m;
int main(){
	n=read(),m=read();a[1]=1;
	for(int i=1;i<=n;i++) b[i]=1;
    for(int i=1;i<=m;i++){
    	int x=read(),y=read();
    	if(a[x]==1){
    		if(b[x]==1) a[x]--;
    		a[y]=1;
		}
    	b[x]--,b[y]++;
//    	printf("b(%d):%d b(%d):%d\n",x,b[x],y,b[y]);
	}for(int i=1;i<=n;i++) ans+=(a[i]>0);
	printf("%d\n",ans);
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      xyp: [(i64, i64, i64); n]
   }

   let num = 1 << n;
   let mut tx = vec![vec![0i64; n]; num];
   let mut ty = vec![vec![0i64; n]; num];
   for s in 0..num {
      let mut xs = vec![];
      let mut ys = vec![];
      let mut idx = vec![];
      for i in 0..n {
         if (s >> i) & 1 == 1 {
            let (x, y, _) = xyp[i];
            xs.push(x);
            ys.push(y);
         } else {
            idx.push(i);
         }
      }
      for &i in idx.iter() {
         let (x, y, p) = xyp[i];
         let mut dx = x.abs();
         let mut dy = y.abs();
         for (xn, yn) in xs.iter().zip(ys.iter()) {
            dx = min(dx, (x - xn).abs());
            dy = min(dy, (y - yn).abs());
         }
         tx[s][i] = p * dx;
         ty[s][i] = p * dy;
      }
   }

   let mut ans = vec![std::i64::MAX; n + 1];
   let num: usize = (0..n).fold(1_usize, |acc, _| acc * 3);
   for _s in 0..num {
      let mut s1 = 0;
      let mut s2 = 0;
      let mut s = _s;
      let mut idx = vec![];
      for i in 0..n {
         if s % 3 == 1 {
            s1 += 1 << i;
         } else if s % 3 == 2 {
            s2 += 1 << i;
         } else {
            idx.push(i);
         }
         s /= 3;
      }
      let score = idx.iter().map(|&i| min(tx[s1][i], ty[s2][i])).sum();
      ans[n - idx.len()] = min(ans[n - idx.len()], score);
   }
   for a in ans {
      println!("{}", a);
   }
}


Measured memory_bytes: 11768
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,a,b=mp()
print(max(((b-a)*(n-2)+1),0))

Measured memory_bytes: 77432
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

func reverseString(s string) string {
	n := len(s)
	bytes := []byte(s)
	for i := 0; i < n/2; i++ {
		bytes[i], bytes[n-1-i] = bytes[n-1-i], bytes[i]
	}
	return string(bytes)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s := next()
	l := list.New()
	for _, c := range s {
		l.PushBack(string(c))
	}
	q := nextInt()

	rev := false

	for i := 0; i < q; i++ {
		t := nextInt()
		switch t {
		case 1:
			rev = !rev
		case 2:
			f, c := nextInt(), next()
			if (!rev && f == 1) || (rev && f == 2) {
				l.PushFront(c)
			} else {
				l.PushBack(c)
			}
		}
	}

	if !rev {
		for e := l.Front(); e != nil; e = e.Next() {
			putf("%s", e.Value.(string))
		}
	} else {
		for e := l.Back(); e != nil; e = e.Prev() {
			putf("%s", e.Value.(string))
		}
	}
	putf("\n")
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}


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

int main(){
    int n;
    cin >> n;
    string tmp;
    getline(cin, tmp);
    for(int rep=0; rep<n; rep++){
        int p = 0;
        string s;
        getline(cin, s);
        s = "^" + s;
        int m;
        cin >> m;
        getline(cin, tmp);
        for(int i=0; i<m; i++){
            string cmd;
            getline(cin, cmd);
            int len = s.length();
            if(cmd == "forward char"){
                if(p < len-1){
                    swap(s[p], s[p+1]);
                    p++;
                }
            }else if(cmd == "backward char"){
                if(p > 0){
                    swap(s[p], s[p-1]);
                    p--;
                }
            }else if(cmd == "delete char"){
                if(p < len-1){
                    s.erase(s.begin()+p+1);
                }
            }else if(cmd == "forward word"){
                while(p<len-1 and s[p+1]==' '){
                    swap(s[p], s[p+1]);
                    p++;
                }
                while(p<len-1 and s[p+1]!=' '){
                    swap(s[p], s[p+1]);
                    p++;
                }
            }else if(cmd == "backward word"){
                while(p>0 and s[p-1]==' '){
                    swap(s[p], s[p-1]);
                    p--;
                }
                while(p>0 and s[p-1]!=' '){
                    swap(s[p], s[p-1]);
                    p--;
                }
            }else if(cmd == "delete word"){
                int ptr = p;
                while(ptr<len-1 and s[ptr+1]==' '){
                    ptr++;
                }
                int head = ptr;
                while(ptr<len-1 and s[ptr+1]!=' '){
                    ptr++;
                }
                if(head != ptr){
                    s.erase(s.begin()+p+1, s.begin()+ptr+1);
                }
            }else{
                string ins = cmd.substr(8, cmd.length()-9);
                s.insert(s.begin()+p, ins.begin(), ins.end());
                p += ins.length();
            }
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

namespace {

}

int main()
{
	set<int> paint;

	for (int i = 0; i < 3; ++i){
		int ptmp;
		cin >> ptmp;
		paint.insert(ptmp);
	}

	cout << paint.size() << endl;

	return 0;
}

Measured memory_bytes: 3580
n,m = map(int,input().split())
data = []
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    data.append((a,b))
data = sorted(data,key=lambda x:x[1])
cnt = 0
dis = -1
for i in range(m):
    a,b = data[i]
    if(dis < a):
        cnt += 1
        dis = b - 1
print(cnt)

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N = il();

  vector<ll> divisor_cnts(10000001, 2);
  divisor_cnts[1] = 1;
  // 1~10^7は全て1の倍数であり、2以上は全てその数自身の倍数でもあるので基本は初期値が2、1の約数だけ1個

  REP(i, 2, 5000001){
    // 10^7/2 までについて、その数の倍数に+1していく（これで約数の個数が入る）
    ll tmpi = i * 2; // i自身は初期化の時点で入れてあるので、x2から始める
    while(tmpi <= 10000000){
      divisor_cnts[tmpi]++;
      tmpi += i;
    }
  }
  

  ll ans = 0;
  REP(i, 1, N+1){
    ans += i * divisor_cnts[i];
  }

  cout << ans << endl;

  
}

Measured memory_bytes: 81428
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string a, b, c; cin >> a >> b >> c;
  cout << "A" << b[0] << "C" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n,a,b;
  cin >> n >> a >> b;
  long long int ans,p;
  p = n/(a+b);
  ans = p*a;
  p = n%(a+b);
  if(p < a) {
    ans += p;
  } else {
    ans += a; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

int n, m, q, ans;
vector<int> a, b, c, d, A;

int calc(){
    int ret = 0;
    rep(i, q){
        if(A[b[i]-1] - A[a[i]-1] == c[i]){
            ret += d[i];
        }
    }
    return ret;
}

void dfs(int depth, int x = 1){
    if (n == depth){
        ans = max(ans, calc());
        return;
    }
    for(int i = x; i <= m; ++i){
        A[depth] = i;
        dfs(depth + 1, i);
    }
}

signed main() {

    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    A.resize(n);
    rep(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(0);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


def solve(N: int, Y: int):
    for x in range(N+1):
        for y in range(N-x+1):
            z = N - x - y
            if 10_000 * x + 5_000 * y + 1_000 * z == Y:
                return x, y, z
    return -1, -1, -1


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    print(*solve(N, Y), sep=" ")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main(){
    string v = "aiueo";
    char c;
    cin >> c;
    int frg = 0;
    for(int i=0;i<5;i++){
        if(c==v[i])frg=1;
    }
    if(frg)cout << "vowel" << endl;
    else cout << "consonant" << endl;
}


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

int check(int h,int top,int ox,int x,int oy,int y);

int main(){
    int n;
    int x[100];
    int y[100];
    int h[100];
    int hmax = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> x[i] >> y[i] >> h[i];
        if(hmax < h[i]) hmax = h[i];
    }
    int flag = 0;
    for(int top = hmax;;top ++){
        for(int ox = 0;ox <= 100;ox ++){
            for(int oy = 0;oy <= 100;oy ++){
                flag = 1;
                for(int i = 0;i < n;i ++){
                    if(!check(h[i],top,ox,x[i],oy,y[i])){
                        flag = 0;
                        break;
                    }
                }
                if(flag){
                    cout << ox << " " << oy << " " << top << endl;
                    return 0;
                }
            }
        }
    }

    return 0;   
}

int check(int h,int top,int ox,int x,int oy,int y){
   int delx = ox > x ? ox - x : x - ox;
   int dely = oy > y ? oy - y : y - oy;
   int h_ = top - delx - dely;
   h_ = h_ < 0 ? 0 : h_;
   if(h == h_) return 1;
   return 0; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

char buf[5];

int main(){
    scanf("%s",buf);
    int ans=0;
    int cur=0;
    for(int i=0;i<3;i++){
        if (buf[i]=='S') cur=0;
        else cur++,ans=max(ans,cur);
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 1732
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 305;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int k;
string t;
char s[N] , rs[N];
int dp[N][N][N];

int solve(int l,int r,int k){
    if(dp[l][r][k] != -1)return dp[l][r][k];
    if(l > r)return 0;
    if(l == r)return dp[l][r][k] = 1;
    int answ = max(solve(l + 1 , r , k) , solve(l , r - 1 , k));
    if(s[l] == s[r]) answ = max(answ , 2 + solve(l + 1 , r - 1 , k));
    if(k) answ = max(answ , 2 + solve(l + 1 , r - 1 , k - 1));
    return dp[l][r][k] = answ;
}

int main(){
    cin>>t>>k;
    int n = (int)t.size();
    for(int i=1;i<=n;i++){
        s[i] = t[i - 1];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int h=0;h<=k;h++){
                dp[i][j][h] = -1;
            }
        }
    }
    cout<<solve(1 , n , k)<<endl;
    return 0;
}


Measured memory_bytes: 110464
#include "iostream"
#include "random"
#include "ctime"
#include "chrono"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"

using namespace std;


int main() {
	
	int H;
	const int W = 5;
	cin >> H;
	list<int>ret;
	while (H) {
		vector<vector<int>>v(H, vector<int>(W));
		int ans = 0;
		for (int i = H - 1; i >= 0; i--) {
			for (int j = 0; j < W; j++) {
				cin >> v[i][j];
			}
		}
		bool flag = true;
		while (flag) {
			//for (auto i : v) {
			//	for (auto j : i) {
			//		cout << j;
			//	}
			//	cout << endl;
			//}
			//cout << endl;
			flag = false;
			for (int i = 0; i < H; i++) {
				vector<int>num(10,0);
				for (int j = 0; j < W; j++) {
					num[v[i][j]]++;
				}
				for (int j = 1; j < 10; j++) {
					while (num[j] >= 3) {
						for (int k = 0; k <= W - num[j]; k++) {
							int cnt = 0;
							for (int l = k; l < k + num[j]; l++) {
								cnt += j == v[i][l];
							}
							if (cnt == num[j]) {
								flag = true;
								ans += j*num[j];
								for (int l = k; l < k + num[j]; l ++) {
									if (v[i][l] == j) {
										v[i][l] = 0;
									}
								}
							}
						}
						num[j]--;
					}
				}
			}
			for (int i = 1; i < H; i++) {
				for (int j = 0; j < W; j++){
					if (v[i][j]) {
						for (int k = i; k > 0; k--) {
							if (!v[k - 1][j]) {
								swap(v[k][j], v[k - 1][j]);
							}
						}
					}
				}
			}
		}
		ret.push_back(ans);
		cin >> H;
	}
	for (auto i : ret) {
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
 int main()
{	
lli n,i,j,a,b,count=0;
cin >> n >> a >> b;
j=(n)%(a+b);
i=(n)/(a+b);
count=(a*i);
if(j>=a){
	count=count+a;
}
else count=count+j;
cout << count << '\n';

return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

//#define int long long

using namespace std;

void Main()
{
	int N;
	cin >> N;
	vector<int> A(N, 0);
	vector<int> Asort(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		Asort[i] = A[i];
	}
	sort(Asort.begin(), Asort.end(), greater<int>());

	for (int i = 0; i < N; i++) {
		if (A[i] == Asort[0]) {
			cout << Asort[1] << endl;
		}
		else {
			cout << Asort[0] << endl;
		}
	}
}

int32_t main()
{
	Main();
	return 0;
}

/*
void sample()
{
	vector<int> v;
	sort(v.begin(), v.end());
	sort(v.begin(), v.end(), greater<int>());

}
*/



Measured memory_bytes: 3200
judge = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(int(input())):
    judge[input()] += 1
print("AC x " + str(judge["AC"]))
print("WA x " + str(judge["WA"]))
print("TLE x " + str(judge["TLE"]))
print("RE x " + str(judge["RE"]))

Measured memory_bytes: 9224
N,K = map(int,input().rstrip().split(" "))
p = list(map(int,input().rstrip().split(" ")))
karians = K
for i in range(K):
  karians += p[i]
ans = karians
for i in range(N - K):
  karians -= p[i]
  karians += p[i + K]
  if ans < karians:
    ans = karians
print(ans / 2)

Measured memory_bytes: 25060
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){

  int i,j,k,t,tmp;
  string s;
  int a,b,c;

  cin>>a>>b>>c;

  if(a+b==c||b+c==a||c+a==b) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

Measured memory_bytes: 764
# coding: utf-8
# Here your code !
import math
i = input()
count=0

def isPrime(x):
    global count
    if x == 2:
        return True
    if x>2 and x%2==0:
        return False
    i = 3
    while i<=math.sqrt(x):
        if x%i==0:
            return False
        i+=2
    return True

for j in range(int(i)):
    j=int(input())
    if isPrime(j):
        count+=1
print(count)

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

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

  vector<int> v(n), c(n);
  for(int i=0; i<n; ++i)cin>>v[i];
  for(int i=0; i<n; ++i)cin>>c[i];

  int ans=0;
  for(int i=0; i<n; ++i){
      if(v[i]-c[i]>0)ans+=v[i]-c[i];
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e18
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    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;
}

int main()
{
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
    A[i]--;
  }
  vector<ll> C(N);
  ll MAXC = -INF;
  REP(i, N){
    cin >> C[i];
  }
  
  ll MAX=-INF;
  REP(i,N){
    vector<ll> vec;
    int now = i;
    ll sum = 0;
    while(1){
      now=A[now];
      vec.push_back(C[now]);
      sum+=C[now];
      if(now==i) break;
    }

    ll nowscore=0;
    REP(j,sz(vec)){
      nowscore+=vec[j];
      ll t = nowscore;
      if(j+1>K) break;
      if(sum>0){
        t+=((K-(j+1))/sz(vec))*sum;
      }
      MAX=max(MAX,t);
    }
  }
  cout << MAX << endl;
}

Measured memory_bytes: 3784
using System;
using System.Linq;

class Solution
{
  static void Main()
  {
    int ans = 0;
    int N = int.Parse(Console.ReadLine());
    var V = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var C = Console.ReadLine().Split().Select(int.Parse).ToArray();
    for (int i = 0; i < N; i++)
    {
      if (C[i] < V[i])
      {
        ans += (V[i] - C[i]);
      }
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int r;
  cin >> r;
  cout << 3*r*r << endl;
}

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

using namespace std;

//Shortcut
#define long long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define X first
#define Y second
#define sz size
#define ft(i , a , b) for (long i = (long)a ; i <= (long)b ; i++)
#define fd(i , a , b) for (long i = (long)a ; i >= (long)b ; i--)
#define lt(i , a , b , c) for (long i = (long)a ; i <= (long)b ; i += (long)c)
#define ld(i , a , b , c) for (long i = (long)a ; i >= (long)b ; i -= (long)c)
#define pll pair <long , long>
#define pls pair <long , string>
#define vtl vector <long>
#define vts vector <string>
#define vtp vector <pll>
#define dql deque <long>
#define mll map <long , long>
#define prio priority_queue<pll , vector<pll > , greater<pll> >
#define pushpq(a , b) push({(long) a , (long) b})

//Variable
const long mxN = 1e3 + 5;
const long base = 311;
const long oo = 1e15;
const long MOD = 1e9 + 7;
const long d4i[4] = {-1 , 0 , 1 , 0} , d4j[4] = {0 , 1 , 0 , -1};
const long d8i[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1} , d8j[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1};

long TestCase;
long n , m , answer; 
long a[mxN][mxN] , dp[mxN][mxN];
bool mark[mxN][mxN];
char c;

long cal(int i , int j) {
    long &ans = dp[i][j];
    bool &tie = mark[i][j];

    if (i > n || j > m) return 0;
    if (i == n && j == m) return 1;
    if (tie) return ans;
    tie = true;

    if (a[i + 1][j]) ans += cal(i + 1 , j);
    if (a[i][j + 1]) ans += cal(i , j + 1);
    ans %= MOD;
    return ans;
}

void Solve() {
    cin >> n >> m;
    ft(i , 1 , n) {
        ft(j , 1 , m) {
            cin >> c;
            if (c == '.') a[i][j] = 1;
        }
    }
    answer = cal(1 , 1) % MOD;
    cout << answer;
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //cin >> TestCase;
    TestCase = 1;
    while(TestCase--)
        Solve();
    return 0;
}

Measured memory_bytes: 20416
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) void(0)
#endif

using namespace std;

template <class T>
struct range_assign {
  int n, trials;
  vector<pair<int, T>> t;
  range_assign(int _n = 0, T a = T{}) : n(_n), trials(0), t(2 * n, {-1, a}) {}
  void assign(int l, int r, T a) {
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) t[l++] = {trials, a};
      if (r & 1) t[--r] = {trials, a};
    }
    ++trials;
  }
  T get(int i) const {
    auto [last, res] = t[i += n];
    while (i >>= 1)
      if (t[i].first > last) tie(last, res) = t[i];
    return res;
  }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<int> a(h), b(h);
  for (int i = 0; i < h; ++i) {
    cin >> a[i] >> b[i];
    --a[i];
  }

#ifdef LOCAL
  vector v(h, vector<int>(w));
  for (int i = 0; i < h; ++i) fill(begin(v[i]) + a[i], begin(v[i]) + b[i], 1);
  DUMP(v);
#endif

  constexpr int inf = numeric_limits<int>::max() / 2;
  range_assign<int> seg(w);
  for (int j = 0; j < w; ++j) seg.assign(j, j + 1, -j);
  map<int, int> mp;
  multiset<int> ms{inf};
  auto add = [&](int j) {
    mp[j] = seg.get(j) + j;
    ms.insert(mp[j]);
  };
  add(0);

  for (int i = 0; i < h; ++i) {
    seg.assign(a[i], b[i], a[i] ? seg.get(a[i] - 1) : inf);
    for (auto it = mp.lower_bound(a[i]); it != end(mp) and it->first < b[i];) {
      assert(ms.find(it->second) != end(ms));
      ms.erase(ms.find(it->second));
      it = mp.erase(it);
    }
    if (b[i] < w and not mp.count(b[i])) {
      add(b[i]);
    }
    DUMP(mp);
    DUMP(ms);
    int res = *begin(ms);
    if (res == inf) {
      res = -1;
    } else {
      res += i + 1;
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 8404
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << 1 << endl;
    }else if(a != b && b != c && c != a){
        cout << 3 << endl;
    }else{
        cout << 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    //fastio
    string s,x;
    cin>>s>>x;
    ll cnt = 0;
    ll len = s.size();
    for(ll i=0;i<len;i++)
    {
        if(s[i]!=x[i]) cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
	int n,m; cin>>n>>m;
	vector<ii> v;
	if(n&1){
		fore(i,0,n) if(i+1<n-i) v.pb({i+1,n-i});
	}
	else{
		fore(i,0,n/2) if(i+1<n/2-i) v.pb({i+1,n/2-i});
		fore(i,0,n/2) if(i+1<n/2-i-1) v.pb({n/2+i+1,n/2+n/2-i-1});
	}
	fore(i,0,m)cout<<v[i].fst<<" "<<v[i].snd<<"\n";
}

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

A = list(map(int,input().split()))

if N % 2 == 0:

    e = 0
    o = 0
    

    for i in range(N):

        if i % 2 == 0:
            e += A[i]
        else:
            o += A[i]

    el = [0]
    ol = [0]

    for i in range(N):

        if i % 2 == 0:
            el.append(el[-1] + A[i])
        else:
            ol.append(ol[-1] + A[i])

    eri = [0]
    ori = [0]

    for i in range(N-1,-1,-1):

        if i % 2 == 0:
            eri.append(eri[-1] + A[i])
        else:
            ori.append(ori[-1] + A[i])

    ans = max(e,o)


    for i in range(N//2+1):
        ans = max(ans,el[i]+ori[N//2-i])
    print (ans)

else:

    el = [0]
    ol = [0]

    for i in range(N):

        if i % 2 == 0:
            el.append(el[-1] + A[i])
        else:
            ol.append(ol[-1] + A[i])

    eri = [0]
    ori = [0]

    for i in range(N-1,-1,-1):

        if i % 2 == 0:
            eri.append(eri[-1] + A[i])
        else:
            ori.append(ori[-1] + A[i])

    ans = float("-inf")



    LS = [0]
    LSM = [0]
    for i in range(0,N-1,2):

        LS.append(LS[-1] + A[i] - A[i+1])
        LSM.append(max(LSM[-1],LS[-1]))

    RS = [0]
    RSM = [0]
    for i in range(N-1,0,-2):

        RS.append(RS[-1] + A[i] - A[i-1])
        RSM.append(max(RSM[-1],RS[-1]))

    EOE = float("-inf")
    for i in range(N//2+1):
        EOE = max(EOE , LSM[i] + RSM[N//2-i])

    
    for i in range(N):

        if i <= N//2:

            ans = max(ans , el[i]+ori[N//2-i] , ol[i]+eri[N//2-i] , el[i]+eri[N//2-i] , ol[-1] + EOE)

    print (ans)

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

typedef long long ll;

const int D[10] = { 1, 10, 100, 1000, 10000, 100000, (int)1e6, (int)1e7, (int)1e8, (int)1e9 };

char question(ll n) {
	cout << "? " << n << endl;
	char rsp;
	cin >> rsp;
	return rsp;
}

int solve_pow(void) {
	int n = D[9];
	for (int i = 0; i <= 8; ++i) {
		ll m = 2LL * (ll)D[i];
		char rsp = question(m);
		if (rsp == 'Y') {
			n = D[i];
			break;
		}
	}
	return n;
}

int check_dig(void) {
	int k = 1;
	for (int i = 8; i >= 1; --i) {
		ll m = (ll)D[i];
		char rsp = question(m);
		if (rsp == 'Y') {
			k = i + 1;
			break;
		}
	}
	return k;
}

int solve_dig(void) {
	int k = check_dig();
	int r = D[k] - 1;
	int l = D[k - 1];
	int n;
	while (r - l > 1) {
		n = (l + r) / 2;
		char rsp = question((ll)n * 10);
		if (rsp == 'Y')
			r = n;
		else
			l = n;
	}
	return r;
}

int main(void) {
	int ans;

	char rsp = question((ll)D[9]);
	if (rsp == 'Y')
		ans = solve_pow();
	else
		ans = solve_dig();

	cout << "! " << ans << endl;
	return 0;
}


Measured memory_bytes: 596
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^63.
// NOTE: This function does not handle error cases.
// Verified: ARC096D
fun fastReadLongs(n: Int): LongArray {
  val xs = LongArray(n)
  val s = readLine()!!
  var currentValue = 0L
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
  return xs
}


fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = fastReadLongs(n).withIndex().map { it.value - it.index - 1 }.sorted()
  val m = xs[n / 2]
  val ans = xs.map { Math.abs(it - m) }.sum()
  println(ans)
}


Measured memory_bytes: 63332
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def func():
    global a,q,ans
    res = 0
    for x in q:
        if a[x[1]-1]-a[x[0]-1]==x[2]:
            res += x[3]
    ans = max(ans,res)
    return

def dfs(pos):
    global a,n,m
    if pos==n:
        return func()
    for i in range(max(1,a[pos-1]),m+1):
        a[pos] = i
        dfs(pos+1)

def main():
    global a,n,m,Q,q,ans
    n,m,Q = readInt()
    q = []
    for i in range(Q):
        q.append(readInt())
    ans = 0
    a = [0 for i in range(n)]
    dfs(0)
    print(ans)
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 9240
/*
    author: Salam_35
    Created at :

*/

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

// /*        speed up       */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define ll double
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    
    ll a,b,v,w,t;
    cin>> a >> v >>  b >> w >> t;
    
    //if(a>b)swap(a,b);
    ll dif=(abs(b-a));
    //if(v==w and a!=b)return cout<<"NO"<<endl,0;
    ll x=(v*dif)/(v-w);
    ll T=x/v;
    if(T<=t and x>0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
/*
         remember:
         ll vs int
         array size
         case for 1 2 3 
*/


Measured memory_bytes: 3756
import java.util.Scanner;

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

        int n = sc.nextInt();

        int array[][] = new int[4][13];

        for(int i = 0; i < n; i++){
            String mark = sc.next();
            int num = sc.nextInt();

            if(mark.equals("S")){
                array[0][num - 1] = num;
            }else if(mark.equals("H")){
                array[1][num - 1] = num;
            }else if(mark.equals("C")){
                array[2][num - 1] = num;
            }else{
                array[3][num - 1] = num;
            }
        }

        String mk = "";
        for(int i = 0; i < 4; i++){
            switch(i){
                case 0:
                    mk = "S";
                    break;
                case 1:
                    mk = "H";
                    break;
                case 2:
                    mk = "C";
                    break;
                case 3:
                    mk = "D";
                    break;
            }
            for(int j = 0; j < 13; j++){
                if(array[i][j] == 0){
                    int number = j + 1;
                    System.out.println(mk + " " + number);
                }
            }
        }
    }
}


Measured memory_bytes: 26264
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  while(cin >> a >> b){
      int sum = a + b;
      int digit = 0;
      while(sum != 0){
        sum /= 10;
        digit++;
      }
      cout << digit << "\n";
  }

  return 0;
}



Measured memory_bytes: 3024
// Indrajeet Mishra
 
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)
 
ll dp[101][101];
void dp_initialiser(){
    memset(dp,-1,sizeof(dp));
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    dp_initialiser();
    string s;cin>>s;
    ll count=0,max=0;
    rep(i,0,s.size()){
        if(s[i]=='R')count++;
        if(count>max)max=count;
        if(s[i]=='S')count=0;
    }
    cout<<max;
    return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

bool ari[10005] = {};
int main()
{
	int n, k, m;
	while (cin >> n >> k >> m, n)
	{

		FOR(i, 1, n + 1) ari[i] = true;
		int cnt = n;
		int t = m;
		while (cnt > 1)
		{
			ari[m] = false;
			cnt--;
			int cnttmp = 0;

			for (int i = 0; cnttmp < (k%cnt ? k%cnt:k); i++)
			{
				m++;
				if (m == n + 1) m = 1;
				if (ari[m] == true) cnttmp++;
			}
		}

		REP(i, n + 1)
		{
			if (ari[i] == true) cout << i << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1168
N, K = map(int, input().split())
A = list(map(int, input().split()))
total = 1
for i in range(K):
    total += A[i]
before = total
for i in range(K, N):
    total -= A[i-K]
    total += A[i]
    if total > before:
        print('Yes')
    else:
        print('No')
    before = total

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

const int MAXN = 105;
int sum, n, a[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	for (int i=0; i<n; i++) {
		cin>>a[i];
		sum += a[i];
	}
	
	int ans = sum;
	for (int i=0, lhalf=0; i<n; i++) {
		lhalf += a[i];
		ans = min(abs(sum-2*lhalf), ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
a=input()
b=input()
c=input()
d=input()
e=input()
k=input()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
e=int(e)
k=int(k)

if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and  e-d<=k:
    print("Yay!")
else:
    print(":(")

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

typedef long long ll;
typedef pair<ll,ll> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    P d[N];
    priority_queue<ll> que[N];
    for(int i=0;i<N;i++){
        ll x,y; cin >> x >> y;
        d[i]={x,y};
    }
    ll ans=0;
    ll f[N];
    ll g[N];
    for(int i=0;i<N;i++){
        f[i]=d[i].first-d[i].second;
        g[i]=d[i].first+d[i].second;
    }
    sort(f,f+N);
    sort(g,g+N);
    ans=max(f[N-1]-f[0],g[N-1]-g[0]);
    cout << ans << endl;
}   

Measured memory_bytes: 16124
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N, 0);
    for(int i=0; i<N; i++) cin >> A[i];
    if(A[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    for(int i=0; i<N-1; i++)
        if(A[i] + 1 < A[i+1]){
            cout << -1 << endl;
            return 0;
        }

    long long ans = A[N-1];
    for(int i=N-2; i>=0; i--){
        if(A[i] == 0) continue;
        if(A[i+1] == A[i] + 1) continue;
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
	int sec,h,m,s;
	cin >> sec;
	h = sec / 3600;
	m = (sec % 3600) / 60;
	s= (sec % 3600) % 60;
	cout << h <<":"<< m  << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<functional>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef string::const_iterator State;
int Factor(State& begin);

int numParse(State& begin){
    int tmp=0;
    bool f=false;
    if(*begin=='-')f=true;
    while(isdigit(*begin)){
        tmp*=10;
        tmp+=*begin-'0';
        begin++;
    }
    if(*begin=='=')begin++;
    return f ? -tmp:tmp;
}
int MulDiv(State& begin){
    int tmp=Factor(begin);
    while(1){
        if(*begin=='*'){
            begin++;
            tmp *= Factor(begin);
        }else if(*begin=='/'){
            begin++;
            tmp /= Factor(begin);
        }else{
            break;
        }
    }
    return tmp;
}

int AddSub(State& begin){
    int tmp=MulDiv(begin);
    while(1){
        if(*begin=='+'){
            begin++;
            tmp+=MulDiv(begin);
        }else if(*begin=='-'){
            begin++;
            tmp-=MulDiv(begin);
        }else {
            break;
        }
    }
    return tmp;
}

int Factor(State& begin){
    if(*begin=='('){
        begin++;
        int tmp=AddSub(begin);
        begin++;
        if(*begin=='=')begin++;
        return tmp;
    }else{
        return numParse(begin);
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s2;
        cin>>s2;
        string s1="0";
        if(s2[0]!='-')s1+="+";
        string s=s1+s2;
        State begin=s.begin();
        int ans=AddSub(begin);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2984
n,m,x=map(int,input().split())
a=[[0 for j in range(m)] for i in range(n)]
c=[0]*n
for i in range(n):
    tmp=list(map(int,input().split()))
    c[i]=tmp[0]
    for j in range(m):
        a[i][j]=tmp[j+1]
#use bitmask to generate all subsets
ans=float('inf')
for mask in range(1<<n):
    tmp=[0]*m
    cost=0
    for i in range(n):
        if (mask>>i)&1:
            cost+=c[i]
            for j in range(m):
                tmp[j]+=a[i][j]
    flag=True
    for i in range(m):
        if tmp[i]<x:
            flag=False
            break
    if flag:
        ans=min(ans,cost)
print(ans) if ans!=float('inf') else print(-1)
            



Measured memory_bytes: 9220