akhauriyash/Code-Regression huggingface dataset:
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  string s;
  cin >> s;
  switch(s[0]){
    case 'A': puts("T"); return 0;
    case 'T': puts("A"); return 0;
    case 'G': puts("C"); return 0;
    case 'C': puts("G"); return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<set>
#define N 100005
using namespace std;
int n,m,ans,pre[N],num[N],vis[N],rt[N];
multiset<int>s[N];
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1,a,b;i<=n;i++)
	{
		scanf("%d %d",&a,&b);
		if(a>m)continue;
		vis[m-a+1]=1;
		s[m-a+1].insert(b);
	}
	for(int i=1,cnt=1;i<=m;i++)
	{
		rt[i]=i;
		if(vis[i-1])pre[i]=i-1;
		else pre[i]=pre[i-1];
		if(vis[i])num[i]=cnt,cnt=1;
		else cnt++;
	}
	for(int i=m;i>=1;i--)
		if(vis[i])
		{
			set<int>::iterator it;
			while(num[i]&&!s[rt[i]].empty())
			{
				it=s[rt[i]].end(),it--;
				ans+=*it,s[rt[i]].erase(it),num[i]--;
			}
			int j=pre[i];
			if(s[rt[j]].size()<s[rt[i]].size())swap(rt[j],rt[i]);
			while(!s[rt[i]].empty())
			{
				it=s[rt[i]].end(),it--;
				s[rt[j]].insert(*it),s[rt[i]].erase(it);
			}
		}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> buka(n, 0);
    for (int i = 2; i <= n; i++) {
        int a; cin >> a;
        buka.at(a-1) += 1;
    }
    for (int x: buka) {
        cout << x << endl;
    }
}

Measured memory_bytes: 4048
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll n;cin>>n;
    ll p[n];REP(i,n)cin>>p[i];

    ll cnt=0;
    REPS(i,n-1-1){
        if(p[i]!=max(p[i],max(p[i-1],p[i+1])) and p[i]!=min(p[i],min(p[i-1],p[i+1])))cnt++;
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){ 
	int n;
	cin >> n;
	long long temp = 1000000;
	long long tempo = -1000000;
	long long all = 0;
	for(int i = 0; i < n; i++){
		long long a;
		cin >> a;
		// tempとaを比較し、小さいほうを新しいaとする
		if(temp>a){
			temp = a;
		}
		if(tempo<a){
			tempo = a;
		}
		all += a;
	}
	cout << temp << " " << tempo << " " << all << endl;
	return 0;
}


Measured memory_bytes: 3104
N,Q = [int(zz) for zz in input().split()]
S = input()

li = [0]*N
Aflag = 0
AC = 0
for i in range(N):
    if S[i] == 'A':
        Aflag = 1
    elif S[i] == 'C' and Aflag:
        AC += 1
        Aflag = 0
    else:
        Aflag = 0
    li[i] = AC

ans = []
for _ in range(Q):
    l,r = [int(zz)-1 for zz in input().split()]
    ans.append(li[r]-li[l])

[print(i) for i in ans]


