akhauriyash/Code-Regression huggingface dataset:
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	N := readInt()
	S := readString()

	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, N+1)
	}

	result := 0
	for i := N - 1; i > -1; i-- {
		for j := N - 1; j > -1; j-- {
			if S[i] == S[j] {
				dp[i][j] = dp[i+1][j+1] + 1
				t := min(dp[i][j], j-i)
				result = max(result, t)
			}
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 207872
#include<stdio.h>
int main ()
{
	int a,b,c,d,i,f,g,h,e;
	
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(a<0)
	{
		i=c*a*-1+d;
		i=i+e*b;
		printf("%d\n",i);
	}
	if(a>0)
	{
	i=b-a;
	i=i*e;
	printf("%d\n",i);
	}
	
	
	return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int map[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            map[i][j] = 0;
        }
    }

    int cou = 0;
    int now = 0;
    for(int i = 0; i < h; i++){
        if(i % 2 == 0){
            for(int j = 0; j < w; j++){
                if(cou == a[now]){
                    cou = 1;
                    map[i][j] = now + 2;
                    now++;
                }else{
                    cou++;
                    map[i][j] = now + 1;
                }
            }
        }else{
            for(int j = w - 1; j >= 0; j--){
                if(cou == a[now]){
                    map[i][j] = now + 2;
                    now++;
                    cou = 1;
                }else{
                    cou++;
                    map[i][j] = now + 1;
                }
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << map[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

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

Measured memory_bytes: 3140
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int N = 105;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-6;
struct node{
	double x,y;
}g[N];
int main()
{
	string a;
	cin>>a;
	if(a[2]==a[3]&&a[4]==a[5])cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int H = 500000;

void maxHeapify(int *A,int i){
  int largest, ch, l, r;
  l = 2*i; 
  r = 2*i+1;

  if(l <= H && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }

  if(r <= H && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    ch = A[i];
    A[i] = A[largest];
    A[largest] = ch;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i = H/2;i >= 1; i--){
    maxHeapify(A, i);
  }
}

int main(){
  int A[H];
  int i;

  scanf("%d",&H);
  for(i = 1;i <= H; i++){
    scanf("%d", &A[i]);
  }

  buildMaxHeap(A);

  for(i = 1; i <= H; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
 
  return 0;
}



Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

bool is_prime[30001];

int main(){
  int side_sum;

  memset(is_prime,true,sizeof(is_prime));
  is_prime[0] = false;
  is_prime[1] = false;
  vector<int> prime;
  for(int i=0;i<=30000;i++){
    if(!is_prime[i]) continue;
    prime.push_back(i);
    for(int j=i+i;j<=30000;j+=i){
      is_prime[j] = false;
    }
  }

  while(~scanf("%d",&side_sum)){
    if(side_sum == 0) break;
    int res = 0;
    map<vector<int>,bool> visited;

    for(int prime_i = 0; prime_i < prime.size(); prime_i++){

      int center_side = prime[prime_i];
      if(2 * center_side >= side_sum) break;

      int remainings = side_sum - center_side;
      if(remainings <= 0) break;
      
      for(int prime_j = 0; prime_j < prime.size(); prime_j++){
        int left_side = prime[prime_j];
        int right_side = remainings - left_side;

        if(right_side <= 0) break;
        if(!is_prime[right_side]) continue;
        if(left_side > right_side) break;

        vector<int> used;
        used.push_back(center_side);
        used.push_back(left_side);
        used.push_back(right_side);
        sort(used.begin(),used.end());
        if(used[0] + used[1] <= used[2]) continue;

        if(visited.find(used) != visited.end()) continue;

        visited[used] = true;
        res++;
      }
    }
    printf("%d\n",res);
  }
}

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

int main() {
  int n;
  cin>>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
  }
  for(int i=0;i<n-1;i++){
    if(a[i]> a[i+1]){
      a[i+1]++;
      if(a[i]>a[i+1]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 4048
from math import sqrt
from collections import defaultdict
def furui(N):
    primes = []
    nums = list(range(2,N+100))#探索リスト
    limit = sqrt(N+1)

    while True:
        p = nums[0]
        if p > limit:
            primes += nums
            return primes

        primes.append(p)
        nums = [num for num in nums if num % p != 0]




N = int(input())
DIV = 10**9 + 7
primes = furui(N)
di = defaultdict(lambda :0)
for i in range(2,N+1):
    temp = i
    for p in primes:
        while True:
            if temp % p == 0:
                di[p] += 1
                temp /=p
            else:
                break

ans = 1
for v in di.values():
    ans *= (v+1)

print(ans%DIV)

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
string a;
int k[5];
int main()
{
    cin>>a;
    int len=a.size();
    for(int i=0;i<len;i++)
    {
        if(a[i]=='C') k[1]++;
        if(a[i]=='F' && k[1]>0) 
        {
           cout<<"Yes";
           return 0;
		}
	}
	cout<<"No";
    return 0;
}


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

using std::cin;
using std::cout;
using std::endl;

int main(int argc, char* argv[])
{
  int N;
  cin >> N;
  std::vector<int> A(N);
  std::map<int, long> data;
  for (size_t i = 0; i < N; ++i)
  {
    int tmp;
    cin >> tmp;
    A[i] = tmp;
    if(data.find(tmp) == data.end()){
      data[tmp] = 1;
    }
    else{
      data[tmp] +=1;
    }
  }

  long all_result = 0;  
  for(auto it = data.begin(); it != data.end(); ++it){
    all_result += it->second * (it->second-1)/2;
  }

  for (size_t k = 0; k < N; ++k)
  {
    cout << all_result - (data[A[k]] - 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 12160
n = int(input())
a = list(map(lambda x: int(x), input().split()))
b = list(map(lambda x: int(x), input().split()))
c = list(map(lambda x: int(x), input().split()))

point = 0
temp = n + 1

for i, num in enumerate(a):
    point += b[num - 1]
    if num == temp + 1:
        point += c[num - 2]
    temp = num

print(point)



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

class combination{
private:
  vector<mint> fact,finv;
public:
  combination(int N){
    fact = finv = vector<mint>(N+1);
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    for(ll i=2;i<=N;i++){
        fact[i] = fact[i-1]*i;
        finv[i] = fact[i].inv();
    }
  }
  mint f(int i){
    return fact[i];
  }
  mint comb(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fact[n]*finv[k]*finv[n-k];
  }
  mint hcomb(int n,int k){
    if(n==0 && k==0) return 1;
    return comb(n+k-1,k);
  }
};

map<ll, int> primeFactor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

int main() {
  //
  ll n,m;
  cin>>n>>m;

  combination comb(n+100);

  map<ll,int> pf = primeFactor(m);
  mint ans = 1;
  for (auto& x : pf) {
    // cout << x.first << "," << x.second << ":" << comb(n+x.second-1,n-1) <<endl;
    ll f = x.second;
    ans = ans * comb.comb(n+f-1, n-1);
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  string S;
  cin >> S;
  
  int ans = 1000;
  for (int i = 0; i + 2 < S.size(); i++) {
    int n = stoi(S.substr(i, 3));
    ans = min(ans, abs(n - 753));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int a;
    string s;
    cin >> a >> s;

    if (a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
	int a[5];
	scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
	sort(a,a + 5);
	reverse(a,a + 5);
	printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
	return 0;
}

Measured memory_bytes: 1040
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long MOD = (long)Math.pow(10, 9) + 7;
    long r1 = 1;
    long r2 = 1;
    long r3 = 1;
    for(int i = 0; i < n; i++) {
      r1 = (r1 * 10) % MOD;
    }
    for(int i = 0; i < n; i++) {
      r2 = (r2 * 9) % MOD;
    }
    for(int i = 0; i < n; i++) {
      r3 = (r3 * 8) % MOD;
    }
    long r4 = (r2 + r2 + MOD - r3) % MOD;
    long ans = (r1 + MOD - r4) % MOD;
    System.out.println(ans);
  }
}


Measured memory_bytes: 35668
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000001
#define DIM 200001
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef set <string>sst;
typedef set <long long>sl;
typedef queue <long long>que;
typedef vector <long long>vec;
typedef unsigned long long ull;
typedef map <long long,long long>mll;
typedef pair <long long,long long>pll;
typedef vector <pair<long long,long long> >vpl;
typedef pair <long long, unsigned long long > pul;
ll n,z,s,x,c,a[200001];
int main()
{
    cin>>n;
    if (n%2!=0)
        return cout<<0<<endl,0;
    n/=2;
    while(n!=0)
    {
        z+=n/5;
        n/=5;
    }
    cout<<z<<endl;

}


Measured memory_bytes: 384
import collections

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

S=[A[0]]
for i in range(1,N):
  S.append(S[i-1]+A[i])
#print(S)
  
cnt=0
for s in S:
  if s==0: cnt+=1
    
S=list(collections.Counter(S).items())
for s in S:
  if s[1]>=2: cnt+=s[1]*(s[1]-1)//2
  
print(cnt)

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

using namespace std;

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

    int k, t;
    cin >> k >> t;
    int best = 0;

    for (int i = 0; i < t; i++) {
        int x;
        cin >> x;
        best = max(best, x);
    }

    int other = k - best;

    cout << max(0, best - other - 1) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <climits>
#include <bitset>
#include <cassert>

using namespace std;

const int SIZE = 1 << 17;

int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0, sign = 1;
    char ch = Advance();
    while (!isdigit(ch) && ch != '-')
        ch = Advance();
    if (ch == '-') {
        sign = -1;
        ch = Advance();
    }
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer * sign;
}

char ReadCh() {
    char ch = Advance();
    while (!isalpha(ch))
        ch = Advance();
    return ch;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int x, y;
    scanf("%d%d", &x, &y);
    if (x % y == 0)
        printf("-1\n");
    else
        printf("%d\n", x);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  const Int INF = 1e15;
  vector<Int> s(n+1,INF);
  vector<Int> ls(n);
  Int len=0;
  for(Int i=0;i<n;i++){
    ls[i]=lower_bound(s.begin(),s.end(),a[i])-s.begin();
    s[ls[i]]=a[i];
    chmax(len,ls[i]+1);
    //cout<<i<<":"<<ls[i]<<endl;
  }
  const Int MAX = 1e5+100;
  vector<map<Int, Int> > dp(MAX);
  for(Int i=0;i<MAX;i++){
    dp[i][-INF]=-INF;
    dp[i][+INF]=+INF;
  }
  dp[0][0]=0;
  for(Int i=0;i<n;i++){
    Int res=(--dp[ls[i]].lower_bound(a[i]))->second;
    res+=a[i];
    
    auto &ms=dp[ls[i]+1];
    chmax(ms[a[i]],res);
    
    {
      auto it=ms.find(a[i]);
      auto ushi=it;ushi--;
      if(ushi->second>=it->second){
        ms.erase(it);
        continue;
      }
    }
    while(1){
      auto it=ms.find(a[i]);
      auto uku=it;uku++;
      if(it->second>=uku->second){
        ms.erase(uku);
        continue;
      }
      break;
    }
  }  
  cout<<((----dp[len].end())->second)<<endl;
  return 0;
}



Measured memory_bytes: 28708
n=int(input())
l=list(map(int,input().split()))
for i in range(n):
  l[i]=l[i]-(i+1)
l.sort()
if n%2==0:
  b=(l[n//2-1]+l[n//2])//2
else:
  b=l[n//2]
ans=0
for i in range(n):
  ans+=abs(l[i]-b)
print(ans)

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

 
int main() {
    ll n,m;
    cin>>n>>m;
    if(n==1&&m==1)cout<<1<<endl;
    else if(n==1)cout<<m-2<<endl;
    else if(m==1)cout<<n-2<<endl;
    else cout<<(n-2)*(m-2)<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<int> v( N );
	rep( i, N ) cin >> v[i];
	sort( ALL( v ) );

	int abc = v[N / 2 - 1];
	int arc = v[N / 2];

	cout << max( arc - abc, 0 ) << endl;

	return ( 0 );
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
vector<int> g[100005];
ll q,n;

int main()
{
    //IOS;
    while(cin>>n)
    {
        ll sum=0;
        ll A,B;
        cin>>A>>B;
        for(int i=1;i<=n;i++)
        {
            ll a=i/10000,b=(i%10000)/1000,c=(i%1000)/100,d=(i%100)/10,e=i%10;
            if(a+b+c+d+e<=B&&a+b+c+d+e>=A) sum+=i;
        }
        cout<<sum<<"\n";
    }

    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int i,n,t,p=0,a,b=0,j=1;
    cin>>n;
    while(n!=0){
        n=n>>1;
        b++;
    }
    for(i=0;i<b;i++){

        p+=j;
       // cout<<p<<endl;
         j*=2;

    }

    cout<<p<<endl;

    return EXIT_SUCCESS;
}




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

const int INF = INT_MAX/2;

int main(){
    int N, K; cin >> N >> K;
    vector<int> h;
    vector<int> dp(N+1, INF);
    for(int i=0; i<N; i++){
        int g; cin >> g;
        h.push_back(g);
    }
    dp[0] = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<K+i+1 && j<N; j++){
            dp[j] = min(dp[j], dp[i]+abs(h[j]-h[i]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<sstream>
#include<map>
#include<vector>
using namespace std;
#define MAX 1000

class Node{
    public:
    int parent;
    vector<int> children;
    Node(){}
};

Node N[MAX];
map<string, int> N_I;
int n;
string line;

void makeTree(){
    for ( int i = 0; i < n; i++ ) N[i] = Node();
    string name;
    int P[MAX], pr;
    N[0].parent = -1;
    for ( int i = 0; i < n; i++ ){
	getline(cin, line);
	int ns = 0;
	while( line[ns] == ' ') ns++;
	name = line.substr(ns, line.size()-ns);
	N_I[name] = i;
	P[ns] = i;
	if ( i == 0 ) continue;
	pr = P[ns-1];
	N[i].parent = pr;
	N[pr].children.push_back(i);
    }
}

bool parse( int u, int target ){
    if ( u == -1 ) return false;
    if ( u == target ) return true;
    if ( parse(N[u].parent, target) ) return true;
    return false;
}

bool check(string s_str, string com, string t_str){
    int s = N_I[s_str];
    int t = N_I[t_str];
    if ( com == "child" ) return N[s].parent == t;
    else if ( com == "parent" )	return N[t].parent == s;
    else if ( com == "sibling" ) return N[t].parent == N[s].parent;
    else if ( com == "ancestor" ) return parse(t, s);
    else if ( com == "descendant" ) return parse(s, t);
}

main(){
    int m;
    string s, com, t, tmp;
    while( cin >> n >> m && n && m){
	getline(cin, line);
	makeTree();
	for ( int i = 0; i < m; i++ ) {
	    getline(cin, line);
	    stringstream sin(line);
	    sin >> s >> tmp >> tmp >> com >> tmp >> t;
	    t = t.substr(0, t.size()-1);
	    if ( check(s, com, t) ) cout << "True" << endl;
	    else cout << "False" << endl;
	}
	cout << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	vi isPrime(10001,1);
	isPrime[0]=isPrime[1]=0;
	repi(i,2,isPrime.size())
		if(isPrime[i])
			for(int j=i+i;j<isPrime.size();j+=i)
				isPrime[j]=0;
	
	for(int n;cin>>n;){
		int res=0;
		for(int i=1;i<=n;i++)
			res+=(isPrime[i]&isPrime[n+1-i]);
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    answer = n
    chk = [0 for _ in range(a[-1] + 1)]
    for aa in a:
        chk[aa] += 1
    if a[0] == 1:
        answer = 0 if chk[1] - 1 else 1
    else:
        for i in range(a[-1] + 1):
            if chk[i]:
                if chk[i] - 1:
                    answer -= chk[i]
                for j in range(2 * i, a[-1] + 1, i):
                    answer -= chk[j]
                    chk[j] = 0
        answer = max(answer, 0)
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 32244
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  bool ans=true;
  if(n%2!=0){
    ans=false;
  }else{
    for(int i=0;i<=(n/2)-1;i++){
      if(s[i]!=s[i+n/2]){
        ans=false;
      }
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
    
  
}

Measured memory_bytes: 256
str = input()

def cnt(s):
    count = 0
    for st in s:
        if st is 'A' or st is 'C' or st is 'G' or st is 'T':
            count += 1
        else:
            return count
    return count

cs = 0
max = 0
for s in str:
    res = cnt(str[cs:len(str)])
    if max < res:
        max = res
    cs += 1
print(max)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

int keta(int x){
    int ret=0;
    while(x>0){
        ret++;
        x/=10;
    }
    return ret;
}

signed main(){
    int n;cin>>n;
    int ans=INF;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0)chmin(ans,max(keta(i),keta(n/i)));
    }   
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define GRAY 0
#define WHITE 1
#define BLACK -1

typedef struct{
  int color;
  int cnt;
  int next[10];
}Node;

int d[101];
Node dfs[101];

int head,tail,que[101];

void enqueue(int x){
  que[tail]=x;
  tail = (tail+1)%101;
}

int dequeue(void){
  int x;
  x=que[head];
   head = (head+1)%101;
  return x;
}



int main(){

  int n,m,k,l,i,j,u;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    dfs[i].color=WHITE;
    d[i]=1000000000;
    scanf("%d%d",&m,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&l);
      dfs[i].next[j]=l;
      dfs[i].cnt=k;
      // printf("aaa %d\n",dfs[i].next[j]);
    }
    
  }
  
  dfs[1].color=GRAY;
  d[1]=0;
  enqueue(1);

  while(head!=tail){
 
    u=dequeue();
    for(i=1;i<=dfs[u].cnt;i++){
      //  printf("coooo %d\n",dfs[dfs[u].next[i]].color);
      // printf("%d next %d color:%d\n",u,dfs[u].next[i],dfs[dfs[u].next[i]].color);
      if(dfs[dfs[u].next[i]].color==WHITE){
	dfs[dfs[u].next[i]].color=GRAY;
	d[dfs[u].next[i]]=d[u]+1;
	enqueue(dfs[u].next[i]);
	//	printf("now:%d distance:%d next:%d\n",u,d[u],dfs[u].next[i]);
      }
    }
    dfs[u].color=BLACK;
    // printf("\n");
  }
  for(i=1;i<=n;i++) {
    if(d[i]==1000000000)d[i]=-1;

    printf("%d %d\n",i,d[i]);


  }

  
 
return 0;
}



Measured memory_bytes: 2132
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int mo = 1e9 + 7,sz=310;
typedef long long ll;
ll n,a[sz][sz];
bool avoid[sz][sz];
ll ans=0;
void solve()
{
    bool ok=1;
    rep(i,n)rep(j,n)rep(k,n)
    {
        if(a[i][k]+a[k][j]<a[i][j])
        {
            ok=0;
            break;
        }
        if(i!=k&&j!=k)if(a[i][k]+a[k][j]==a[i][j])avoid[i][j]=1;;
    }
    rep(i,n)rep(j,n)if(!avoid[i][j])ans+=a[i][j];
    if(!ok)ans=-1;
    else ans/=2;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n;
    rep(i,n)rep(j,n)cin>>a[i][j];
    solve();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1152
//By Vlgd
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
//OrthogonalÕý½» 
bool isOrthogonal(Vector a,Vector b){
	return equals(dot(a,b),0.0);
}
//ParallelÆ½ÐÐ 
bool isParallel(Vector a,Vector b){
	return equals(cross(a,b),0.0);
}
int main(){
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Vector a(x1-x2,y1-y2);
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Vector b(x1-x2,y1-y2);
		if(isOrthogonal(a,b))printf("1\n");
		else if(isParallel(a,b)) printf("2\n");
		else printf("0\n");
	}
	return 0;
}


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

int main(){
    int a1,a2,a3,b1,b2,b3;
    cin >> a1 >> a2 >> a3;
    if (a1 > a2){
        b1 = a1; 
        a1 = a2;
        a2 = b1;
        if (a2 > a3){
            b2 = a2;
            a2 = a3;
            a3 = b2;
            if (a1 > a2){
                b3 = a1;
                a1 = a2;
                a2 = b3;
            }
        }
    }
    else if (a1 < a2){
        a1 = a1;
        a2 = a2;
        if (a2 > a3){
            b2 = a2;
            a2 = a3;
            a3 = b2;
            if (a1 > a2){
                b1 = a1;
                a1 = a2;
                a2 = b1;
            }
        }
    }
    cout << a1 << " " << a2 << " " << a3 << '\n';
    return 0;

}



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

int main() {
  int N,M,sum=0;
  cin >> N;
  M=N;
  for(int i=100000000;i>=1;i /= 10){
    sum += M/i;
    M=N%i;
  }
  if(N%sum==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main()
{
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool isValid = true;
	for (int i = 0; i < s.size(); i++)
	{
		if (((s[i] < '0' || s[i] > '9') && i != a) || (i == a && s[i] != '-'))
		{
			isValid = false;
			break;
		}
	}
	if (isValid) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


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

#define MAXN 1000010
#define mod 1000000007

int n,f[MAXN],add;

int main()
{
	scanf("%d",&n);
	f[n]=n;
	f[n-1]=(long long)n*n%mod;
	for(int i=n-2;i>=1;--i)
	{
		add=(add+f[i+3])%mod;
		f[i]=f[i+1];
		f[i]=(f[i]+(long long)(n-1)*(n-1)%mod)%mod;
		f[i]=(f[i]+add)%mod;
//		f[i]=(f[i]+(n-(n-i+1)+1))%mod;
		f[i]=(f[i]+i+1)%mod;
	}
	printf("%d\n",f[1]);
}

Measured memory_bytes: 4096
while True:
    s = input().split('"')
    if s == ['.']:
        exit()
    t = input().split('"')

    is_diff = False
    is_close = 0
    if len(s) == len(t):
        for i in range(len(s)):
            if i % 2 == 0:
                if s[i] != t[i]:
                    is_diff = True
            else:
                if s[i] != t[i]:
                    is_close += 1
    else:
        is_diff = True

    if is_diff:
        print('DIFFERENT')
    elif is_close == 0:
        print('IDENTICAL')
    else:
        print(['CLOSE', 'DIFFERENT'][is_close > 1])




Measured memory_bytes: 5584
k = int(input())
mod = 7
#l = []

for i in range(10**6):
    j = mod % k
#    logging.debug("i = {}, mod = {}, mod % k ={}".format(i,mod,j))
    if i > 1 and j == 7:
        print(-1)
        exit()
    if j == 0:
        print(i + 1)
        exit()
    else:
        #l.append(j)
        #if len(set(l)) != len(l):
        #    print(-1)
        #    exit()
        mod = j * 10 + 7
print(-1)

Measured memory_bytes: 9160
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LIN(N)
    for i,a in enumerate(A):
        if i<a:
            print(-1)
            return
    now_lim = 0
    ans = 0
    for i in range(N)[::-1]:
        now_lim-=1
        now_lim = max(0, now_lim)
        if A[i]<now_lim:
            print(-1)
            return
        elif A[i] == now_lim:
            pass
        else:
            ans += A[i]
        now_lim = max(A[i],now_lim)
    print(ans)
        
if __name__ == '__main__':
    main()


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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

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

ll cost[405][405];
ll prefixSum[405];

ll d[405][405]; 

ll a[405];


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
	int n;
	cin >> n;

	FOR (i, 1, n) {
		cin >> a[i];
	}

	FOR (i, 1, n) {
		prefixSum[i] = prefixSum[i - 1] + a[i];
	}

	FOR (i, 1, n) {
		FOR (j, i, n) {
			cost[i][j] = prefixSum[j] - prefixSum[i - 1];
		}
	}

	FOR (len, 0, n - 1) {
		FOR (i, 1, n) {
			int j = i + len;
			if (len == 0) {
				d[i][j] = 0;
				continue;
			}
			d[i][j] = 1e18;

			FOR (k, i, j - 1) {
				d[i][j] = min(d[i][j], d[i][k] + d[k + 1][j] + cost[i][j]);
			}
		}
	}    

	cout << d[1][n] << endl;
	
    return 0;
}

Measured memory_bytes: 2816
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    cnt = 1
    p, l = 0, u[0] + k
    for v in t:
        if v <= l and p < c:
            p += 1
        else:
            cnt += 1
            l = v + k
            p = 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14052
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int n, z, w, a[2010];
int dp[2010][2];

int f(int id, int turn, int x, int y) {
	//終了条件
	//山札がなくなったら、互いの手の差の絶対値がスコア
	if (id == n)return abs(x - y);

	//メモしてあればそれを使う
	if (dp[id][turn] != -1)return dp[id][turn];

	//先手
	if (turn == 0) {
		int ma = -1;
		for (int i = id; i < n; i++) {
			ma=max(ma, f(i + 1, 1, a[i], y));
		}
		return dp[id][turn] = ma;
	}

	//後手
	if (turn == 1) {
		int mi = INF;
		for (int i = id; i < n; i++) {
			mi=min(mi, f(i + 1, 0, x, a[i]));
		}
		return dp[id][turn] = mi;
	}
}

int main() {

	cin >> n >> z >> w;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i][j] = -1;
		}
	}

	cout << f(0, 0, z, w) << endl;


	return 0;
}

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

using namespace std;

int main(){

   string s;
   int cnt = 0, ans = 0;

   cin >> s;

   for(int i = 0; i < s.length(); i++){
      if(s[i] == 'R'){
         cnt++;
      }
      else{
         if(ans < cnt){
            ans = cnt;
         }
         cnt = 0;
      }
   }

if(ans < cnt){
   ans = cnt;
}

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<int,int>;
using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////

void solve(){
  ini(N);
  vi a(N),b(N),c(N-1);
  in(a,b,c);
  rep(i,N) a[i]--;
  int ans  = 0;
  rep(i,N){
    ans += b[a[i]];
    if(i && a[i-1] + 1 == a[i]) ans += c[a[i-1]];
  }
  out(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int dijkstra(const vector<vector<int>> edge) {
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
  vector<int> dist(edge.size(),INF);
  dist[0] = 0;
  q.push(mp(0,0));
  while(!q.empty()) {
    auto p = q.top();
    q.pop();
    if(p.first > dist[p.second]) break;
    for(int i = 0;i < edge[p.second].size(); ++i){
      int to = edge[p.second][i];
      if(dist[to] > dist[p.second]+1) {
        dist[to] = dist[p.second]+1;
        q.push(mp(dist[to],to));
      }
    }
  }
  return dist[edge.size()-1];
}

int main(void) {
  int n;
  cin >> n;
  vector<int> ary(n);
  vector<int> jmp(n);
  vector<int> ok(n,0);
  REP(i,n)cin>>ary[i];
  REP(i,n) {
    if(ary[i] != 0) {
      if(ok[i] == 0) {
        set<int> s;
        s.insert(i);
        int j = i;
        bool f = true;
        while(f) {
          j += ary[j];
          f = false;
          switch(ok[j]) {
            case 0:
              if(s.find(j) != s.end()) {
                for(int k : s)
                  ok[k] = -1;
              } else if(ary[j] == 0) {
                jmp[j] = j;
                ok[j] = 1;
                for(int k : s) {
                  ok[k] = 1;
                  jmp[k] = j;
                }
              } else {
                s.insert(j);
                f = true;
              }
              break;
            case 1:
              for(int k : s) {
                ok[k] = 1;
                jmp[k] = jmp[j];
              }
              break;
            case -1:
              for(int k : s)
                ok[k] = -1;
              break;
          }
        }
      }
    } else {
      ok[i] = 1;
      jmp[i] = i;
    }
  }
  vector<vector<int>> edge(n);
  REP(i,n) {
    if(ok[i] >= 0) {
      FOR(j,1,7) {
        if(i+j>=n)
          edge[i].push_back(n-1);
        else if(ok[i+j] >= 0)
          edge[i].push_back(jmp[i+j]);
      }
    }
  }
  int l = dijkstra(edge);
  cout<<l<<endl;
  return 0;
}

Measured memory_bytes: 15188
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	ll a, b;
	cin >> a >> b;
	if(a <= 8 && b <= 8){
		cout << "Yay!";
		return 0;
	}
	cout << ":(";
	return 0;
}

Measured memory_bytes: 3588
k = int(input())
n = 0

def ff(s, i):
    for j in range(i+1, len(s)):
        #print(s[j-1])
        if s[j-1] > 0:
            s[j] = s[j-1] - 1
        else:
            s[j] = 0
    return s

def next(s):
    ls = len(s)
    for i in range(ls-1, 0, -1):
        if s[i-1] >= s[i] and s[i] != 9:
            s[i] += 1
            #print(s[i-1],s[i])
            return ff(s, i)
    if s[0] == 9:
        return [1] + ([0] * ls)
    else:
        s[0] += 1
        return ff(s, 0)

if k < 10:
    print(k)
    exit()

ans = [1,0]
for i in range(k - 10):
    ans = next(ans)
#print(ans)
print(''.join(map(str, ans)))






Measured memory_bytes: 42972
#include<iostream>
using namespace std;
void cube(int x,int y,int& z,int& t){
    z=x*y;
    t=(x+y)*2;
}
int main(){
    int a,b,c,d;
    cin>>a>>b;
    cube(a,b,c,d);
    cout<<c<<" "<<d<<endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <limits>
#include <queue>
#include <set>
using namespace std;
typedef long long int lld;
int T;
int main(void){
    string s; string front; string end;
    cin >> s;
    int n;
    cin >> n;
    int reverse = 0;
    while(n--){
        int cc; cin >> cc;
        if(cc == 1){
            reverse = 1-reverse;
        }
        else if(cc == 2){
            int cc2; cin >> cc2;
            char cc3; cin >> cc3;
            if(reverse == 0) {
                if (cc2 == 1) front += cc3;
                else end += cc3;
            }
            else{
                if (cc2 == 1) end += cc3;
                else front += cc3;
            }
        }
    }
    if(reverse == 1) {
        for(int i = end.size()-1; i >= 0; i--) cout << end[i];
        for(int i = s.size()-1; i >= 0; i--) cout << s[i];
        cout << front;
    }
    else {
        for(int i = front.size()-1; i >= 0; i--) cout << front[i];
        cout << s;
        cout << end;
    }
    return 0;
}


Measured memory_bytes: 1088
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
C = read().rstrip().decode()

l, r = 0, N - 1
cost = 0
while l < r:
    if C[l] == 'R':
        l += 1
    elif C[r] == 'W':
        r -= 1
    else:
        # R...W
        cost += 1
        l += 1
        r -= 1

print(cost)


Measured memory_bytes: 9436