akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = (ll)1e18;
const ll maxn = 1e9+1;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x, ll y, ll mod) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x, ll mod) {return power(x,mod-2,mod);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng((ll)chrono::steady_clock::now().time_since_epoch().count());

// I can solve mirror cube in 2 mins but can't solve div2 C in 1hr.
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    ll x = 0;
    rep0(i,n) {
        cin>>a[i];
        x ^= a[i];
    }
    rep0(i,n) {
        cout<<(x^a[i])<<" ";
    }
    cout<<endl;
}
int main()
{
    ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 5176
import java.util.*;
class Main{
  public static long knapsack(int[] wt,int[] val,int w,int n)
  {
    long[][] t = new long[n+1][w+1];
    for(int i=0;i<n+1;i++)
    {
      for(int j=0;j<w+1;j++)
      {
        if(i==0||j==0)
          t[i][j]=0;
      }
    }
    
    for(int i=1;i<n+1;i++)
    {
      for(int j=1;j<w+1;j++)
      {
        if(wt[i-1]<=j)
          t[i][j]=Math.max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
        else
          t[i][j]=t[i-1][j];
      }
    }
    return t[n][w];
  }
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int w=sc.nextInt();
    int[] wt = new int[n];
    int[] val = new int[n];
    for(int i=0;i<n;i++)
    {
     wt[i]=sc.nextInt();
     val[i]=sc.nextInt();
    }
    System.out.println(knapsack(wt,val,w,n));
  }
}


Measured memory_bytes: 126928
#include <iostream>
#include <vector>
#include <algorithm>


unsigned get_sum(unsigned sum, std::vector<int>& cache, std::vector<int>& vec, unsigned i)
{
  if (i+1 == vec.size())
  {   
    cache[i] = 0;
  }   
  else if (i+2 == vec.size())
  {   
    cache[i] = abs(vec[i] - vec[i+1]);
  }
  else if (cache[i] == -1) 
  {   
    auto sum1 = get_sum(abs(vec[i] - vec[i+1]), cache, vec, i+1);
    auto sum2 = get_sum(abs(vec[i] - vec[i+2]), cache, vec, i+2);
    cache[i] = std::min(sum1, sum2);
  }
  return sum + cache[i];
}

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

  unsigned N = 0;
  std::cin >> N;
  std::vector<int> vec(N, 0); 
  for (unsigned i = 0; i < N; ++i)
  {
    std::cin >> vec[i];
  }
  std::vector<int> cache(vec.size(), -1);
  auto ans = get_sum(0, cache, vec, 0); 
  std::cout << ans;

  return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <cmath>