Measured memory_bytes: 65752
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = 0;
  if (n == 1) {
    cout << 0 << '\n';
    return 0;
  }
  else {
    auto a = prime_factorize(n);
    for (ll i = 0; i < a.size(); i++) {
      ll b = a[i].second;
      ll c = 0;
      for (ll j = 1; ; j++) {
        c += j;
        if (c > b) {
          ans += j-1;
          break;
        }
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,t,s) for(int i = (int)(t); i >= (int)(s); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1) / (d) + 1)
#define parity(a,b) (a & 1 == b & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const int mod = 1e9 + 7;

int N,A,B,h[100100];

bool judge(ll n){
	ll s = 0;
	rep(i,N){
		if(h[i] <= n * B) continue;
		s += q_ceil(h[i] - n * B,A - B);
		if(s > n) return 0;
	}
	return 1;
}

int solve(){
	ll upper = inf32;
	ll lower = 0;
	while(upper - lower > 1){
		ll mid = (upper + lower) / 2;
		if(judge(mid)) upper = mid;
		else lower = mid;
	}
	return upper;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
		
	cin >> N >> A >> B;
	rep(i,N) cin >> h[i];
	cout << solve() << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  vvi c(3, vi(3));
  rep(i, 0, 3) {
    rep(j, 0, 3) {
      in(c[i][j]);
    }
  }
  rep(i, 0, 3) {
    set<int> a, b;
    rep(j, 0, 3) {
      a.insert(c[i][j] - c[(i + 2) % 3][j]);
      b.insert(c[j][i] - c[j][(i + 2) % 3]);
    }
    if (a.size() != 1 || b.size() != 1) {
      print("No");
      return;
    }
  }
  print("Yes");
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	str := oneStr()

	nums := []int{}

	for _, s := range str {
		n := string(s)
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}


	ans := calc(nums)

	fmt.Println(ans)
}

func calc(nums []int) int {
	if len(nums) == 1 {
		return 0
	}

	if len(nums) == 2 {
		if nums[0] == nums[1] {
			return 1
		} else {
			return 0
		}
	}

	ans0 := 0
	ans1 := 0
	for i :=0;i< len(nums);i++ {

		if i == 0 {
			if nums[0] == 0 {
				ans1++
			} else {
				ans0++
			}
		}

		if i ==1{
			if nums[1] == 0{
				ans0++
			}else{
					ans1++
			}
		}

		// 0スタート
		if i != 0 && i!=1 &&  i % 2 != 0 &&  nums[i] == 0{
			ans0++
		}
		if i != 0 && i!=1 && i % 2 == 0 &&  nums[i] == 1{
			ans0++
		}

		//1
		if i != 0 &&i!=1 &&  i % 2 != 0 &&  nums[i] == 1{
			ans1++
		}
		if i != 0 &&i!=1 &&  i % 2 == 0 &&  nums[i] == 0{
			ans1++
		}
	}

	return min(ans0,ans1)
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


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

int main()
{
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  cout << (A[1]-A[0])+(A[2]-A[1]) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 1000000007
/****************************/
int a,b;
int main()
{
	cin>>a>>b;
	rep(i,100010)
	{
		double d,e;
		d=(double)((double)(i*1.000000)*(double)(0.080000));
		e=(double)((double)(i*1.000000)*(double)(0.100000));
		if((int)(d)==a&&(int)(e)==b)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<string>
#include<iostream>
using namespace std;
struct pro
{
    string name;
    int time;
}p[100000];
int n,q,sum=0;
int main()
{
    queue<pro>Q;
    cin>>n>>q;
    int i;
    for(i=0;i<n;i++)
    {
        cin>>p[i].name>>p[i].time;
        Q.push(p[i]);
    }
    while(!Q.empty())
    {
        int t=Q.front().time;
        if(t<=q)
        {
            sum+=Q.front().time;
            cout<<Q.front().name<<" "<<sum<<endl;
            Q.pop();
        }
        else
        {
            sum+=q;
            Q.front().time-=q;
            Q.push(Q.front());
            Q.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 7952
def solve():
    def combis(n, k, mod):
        from math import factorial
        numerator = 1
        denominator = 1
        for i in range(k):
            numerator = numerator * (n-i) % mod
            denominator = denominator * (i+1) % mod
        return numerator * pow(denominator, mod-2, mod) % mod

    n,a,b = [int(i) for i in input().split()]
    mod = 10**9 + 7
    ans = pow(2, n, mod) - 1 - combis(n, a, mod) - combis(n, b, mod)
    print(ans % mod)

if __name__ == "__main__":
    solve()

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    string s;
    cin >> s;

    int size = s.size();

    for(int i = size - 2; i >= 0; i = i - 2){

        if(s.substr(0, i / 2) == s.substr(i / 2, i / 2)){
            cout << i << endl;
            break;
        }
    }


    return 0;
}
/*
|S|が小さいので全探索
*/

Measured memory_bytes: 3588
import java.util.*;

public class Main{
	public static int[][] value,dp;
	public static int i,j;


	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		value=new int[N+1][3];
		dp=new int[N+1][3];

		//valueの読み込み
		for(int i=1;i<=N;i++){
			for (int k=0;k<=2;k++){
			value[i][k]=sc.nextInt();
			}
		}
		//dpの初期化
		for(int i=1;i<=N;i++){
			for (int k=0;k<=2;k++){
			dp[i][k]=0;
			}
		}
		for (int i=0;i<=2;i++){
			dp[1][i]=value[1][i];
		}
		//dp_change
		for (i=1;i<=N;i++) {
			for (j=0;j<=2;j++) {
			chmax(i,j);
			}
		}
		System.out.println(Math.max(dp[N][0],Math.max(dp[N][1],dp[N][2])));
}
	//dp更新用の関する定義
	public static void chmax(int i,int j){
		dp[i][j]=Math.max(dp[i-1][(j+1)%3]+value[i][j],dp[i-1][(j+2)%3]+value[i][j]);
	}
}

Measured memory_bytes: 101228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var ans = "";
            for (int i = 0; i < S.Length; i++)
            {
                ans += "x";
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
/* D-"Median of Medians" */
/*  */
//include <bits/stdc++.h>
#include <iostream>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++) 
using namespace std;

template <typename T> 
void print(deque<T>& d){
    for(auto x: d){
        cout << x << " "; 
    }
    cout << endl;
}

int main(){
    deque<char> d1;
    string s;
    cin >> s;
    for(char c : s) d1.push_back(c);
    bool flip = false;
    ll q;
    cin >> q;
    rep(qi,q){
        int ty;
        cin >> ty;
        if(ty == 1) {
            flip = !flip;
        } else {
            int f;char c;
            cin >> f >> c;
            if(flip) f = 3-f;
            if(f == 1) d1.push_front(c);
            else d1.push_back(c); 
        }
    }
    if(flip) reverse(d1.begin(), d1.end());
    string ans;
    for(char c : d1) ans += c;
    cout << ans << endl;
    return 0;
}
    

Measured memory_bytes: 1412
#include <iostream>
#include <map>
#include <cstdio>

using namespace std;

int A;
int a [200010];
int B;
int b [200010] ;
map <int , int> mpa,mpb;
int main ( void ){
int i ;
cin >> A;
for ( i =0; i<A; i++) scanf ("%d", &a[i]) ;
cin >> B;
for ( i =0; i<B; i++) scanf("%d", &b[i]) ;
for ( i =0; i<A; i++) mpa[a[i]]++;
for ( i =0; i<B; i++) mpb[b[i]]++;
for ( i =0; i<B; i++){
int x = b[i] ;
if (mpb[x] > mpa[x] ) {
cout << "NO" << endl;
return 0 ;
}
}

cout << "YES\n";
return 0;
}


Measured memory_bytes: 20608
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 二分探索
N = ir()
S = sr()

def check(x):
    candidate = set()
    for i in range(N - 2*x + 1):
        candidate.add(S[i:i+x])
        if S[i+x:i+2*x] in candidate:
            return True
    return False

left = 0 # 可能
right = N
while right > left + 1:
    mid = (right+left) // 2
    if check(mid):
        left = mid
    else:
        right = mid

print(left)
# 54

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

double p[3050];

double dp[3050][3050];

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i];

    dp[0][0] = 1.0;

    forn(i, n) {
        forn(j, i + 2) {
            dp[i + 1][j] = dp[i][j] * (1 - p[i]);
            if (j)
                dp[i + 1][j] += dp[i][j - 1] * p[i];
        }
    }

    double ans = 0;

    for (int i = 0; i <= n; i++)
        if (i > n / 2)
            ans += dp[n][i];

    cout << fixed << setprecision(10);
    cout << ans;

    return 0;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,k;
    cin >> n >> k;
    
    if (k%2==0)
    {
        k = k/2;
        int num;
        num = n/k;
        int gu, ki;
        ki = num/2; gu = num/2;

        if (num%2==1)
        {
            ki++;
        }
        ll ans = 0;
        ll ki_sum = 1;
        ll gu_sum = 1;
        rep(i,3)
        {
            ki_sum *= ki;
            gu_sum *= gu;
        }
        ans = ki_sum+gu_sum;
        cout << ans << endl;
        return 0;
    }

    if (k % 2 == 1)
    {
        int num;
        num = n / k;
        ll ans = 1;
        rep(i, 3)
        {
            ans *= num;
        }
        cout << ans << endl;
        return 0;
    }
}

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

long int rec(vector<vector<long int> >&dp,vector<long int>&a,int st,int en)
{
   if(st>en)
   return 0;
   if(dp[st][en])
   return dp[st][en];
   long int x=rec(dp,a,st+2,en);
   if(x>rec(dp,a,st+1,en-1))
   x=rec(dp,a,st+1,en-1);
   x+=a[st];
   long int y=rec(dp,a,st+1,en-1);
   if(y>rec(dp,a,st,en-2))
   y=rec(dp,a,st,en-2);
   y+=a[en];
   if(x>y)
   dp[st][en]=x;
   else
   dp[st][en]=y;
   return dp[st][en];
}
int main()
{
  int n;
  cin>>n; 
  vector<long int>a(n,0);
  long int sum=0;
  for(int i=0;i<n;i++)
  {cin>>a[i];sum+=a[i];}

  vector<long int>tmp(n,0);
  vector<vector<long int> >dp(n,tmp);
  for(int i=0;i<n;i++)
  dp[i][i]=a[i];
  
  long int ans=rec(dp,a,0,n-1);
  cout<<(2*ans-sum)<<endl;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 2005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,len[MAXN * 2];
int64 x,a[MAXN * 2],st[MAXN * 2][15];
int64 query(int l,int r) {
    int t = len[r - l + 1];
    return min(st[l][t],st[r - (1 << t) + 1][t]);
}
void Solve() {
    read(N);read(x);
    for(int i = 1 ; i <= N ; ++i) {read(a[i]);a[i + N] = a[i];st[i][0] = a[i];st[i + N][0] = a[i];}
    for(int j = 1 ; j <= 13 ; ++j) {
	for(int i = 1 ; i <= 2 * N ; ++i) {
	    if(i + (1 << j) - 1 > 2 * N) break;
	    st[i][j] = min(st[i][j - 1],st[i + (1 << j - 1)][j - 1]);
	}
    }
    for(int i = 2 ; i <= 2 * N ; ++i) len[i] = len[i / 2] + 1;
    int64 ans = 1e18;
    for(int i = 0 ; i <= N ; ++i) {
	int64 tmp = i * x;
	for(int j = 1 ; j <= N ; ++j) {
	    tmp += query(j + N - i,j + N);
	}
	ans = min(ans,tmp);
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 768
import math

def count_groups(n, m):
    if n == 0:
        return 0

    if m == 0:
        return 0

    if m == n:
        return 1

    if m > n:
        return 0

    return math.factorial(n-1) // math.factorial(m-1) // math.factorial(n-m)


N, K = map(int, input().split())

blue = K
red = N - K
den = 10**9 + 7

for i in range(1, K + 1):
    blue_groups = count_groups(blue, i)

    red1 = count_groups(red, i-1)
    red2 = count_groups(red, i)
    red4 = count_groups(red, i+1)
    red_patterns = red1 + red2 * 2 + red4

    patterns = blue_groups * red_patterns
    if blue_groups > 0 and red_patterns == 0 and i == 1:
        patterns = 1
    print(patterns % den)

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

public class Main {
	public static void main (String[] args) {
	Scanner s=new Scanner(System.in);	
	String c=s.next();
	int n=c.length();
	boolean flag=true;
	if(n%2==1)
	flag=false;
	else
	{for(int i=0;i<n;i+=2)
	{if(c.substring(i,i+2).equals("hi"))
	{}
	else
	{flag=false;
	break;
	}}}
	if(flag)
	System.out.println("Yes");
	else
	System.out.println("No");
	}}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        var (n, a, b) = ReadTuple<long,long,long>();
        a--;b--;n--;
        var dif = Abs(a - b);
        if (dif % 2 == 0)
        {
            WriteLine(dif/2);
        }
        else
        {
            long top = (n - a) + (n - b) + 1;
            long btm = a + b + 1;
            top = top / 2 + top % 2;
            btm = btm / 2 + btm % 2;
            WriteLine(Min(top,btm));
        }
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 27320
n=int(input())
heights=list(map(int,input().split(" ")))
dic={}
res=0
for i in range(n):
    if heights[i]-i not in dic:
        dic[heights[i]-i]=1
    else:
        dic[heights[i]-i]+=1
for j in range(n):
    if -heights[j]-j in dic:
        res+=dic[-heights[j]-j]
print(res)

Measured memory_bytes: 40420
n = int(input())
c = [[0] * 10 for i in range(10)]

for i in range(1, n+1):
  t = int(str(i)[0])
  b = int(str(i)[-1])
  c[t][b] += 1

s = 0
for t in range(10):
  for b in range(10):
    s += c[t][b] * c[b][t]

print(s)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// fatorial.cpp depend on this.
#ifndef MOD_INT
#define MOD_INT
template<int mod>
struct ModInt{
	private:
		int x;

	public:
		ModInt(): x(0){}
		ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
		
		ModInt &operator+=(const ModInt &p){
			if((x += p.x) >= mod) x -= mod;
			return *this;
		}
		ModInt &operator-=(const ModInt &p){
			if((x += mod - p.x) >= mod) x -= mod;
			return *this;
		}
		ModInt &operator*=(const ModInt &p){
			x = (int) (1LL * x * p.x % mod);
			return *this;
		}
		ModInt &operator/=(const ModInt &p){
			*this *= p.inverse();
			return *this;
		}
	
		ModInt operator-() const {return ModInt(-x);}
		ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}
		ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}
		ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}
		ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}
		bool operator==(const ModInt &p) const {return x == p.x;}
		bool operator!=(const ModInt &p) const {return x != p.x;}
		bool operator<(const ModInt &p) const {return x < p.x;}
		bool operator>=(const ModInt &p) const {return x>= p.x;}
		bool operator>(const ModInt &p) const {return x > p.x;}
		bool operator<=(const ModInt &p) const {return x <= p.x;}
	
		template<typename T>
		operator T() const {return (T)x;}
	
		ModInt inverse() const {
			int a = x, b = mod, u = 1, v = 0, t;
			while(b > 0) {
				t = a / b;
				swap(a -= t * b, b);
				swap(u -= t * v, v);
			}
			return ModInt(u);
		}
	
		ModInt pow(int64_t n) const {
			ModInt ret(1), mul(x);
			while(n > 0) {
				if(n & 1) ret *= mul;
				mul *= mul;
				n >>= 1;
			}
			return ret;
		}
	
		friend ostream &operator<<(ostream &os, const ModInt &p){
			return os << p.x;
		}
	
		friend istream &operator>>(istream &is, ModInt &a){
			int64_t t;
			is >> t;
			a = ModInt<mod>(t);
			return (is);
		}
};

using mint = ModInt<MOD>;
#endif

#ifndef COMBINATION
#define COMBINATION
// o(k)
mint permutation(int n, int k){
	if(n < 0 or k < 0 or n < k) return 0;
	mint res = 1;
	for(int i = 0; i < k; i++) res *= mint(n-i);
	return res;
}

// o(k)
mint combination(int n, int k){
	if(n < 0 or k < 0 or n < k) return 0;
	mint res = 1;
	for(int i = 0; i < k; i++){
		res *= mint(n-i);
		res /= mint(i+1);
	}
	return res;
}

// o(k)
mint hcombination(int n, int k){
	if(n < 0 or k < 0) return 0;
	if(n == 0 and k == 0) return 1;
	return combination(n+k-1, k);
}
#endif

int n, a, b;
 
int main(void){
	cin >> n >> a >> b;
	mint res = mint(2).pow(n) - 1;
	res -= combination(n, a);
	res -= combination(n, b);

	cout << res << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 1000000007
#define INF 1000000007
#define MAXN 1001
#define MAXM 1001
#define MAXP 1000001
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int N, M;
int prime[MAXN];

ll prime_factorial_cnt(ll n, ll p){
    ll res = 0, pd = p;
    while(n >= p){
        res = res + n / p;
        p *= pd;
    }

    return res;
}

vector<ll> prime_vec(int n){
    vector<ll> res;
    for(int i = 2;i <= n;i++){
        if(prime[i] == 0){
            res.push_back(i);
            for(int j = i;j <= n;j += i){
                prime[j] = 1;
            }
        }
    }

    return res;
}

int main(){
    cin >> N;
    vector<ll> vec = prime_vec(N);
    vector<ll> cnt(MAXN, 0);

    for(int i = 0;i < vec.size();i++){
        cnt[i] = prime_factorial_cnt(N, vec[i]);
    }

    ll ans = 1;
    for(int i = 0;i < vec.size();i++){
        ans = (ans * (cnt[i] + 1)) % MOD;
    }

    printf("%lld\n", ans);
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  int min_x = n;
  int cnt = 0;

  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x <= min_x) {
      cnt++;
      min_x = x;
    }
  }
  cout << cnt << endl;
}


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

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int divideByTwo(int num) {
    int cnt = 0;
    while (num % 2 == 0 && num != 0) {
        cnt++;
        num /= 2;
    }
    return cnt;
}

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

    int max_cnt = 0;
    int max_arg = 1;
    FOR(i, 1, n+1) {
        if (max_cnt < divideByTwo(i)) {
            max_cnt = divideByTwo(i);
            max_arg = i;
        }
    }
    cout << max_arg << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int gcd(int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = h - 1; i >= 0; --i)
        cin >> s[i];

    int ans = 2;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (gcd(i, j) > 1) continue;
            // up-right
            int c = 0;
            for (int k = 0; k <= h; ++k) {
                int l = j * k / i;
                if (l < 0) continue;
                if (l >= w) break;
                if (k == 0)
                    c += s[k][l] == '#';
                else if (k == h)
                    c += s[k - 1][l] == '#';
                else
                    c += s[k - 1][l] != s[k][l];
            }
            for (int k = 0; k <= w; ++k) {
                int l = (i * k - 1) / j;
                if (l < 0) continue;
                if (l >= h) break;
                if (k == 0)
                    c += s[l][k] == '#';
                else if (k == w)
                    c += s[l][k - 1] == '#';
                else
                    c += s[l][k - 1] != s[l][k];
            }
            ans = max(ans, c / 2 + 1);

            // down-left
            c = 0;
            for (int k = 0; k <= h; ++k) {
                int l = (j * k - 1) / i;
                if (l < 0) continue;
                if (l >= w) break;
                if (k == 0)
                    c += s[k][l] == '#';
                else if (k == h)
                    c += s[k - 1][l] == '#';
                else
                    c += s[k - 1][l] != s[k][l];
            }
            for (int k = 0; k <= w; ++k) {
                int l = i * k / j;
                if (l < 0) continue;
                if (l >= h) break;
                if (k == 0)
                    c += s[l][k] == '#';
                else if (k == w)
                    c += s[l][k - 1] == '#';
                else
                    c += s[l][k - 1] != s[l][k];
            }
            ans = max(ans, c / 2 + 1);
        }
    }
    cout << ans << "\n";
    return 0;
}



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

