akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
vector<int> Zalgorithm(string s){
    vector<int> a(s.size());a[0]=s.size();
    int i=1,j=0;
    while(i<s.size()){
        while(i+j<s.size()&&s[j]==s[i+j])++j;
        a[i]=j;
        if(j==0){i++;continue;}
        int k=1;
        while(i+k<s.size()&&k+a[k]<j)a[i+k]=a[k],k++;
        i+=k;j-=k;
    }
    return a;
}

int main(){
    ll n;cin >> n;
    string s;cin >> s;
    int ans=0;
    rep(i,n){
        string S=s.substr(i);
        auto v=Zalgorithm(S);
        rep(j,v.size()){
            if(v[j]>j)v[j]=j-i;
            chmax(ans,v[j]);
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

template<typename T>
void printVec(vector<T> &v) {
    for(int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

vector<int> divisors(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int gcd(int n, int m) {
    if(n < m) gcd(m, n);
    int r;
    while((r = n % m)) {
        n = m;
        m = r;
    }
    return m;
}

int vector_gcd(vector<int> &v) {
    int ret = v[0];
    for(int i = 1; i < v.size(); i++) {
        ret = gcd(ret, v[i]);
    }
    return ret;
}

signed main() {
    int a, b; cin >> a >> b;
    vector<int> div_a = divisors(a);
    vector<int> div_b = divisors(b);
    vector<int> common_div;
    for(int i = 0; i < div_a.size(); i++) {
        for(int j = 0; j < div_b.size(); j++) {
            if(div_a[i] == div_b[j]) common_div.push_back(div_a[i]);
        }
    }

    int n = common_div.size();
    vector<int> ans;
    ans.push_back(common_div[0]);
    for(int i = 1; i < n; i++) {
        bool flag = true;
        for(int j = 0; j < ans.size(); j++) {
            if(gcd(common_div[i], ans[j]) != 1) {
                flag = false;
            }
        }
        if(flag) ans.push_back(common_div[i]);
    }

    cout << ans.size() << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int a=0,b=0,c=0;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
	    if(a<b&&a<c&&b<c)
			   printf("Yes\n");
        else 
        	 printf("No\n");
	}
	return 0; 
}

Measured memory_bytes: 580
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  bool check = A + 2 * sqrtl(A * B) + B < C;
  string ans;
  if (check) {
    ans = "Yes";
  } else {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[n][m],b[m],c[n];
    //行列a入力
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }    
    }  
    //行列bの入力
    for(int j=0;j<m;j++){
        cin>>b[j];
    }            
    //行列cの初期化
    for(int i=0;i<n;i++){
        c[i]=0;                                                
    }
    //行列計算・行列c表示
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
        }
        cout<<c[i]<<"\n";
    }
}


Measured memory_bytes: 3100
#include<stdio.h>

int main(){
    int n,i;
    scanf("%d", &n);
    int array[n];
    for(i=0; i<n; i++)scanf("%d", &array[i]);
    for(i=n-1; i>=0; i--){
        printf("%d",array[i]);
        if(i != 0) {
            printf(" ");
        } else {
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2040
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1

    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N,M = map(int,input().split())
UF = UnionFind(N)

for i in range(M):
    A,B = map(int,input().split())
    A -= 1; B -= 1
    UF.Unite(A,B)
ans = 0
for i in range(N):
    ans = max(ans,UF.Count(i))

print(ans)

Measured memory_bytes: 14548
n,a=gets.split.map(&:to_i)
array=gets.split.map(&:to_i)

smallarray=[]
ec=0
bigarray=[]

array.map{|value|
    if value-a<0
        smallarray.push(a-value)
    elsif value==a
        ec+=1
    else
        bigarray.push(value-a)
    end
}

bc=bigarray.count
sc=smallarray.count

dparray=Array.new(sc).map{Array.new(sc*50+1,0)}

if dparray[0]
    dparray[0][0]=1
    dparray[0][smallarray[0]]=1
end

(sc-1).times{|i|
   
    (sc*50+1).times{|j|
        add=smallarray[i+1]
       dparray[i+1][j]+=dparray[i][j]
       
       if dparray[i+1][j+add]
            dparray[i+1][j+add]+=dparray[i][j]
       end
    }
    
}


dparray2=Array.new(bc).map{Array.new(bc*50+1,0)}

if dparray2[0]
    dparray2[0][0]=1
    dparray2[0][bigarray[0]]=1
end

(bc-1).times{|i|
   
    (bc*50+1).times{|j|
        add=bigarray[i+1]
        dparray2[i+1][j]+=dparray2[i][j]
       
       if dparray2[i+1][j+add]
            dparray2[i+1][j+add]+=dparray2[i][j]
       end
    }
    
}


ans=2**ec-1


if dparray[0]&&dparray2[0]
    i=1
    loop{
        if dparray[-1][i] && dparray2[-1][i]
            seki=dparray[-1][i]*dparray2[-1][i]
            seki=seki*(2**ec)
            ans+=seki
        else
            break
        end
        i+=1
    }
    
end

puts ans

Measured memory_bytes: 2812
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();

    let maxv = max(a, max(b, c));
    let minv = min(a, min(b, c));
    let midv = (a + b + c) - minv - maxv;

    println!("{}", midv * minv / 2);
}


Measured memory_bytes: 4352
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-25T01:36:10+09:00
 */

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;
int dx[4] = {-1,0,0,1};
int dy[4] = {0,1,-1,0};
/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,W; cin >> n >> W;
  vector<int> v(n),w(n);

  rep(i,n) cin >> v[i] >> w[i];

  int dp[110][10010];
  for(int i=0; i<=W; ++i) dp[0][i] = 0;

  rep(i,n){
      for(int j=0; j<=W; j++){
          if(j-w[i]>=0) chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
          chmax(dp[i+1][j], dp[i][j]);
      }
  }

  cout << dp[n][W] << endl;

  return 0;
}
/********  Main() Ends Here *************/



Measured memory_bytes: 7108
# -*- coding: utf-8 -*-

def main():
     n, k = map(int, input().split())
     sunuke = [0 for i in range(n)]

     for i in range(k):
          num = int(input())
          have = list(map(int, input().split()))
          for k in have:
               sunuke[k-1] += 1
     
     ans = 0
     for i in range(len(sunuke)):
          if sunuke[i] == 0:
               ans += 1
     
     print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    /*
     * REMOVE ME PLS
     */

    //freopen("input.txt", "r", stdin);

    long long r, d, x;

    cin >> r >> d >> x;

    for(int i = 0; i < 10; ++i){
        x = r * x - d;
        cout << x << "\n";
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
const int N = 1e5 + 10;
using namespace std;
int n, cnt[N], odd, even;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	for (int i = 1; i <= 1e5; i++) if (cnt[i]) {
		if (cnt[i]%2) odd++;
		else even++;
	}
	cout << odd + even - even%2;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int>> s(h,vector<int>(w));
    rep(i,h) {
        string str;
        cin >> str;
        rep(j,w) s[i][j] = str[j] - '0';
    }
    int INF = INT32_MAX>>2;
    int sep_max = INF;
    for(int bits = 0; bits < (1<<(h-1)); bits++) {
        int h_sep = 0;
        rep(i,h) if((bits >> i)&1) h_sep++;
        vector<vector<int>> s_grp(h_sep+1,vector<int>(w,0));
        int grp = 0;
        rep(i,h) {
            rep(j, w) s_grp[grp][j] += s[i][j];
            if((bits >> i)&1) grp++;
        }
        vector<int> grp_sum(h_sep+1,0);
        int w_sep = 0;
        bool ok1 = true;
        bool w_sep_inc = false;
        rep(i, w) {
            if(w_sep_inc) {
                w_sep++;
                w_sep_inc = false;
                rep(j,h_sep+1) grp_sum[j] = 0;
            }
            rep(grp2, h_sep+1) {
                grp_sum[grp2] += s_grp[grp2][i];
                if (grp_sum[grp2] > k) {
                    ok1 = false;
                    break;
                }
                if (i == w-1) continue;
                if (grp_sum[grp2] + s_grp[grp2][i+1] > k) {
                    w_sep_inc = true;
                }
            }
            if(!ok1) {w_sep = INF;break;}
        }
        chmin(sep_max, w_sep+h_sep);
    }
    cout << sep_max << endl;
}

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

using namespace std;

typedef long long ll;
#define rep(i,b) for(int i = 0; i < b; i++)
#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rRep(i,a,b) for(int i = a; i >= b; i--)
#define allof(a) (a).begin(), (a).end()
#define INF (1<<30)
#define INFLL (1ll << 60)

const ll mod = 1e9 + 1;

// 型による変数のオーバーフローに気をつけろ！！

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	// 左から詰めてく
	// 最小の値を探す
	int num = 0;

	rep(i, n) {
		if (a[i] == 1) {
			num = i;
		}
	}

	// num番目が最小の値

	int cnt = 0;

	if (((n - 1) % (k - 1)) == 0) cnt = (n - 1) / (k - 1);
	else cnt = 1 + (n - 1) / (k - 1);

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for i in [1, 2, 3]:
    g = [abs(x[m] - y[m]) ** i for m in range(n)]
    print(sum(g) ** (1 / i))
print(max([abs(x[m] - y[m]) for m in range(n)]))



Measured memory_bytes: 5648
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	cin.tie(0);ios::sync_with_stdio(false);
	/* ====================================== */
	int N, M;
	cin >> N >> M;
	vector<int> X(M);
	for(int i = 0; i < M; i++){
		cin >> X[i];
	}
	int ans = 999;
	if(N >= M)ans = 0;
	std::sort(X.begin(),X.end());

	int m1 = M-1;
	vector<int> gaps(m1);
	for(int i = 0; i < m1; i++){
		gaps[i] = 0;
	}

	int sum = 0;
	int min = 100000;
	int count = 0;
	for(int i = 0; i < M-1; i++){
		int gap = X[i+1] - X[i];
		gaps[i] = gap;
	}
	std::sort(gaps.begin(),gaps.end());
	for(int i = 0; i < M-N;i++){
		sum += gaps[i];
	}
	ans = sum;


	cout << ans;
	/* ====================================== */
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <deque>
#define KMAX 100008
#define INT_MAX 2147483647
using namespace std;
int k, dist[KMAX];
deque<int> graf;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> k;
    for(int i = 0; i < k; i++)
        dist[i] = INT_MAX;
    dist[1] = 1;
    graf.push_back(1);
    while(!graf.empty())
    {
        int ost = graf.front();
        graf.pop_front();
        int sledeci1 = (10 * ost) % k;
        int sledeci2 = (ost + 1) % k;
        if(dist[sledeci1] > dist[ost])
        {
            dist[sledeci1] = dist[ost];
            graf.push_front(sledeci1);
        }
        if(dist[sledeci2] > dist[ost] + 1)
        {
            dist[sledeci2] = dist[ost] + 1;
            graf.push_back(sledeci2);
        }
    }
    cout << dist[0];
    return 0;
}


Measured memory_bytes: 896
a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in[0]*b]
d=[]
e=[]
for i in c:
  if i[0]==1:d+=[i[1]]
  elif i[1]==a:e+=[i[0]]