int main()
{
	double velocity;
	while (std::cin >> velocity) {
		double const gravity = 9.8;
		double const y = velocity * velocity / (2 * gravity);
		std::cout << std::ceil((y + 5) / 5) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1276
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d float64
	var ans string
	fmt.Scan(&a, &b, &c, &d)

	if (math.Abs(a-b) <= d && math.Abs(b-c) <= d) || math.Abs(a-c) <= d {
		ans = "Yes"
	} else {
		ans = "No"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int real_start = -1, ok = 0;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length() && !ok; ++i) {
        int cnt = 0, nrq = 0;
        for (int k = i; k < i + t.length() && k < s.length(); ++k) {
            if (s[k] == '?') {
                ++nrq;
                ++cnt;
            }
            if (s[k] == t[k - i])
                ++cnt;
        }
        if (cnt == t.length()) {
            real_start = i;
            if (nrq == 0)
                ok = 1;
        }
    }

    if (real_start != -1) {
        for (int k = real_start; k < real_start + t.length(); ++k)
            s[k] = t[k - real_start];
        for (int k = 0; k < s.length(); ++k) {
            if (s[k] == '?')
                s[k] = 'a';
            cout << s[k];
        }
        return 0;
    }
    cout << "UNRESTORABLE";
    return 0;
}


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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100010
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;
#define sorti(x) sort(x.begin(), x.end())

vector<vector<int> > edge;
vector<bool> visit;

void dfs(int v) {
  if(visit[v]) return;
  visit[v] = true;
  rep(i,edge[v].size()) {
    dfs(edge[v][i]);
  }
}

int main() {
  int n,m,k,l;
  cin >> n >> m;
  edge.resize(n+m);

  rep(i,n) {
    cin >> k;
    edge[i].resize(k);
    rep(j,k) {
      cin >> l;
      l = n + l - 1;
      edge[i][j] = l;
      edge[l].pb(i);
    }
  }
  visit.resize(n+m);
  dfs(0);
  rep(i,n) {
    if (!visit[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}

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

int main(){
    int H,W; cin >> H >> W;
    string tmp;
    for (int i = 0; i < H + 2; ++i) {
        if (i == 0 || i == H + 1) {
            for (int j = 0; j < W + 2; ++j) cout << "#";
            cout << endl;
        } else {
            cin >> tmp;
            cout << "#" << tmp << "#" << endl;
        }
    }
    return 0;
}

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

int solve_testcase() {
  vector<int> s1(5), s2(5);
  cin >> s1[0] >> s2[0];
  if(s1[0] == 0 and s2[0] == 0) return 1;
  for(int i=1; i<5; i++) {
    cin >> s1[i] >> s2[i];
  }

  char c[] = {'A', 'B', 'C', 'D', 'E'};
  int max_val = 0, arg = -1;
  for(int i=0; i<5; i++) {
    if(s1[i] + s2[i] > max_val) {
      max_val = s1[i] + s2[i];
      arg = i;
    }
  }
  cout << c[arg] << " " << max_val << endl;
  return 0;
}

int main() {
  while(!solve_testcase());
  return 0;
}



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

public class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int i = 0;
        int dam = 0;
        for(i = 0; dam < h; i++)
            dam+= a;
        pw.println(i);

        pw.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}




Measured memory_bytes: 20948
import sys
for i in sys.stdin:
    m, n = map(int, i.split())
    t1, t2 = m, n
    while True:
        if m % n == 0:
            break
        m, n = n, m % n
    a = n
    b = (t1/ a) * t2
    print("{} {}".format(a, b))

Measured memory_bytes: 6228
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int i,red,blue,l,num;
  char str[100005],*p,s[100005];
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  strcpy(s,p);
  
  l=strlen(s);
  
  for(i=0,red=0,blue=0;i<l;i++){
    if(s[i]=='0'){
      red++;
    }else{
      blue++;
    }
  }
  
  if(red<=blue){
    num=2*red;
  }else{
    num=2*blue;
  }
  
  printf("%d\n",num);
  
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
int a[maxn];
int main(){
    int n;
    cin>>n;
    for(int i = 0;i < n;i++){
        cin>>a[i];
    }
    sort(a,a + n);
    int ans = 0;
    for(int i = 0;i < n - 2;i++){
        for(int j = i + 1;j < n - 1;j++){
            for(int k = j + 1;k < n;k++){
                if(a[i] + a[j] > a[k]){
                    ans++;
                } else {
                    break;
                }
            }

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

Measured memory_bytes: 384
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed 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")
}

fn main() {
    let n:usize = read();
    let arr:Vec<i64> = (0..n).map(|_| read()).collect();
    let max = arr.iter().max().unwrap();
    let min = arr.iter().min().unwrap();
    let sum:i64 = arr.iter().sum();
    println!("{} {} {}", min, max, sum);
}


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

int main() {
    int N;
    int val;
    cin >> N;
    map<int, int> mp;
    for(int i=1; i<=N; i++) {
        cin >> val;
        mp[val] = i;
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        cout << itr->second << ' ';
    }
    cout << endl;
    return 0;
}

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

int main() {
    ll N, M; cin >> N >> M;
    string ans(N, '0');
    for (int i = 0; i < M; ++i) {
        ll s; char c; cin >> s >> c;
        if (ans[s - 1] == '0') ans[s - 1] = c;
        if (N != 1 && s == 1 && c == '0') {
            cout << "-1" << endl;
            return 0;
        }
        else {
            if (ans[s - 1] == c) {
                continue;
            }
            cout << "-1" << endl;
            return 0;
        }
    }
    if (ans[0] == '0') {
        if (N == 1) cout << ans << endl;
        else {
            ans[0] = '1';
            cout << ans << endl;
        }
    }
    else cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
using System;
class Program
{
	static void Main()
	{
	int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
	//出力
    int a = 0;
   	  for(int i = 0; i<n;i++)
      {
       if(nums[i]%2==1)a++; 
      }
	Console.WriteLine((a % 2 == 0) ? "YES" : "NO");
	}
}

Measured memory_bytes: 18400
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()
	k := nextInt64()

	for i := 0; i < len(s); i++ {
		if s[i] != '1' {
			fmt.Println(string(s[i]))
			return
		} else if int64(i) == k-1 {
			break
		}
	}
	fmt.Println(1)
	return

}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1780
#include<iostream>
#include<vector>
#include<string>

// ref : https://scrapbox.io/luckyrat/%E3%80%90Comp-Prog:20190521%E3%80%91ABC059-C_Sequence

using ll = long long;

int main(){
    int n;
    std::cin >> n;
    std::vector<ll> input(n);
    for(int i = 0; i < n; i++){
        std::cin >> input[i];
    }

    // +-+-...
    long long cost1 = 0, sum1 = 0;
    std::vector<ll> a = input;
    for(int i = 0; i < n; i++){
        sum1 += a[i];
        if(i % 2 == 0 && sum1 <= 0){
            cost1 += 1 - sum1;
            a[i] += 1 - sum1;
            sum1 = 1;
        }else if(i % 2 == 1 && sum1 >= 0){
            cost1 += 1 + sum1;
            a[i] -= 1 + sum1;
            sum1 = -1;
        }
    }

    // -+-+....
    long long cost2 = 0, sum2 = 0;
    a = input;
    for(int i = 0; i < n; i++){
        sum2 += a[i];
        if(i % 2 == 0 && sum2 >= 0){
            cost2 += 1 + sum2;
            a[i] -= 1 + sum2;
            sum2 = -1;
        }else if(i % 2 == 1 && sum2 <= 0){
            cost2 += 1 - sum2;
            a[i] += 1 - sum2;
            sum2 = 1;
        }
    }

    std::cout << std::min(cost1, cost2) << std::endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        if(n == 1 && a != b || a > b){
            System.out.println(0);
        }else if(a == b || n == 2 && a != b){
            System.out.println(1);
        }else{
            System.out.println((n-2)*b-(n-2)*a+1);
        }
    }
}


Measured memory_bytes: 22996
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a += mod - rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        is >> rhs.a;
        return is;
    }
};
using mint = ModInt<MOD>;

class Combination {
public:
    vector <mint> fac, inv, fiv;
    Combination(int N) : fac(N + 1), inv(N + 1), fiv(N + 1) {
        fac[0] = inv[0] = fiv[0] = fac[1] = inv[1] = fiv[1] = 1;
        for (ll i = 2; i <= N; i++) {
            fac[i] = fac[i - 1] * i; // n!
            inv[i] = inv[MOD % i] * (MOD - MOD / i); // n^-1
            fiv[i] = fiv[i - 1] * inv[i]; // (n!)^-1
        }
    }
    mint C(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[k] * fiv[n - k];
    }
    mint P(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[n - k];
    }
    mint H(ll n, ll k) {
        if (n == 0 && k == 0) return 1;
        return C(n + k - 1, k - 1);
    }
};

int main() {
    ll n, k;
    cin >> n >> k;
    Combination com(1005);
    cout << com.C(k, n) << endl;
    return 0;
}


Measured memory_bytes: 3136
def main():
    n=int(input())
    d=[0]+[-10**18]*n
    for j,(a,i)in enumerate(sorted((-a,i)for i,a in enumerate(map(int,input().split())))):
        d=[max(t-a*abs(~i-j+k+n),d[k-1]-a*abs(~i+k))for k,t in enumerate(d)]
    print(max(d))
main()

Measured memory_bytes: 75480
n = int(input())
a = list(map(int,input().split()))

o=[]
e=[]
for i in range(n):
    if i%2==0:
        o.append(a[i])
    if i%2==1:
        e.append(a[i])

if n%2==0:
    E=[]
    for i in range(n//2):
        E.append(e[n//2-1-i])
    ans = []
    for i in range(n//2):
        ans.append(E[i])

    for i in range(n//2):
        ans.append(o[i])
    s = ""
    for i in range(len(ans)):
        s = s+str(ans[i])
        s = s+" "
    print(s)
    exit()
else:
    O=[]
    for i in range(len(o)):
        O.append(o[len(o)-1-i])
    ans = []
    for i in range(len(O)):
        ans.append(O[i])
    for i in range(n//2):
        ans.append(e[i])
    s = ""
    for i in range(len(ans)):
        s = s+str(ans[i])
        s = s+" "
    print(s)
    exit()

Measured memory_bytes: 25156
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
int diff(int x,int y,int z) {
  if(x == y || x == z || y == z) return 0;
  return 1;
}
int triangle(int a, int b, int c) {
  if(a + b <= c) return 0;
  if(a + c <= b) return 0;
  if(b + c <= a) return 0;
  return 1;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; i + 2 < n; i++) {
    for(int j = i + 1; j + 1 < n; j++) {
      for(int k = j + 1; k < n; k++) {
        if(diff(a[i] , a[j] , a[k]) && triangle(a[i] , a[j] , a[k])) {
          ans++;
          dg3(i+1,j+1,k+1);
        }
      }
    }
 
  }
  cout << ans << '\n';
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Dinic {
  struct edge {
    int to, cap, rev;
    edge(){}
    edge(int to, int cap, int rev)
      :to(to), cap(cap), rev(rev){}
  };
  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int V):graph(V), level(V), iter(V){}
  void add_edge(int from, int to, int cap) {
    graph[from].emplace_back(to, cap, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
  }
  void bfs(int s) {
    fill(all(level), -1);
    level[s] = 0;
    queue<int> que;
    que.push(s);
    while(que.size()) {
      int v = que.front(); que.pop();
      for(edge e : graph[v]) {
	if(e.cap > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }
  int dfs(int v, int t, int f) {
    if(v == t) return f;
    for(int &i = iter[v]; i < (int)graph[v].size(); i++) {
      edge &e = graph[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, t, min(f, e.cap));
	if(d > 0) {
	  e.cap -= d;
	  graph[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
      bfs(s);
      if(level[t] < 0) return flow;
      fill(all(iter), 0);
      int f; while((f = dfs(s, t, inf)) > 0) flow += f;
    }
  }
};

int H, W;
char S[101][101];

int sx, sy, gx, gy;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> H >> W;
  Dinic graph(H+W+2);
  int s = H+W, t = s+1;
  rep(i, H) rep(j, W) {
    cin >> S[i][j];
    if(S[i][j] == 'S') {
      sx = j, sy = i;
      graph.add_edge(s, i, inf);
      graph.add_edge(s, H+j, inf);
    } else if(S[i][j] == 'T') {
      gx = j, gy = i;
      graph.add_edge(i, t, inf);
      graph.add_edge(H+j, t, inf);
    } else if(S[i][j] == 'o') {
      graph.add_edge(i, H+j, 1);
      graph.add_edge(H+j, i, 1);
    }
  }

  if(sx == gx || sy == gy) cout << -1 << endl;
  else cout << graph.max_flow(s, t) << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	string s, ss;
	cin >> s >> ss;
	bool ans = false;
	if (s.substr(0, s.size()) == ss.substr(0, s.size())) ans = true;



	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    string S;
    cin >> N >> S;

    vector<vector<int>> dp(N + 1, vector<int>(N + 1));
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (S[i] == S[j]) {
                int tmp = dp[i][j] + 1;
                if (dp[i + 1][j + 1] < tmp && tmp <= j - i) {
                    dp[i + 1][j + 1] = tmp;
                    ans = max(ans, tmp);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 101124
#include<iostream>
#include<set>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
    set<string> S;
    int n; cin >>n;

    string cmd;
    string str;

    for(int i=0;i<n;i++)
    {
        cin >> cmd >> str;
        if(cmd=="insert")
        {
            S.insert(str);
        }
        else if(cmd=="find")
        {
            if(S.find(str)==S.end()) cout << "no"<<endl;
            else cout<< "yes" <<endl;
        }
    }
}


Measured memory_bytes: 32560
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <numeric>
#include <cmath>
#include <cctype>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


int main(){
  ll N; cin>>N; 
  if(N%2==0){ printf("%d %d %d\n",N,N,N/2); }
  else{
    bool ok = false;
    for(int h=3500;h>=0;--h){
      for(int n=h;n>=0;--n){
        ll temp = 4*h*n-N*(n+h);
        if( temp<=0){break;}
        ll semp = N*h*n;
        if( semp%temp==0 ){
          printf("%d %d %d\n",h,n,semp/temp);
          ok = true;
          break;
        }
      }
      if(ok){break;}
    }
  }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Dice[] d=new Dice[100];
        int n=Integer.parseInt(br.readLine());
        for(int i=0;i<n;i++){
            String input[]=new String[6];
            input=br.readLine().split(" ");
            int[] in=new int[6];
            for(int j=0;j<6;j++)in[j]=Integer.parseInt(input[j]);
            d[i]=new Dice(in);
        }
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++){
                if((d[i].isequal(d[j]))){
                    out.println("No");
                    out.flush();
                    return;
                }
            }
        }
        out.println("Yes");
        out.flush();
    }
}
class Dice{
    private int[] memo=new int[6];
    private static final String equalmove="NNNNWNNNWNNNENNNENNNWNNN";
    public Dice(int[] in){
        Set(in[0],in[1],in[2],in[3],in[4],in[5]);
    }
    private void Set(int a,int b,int c,int d,int e,int f){
        memo[0]=a;memo[1]=b;memo[2]=c;memo[3]=d;memo[4]=e;memo[5]=f;
    }
    public void move(char c){
        switch(c){
            case 'W':
                Set(memo[2],memo[1],memo[5],memo[0],memo[4],memo[3]);
                break;
            case 'N':
                Set(memo[1],memo[5],memo[2],memo[3],memo[0],memo[4]);
                break;
            case 'S':
                Set(memo[4],memo[0],memo[2],memo[3],memo[5],memo[1]);
                break;
            case 'E':
                Set(memo[3],memo[1],memo[0],memo[5],memo[4],memo[2]);
                break;
            default:
                System.out.println("error");
        }
    }
    public int Get(int i){
        return memo[i];
    }
    public boolean isequal(Dice D2){
        if(D2==this)return true;
        for(int i=0;i<equalmove.length();i++){
            this.move(equalmove.charAt(i));
            boolean flag=true;
            for(int j=0;j<6;j++){
                if(this.Get(j)!=D2.Get(j)){
                    flag=false;
                    break;
                }
            }
            if(flag)return true;
        }
        return false;
    }
}




Measured memory_bytes: 26064
import math
a,b,k = map(int, input().split())
res = []
if 2*k > b-a:
    k = math.ceil((b-a)/2)+1
for i in range(k):
    res.append(a+i)
    res.append(b-i)

for s in sorted(set(res)):
    print(s)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    static int[] ori ;
    static int N;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
        char[] s = sc.next().toCharArray();
        ori = new int[N];
        for(int i = 0;i < N;i++){
            if(s[i] ==  'o'){
                ori[i] = 1;
            }else{
                ori[i] = -1;
            }
        }
        int[] res = new int[N];
        //ss
        Arrays.fill(res,0);
        res[0] = 1;
        res[1] = 1;
        if(chal(res)){
            out(res);
            return;
        }
        
        //sw
        Arrays.fill(res,0);
        res[0] = 1;
        res[1] = -1;
        if(chal(res)){
            out(res);
        return;
            
        }
        //ws
        Arrays.fill(res,0);
        res[0] = -1;
        res[1] = 1;
        if(chal(res)){
            out(res);
        return;
            
        }
        //ww
        Arrays.fill(res,0);
        res[0] = -1;
        res[1] = -1;
        if(chal(res)){
            out(res);
        return;
            
        }
        
        System.out.println(-1);
    }
    public static boolean chal(int[] res){
        for(int i = 1; i < N-1; i++){
            res[i + 1] = res[i - 1] * res[i] *  ori[i];
        }
        if(res[N-2] * res[N-1] * ori[N-1] == res[0] 
         &&res[N-1] * res[0] * ori[0] == res[1])return true;
         return false;
    }
    public static void out(int[] res){
        for(int i = 0; i < N;i++){
            char c;
            if(res[i] == 1)c = 'S';
            else c = 'W';
            System.out.print(c);
        }
        System.out.println("");
    }
    
}


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

int main() {
	string S;
	int i=0,cnt=0;
	
	cin >> S;
	for(i=0;i<S.size();i++){
	    if(S.substr(i,1)!=S.substr(i+1,1))
	        cnt++;
	}
	cout<<cnt-1<<endl;
	
	return 0;
}


Measured memory_bytes: 512
// Problem : A - Circle Pond
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define pii pair<int,int>
#define S second
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
#define mod 1000000007
#define YES "YES"
#define NO "NO"
const long long INF = 1000000000000000000LL;
//const int WASTE=∞;
ll power(ll a,ll b){
	ll i=1;
	while(b){
		if(b%2)
			i=(i*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return i;
}
ll mulmod(ll a, ll b) { 
    ll res = 0;
    a = a % mod; 
    while (b > 0) {
        if (b % 2 == 1) 
            res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }
    return res % mod; 
} 
const int N=1e5+5;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  	cout<<fixed;
  	cout.precision(20);
   	int b;
   	cin>>b;
   	double ans=(double)b*2*22;
   	ans/=7;
   	cout<<ans;
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
  	return 0;
}



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

int dp[110][2];
int arr[110];
int n;
int rec(int p,int f)
{
    if(p==n+1) return 0;
    int &ret=dp[p][f];
    if(ret!=-1) return ret;
    ret=100000;
    if(f==1)
    {
        ret=min(ret,1+rec(p+1,1));
        ret=min(ret,rec(p+1,0));
    }
    else
    {
        if(arr[p]!=arr[p-1]) ret=min(ret,rec(p+1,0));
        ret=min(ret,1+rec(p+1,1));
    }
    return ret;
}

int main()
{
    cin >> n;
    for(int i=1; i<=n; i++) cin >> arr[i];
    memset(dp,-1,sizeof dp);
    int ret=min(1+rec(2,1),rec(2,0));
    cout<<ret<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define f first
#define s second
#define y1 yasfasf
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILE "substring"
#define fr freopen(FILE".in", "r", stdin); freopen(FILE".out", "w", stdout);
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef struct node* treap;

const int N = 1e5 + 11, inf = 1e9;
const ll linf = 1e18, mod = 1e9 + 7;

int a, b, c, d, e, f, ansa, ansb;
bool ok[N], oka[N];
double ans = -1.0;

int main(){
	cin >> a >> b >> c >> d >> e >> f;
	ok[0] = 1;
	for(int i = 0; i <= f; ++i){
		if(!ok[i])
			continue;
		ok[i + 100 * a] = 1;
		ok[i + 100 * b] = 1;
	}
	oka[0] = 1;
	for(int i = 0; i <= f; ++i){
		if(!oka[i])
			continue;
		oka[i + c] = oka[i + d] = 1;
	}
	for(int i = 1; i <= f; ++i){
	for(int j = 0; j <= f; ++j){
		if(!ok[i] || !oka[j])
			continue;
		if(i + j <= f && j * 100 <= e * i){
			if(ans < (double)100 * j / (i + j)){
				ans = (double)100 * j / (i + j);
				ansa = i;
				ansb = j;
			}
		}
	}
	}
	cout << ansa + ansb << " " << ansb;
	return 0;
}           

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, k;
  string s;
  cin >> n >> k >> s;

  vector<pii> a;
  rep(i, n) {
    int cnt = 1;
    while (i < n-1 && s[i] == s[i+1]) {
      i++;
      cnt++;
    }
    a.push_back({cnt, s[i]-'0'});
  }

  ll right = 0;
  ll cnt = 0;
  ll sum = 0;
  ll ans = 0;
  // [left, right)
  rep(left, a.size()) {
    while (right < a.size() && cnt + !a[right].second <= k) {
      cnt += !a[right].second;
      sum += a[right].first;
      right++;
      //cerr << left << " " << right << endl;
      //cerr << "  " << cnt << " " << sum << endl;
    }

    cmax(ans, sum);

    if (right == left) right++;
    else {
      cnt -= !a[left].second;
      sum -= a[left].first;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1528
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,l,a[100010],last=-1;
    vector<ll> ans;
    cin>>n>>l;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-1){
        if(a[i]+a[i+1]>=l){
            last=i+1;
            break;
        }
    }
    if(last==-1){
        cout<<"Impossible"<<endl;
    }
    else{
        cout<<"Possible"<<endl;
        rep2(i,1,last){
            cout<<i<<endl;
        }
        for(ll i=n-1;i>last;i--){
            cout<<i<<endl;
        }
        cout<<last<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
def solve():
    import bisect
    import sys
    A, B, Q = map(int, input().split())
    INF = 10 ** 13
    s = [-INF] + [int(input()) for i in range(A)] + [INF]
    t = [-INF] + [int(input()) for i in range(B)] + [INF]
    xs = [int(sys.stdin.readline()) for i in range(Q)]
    for x in xs:
        b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
        res = INF
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min(res, d1, d2)
        print(res)
if __name__ == '__main__':
  	solve()


Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

int main(){
    int h,w,n;
    cin >>h >>w >>n;

    queue<int> que;
    rep(i,n){
        int a;
        cin >>a;
        rep(j,a) que.push(i+1);
    }

    #define IN(y,x) (0<=y && y<h && 0<=x && x<w)
    vector<vector<int>> c(h,vector<int>(w,0));
    int y=0,x=0;
    int dir=0;
    while(!que.empty()){
        int col=que.front();
        que.pop();
        c[y][x] = col;

        rep(i,4){
            int ny=y+dy[dir], nx=x+dx[dir];
            if(!IN(ny,nx) || c[ny][nx]!=0) dir = (dir+1)%4;
            else{
                y = ny;
                x = nx;
                break;
            }
        }
    }

    rep(i,h)rep(j,w) printf("%d%c",c[i][j]," \n"[j==w-1]);
    return 0;
}


Measured memory_bytes: 384
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [Usize1; n],
    };

    // k <= n (k <= 2*10^5 と十分小さいので愚直に探索する)
    if k <= n {
        println!("{}", (0..k).fold(0, |c, _| a[c]) + 1);
        return;
    }

    // k > n (k 回移動した先は cycle の中にある)
    let (start, cycle) = {
        let mut i = vec![None; n];
        let mut ci = 0;
        let mut ca = 0;
        while let None = i[ca] {
            i[ca] = Some(ci);
            ci += 1;
            ca = a[ca];
        }
        match i[ca] {
            Some(i_i) => (i_i, ci - i_i),
            None => unreachable!(),
        }
    };
    let ans = (0..(k - start) % cycle).fold((0..start).fold(0, |c, _| a[c]), |c, _| a[c]) + 1;
    println!("{}", ans);
}


Measured memory_bytes: 7984
/*input
RRS
*/

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for (char c: s) {
        if (c == 'R') {
            cnt++;
            ans = max(ans, cnt);
        }
        else cnt = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
    int N,K;
    cin >> N >> K;
    int sum=0;
    int x;
    REP(i,N){
        cin >> x;
        sum += 2*min(x,K-x);
    }
    cout << sum;
}

Measured memory_bytes: 256
h = {}

STDIN.gets.to_i.times do
  q = STDIN.gets.split
  case q[0]
  when '0' then
    h[h.length.to_s] = q[1]
  when '1' then
    puts h[q[1]]
  when '2' then
    h.delete((h.length - 1).to_s)
  end
end



Measured memory_bytes: 33800
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using II = pair<int,int>;
using VII = vector<II>;
using MII = map<int,int>;
using IIII = tuple<int,int,int,int>;

IIII max12(MII &M){
	int v1 = 0, c1 = 0;
	int v2 = 0, c2 = 0;
	for(auto p:M)
		if(c1 < p.second){
			v2 = v1; v1 = p.first;
			c2 = c1; c1 = p.second;
		}
		else if(c2 < p.second){
			v2 = p.first;
			c2 = p.second;
		}
	return make_tuple(v1,c1,v2,c2);
}

int main(){
	int N; cin>>N;
	vi V(N); rpz(i,N)cin>>V[i];
	MII E,O;//<value,count>
	for(int e=0; e<=N-2; e+=2){ E[V[e]]++; O[V[e+1]]++; }

	int E1, E1C, E2, E2C;
	tie(E1, E1C, E2, E2C) = max12(E);
	int O1, O1C, O2, O2C;
	tie(O1, O1C, O2, O2C) = max12(O);

	int ans = 0;
	if(E1 != O1){
		ans = N - E1C - O1C;
	}
	else{
		ans = min(N - E1C - O2C, N - E2C - O1C);
	}
	cout<< ans <<endl;

	// puts("-----");///
	// for(auto e:E) printf("%d %d\n",e.first,e.second);puts("--");//
	// for(auto e:O) printf("%d %d\n",e.first,e.second);puts("--");//
	// printf("(%d %d) (%d %d)\n",E1,E1C,E2,E2C);puts("--");///
	// printf("(%d %d) (%d %d)\n",O1,O1C,O2,O2C);puts("--");///
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n,d;
  cin>>n>>d;
  int x[n][d];
  rep(i,n){
    rep(j,d){
      cin>>x[i][j];
    }
  }
  
  //////////
  
  
  int ans=0;
  rep(i,n){
      for(int j = i+1 ; j < (n) ; j ++ ){
         int sum=0;
         rep(k,d){
            sum+=pow(x[i][k]-x[j][k],2) ;
         }
        double dis=pow(sum,0.5);
        int q=dis;
        if(dis-q==0) ans++;
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    vector<ll> l(n+1);
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i <= n; i++) {
        l[i] = l[i-1]+l[i-2];
    }
    std::cout << l[n] << std::endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

// if A >= 1000 then |A^5| - |(A-1)^5| > 10^9 なので、1000を越える数は考慮しない
fn main() {
    let mut line = String::new();
    std::io::stdin().read_to_string(&mut line).unwrap();
    let mut it = line.split_whitespace();
    let x: i64 = it.next().unwrap().parse().unwrap();
    for a in -1000i64..=1000i64 {
        for b in -1000i64..=1000i64 {
            if a * a * a * a * a - b * b * b * b * b == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	vi a(3);
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());

	cout << (a[0] +a[1]) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
 
char a[15];
ll c[10];
 
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	memset(c, 0, sizeof(c));
	while(n--){
		cin >> a;
		if(a[0] == 'M') c[1]++;
		if(a[0] == 'A') c[2]++;
		if(a[0] == 'R') c[3]++;
		if(a[0] == 'C') c[4]++;
		if(a[0] == 'H') c[5]++;
	}
	ll ans = 0;
	for(int i = 1; i <= 3; i++)
		for(int j = i + 1; j <= 4; j++)
			for(int k = j + 1; k <= 5; k++)
				ans += c[i] * c[j] * c[k];
				cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> V(N),C(N);
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }

    int count=0;
    for(int i=0;i<N;i++){
        if(V[i]>C[i]) count+=V[i]-C[i];
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

 struct Node{
             int parent;
             int left;
             int right;
             };

 struct Node N[10000];

 void preorder(int u){
             if(u==NIL)return;
             printf(" %d",u);
             preorder(N[u].left);
             preorder(N[u].right);
             }

 void inorder(int u){
             if(u==NIL)return;
             inorder(N[u].left);
             printf(" %d",u);
             inorder(N[u].right);
             }

 void postorder(int u){
             if(u==NIL)return;
             postorder(N[u].left);
             postorder(N[u].right);
             printf(" %d",u);
             }


 int main(){
       int i,n,root=0,v,l,r;
       scanf("%d",&n);
       for(i=0;i<n;i++){N[i].parent=NIL;}
       for(i=0;i<n;i++){
              scanf("%d %d %d",&v,&l,&r);
              N[v].left=l;
              N[v].right=r;
              if(l!=NIL)N[l].parent=v;
              if(r!=NIL)N[r].parent=v;
              }

       for(i=0;i<n;i++)if(N[i].parent==NIL)root=i;

       printf("Preorder\n");
       preorder(root);
       printf("\n");

       printf("Inorder\n");
       inorder(root);
       printf("\n");

       printf("Postorder\n");
       postorder(root);
       printf("\n");
       
       return 0;
       }






Measured memory_bytes: 2124
n=int(input())
word=[]
word.append(input())
word.append(input())
word.append(input())
count=0
for i in range(len(word[0])):
    if word[0][i] != word[1][i] and word[1][i] != word[2][i] and word[0][i] != word[2][i]:
        count+=2
    elif word[0][i] != word[1][i] or word[1][i] != word[2][i]:
        count+=1
    else:
        pass
print(count)


Measured memory_bytes: 3064
#define i(a,b) a=a<b?a:b;
d,a[100][100],b[100][100],u=-1,v,c;main(n){for(scanf("%d%*d",&n);++u<n;)for(v=0;v<n;)b[u][v++]=1<<28;for(;~scanf("%d%d%d",&u,&v,&c);a[--u][--v]=a[v][u]=b[u][v]=b[v][u]=c);for(u=0;u<n;u++)for(v=0;v<n;v++)for(c=0;c<n;c++)i(b[v][c],b[v][u]+b[u][c])for(u=-1;++u<n;)for(c=u;c<n;)a[u][c]>b[u][c++]?d++:0;printf("%d\n",d);}

Measured memory_bytes: 256