using namespace std;

using int64 = long long;

template< typename T >
vector< T > fast_mobius_transform(vector< T > f) {
  for(int i = 0; (1 << i) < f.size(); i++) {
    for(int j = 0; j < f.size(); j++) {
      if(j & (1 << i)) f[j] -= f[j ^ (1 << i)];
    }
  }
  return f;
}

int main() {
  int64 N, M;
  int64 A[20], P[20];
  cin >> N >> M;
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < N; i++) cin >> P[i];


  vector< int64 > f(1 << N);
  f[0] = 1;
  for(int i = 1; i < (1 << N); i++) {
    int bit;
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) bit = j;
    }
    auto g = __gcd(f[i ^ (1 << bit)], A[bit]);
    f[i] = min((__int128) M + 1, (__int128) f[i ^ (1 << bit)] / g * A[bit]);
  }
  for(int i = 0; i < (1 << N); i++) {
    f[i] = M / f[i];
  }
  f[0] = 0;
  auto beet = fast_mobius_transform(f);
  double ret = 0.0;
  for(int i = 0; i < 1 << N; i++) {
    double uku = 1.0;
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) uku *= P[j] / 100.0;
      else uku *= (100.0 - P[j]) / 100.0;
    }
    ret += llabs(beet[i]) * uku;
  }
  cout << fixed << setprecision(10) << ret << endl;
}