print((set(d)&set(e)==set())*'IM'+'POSSIBLE')

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

using namespace std;

#define MAX 100000

long sumDigs(long a)
{	
	long res = 0;
	while(a)
	{
		res += a % 10;
		a /= 10;
	}
	return res;
}
int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, a;
	cin >> n;

	long minimim = MAX;
	for(int b = 1; b < n; b++)
	{
		a = n - b;
		long current = sumDigs(a) + sumDigs(b);
		minimim = min(current, minimim);
	}
	cout << minimim << '\n';

	return  0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int d = in();
    int n = in();
    if (d == 0 && n == 0) break;
    vector<int> a(n), e(n), r(n);
    rep(i, n) cin >> a[i] >> e[i] >> r[i];
    auto dp = vectors(d + 1, 101, INF);
    dp[d][0] = 0;
    for (int i = d; i >= 0; i--) {
      for (int j = 0; j <= 100; j++) {
        for (int k = 0; k < n; k++) {
          if (j < r[k]) continue;
          cmin(dp[max(0LL, i - a[k])][min(100LL, j + e[k])], dp[i][j] + 1);
        }
      }
    }
    int ans = INF;
    for (int j = 0; j <= 100; j++) cmin(ans, dp[0][j]);
    if (ans == INF) {
      cout << "NA" << endl;
      continue;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3236
import sys
from heapq import*
input = sys.stdin.readline
def main():
    N,M,S = map(int,input().split())
    edges = [[]for _ in range(N)]
    for _ in range(M):
        u,v,a,b = map(int,input().split())
        u -= 1
        v -= 1
        edges[u].append((v,a,b))
        edges[v].append((u,a,b))
    ex = [tuple(map(int,input().split()))for _ in range(N)]

    M = 2500
    dist = [[2**60]*M for _ in range(N)]
    if S >= M:S = M-1
    dist[0][S] = 0
    q = [(0,S,0)]
    while q:
        cost,sil,u = heappop(q)
        if dist[u][sil] < cost:continue
        if sil+ex[u][0] < M and cost+ex[u][1] < dist[u][sil+ex[u][0]]:
            dist[u][sil+ex[u][0]] = cost + ex[u][1]
            heappush(q,(dist[u][sil+ex[u][0]],sil+ex[u][0],u))
        for v,a,b in edges[u]:
            if sil >= a and cost+b < dist[v][sil-a]:
                dist[v][sil-a] = cost+b
                heappush(q,(dist[v][sil-a],sil-a,v))
    for t in range(1,N):
        print(min(dist[t]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 23996
// Problem : A - The Number of Even Pairs
// Contest : AtCoder - AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int n,m;

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n>>m;
    cout<<n*(n-1)/2 + m*(m-1)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, k;
  cin >> n >> k;

  //-30 -10 10 20 50
  vector<ll> a(n);
  rep (i, n) cin >> a[i];

  ll ans = INF;
  rep (i, n - k + 1) {
    ll left = a[i];
    ll right = a[i + (k - 1)];
    ll dis = right - left;

    ll tmp;
    if (abs(left) + dis > abs(right) + dis) {
      tmp = abs(right) + dis;
    } else {
      tmp = abs(left) + dis;
    }

    ans = min(ans, tmp);
  }

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


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

const int N = 200054, M = N * 2;

int n, E = 0;
int to[M], first[N], next[M];
int p[N], S1[N], S2[N];
int pmax[N], f[N];

inline void up(int &x, const int y) {x < y ? x = y : 0;}

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

void dfs(int x) {
	int i, y, z = pmax[x]; S1[x] = S2[x] = 1;
	for (i = first[x]; i; i = next[i])
		if ((y = to[i]) != p[x]) {
			p[y] = x, up(pmax[y], z), dfs(y);
			if (y < z) S1[x] += S1[y];
			if (y < pmax[p[z]]) S2[x] += S2[y];
		}
	if (x != z && x >= pmax[p[z]]) S2[x] = 0;
}

void solve(int x) {
	int i, y;
	if (pmax[x] == x) f[x] += S2[x];
	else if (pmax[ p[x] ] == p[x]) f[x] += S1[x] - S2[x];
	for (i = first[x]; i; i = next[i])
		if (p[y = to[i]] == x) f[y] = f[x], solve(y);
}

int main() {
	int i, u, v;
	scanf("%d", &n);
	for (i = 1; i < n; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	std::iota(pmax, pmax + (n + 1), 0), dfs(1);
	S2[1] = 0, solve(1);
	for (i = 2; i <= n; ++i) printf("%d%c", f[i], i == n ? 10 : 32);
	return 0;
}

Measured memory_bytes: 25088
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<ll> S(N);
  REP(i,N) cin >> A[i];
  sort(A.begin(),A.end());
  S[0] = A[0];
  REPS(i,N-1) S[i] = A[i] + S[i-1];
  int l = 0;
  int r = N-1;
  while(l+1 < r){
    int mid = (l+r)/2;
    bool flag = true;
    ll sum = S[mid];
    FOR(i,mid+1,N){
      if(2*sum < A[i]){
        flag = false;
        break;
      }
      else sum += A[i];
    }
    if(flag) r = mid;
    else l = mid;
  }
  int ans = N - l - 1;
  bool flag = true;
  ll sum = S[0];
  FOR(i,1,N){
    if(2*sum < A[i]){
      flag = false;
      break;
    }
    else sum += A[i];
  }
  if(flag) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
    int m , f , b;
    cin >> m >> f >> b;
    if (m >= b) {cout << 0 <<endl;} 
                else
                if (m + f < b){cout << "NA" <<endl;}
                else
                {cout << b - m <<endl;}
                
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    const ll INIT = -1L * (1L<<60);
    const ll INF = 1L<<60;

    ll n,m,p;
    cin >> n >> m >> p;
    vector<vector<pair<ll,ll>>> edge(n+1,vector<pair<ll,ll>>()); // [from] first=to second=cost

    REP(i,m) {
        ll a,b,c;
        cin >> a >> b >> c;
        edge[a].emplace_back(make_pair(b,c));
    }

    vector<ll> score(n+1,INIT);
    vector<bool> visit(n+1,false);
    visit[1] = true;
    score[1] = 0;
    
    REP(i,n*2) {
        FOR(j,1,n+1) {
            if (visit[j]) {
                for (auto x:edge[j]) {
                    if (!visit[x.first]) {
                        visit[x.first] = true;
                        score[x.first] = score[j] + x.second - p;
                    } else {
                        if (score[x.first] < score[j] + x.second - p) {
                            if (i > n-1) {
                                score[x.first] = INF;
                            } else {
                                score[x.first] = score[j] + x.second - p;
                            }
                        }
                    }
                }
            }
        }
    }

    if (score[n] == INF) {
        cout << -1 << endl;
    } else {
        cout << (score[n] < 0 ? 0 : score[n]) << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> A(n), B(n);
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    int diff = 0;
    for(int i = 0; i < n; i++) if(A[i] != B[i]) diff++;
    int q; cin >> q;
    int ans = -1;
    if(diff == 0) ans = 0;
    for(int i = 0; i < q; i++)
    {
        int x, y; cin >> x >> y; 
        x--, y--;
        int t1 = A[x], t2 = A[y];
        if(t1 == t2) continue;
        swap(A[x], A[y]);
        if(t1 == B[x]) diff++;
        if(t2 == B[y]) diff++;
        if(A[x] == B[x]) diff--;
        if(A[y] == B[y]) diff--;
        if(diff == 0 && ans == -1) ans = i + 1;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5152
/* 
* code by: imasnegi
**/

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

#define ll long long
#define nl "\n"
#define spc " "
#define fr(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define deb(a) cout << #a << " " << a << nl;

template<typename T>
void printArray(vector<T>& v) {
	for(auto& i : v)
		cout << i << spc;
	cout << nl;
}
const int MaxN = 2e5 + 5;
const int MOD = 1e9 + 7;

ll n, k;
ll a[MaxN];

void solve_cases() {
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	ll l = 1, r = 1e9;
	ll ans = -1;
	ll cnt = 0;
	
	while(l <= r) {
		ll mid = (l + r) / 2;
		cnt = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] > mid) {
				cnt += a[i] / mid;
				if(cnt%mid == 0) cnt--;
			}
		}
		
		if(cnt <= k) {
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	
	cout << ans << nl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cout << setprecision(10) << fixed;
	int t = 1;
	//cin >> t;
	FOR(tt, 1, t) {
		//cout << "Case #" << tt << ": ";
		solve_cases();
	}
}

Measured memory_bytes: 5076
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
	double xa,xb,ya,yb;
	scanf("%lf%lf%lf%lf", &xa, &ya, &xb, &yb);
	printf("%lf\n",(double)hypot(xa-xb,ya-yb) );
	return 0;
}


Measured memory_bytes: 3284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if((a ==1||a ==3||a ==5||a ==7||a ==8||a ==10||a ==12)&&(b ==1||b ==3||b ==5||b ==7||b ==8||b ==10||b ==12)){
    	System.out.println("Yes");
    }else if((a==4||a==6||a==9||a==11)&&(b==4||b==6||b==9||b==11)){
    	System.out.println("Yes");
    }else if(a==2 && b==2){
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
	}

}

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

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

#define MOD 1000000007  //E9

//a^n%m
ll modpow(ll a,ll n,ll m=MOD){
    ll r=1;
    while(n>0){
        if(n&1)r=r*a%m;
        a=a*a%m;
        n>>=1;
    }
    return r;
}
ll num[100001];

int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i>=1;i--){
        ll tnum=modpow(k/i,n);
        for(int a=i+i;a<=k;a=a+i){
            tnum=(tnum-num[a]+MOD)%MOD;
        }
        num[i]=tnum%MOD;
        ans=(ans+(tnum*i)%MOD)%MOD;
    }
    cout<<ans<<endl;

    return 0;
}

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

int main(void){
	int n;
	int m;
	char a;
	char jisyo[1000][2];
	char message[10][200000];
	for(int x;x<5;x++){
		cin >> n;
		if(n==0){
			break;
		}
		for(int i=0;i<n;i++){
			cin >> jisyo[i][0];
			cin >> jisyo[i][1];
		}
		cin >> m;
		for(int i=0;i<m;i++){
			cin >> a;
			for(int i0=0;i0<n;i0++){
				if(a==jisyo[i0][0]){
					a=jisyo[i0][1];
					break;
				}
			}
			message[x][i]=a;
		}
		cout << message[x] << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

diff = [V[i]-C[i] for i in range(N)]

optCost = 0
for i in range(N):
    if diff[i]>0:
        optCost+=diff[i]
print(optCost)

Measured memory_bytes: 3060
#たかだか2019
#かけたら超える可能性があるのか
#問題文読み違えた
#色々ダメすぎる
#意味がわからない

l,r=input().split()
l,r=int(l),int(r)
if r-l>=2018:
    print(0)
else:
    '''
    l,r=l%2019,r%2019
    if r>l:
        print(l*(l+1))
    else:
        print(0)
    '''
    '''
    x=(l*(l+1))%2019
    for i in range(l+1,r+1):
        x=min([i*(i+1),x])%2019
        if x==0:
            break
    print(x)
    '''
    a=[i%2019 for i in range(l,r+1)]
    x=(a[0]*a[1])%2019
    for i in range(len(a)):
        for j in range(len(a)-i-1):
            x=min([x,(a[i]*a[i+1+j])%2019])
            if x==0:
                break
        if x==0:
            break
    print(x)


Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
	let (n,m) = read!(usize, usize);
	let a = read!([usize]);
	let mut sum = 0;
	for i in 0..m {
		sum += a[i];
	}
	if n>=sum {
		println!("{}", n-sum);
	}
	else {
		println!("{}", -1);
	}
}


fn run() {
    solve();
}


Measured memory_bytes: 2372
import std.stdio,
       std.algorithm,
       std.array,
       std.conv,
       std.string;

void main(){
    int n = readln.split.to!(int[]).front;
    string[] instr = new string[n];
    for(int i=0;i<n;i++) instr[i] = readln().chomp;

    for(int i=0;i<n;i++) write(sort!("a<b")(instr)[i]);
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s; cin >> s;
    bool ok = false;
    if(s[2]==s[3] && s[4]==s[5]) ok = true;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int n, a[100000];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) { scanf("%d", &a[i]); }
	
	long long int ans = 0, pre = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] == 0) { pre = 0; }
		a[i] += pre;
		ans += a[i] / 2;
		pre = a[i] % 2;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;

