akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define llint long long
#define inf 1e18

using namespace std;

llint n;
llint a[505][505];
llint sum[505][505];
llint dp[505][505][505];

llint get(llint sx, llint sy, llint tx, llint ty)
{
	if(sx > tx || sy > ty) return 0;
	return sum[tx][ty] - sum[sx-1][ty] - sum[tx][sy-1] + sum[sx-1][sy-1];
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i == j) continue;
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			sum[i][j] = sum[i][j-1] + sum[i-1][j] - sum[i-1][j-1] + a[i][j];
		}
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= n; k++){
				dp[i][j][k] = inf;
			}
		}
	}
	dp[1][0][0] = 0;
	
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= n; k++){
				dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k] + get(j+1, i+1, i, i+1) + get(i+1, 1, i+1, k) );
				dp[i+1][i][j] = min(dp[i+1][i][j], dp[i][j][k] + get(i+1, 1, i+1, j) );
			}
		}
	}
	
	llint ans = inf;
	for(int j = 0; j <= n; j++){
		for(int k = 0; k <= n; k++){
			ans = min(ans, dp[n][j][k]);
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1002240
c=[list(map(int,input().split())) for _ in range(3)]
b1=c[0][0]
b2=c[0][1]
b3=c[0][2]
a2=c[1][0]-b1
a3=c[2][0]-b1
f=True
if a2+b2!=c[1][1]:f=False
if a2+b3!=c[1][2]:f=False
if a3+b2!=c[2][1]:f=False
if a3+b3!=c[2][2]:f=False
if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#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<ll>
#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(){
	int n, w;
	cin>>n>>w;
	vector<pi> vec;
	FOR0(i, n){
		ll x,v;
		cin>>x>>v;
		vec.push_back({x,v});
	}

	vector< vector<ll> > dp(n+1, vector<ll> (w+1));
	FOR0(i, w+1)
		dp[0][i] = 0;

	FOR1(i, n){
		FOR0(j, w+1){
			if(j-vec[i-1].first >= 0)
				dp[i][j-vec[i-1].first] = max(dp[i-1][j-vec[i-1].first], dp[i-1][j]+vec[i-1].second);
			dp[i][j] = max(dp[i-1][j], dp[i][j]);
		}
	}

	ll maxval = 0;
	FOR0(i, w+1)
		maxval = max(maxval, dp[n][i]);
	cout<<maxval<<"\n";
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;


int main() {
    cin>>N;
    if(N-1){
        ll ans=IN()+IN();
        cout << ans <<"\n";
    }else{
        cout << "Hello World" <<"\n";
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,a,b;
    cin >> n >> a >> b;
    if(n < a + b - 1 || a * b < n){
        ANS(-1);
        return 0;
    }
    FORR(i,b,1){
        cout << i << " ";
    }
    int32 remain = n - b;
    FORR(i,a-1,1){
        int32 l = remain / i;
        remain -= l;
        REP(j,l)cout << n - remain - j << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
 const double PI = 3.141592653589;
 double r;
 double area, circle;
 cin >> r;
 area = r * r * PI;
 circle = 2 * r * PI;
 cout << fixed << setprecision(5) << area << " " << circle << endl;
}


Measured memory_bytes: 3284
from heapq import heapify, heappop, heappush

N, M = map(int, input().split())
A = [-1*int(i) for i in input().split()]
heapify(A)

for i in range(M):
    n = -1 * heappop(A)
    heappush(A, -1*(n//2))

print(-1*sum(A))


Measured memory_bytes: 14380
#include<iostream>
using namespace std;
long long Mode(long long a,long long b)
    {
        long long sum=1;
        a=a;
        while(b>0)
        {
            if(b%2==1)
            sum=sum*a;
            b/=2;
            a=a*a;
        }
        return sum;
    }
int main()
{
    long long N,K;
    cin>>N>>K;
    cout<<K*Mode(K-1,N-1);
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] ar = new int[n];
            for (int i = 0; i < n; i++)
                ar[i] = in.nextInt();
            int[] dp = new int[n];
            dp[1] = Math.abs(ar[1] - ar[0]);
            for (int i = 2; i < n; i++)
                dp[i] = Math.min(dp[i - 1] + Math.abs(ar[i] - ar[i - 1]), dp[i - 2] + Math.abs(ar[i] - ar[i - 2]));
            out.println(dp[n - 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 32336
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var SkewHeapNode = function SkewHeapNode(val) {
  _classCallCheck(this, SkewHeapNode);

  this.left = null;
  this.right = null;
  this.value = val;
};

function meld(a, b, comp) {
  if (!(a && b)) return a || b;
  if (comp(a.value, b.value)) {
    ;
    var _ref = [b, a];
    a = _ref[0];
    b = _ref[1];
  }a.right = meld(a.right, b, comp);
  var _ref2 = [a.right, a.left];
  a.left = _ref2[0];
  a.right = _ref2[1];

  return a;
}

var SkewHeap = (function () {
  function SkewHeap(comp) {
    _classCallCheck(this, SkewHeap);

    this.comp = comp || function (a, b) {
      return a < b;
    };
    this.root = null;
  }

  _createClass(SkewHeap, [{
    key: "push",
    value: function push(val) {
      this.root = meld(this.root, new SkewHeapNode(val), this.comp);
      return this;
    }
  }, {
    key: "pop",
    value: function pop() {
      if (!this.root) return null;
      var ret = this.root;
      this.root = meld(this.root.right, this.root.left, this.comp);
      return ret.value;
    }
  }, {
    key: "merge",
    value: function merge(other) {
      this.root = meld(this.root, other.root, this.comp);
      return this;
    }
  }, {
    key: "empty",
    value: function empty() {
      return !!this.root;
    }
  }]);

  return SkewHeap;
})();

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

(function solve(lines){
  var pq = new SkewHeap();
  lines.forEach(function(line){
    words = line.split(" ");
    if(words[0] === "insert"){
      pq.push(parseInt(words[1]));
    }else if(words[0] === "extract"){
      console.log(pq.pop());
    }
  });
})(lines);

Measured memory_bytes: 223572
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll myCeil(ll x, ll y){
  ll ans = x/y;
  if(x%y>0) ans++;
  return ans;
}

ll get_gcd(ll x, ll y){
  ll rest=1;
  while(rest>0){
    x %= y; rest = x;
    if(x<y) swap(x,y);
  }
  return x;
}

ll get_lcm(ll x, ll y){
  ll gcd = get_gcd(x,y);
  ll lcm = x*y/gcd;
  //cout << "gcd = " << gcd << ", lcm = " << lcm << "\n";
  return lcm;
}

int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  // c
  ll init_c = myCeil(a,c); ll end_c  = b/c; ll ans_c = end_c - init_c + 1;
  // d
  ll init_d = myCeil(a,d); ll end_d  = b/d; ll ans_d = end_d - init_d + 1;
  // LCM(c,d)
  ll lcm = get_lcm(c,d);
  ll init_lcm = myCeil(a,lcm); ll end_lcm  = b/lcm; 
  ll ans_lcm = end_lcm - init_lcm + 1;
  ll ans = (b-a+1) - ans_c - ans_d + ans_lcm;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let _: usize = read!();
    let s: String = read!();
    let s = s.chars();
    let r = s.clone().filter(|&c| c == 'R').count();
    let b = s.filter(|&c| c == 'B').count();
    let ans = if r > b { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 2160
N, M = map(int, input().split())
KS = [list(map(int, input().split())) for i in range(M)]
P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    switches = bin(i)[2:].zfill(N)
    all_light_on = True
    for j in range(M):
        _, *S = KS[j]
        on = 0
        for k, s in enumerate(switches, 1):
            if s == '1' and k in S:
                on += 1
        if on % 2 == P[j]:
            continue
        else:
            all_light_on = False
            break
    if all_light_on:
        ans += 1
print(ans)

Measured memory_bytes: 9128
io = STDIN
H,W=io.gets.split.map(&:to_i)
$ans=[]
$masu=[Array.new(W+1)]
def move(i,j)
  if $masu[i][j].odd?
    if j<W
      $masu[i][j]-=1
      $masu[i][j+1]+=1
      $ans <<  [i,j,i,j+1]
    else
      if i<H
        $masu[i][j]-=1
        $masu[i+1][j]+=1
        $ans << [i,j,i+1,j]
      end
    end
  end
end
H.times do |rno|
  $masu << [nil,io.gets.split.map(&:to_i)].flatten
end
(1..H).each do |i|
  (1..W).each do |j|
    move(i,j)
  end
end
puts $ans.size
$ans.each do |ar|
  puts ar.join(" ")
end


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

long long int arr1[1000000],arr2[1000000];


int main()
{
    long long int n,z,j,k,i,u,m,A2,C0,C1,e;
    double a,A1;
    while(scanf("%lld",&z)==1)
    {
        n=z%1000000007;

        for(i=0,C0=0,C1=0; i<n; i++)
        {
            scanf("%lld",&arr1[i]);
            if(arr1[i]==0){C0++;}
             if(arr1[i]==1){C1++;}

        }
        if(n%2==0 && (C1>2 || C1<2)){printf("0\n");}
         else if(n%2==1 && (C0>1 || C0<1)){printf("0\n");}

        else
        {

            for(e=0,A2=1;e<n/2;e++)
            {
                A2=(A2%1000000007)*(2%1000000007);
            }
            printf("%lld\n",A2%1000000007);


        }
    }
    return 0;

}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>
#include <map>
#include <set>
#include <bitset>

#define forin(i, f, t) for(ll i = f; i < t; i++)

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using Pair = pair<ll, ll>;

int divisor[201];

int main() {
    int a, b;
    cin >> a >> b;
    
    cout << (a - 1) * (b - 1) << endl;
    
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N int
	fmt.Scan(&N)
	var K int
	fmt.Scan(&K)
	var S string
	fmt.Scan(&S)
	ary := strings.Split(S, "")

	firstHappy := 0
	for i := 0; i < N-1; i++ {
		if ary[i] == ary[i+1] {
			firstHappy++
		}
	}
	ret := firstHappy + 2*K
	if (N - 1) < ret {
		ret = N - 1
	}
	fmt.Println(ret)
}


Measured memory_bytes: 2944
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X==500*i+100*j+50*k:
                ans+=1
            else:
                pass

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

ll INF = 1000000007;

int main() {
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i, n - 1) {
		int k;
		cin >> k;
		mp[k]++;
	}
	rep(i, n) {
		cout << mp[i+1] << endl;
	}
}

Measured memory_bytes: 13004
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}


signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    intl len = s.length();
    if(len < 26){
        bool f[26];
        m0(f);
        rep(i,len)f[s[i] - 'a'] = true;
        rep(i,26){
            if(!f[i]){
                s += (char)(i + 'a');
                break;
            }
        }
    }
    else{
        vector<char> v;
        rep(i,len)v.pb(s[i]);
        next_permutation(all(v));
        string t = "";
        rep(i,26){
            t += v[i];
            if(s[i] != v[i])break;
        }
        s = t;
        if(s == "a")s = "-1";
    }
    cout << s << endl;
    return 0;
}


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

int main()
{
	while (1){
		int n, m, sum = 0;
		cin >> n >> m;

		if (n == 0 && m == 0){ break; }
		else{
			int a[10000];
			int b[10000];
			int fri1[500];
			int fri2[500];

			for (int i = 0; i < m; i++){
				int ai, bi;
				cin >> ai >> bi;
				a[i] = ai - 2;
				b[i] = bi - 2;
			}

			for (int i = 0; i < n - 1; i++){
				fri1[i] = 0;
				fri2[i] = 0;
			}

			for (int i = 0; i < m; i++){
				if (a[i] == -1){ fri1[b[i]] = 1; }
				if (b[i] == -1){ fri1[a[i]] = 1; }
			}

			for (int i = 0; i < n - 1; i++){
				if (fri1[i]){
					for (int j = 0; j < m; j++){
						if (a[j] == i){ fri2[b[j]] = 1; }
						if (b[j] == i){ fri2[a[j]] = 1; }
					}
				}
			}

			for (int i = 0; i < n - 1; i++){
				if (fri1[i] == 1){ fri2[i] = 1; }
			}

			for (int i = 0; i < n - 1; i++){ sum += fri2[i]; }

			cout << sum << endl;	
		}
	}

	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    ll a,b;
    scanf("%lld%lld",&a,&b);

    if(b<0){
        if((b-a)%2==1){
            puts("Positive");
        }else{
            puts("Negative");
        }
    }else if(0<a){
        puts("Positive");
    }else{
        puts("Zero");
    }

    return 0;
}
 
 


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

#define pi 3.14159265358979323846264338

int main() {
    double a, b, h, m, x;
    cin >> a >> b >> h >> m;
    double c = 11.0/360.0*(60*h+m)*pi;
    x = sqrt(a * a + b * b - 2 * a * b * cos(c));
    cout << fixed << setprecision(20) << x << endl;
    return 0;
}

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

int main(){
  string s;
  long long t=0,u=0;
  cin >> s;
  for(long long i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]=='0'){
        u++;
      }else{
        t++;
      }
    }else{
      if(s[i]=='0'){
        t++;
      }else{
        u++;
      }
    }
  }
  cout << s.size() - max(t,u) << endl;
  return 0;
}

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

int a,b, c, d, r;

int main(){

    scanf("%d %d %d", &a, &b, &c);
    d= a-b;
    if(c-d>=0)r = c-d;
    else r=0;
    printf("%d\n", r);
}


Measured memory_bytes: 384
import java.util.*;
import java.math.*;

public class Main {

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

    String ans = "";

    for (int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '0') {
        ans += "0";
      }

      if (s.charAt(i) == '1') {
        ans += "1";
      }

      if (s.charAt(i) == 'B') {
        if (ans.length() > 0) {
          ans = ans.substring(0,ans.length()-1);
        }
      }
    }

    System.out.println(ans);

  }

}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
# include <bits/stdc++.h>
using namespace std;
long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  
int main()
{
  
  int flag=1;
  ll sum=0;
  int flag1=0;
  ll tot=0;
  int ans=0;
  map<int,int>mp;
  vi v;
  set<int>st;
  string str;
  scii(s,w);
  if(w>=s) cout<<"unsafe";
  else cout<<"safe";


  
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
/*#ifndef LOCAL_RUN
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("fast-math")
    #pragma GCC target("avx2,tune=native")
#endif*/
#define X first
#define Y second
using namespace std;

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

const int N = 1e5 + 228;

ll dp[101][N], g[101], c[101];

int main()
{
    #ifdef LOCAL_RUN
        freopen("input.txt", "r", stdin);
    //#else
        //freopen("tickets.in", "r", stdin);
        //freopen("tickets.out", "w", stdout);
    #endif
	ios::sync_with_stdio(false);
    cin.tie(0);

    int n, w;
    cin >> n >> w;
    for (int i = 1; i <= n; i++)
        cin >> g[i] >> c[i];
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= w; j++) {
            dp[i][j] = dp[i-1][j];
            if (j >= g[i])
                dp[i][j] = max(dp[i][j], dp[i-1][j-g[i]] + c[i]);
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans;

    return 0;
}

// 272472LF


Measured memory_bytes: 81884
#include <bits/stdc++.h>
        using namespace std;
        #define rep(i,a,b) for(int i =a; i<b;++i)
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define endl "\n"
        typedef  long long  unsigned int ll;
        const int N = 2e5+3;
        const int mod = 1e9+7;
        ll n,m,a,b;
    int  main()
    {
        IOS;
        int t = 1;
      //  cin>>t;
        while(t--)
        {
            cin>>n>>m>>a>>b;
            rep(i,0,n)
            {
                rep(j,0,m)
                {
                    int x = (i<b) ^(j<a);
                    cout<<x;
                }
                cout<<endl;
            }
        }
    }


Measured memory_bytes: 1280
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----

-- returns (b^n) % m
local function modpow(b, n, m)
    if n == 0 then
        return 1
    elseif n % 2 == 0 then
        -- be careful about overflow of b*b
        return modpow(b * b % m, n//2, m)
    else
        return b * modpow(b, n - 1, m) % m
    end
end

-- returns n! % m
local function modfactorial(n, m)
    local a = 1
    for i=1, n do
        a = a * i % m
    end
    return a
end

local function make_mod_nCr(nmax, m)
    -- Create n! table
    local mfac = {}
    mfac[0] = 1
    for i=1,nmax do
        mfac[i] = mfac[i-1] * i % m
    end
    -- Create (n!)^(-1) table
    -- (n!)^(-1) ≡ (n!)^(m - 2)  <mod m>
    local invmfac = {}
    invmfac[nmax] = modpow(mfac[nmax], m - 2, m)
    for i=nmax,1,-1 do
        -- ((a-1)!)^(-1) ≡ a * (a!)^(-1)  <mod m>
        invmfac[i-1] = i * invmfac[i] % m
    end
    -- returns nCr % m
    local function mod_nCr(n, r)
        -- nCr ≡ n! * (r!)^(-1) * ((n-r)!)^(-1)  <mod m>
        local a = mfac[n] * invmfac[r] % m
        a = a * invmfac[n-r] % m
        return a
    end
    return mod_nCr
end

-- larger n and small r
local function make_mod_nCr_2(rmax, m)
    -- Create n! table
    local mfac = {}
    mfac[0] = 1
    for i=1,rmax do
        mfac[i] = mfac[i-1] * i % m
    end
    -- Create (n!)^(-1) table
    -- (n!)^(-1) ≡ (n!)^(m - 2)  <mod m>
    local invmfac = {}
    invmfac[rmax] = modpow(mfac[rmax], m - 2, m)
    for i=rmax,1,-1 do
        -- ((a-1)!)^(-1) ≡ a * (a!)^(-1)  <mod m>
        invmfac[i-1] = i * invmfac[i] % m
    end
    -- returns nCr % m
    local function mod_nCr(n, r)
        if r > n then
            return 0
        end
        if r > n/2 then
            r = n - r
        end
        -- nCr ≡ (n * (n - 1) * ... * (n-r+1)) * (r!)^(-1)  <mod m>
        local a = 1
        for i=n, n-r+1, -1 do
            a = (a * i) % m
        end
        a = a * invmfac[r] % m
        return a
    end
    return mod_nCr
end


---------------------------------------
local MOD = math.floor(10^9)+7
----
local n, a, b = read.nnn()
local S = modpow(2, n, MOD) - 1
local rmax = math.max(a, b)
local mod_nCr = make_mod_nCr_2(rmax, MOD)
local NGa = mod_nCr(n, a)
local NGb = mod_nCr(n, b)
local ans = (S - NGa - NGb) % MOD
print(ans)

Measured memory_bytes: 12648
n,*a=`dd`.split.map &:to_i;a.sort!
r=0
b=[0]+n.times.map{|j|a[j]*(-1)**j%24}
s=24
n.times{|j|(j+1..n).each{|k|s=[s,(b[j]-b[k])%24,(b[k]-b[j])%24].min}}
r=[r,s].max
p r

Measured memory_bytes: 4092
#include <iostream>
#include <algorithm>

#define rep(i,n) for(int i=0;i!=(n);++i)

using namespace std;

typedef long long ll;

int num=1000001;


int main(){
    int N;
    scanf("%d",&N);

    int A[N];
    
    int B[num];
    rep(i,num)B[i]=0; 
    int count=0;

    rep(i,N) {
        scanf("%d",A+i);
    } 
    sort(A,A+N);

    rep(i,N){
        int a=A[i];
        if(B[a]!=0){
            B[a]+=1;
        }else{
            for(int j=a;j<=num;j+=a){
                B[j]+=1;
            }
        }
    }

    for(int i=0;i!=N;++i){
        int a=A[i];
        if(B[a]<=1){
            ++count;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 8324
#include <algorithm>
#include <cstdio>
#include <vector>

const int N = 2000;

int n, m, a[N][N], h[N + 1], left[N + 1], right[N + 1];
char buf[N];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i) {
        scanf("%s", buf);
        for (int j = 0; j < m; ++ j) {
            a[i][j] = buf[j] == '#';
        }
    }
    int result = n;
    for (int i = 0; i < n; ++ i) {
        if (!i) {
            for (int j = 1; j < m; ++ j) {
                h[j] = 1;
            }
        } else {
            for (int j = 1; j < m; ++ j) {
                if ((a[i][j - 1] ^ a[i][j]) == (a[i - 1][j - 1] ^ a[i - 1][j])) {
                    h[j] ++;
                } else {
                    h[j] = 1;
                }
            }
        }
        h[0] = h[m] = -1;
        std::vector<int> stack;
        stack.push_back(0);
        for (int j = 1; j < m; ++ j) {
            while (h[stack.back()] >= h[j]) {
                stack.pop_back();
            }
            left[j] = stack.back();
            stack.push_back(j);
        }
        stack.clear();
        stack.push_back(m);
        for (int j = m - 1; j >= 1; -- j) {
            while (h[stack.back()] >= h[j]) {
                stack.pop_back();
            }
            int right = stack.back();
            stack.push_back(j);
            result = std::max(result, h[j] * (right - left[j]));
        }
    }
    printf("%d\n", result);
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

bool check(int num){
	string snum=to_string(num);
	int m=snum.size();
	rep(i,m/2) if(snum[i]!=snum[m-1-i]) return false;
	return true;
}

int main(void){
	int n;
	cin >> n;
	int ans=-1,diff=inf;
	rep(i,10002){
		if(check(i)==false) continue;
		if(abs(i-n)<diff) diff=abs(i-n),ans=i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
bool flag,dame;

void dfs(ll node,ll color){
	//p(node);
	x[node] = color;
	for(int i=0;i<tree[node].size();i++){
		P p = tree[node][i];
		ll length = p.second;
		ll nextnode = p.first;
		if(x[nextnode] != 0)continue;
		if(length % 2 == 0){
			dfs(nextnode,color);
		}else{
			dfs(nextnode,3-color);
		}
	}
	return ;
}



int main(){
	cin >> n;
	for(i=0;i<n-1;i++){
		cin >> a >> b >> c;
		tree[a].pb(P(b,c));
		tree[b].pb(P(a,c));
	}
	dfs(1,1);
	for(i=1;i<=n;i++){
		p(x[i]-1);
	}
	return 0;
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int N, Q;
vector<ll> A;
vector<ll> cumsum, esum;
void solve(){
	int x;
	cin >> x;

	int lb = 0, ub = (N+1)/2;
	while(ub-lb>1){
		int k = (ub+lb)/2;
		int l = max(0, N-1-2*k);
		//debug(x, k, lb, ub, l, abs(x-A[N-1-k]), abs(x-A[l]));
		if(abs(x-A[N-1-k])<abs(x-A[l])){
			ub = k;
		} else {
			lb = k;
		}
		//debug(lb, ub);
	}
	debug(x, ub);

	ll ans = cumsum[N-1]-cumsum[N-1-ub];
	if(N%2){
		if(N-1-2*ub>=0) ans += esum[N-1-2*ub];
	} else {
		if(N-1-2*ub>=1) ans += cumsum[N-1-2*ub]-esum[N-2-2*ub];
	}
	cout << ans << endl;
}


int main(){
	cin >> N >> Q;
	A.assign(N, 0);
	for(int i=0; i<N; i++) cin >> A[i];

	cumsum.assign(N, 0);
	esum.assign(N, 0);
	cumsum[0] = A[0];
	esum[0] = A[0];
	for(int i=1; i<N; i++){
		cumsum[i] = cumsum[i-1]+A[i];
		esum[i] = esum[i-1] + (i%2?0:A[i]);
	}
	for(int q=0; q<Q; q++) solve();

	return 0;
}


Measured memory_bytes: 4096
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    nt = 200000
    n = int(input())
    xy = np.empty((2, n))
    for i in range(n):
        x, y = map(int, input().split())
        xy[:, i] = [x, y]
    x_rot = np.zeros((nt, n))
    thetas = np.linspace(0, 2.0 * np.pi, nt, endpoint=False)
    cnt = [0 for i in range(n)]
    for i in range(n):
        x_rot[:, i] = xy[0, i] * np.cos(thetas) - xy[1, i] * np.sin(thetas)
    am = np.argmax(x_rot, axis=1)
    for t in range(nt):
        cnt[am[t]] += 1
    for i in range(n):
        print("%.10f" % (cnt[i] / nt))

main()


Measured memory_bytes: 174716
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');
                int h = int.Parse(s[0]);
                int w = int.Parse(s[1]);
                if (h == 0 && w == 0)
                {
                    break;
                }
                for (int i = 0; i < h; i++)
                {
                    if (i % 2 == 0)
                    {
                        for (int j = 0; j < w; j++)
                        {
                            if (j % 2 == 0)
                            {
                                Console.Write("#");
                            }
                            else
                            {
                                Console.Write(".");
                            }
                        }
                    }
                    else if (i % 2 == 1)
                    {
                        for (int j = 0; j < w; j++)
                        {

                            if (j % 2 == 1)
                            {
                                Console.Write("#");
                            }
                            else
                            {
                                Console.Write(".");
                            }
                        }
                    }
                    Console.WriteLine("");
                }

                Console.WriteLine("");
            }
        }
    }
}

Measured memory_bytes: 8788
import math
import sys
from collections import Counter
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])

#print(a,b)

arr_list=[]
for i in range(1,10):
    
    for j in range(0,10):
        
            for k in range(0,10):
                
                arr_list.append(int(str(i)+str(j)+str(k)+str(j)+str(i)))
                
                
arr2 = list(filter(lambda x : x >= a and x<=b, arr_list))

print(len(arr2))

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

using namespace std;

int R, S, P;

int tokuten(char t){
  if(t == 'r') return R;
  if(t == 's') return S;
  if(t == 'p') return P;
}

char kachite(char t){
  if(t == 'r') return 'p';
  if(t == 's') return 'r';
  if(t == 'p') return 's';
}

string dasute(int R, int S, int P){
  int a[] = {R, S, P};
  int m;
  string s = {"rsp"};
  char c;
/*
  for(int i=0; i<2; i++){
    for(int j=0; j<2; j++){
      if(a[j]>a[j+1]){
        m=a[j];
        c=s[j];
        a[j]=a[j+1];
        s[j]=s[j+1];
        a[j+1]=m;
        s[j+1]=c;
      }
    }
  }
*/
  return s;
}

int main(void){

  int N, K;
  int x = 0;
  string T;
  string te, l;

  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  l = dasute(R, S, P);

  for(int i=0; i<N; i++){
    if(i<K || kachite(T[i])!=te[i-K]){
      te+=kachite(T[i]);
      x+=tokuten(te[i]);
    }
    else{
      for(int j=0; j<3; j++){
        if(l[j]!=te[i-K] && l[j]!=kachite(T[i+K])){
          te+=l[j];
          break;
        }
      }
    }
  }
  cout << x << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, M;
    cin >> N >> M;
    vll S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];

    vvvvll dp(N, vvvll(M, vvll(2, vll(2, 0))));
    rep(i, N) dp[i][0][0][0] = 1;
    rep(i, M) dp[0][i][0][0] = 1;
    rep(i, N) dp[i][0][1][1] = S[i]==T[0]? 1 : 0;
    rep(i, M) dp[0][i][1][1] = S[0]==T[i]? 1 : 0;
    REP(i, 1, N) dp[i][0][0][1] = dp[i-1][0][0][1] + dp[i-1][0][1][1];
    REP(i, 1, M) dp[0][i][1][0] = dp[0][i-1][1][0] + dp[0][i-1][1][1];

    REP(i, 1, N) REP(j, 1, M){
        dp[i][j][0][0] = (dp[i][j-1][0][0] + dp[i][j-1][0][1]) % 1000000007;
        dp[i][j][0][1] = (dp[i-1][j][0][1] + dp[i-1][j][1][1]) % 1000000007;
        dp[i][j][1][0] = (dp[i][j-1][1][0] + dp[i][j-1][1][1]) % 1000000007;
        dp[i][j][1][1] = S[i]==T[j]? (dp[i-1][j-1][0][0]+dp[i-1][j-1][0][1]+dp[i-1][j-1][1][0]+dp[i-1][j-1][1][1])%1000000007 : 0;
    }
    ll ans = dp[N-1][M-1][0][0]+dp[N-1][M-1][0][1]+dp[N-1][M-1][1][0]+dp[N-1][M-1][1][1];
    ans %= 1000000007;
    cout << ans << endl;
}


Measured memory_bytes: 597404
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        long K = NextInt();
        long k = K;
        int A = NextInt();
        int B = NextInt();
        long C = 1;
        //最初は手動
        long c = A - C + 2;
        K -= c;
        if (K < 0) { Console.WriteLine(k+1);return; }
        C += B - 1;
        //1回ごとに得られる差
        int r = B - A;

        //あまりを増やし続けながらK + 2 で変換だけする
        long dc = K / 2;
        if (K - dc * 2 == 1) C++;
        C += dc * r;

        Console.WriteLine(Math.Max(C, 1 + k));
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n;
int p[20010];
int a[20010],b[20010];

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

	cin>>n;
	REP(i,n) {
		cin>>p[i];
	}
	REP(i,n) {
		a[i]=(i+1)*n;
		b[i]=(n-i+2)*n;
	}
	REP(i,n) b[p[i]-1]+=i;
	REP(i,n) cout<<a[i]<<(i==n-1?'\n':' ');
	REP(i,n) cout<<b[i]<<(i==n-1?'\n':' ');

	return 0;
}


Measured memory_bytes: 896
import sys
import math
from  collections import defaultdict

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

def solve(test):
	a, b, c, k = map(int, input().split())
	ans = min(k, a)
	k -= a + b
	if k > 0:
		ans -= k
	print(ans)




if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)


Measured memory_bytes: 9500
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]
    result = 0
    for i in range(N):
        tmp = sum(A[0][:i + 1]) + sum(A[1][i:])
        if result < tmp:
            result = tmp
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL a;
    LL b;
    LL k;
    cin >> a >> b >> k;
    if(b-a<=2*(k-1)){
        for(LL i=a; i<=b; i++){
            cout << i << endl;
        }
    }else{
        for(LL i=a; i<a+k; i++){
            cout << i << endl;
        }
        for(LL i=b-k+1; i<=b; i++){
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3620