Measured memory_bytes: 19252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        boolean flg = true;
        int cCount = 0;
        for(int i = 0; i < S.length(); i++) {
            if(i == 0) {
                //一文字目
                if(!(S.charAt(0) == 'A')) {
                    flg = false;
                    break;
                }
            } else if(i >= 2 && i <= S.length()-2) {
                //先頭3文字目 ~ 後ろから2文字目
                if(S.charAt(i) == 'C') {
                    if(cCount != 0) {
                        flg = false;
                        break;
                    } else {
                        cCount += 1;
                    }
                } else {
                    if(Character.isUpperCase(S.charAt(i))) {
                        flg = false;
                        break;
                    }
                }
            } else {
                //それ以外
                if(Character.isUpperCase(S.charAt(i))) {
                    flg = false;
                    break;
                }
            }
        }
        if(flg && cCount == 1) {
            System.out.println("AC");
        } else {
            System.out.println("WA");
        }
    }
}

Measured memory_bytes: 23764
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n,d=parseMap(split(readline()))
    x=[parseMap(split(readline())) for i in 1:n]
    ans=0
    for i in 1:n
        for j in i+1:n
            res=0
            for k in 1:d
                res+=(x[i][k]-x[j][k])^2
            end
            if isinteger(sqrt(res))
                ans+=1
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 113124
#include<bits/stdc++.h>
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;
#define fr(i, a, b) for (ll i = a; i < b; i++)