#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

ll a, b, x;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin>>a>>b>>x;
    if(a==0)    cout<<((b/x) + 1);
    else    cout<<((b/x) - (a-1)/x);
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
  int r, g, b, n = 0;
  int ans, tmp = 0;
  scanf("%d", &r);
  scanf("%d", &g);
  scanf("%d", &b);
  scanf("%d", &n);
  for (int i = 0; i <= n / r; i++)
  {
    int ri = r * i;
    if (ri > n)
    {
      break;
    }
    for (int j = 0; j <= n / g; j++)
    {
      tmp = ri + g * j;
      if (tmp > n)
      {
        break;
      }
      else if ((n - tmp) % b == 0)
      {
        ans++;
      }
    }
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.util.Arrays;
import java.util.stream.Collectors;

class Main {
  public static void main(String[] args) {
    try {
        var stdin = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        Integer n = null;
        while((line = stdin.readLine()) == null);
        n = Integer.valueOf(line);
        line = null;
       while((line = stdin.readLine()) == null);
        var parsed = Arrays.asList(line.split(" ")).stream().map(s -> Integer.valueOf(s)).sorted().collect(Collectors.toList());
        if (parsed.size() < 3) {
            System.out.println("0");
            return;
        }
        
        int count =0;
        for (int x = 0;x<n;x++) {
            for (int y = x+1;y<n;y++) {
                int currentValueX = parsed.get(x);
                int currentValueY = parsed.get(y);
                if (currentValueX == currentValueY) continue;
                int left = Math.abs(currentValueX-currentValueY);
                int right = currentValueX + currentValueY;
                count += parsed.stream().skip(y+1).filter(item -> item != currentValueX && item != currentValueY && left < item && item < right).count();
            }
        }
        System.out.println(count);
        /*
        a+b>cかつb+c>aかつc+a>b
|b-c| <a < b+c

for (
*/        
       
    } catch(Exception e) {
    }
   
  }
}

Measured memory_bytes: 37508
#include  <stdio.h>

#define NUM 100

void insertionSort(int numbers[], int array_size);

void swap(int *p_from, int *p_to);

int numbers[NUM];


int main()
{
  int i, n, c;
  int numbers[NUM];

   
  scanf("%ld", &n);

   
  for(c = 0; c < n; c++)
    scanf("%ld", &numbers[c]);
  
  for (i = 0; i < n-1;i++) {
    printf("%d ", numbers[i]);
  }
  printf("%d\n",numbers[i]);

  insertionSort(numbers, n);

   

  return 0;
}

void insertionSort(int data[], int n)
{
  int i, j,tmp,k;

  for (i = 1; i < n; i++) {
    tmp = data[i];
    if (data[i - 1] > tmp) {
      j = i;
      do {
	data[j] = data[j - 1];
	j--;
      } while (j > 0 && data[j - 1] > tmp);
      data[j] = tmp;
    }

    for(k=0;k<n-1;k++){
      printf("%d ",data[k]);
    }
    printf("%d\n",data[k]);

  }



}


Measured memory_bytes: 2104
s = input()
flg = 0
if len(s) % 2 == 0:
    for i in range(0, len(s), 2):
       if s[i] != 'h':
           flg = 1
           break
    else:
        for i in range(1, len(s), 2):
            if s[i] != 'i':
                flg = 1
                break
else:
    flg = 1

if flg == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
from sys import stdin
a = stdin.readline().rstrip().split('/')
year = int(a[0])
month = int(a[1])
day = int(a[2])

if year <= 2018:
    print("Heisei")
elif year >= 2019 and month <=4:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3060
seireki = list(input())
flag = "ok"
dummy = ""
dummy2 = ""
dummy3 = ""
for i in range(4):
  dummy = dummy + seireki[i]
if int(dummy) < 2019:
  print("Heisei")
elif int(dummy) > 2019:
  print("TBD")
else:
  dummy2 = seireki[5] + seireki[6]
  if int(dummy2) > 4:
    print("TBD")
  else:
    print("Heisei")

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

using namespace std;

int sho(int N,int P) // N:原価　P:消費税率
{
    double answer = (N*P)/100;
    return floor(answer);
}

int minrev(int N,int P) // N:税 P:消費税率
{
    double answer = ((double)N*100.0)/(double)P;
    return ceil(answer);
}

int main()
{
    int A,B;
    cin >> A >> B;

    int min8,max8,min10,max10;

    min8 = minrev(A,8);
    max8 = minrev((A+1),8)-1;
    min10 = minrev(B,10);
    max10 = minrev((B+1),10)-1;

/*
    10    min o---------o max
    8        min o----------o max
*/

    if(max8 < min10 || max10 < min8)
    {
        cout << "-1" << endl;
    }
    else
    {
        if(min8 == min10) cout << min8 << endl;
        if(min8 < min10) cout << min10 << endl;
        if(min8 > min10) cout << min8 << endl;
    }

    return 0;
}

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


using namespace std;

int main(){
	string s;
	cin>>s;
	if(s[0]=='R'){
		if(s[1]=='R'){
			if(s[2]=='R'){
				cout<<"3"<<endl;
			}
			else{
				cout<<"2"<<endl;
			}
		}
		else{
			cout<<"1"<<endl;
		}
	}
	else{
		if(s[1]=='R'){
			if(s[2]=='R'){
				cout<<"2"<<endl;
			}
			else{
				cout<<"1"<<endl;
			}
		}
		else{
			if(s[2]=='R') cout<<"1"<<endl;
			else cout<<"0"<<endl;
		}
	}
} 

Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define max(a, b) ((a)>(b)?(a):(b))
#define min(a, b) ((a)<(b)?(a):(b))

int main(void){
    int *r;
    int n;
    int maxv;
    int minr;
    int j;
    maxv = -1000000000;
    minr = 1000000000;
    scanf("%d", &n);

    r = (int *)malloc(sizeof(int) * n);
    for (j = 0; j < n; j++){
        scanf("%d", &r[j]);
    }

    for (j = 1; j < n; j++){
        minr = min(minr , r[j - 1]);
        maxv = max(maxv, r[j] - minr);
    }

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

    return 0;
}

Measured memory_bytes: 1380
N = int(input())
T, A = map(int, input().split())
H = list(input().split())
H = [int(H[i]) for i in range(N)]

min_diff = 10000
plan = 0
for i in range(N):
    tmpe = T - 0.006 * H[i]
    diff_A = abs(A - tmpe)
    if min_diff > diff_A:
        plan = i+1
        min_diff = diff_A

print(plan)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> graph(n, vector<bool>(n));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a][b] = graph[b][a] = true;
    }
    int ans = 0;
    vi p(n-1);
    rep(i, n-1) p[i] = i + 1;
    do {
        bool ok = true;
        int v = 0;
        rep(i, n-1) {
            if (!graph[v][p[i]]) ok = false;
            v = p[i];
        }
        if (ok) ++ans;
    } while (next_permutation(all(p)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

void solve(){
    ll n,k;cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(i,k){
        vi nv(n);
        rep(j,n){
            nv[max(j-v[j],0ll)]++;
            if(j+v[j]+1<n)nv[j+v[j]+1]--;
            // REP(t,max(j-v[j],0ll),min(j+v[j]+1,n))nv[t]++;
        }
        // outv(nv);
        REP(j,1,n)nv[j]+=nv[j-1];
        bool ok=true;
        rep(j,n)if(nv[j]!=n)ok=false;
        v=nv;
        if(ok)break;
    }
    outv(v);
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 6368
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
H, W = map(int, input().split())
ch, cw = map(lambda x: int(x) - 1, input().split())
dh, dw = map(lambda x: int(x) - 1, input().split())
S = [0] * H
for i in range(H):
    S[i] = input()

q = deque([])
dist = [[-1] * W for _ in range(H)]
q.append((ch, cw, 0))
dist[ch][cw] = 0
while len(q) > 0:
    cur = []
    while len(q) > 0:
        cy, cx, d = q.popleft()
        cur.append((cy, cx, d))
        for dy, dx in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
            y = cy + dy
            x = cx + dx
            if y < 0 or y >= H or x < 0 or x >= W:
                continue
            if S[y][x] == '#':
                continue
            if dist[y][x] != -1:
                continue
            dist[y][x] = dist[cy][cx]
            q.appendleft((y, x, d))
    for cy, cx, d in cur:
        for dy in range(-2, 3):
            for dx in range(-2, 3):
                y = cy + dy
                x = cx + dx
                if y < 0 or y >= H or x < 0 or x >= W:
                    continue
                if S[y][x] == '#':
                    continue
                if dist[y][x] != -1:
                    continue
                dist[y][x] = d + 1
                q.appendleft((y, x, d + 1))
print(dist[dh][dw])



Measured memory_bytes: 103476