int main() {
    ios::sync_with_stdio(false);
    #ifdef CODE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n, k;
    cin >> n >> k;
    vl arr(n);
    fr (i, 0, n) {
        cin >> arr[i];
    }
    ll low = 1, high = 1e+10;
    ll ans = high;

    auto func = [&] (ll x) {
        ll total = 0;
        fr(i, 0, n) {
            int temp = arr[i] / x;
            if (x * temp == arr[i]) temp--;
            total += temp;
        }
        return (total <= k);
    };
    while (low <= high) {
        ll mid = low + (high - low) / 2;
        if (func(mid)) {
            ans = mid;
            high = mid - 1;
        } else {
            low = mid + 1;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 4780
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>

using namespace std;
int a[] = { 1,3,5,7,8,10,12 };
int b[] = { 4,6,9,11 };
int c[] = { 2 };
int main()
{
	int a1, b1;
	cin >> a1 >> b1;
	int flag1=0,flag2=0,flag3=0;
	for (int i = 0; i < 7; i++)
	{
		if(a1==a[i])
            flag1=1;
            if(b1==a[i])
                flag2=1;
	}
	for(int i=0;i<4;i++)
    {
        if(a1==b[i])flag1=2;
        if(b1==b[i])flag2=2;
    }
    if(a1==b1&&a1==2)flag1=flag2=1;
    if(flag1==flag2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main()
{
  int N, a;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
    {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
ll n, q;
string s;
vector<pair<char, char>> ps;

bool fl(int i) {
  if (i == n)
    return false;

  for (int j = 0; j < q; j++) {
    if (ps[j].first == s[i]) {
      if (ps[j].second == 'R')
        i++;
      else
        i--;
    }
    if (i < 0)
      return true;
    if (i >= n)
      return false;
  }
  return false;
}

bool fr(int i) {
  if (i < 0)
    return false;
  for (int j = 0; j < q; j++) {
    if (ps[j].first == s[i]) {
      if (ps[j].second == 'R')
        i++;
      else
        i--;
    }
    if (i < 0)
      return false;
    if (i >= n)
      return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  ps.resize(q);
  for (int i = 0; i < q; i++) {
    cin >> ps[i].first >> ps[i].second;
  }
  int l = 0, r = n;
  ll ans = 0;
  if (fl(l)) {
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (fl(m)) {
        l = m;
      } else {
        r = m;
      }
    }
    ans = l + 1;
  }
  l = -1;
  r = n - 1;
  if (fr(r)) {
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (fr(m)) {
        r = m;
      } else {
        l = m;
      }
    }
    ans += (n - r);
  }
  cout << n - ans << endl;

  return 0;
}


Measured memory_bytes: 976
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        a: char, b: char,
    }
    if a < b {
        println!("<");
    } else if a == b {
        println!("=");
    } else {
        println!(">");
    }
}


Measured memory_bytes: 2120
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)          cout<<#x<<" "<<x<<endl
#define ar 				array
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool compare(pair<int, int>&a, pair<int, int>&b)
{
	return a.first < b.first;
}
int cb(int number)
{
	return (int)log2(number) + 1;
}
int32_t main()
{
	Raghav();
	int n, k;
	cin >> n >> k;
	vector<int>v(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
	}
	for (int i = 1; i <= n - k; i++)
	{
		if (v[i] < v[i + k])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int a,b;
    char c;
    cin >> a >> c >> b;
    if(c == '+')cout << a+b << endl;
    else cout << a-b << endl;
    return 0;
}

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

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 ll, rr, ans = 3000;
	cin >> ll >> rr;
	for(int64 ii = ll;ii < rr && ii <= ll + 2020;ii++)
	{
		for(int64 jj = ii + 1;jj <= rr && jj <= ii + 2020;jj++)
		{
			if(ans > (ii * jj) % 2019)
			{
				ans = (ii * jj) % 2019;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
typedef pair<int, int> P;

ll dp[101][100001] = {};

int main(){
    ll n, w, w_i, v, i, j, res = 0;
    cin >> n >> w;
    for(i=0; i<=100000; i++){
        dp[0][i] = 1000000000000;
    }
    dp[0][0] = 0;
    for(i=1; i<=n; i++){
        cin >> w_i >> v;
        for(j=0; j<=100000; j++){
            if(j >= v){
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v] + w_i);
            }else{
                dp[i][j] = dp[i-1][j];
            }
            if(dp[i][j] <= w && i == n){
                res = j;
            }
            //cout << dp[i][j] << " ";
        }
        //cout << "\n";
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 79104
Oni = input().split(" ")
A = int(Oni[0])
V = int(Oni[1])
child = input().split(" ")
B = int(child[0])
W = int(child[1])
T = int(input())

if V - W > 0:
    X = V - W
    Y = abs(A - B)
    if X * T >= Y:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

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

	while(true){
		R++;
		if(next == 2){
			break;
		}
		if(R == N){
			R = -1;
			break;
		}
		next = A.at(next-1);

	}

	cout << R << endl;
	
}

Measured memory_bytes: 640
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define qread(x) x=read()
#define mes(x,y) memset(x,y,sizeof(x))
#define mpy(x,y) memcpy(x,y,sizeof(x))
#define INF 2147483647
inline int read(){
	int f=1,x=0;char ch;
	while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int x;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	qread(x);
	if(x<1200)printf("ABC\n");
	else if(x<2800)printf("ARC\n");
	else printf("AGC\n");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			char[] charArray = str.toCharArray();
			
			for(int i = 0; i < charArray.length ; i++){
				if(charArray[i] == '@'){
					for(int j = 0; j < charArray[i + 1] - '0' ; j++){
						System.out.print(charArray[i + 2]);
					}
					i += 2;
				}
				
				else {
					System.out.print(charArray[i]);
				}
			}
			System.out.println();
		}
	}

}

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

int f(int n){
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    return f(n-1) + f(n-2) + f(n-3);
}

int main(void){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << (f(n) / 3650)+1 << endl;
    }
}


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

int o(int x) {
	if (x < 0) {
		return x * -1;
	}
	return x;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (o(a - b) <= d && o(b - c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		if (o(a - c) <= d) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256
MAX=100001
array=[True for i in range(MAX)]
array[1]=False
similar=[True for i in range(MAX)]

for i in range(2, MAX):
	if array[i]:
		for j in range(2, int(MAX/i)+1):
			if(j*i < MAX):
				array[i*j]=False
c=[0 for i in range(MAX)]
count=0

for i in range(2, MAX):
	if array[i] and array[int((i+1)/2)]:
		count+=1

	c[i]=count

Q=int(input())
for i in range(Q):
	l,r=map(int, input().split())
	print(c[r]-c[l-1])

Measured memory_bytes: 5912
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define MAX_N 100000
#define MOD 1000000007

int int_sort(const void* a, const void* b) {
  return (*(int*)a - *(int*)b);
}

int main(void) {
  int N;
  scanf("%d\n", &N);
  int A[MAX_N];
  for(int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  qsort(A, N, sizeof(int), int_sort);

  int64_t ANS = 1;
  int ST  = 0;
  int NUM = 1;
  if(N % 2) {
    if(A[0] != 0) {
      printf("0\n");
      return 0;
    }
    ST  = 1;
    NUM = 2;
  } else {
    ST  = 0;
    NUM = 1;
  }
  for(int i = ST; i < N; i+=2) {
      if(A[i] != NUM || A[i+1] != NUM) {
	printf("0\n");
	return 0;
      }
      NUM += 2;
      ANS = (ANS * 2) % MOD;
    }
  
  printf("%ld\n", ANS);
  return 0;
}


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





int main(){
    int M = 0, m = 100000;
    int N; cin >> N;
    for (int i = 0; i < N; i++)
    {
        int v;cin >> v;
        if ( m  > v) m = v;
        if ( M < v)  M = v;
    }
    cout << M - m << endl;
    
}


Measured memory_bytes: 256