akhauriyash/Code-Regression huggingface dataset:
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
function lower_bound(d,e,a=0,b=d.length){for(var c;1<b-a;)d[c=a+b>>1]<e?a=c:b=c;return d[a]<e?b:a};

var ans, dp = [0];
var g,a;

function main(){
  var n = next();
  a = nexts(n);
  g = xArray("[]",n);
  for(var i = 1; i < n; i++){
    var u = next()-1, v = next()-1;
    g[u].push(v);
    g[v].push(u);
  }
  ans = xArray(0,n);
  dfs(0,-1);
  return ans.join("\n");
}

function dfs(v,p){
  var ix = lower_bound(dp,a[v]),iv;
  if(ix !== dp.length){
    iv = dp[ix];
    dp[ix] = a[v];
  }else ix++,dp.push(a[v]);
  ans[v] = dp.length-1;
  for(var i = 0; i < g[v].length; i++){
    if(g[v][i] === p)continue;
    dfs(g[v][i],v);
  }
  if(ix === dp.length)dp.pop();
  else dp[ix] = iv;
}

if (process.argv[2] === "--stack-size=262144") require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=327680"] });
else {
  var myOut = main();
  if(myOut !== undefined)console.log(myOut);
}

Measured memory_bytes: 170932
n = int(input())

s = input()


a = [0] * (n+1)
b = [0] * (n+1)
ans = 3 * 10 ** 5

aN = s.count("E")
for i in range(n):
  if s[i] == "E":
    a[i+1] = a[i] + 1
    b[i+1] = b[i]
  else:
    a[i+1] = a[i]
    b[i+1] = b[i] + 1
  #print(ans, aN-a[i+1]+b[i])  
  ans = min(ans, aN-a[i+1]+b[i])
  
  
  
print((ans))

Measured memory_bytes: 17636
use input::Input;

fn main() {
    let mut input = Input::default();

    let d = input.parse::<usize>();
    let _c = (0..26).map(|_| input.parse()).collect::<Vec<i64>>();
    let _s = (0..d)
        .map(|_| (0..26).map(|_| input.parse()).collect())
        .collect::<Vec<Vec<i64>>>();

    let mut x = 1;
    for _ in 0..d {
        println!("{}", x);
        x = (x % 26) + 1;
        if x == 3 {
            x = 1;
        }
    }
}

#[allow(dead_code)]
pub mod input {
    #[derive(Default)]
    pub struct Input(Vec<String>);

    impl Input {
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok().expect("read error");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            let x = if let Some(x) = self.0.pop() {
                x
            } else {
                let s = self.read_line();
                self.0 = s.split_whitespace().map(String::from).rev().collect();
                self.0.pop().expect("reached EOF")
            };
            x.parse().ok().expect("parse error")
        }
    }
}


Measured memory_bytes: 2276
def main():
    N = int(input())
    cnt = 0
    for i in range(N):
        D1, D2 = map(int, input().split())
        if D1 == D2:
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print('Yes')
            return
    print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Map<Integer,List<int[]>> map = new HashMap<>();
		for(int i=0;i<n-1;i++) {
			int[] tmp = new int[3];
			tmp[0] = in.nextInt();
			tmp[1] = in.nextInt();
			tmp[2] = in.nextInt();
			int[] tmp2 = new int[3];
			tmp2[0] = tmp[1];
			tmp2[1] = tmp[0];
			tmp2[2] = tmp[2];
			if(map.containsKey(tmp[0])) {
				map.get(tmp[0]).add(tmp);
			}else {
				List<int[]> list = new ArrayList<>();
				list.add(tmp);
				map.put(tmp[0], list);
			}
			if(map.containsKey(tmp2[0])) {
				map.get(tmp2[0]).add(tmp2);
			}else {
				List<int[]> list = new ArrayList<>();
				list.add(tmp2);
				map.put(tmp2[0], list);
			}
		}
		int[] ans = new int[n+1];
		for(int i=1;i<=n;i++) {
			ans[i] = -1;
		}
		ans[1] = 0;
		Queue<Integer> que = new ArrayDeque<>();
		que.add(1);
		while(!que.isEmpty()) {
			int tmp = que.poll();
			List<int[]> list = map.get(tmp);
			for(int[] edge : list) {
				if(ans[edge[1]]!=-1) continue;
				que.add(edge[1]);
				if(edge[2]%2==0) ans[edge[1]] = ans[edge[0]];
				else ans[edge[1]] = ans[edge[0]]==0?1:0;
			}
		}
		for(int i=1;i<=n;i++) {
			System.out.println(ans[i]);
		}
		in.close();
	}

}


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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

LL f[2500];
LL inv[2500];
LL quickmul(LL a,LL b,LL p)
{
    LL res=0;
    while(b!=0)
    {
        if(b&1)
            (res+=a)%=p;
        (a*=2)%=p;
        b>>=1;
    }
    res%=p;
    return res;
}

LL quickpow(LL a,LL b,LL p)
{
    LL res=1;
    while(b!=0)
    {
        if(b&1)
            res=quickmul(res,a,p);
        a=quickmul(a,a,p);
        b>>=1;
    }
    res%=p;
    return res;
}

void init()
{
    f[0]=f[1]=1;
    for(int i=2;i<=2100;i++)
    {
        f[i]=i*f[i-1];
        f[i]%=mod;
    }
    for(int i=0;i<=2100;i++)
    {
        inv[i]=quickpow(f[i],mod-2,mod);
    }
}

const int MAXN = 2000;
int C[MAXN+1][MAXN+1];
void init2()
{
    int i,j;
    for(i=0; i<=MAXN; ++i)
    {
        C[0][i] = 0;
        C[i][0] = 1;
    }
    for(i=1; i<=MAXN; ++i)
    {
        for(j=1; j<=MAXN; ++j)
        C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
    }
}

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

    LL ans;
    for(int i=1;i<=k;i++)
    {
        //cout<<f[n-k+1]<<" "<<inv[i]<<" "<<inv[n-k+1-i]<<endl;
        /*ans=quickmul(st,inv[i-1],mod);
        ans=quickmul(ans,inv[k-i],mod);
        ans=quickmul(ans,inv[i],mod);
        ans=quickmul(ans,inv[n-k+1-i],mod);*/
        ans=quickmul(C[n-k+1][i],C[k-1][i-1],mod);
        cout<<ans<<"\n";
    }
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector<int> rev(N);
  for(int i = 0; i < N; i++) {
    rev[A[i] - 1] = i + 1;
  }

  for(int i = 0; i < N; i++) {
    cout << rev[i];
    if(i == N - 1) {
      cout << endl;
    }
    else {
      cout << " ";
    }
  }

  return 0;
}


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

using namespace std;

typedef long long LL;
int N;
LL K;
LL a[200010],s[200010];

const LL INF = 1e15;
struct seg
{
	int ls,rs;
	int sum;
}T[20000010];
int cnt;

void ins(int x,LL l,LL r,LL v)
{
	//printf("%lld %lld\n",l,r);
	T[x].sum++;
	if (l == r) return;
	LL mid = (l+r) >> 1;
	if (v <= mid)
	{
		if (!T[x].ls)
			T[x].ls = ++cnt;
		ins(T[x].ls,l,mid,v);
	}
	else
	{
		if (!T[x].rs)
			T[x].rs = ++cnt;
		ins(T[x].rs,mid+1,r,v);
	}
}

LL query(int x,LL l,LL r,LL v)
{
	if (l == r) return T[x].sum;
	LL mid = (l + r) >> 1;
	if (v <= mid)
		return query(T[x].ls,l,mid,v);
	else
		return T[T[x].ls].sum + query(T[x].rs,mid+1,r,v);
}

int main()
{
	scanf("%d%lld",&N,&K);
	s[0] = 0;
	for (int i=1;i<=N;i++)
	{
		scanf("%lld",&a[i]);
		a[i] -= K;
		s[i] = s[i-1] + a[i];
	}
	cnt = 1;
	T[1].ls = T[1].rs = T[1].sum = 0;
	ins(1,-INF,INF,0);
	LL ans = 0;
	for (int i=1;i<=N;i++)
	{
		ans += query(1,-INF,INF,s[i]);
		//printf("%lld\n",ans);
		ins(1,-INF,INF,s[i]);
	}
	printf("%lld\n",ans);
}

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

int main(){
//srandom((unsigned long)time(NULL));
int n;
cin>>n;
vector<long long> b;
for(int i=0;i<n-1;i++){
    long long x;
    cin>>x;
    b.emplace_back(x);
}
vector<long long> a(n);
a[0]=b[0];
long long sum=0;
a[n-1]=b[n-2];
sum+=a[0]+a[n-1];
for(int i=1;i<n-1;i++){
    a[i]=min(b[i-1],b[i]);
   // cout<<"a"<<a[i]<<endl;
    sum+=a[i];
}
cout<<sum<<endl;
//A 5 5 8 9 4 4 5 6
//a 4 5 8 9 4 3 5 6
//b 5 8 9 9 4 5 6 


return 0;
}

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

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

    int sum=0;
    int a,b,c,r;
    for(int i=1;i<n+1;i++){
        a = i;
        for(int j=1;j<n+1;j++){
            int f = a;
            b = j;
            if (f<b) {
                int temp = b;
                b = f;
                f = temp;
            }
            while(f%b!=0){
               r = f % b;
                f = b;
                b = r;
            }
            for(int k=1;k<n+1;k++){
                int g = b;
                c = k;
                if (g>c){
                    int temp = c;
                    c = g;
                    g = temp;
                }
                while(c%g!=0){
                    r = c % g;
                    c = g;
                    g = r;
                }
                sum += g;
            }
        }
    }

    cout << sum << endl;;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
 
#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back
 
#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif
 
template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}
 
template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}
 
const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;
 
const int N = 15;
ll e[N][N];
ll dp[1 << N][N];
 
int main() {
    int n, eds;
    cin >> n >> eds;
    forn(i, 0, n) forn(j, 0, n) e[i][j] = 0;
    while (eds--) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        e[a][b] = c;
        e[b][a] = c;
    }
    forn(i, 0, 1 << n) forn(j, 0, n) dp[i][j] = INF;
    dp[1][0] = 0;
    forn(i, 1, n) dp[1][i] = INF;
    for (int mask = 1; mask < (1 << (n - 1)); mask += 2) {
        //cerr << mask << '\n';
        dp[mask][0] = 0;
        for (int m = mask; m; m = (m - 1) & mask) {
            //cerr << m << ' ';
            ll sum = 0;
            vector<pair<int, int>> good;
            forn(i, 0, n) if (m & (1 << i)) forn(j, 0, n) {
                if (mask & (1 << j)) if (!(m & (1 << j))) {
                    sum += e[i][j];
                    if (e[i][j]) good.eb(i, j);
                }
            }
            //cerr << sum << '\n';
            for (auto p : good) {
                int i = p.fs, j = p.sn;
                setmin(dp[mask][j], dp[m][i] + sum - e[i][j]);
            }
        }
    }
    {
        int mask = (1 << n) - 1;
        //cerr << mask << '\n';
        dp[mask][0] = 0;
        for (int m = mask; m; m = (m - 1) & mask) {
            //cerr << m << ' ';
            ll sum = 0;
            forn(i, 0, n) if (m & (1 << i)) forn(j, 0, n) {
                if (mask & (1 << j)) if (!(m & (1 << j)))
                    sum += e[i][j];
            }
            //cerr << sum << '\n';
            forn(i, 0, n) if (m & (1 << i)) forn(j, 0, n) {
                if (mask & (1 << j)) if (!(m & (1 << j))) {
                    if (e[i][j]) setmin(dp[mask][j], dp[m][i] + sum - e[i][j]);
                }
            }
 
        }
    }
    cout << dp[(1 << n) - 1][n - 1] << '\n';
}


Measured memory_bytes: 4096
import sys
def prime_boolean_table(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n + 1):
        if primes[i]:
            for j in range(i + i, n + 1, i):
                primes[j] = False
    return primes

p = [i for i,x in enumerate(prime_boolean_table(55555)) if x and i%5==1]
n = int(input())
s = ""
for i in range(n):
    s+="{0}".format(p[i])
    if i==n-1: break
    s+=" "
print(s)

Measured memory_bytes: 3444
#include <stdio.h>
#include <algorithm>

using namespace std;

void set_prime_number(bool* array, int num) {

  fill(array, array + num,false);
  array[1] = false;

  for (int i = 2; i < num; i++) {
    if(i%7 == 1 || i%7 == 6){
		array[i]=true;
	}
  }

    for (int i = 2; i < num; i++) {
		if(!array[i])continue;//月曜土曜数以外を省く

		//月曜土曜数の倍数を削除していく
		for(int j=i*2; j<num; j=j+i){
			array[j]=false;
		}
  }


}

int main() {
  bool prime_number[300000];
  int num;

  set_prime_number(prime_number,300000);
  scanf("%d",&num);
	while(num!=1){
		printf("%d:",num);
	 for (int i = 0; i <= num; i++) {
		 if (prime_number[i]){
			 if(num%i==0){
				 printf(" %d",i);
			 }
		 }
		 
	 }
	 printf("\n");
	  scanf("%d",&num);
	}

  return 0;
}

Measured memory_bytes: 1320
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in ab:
  n = 10 ** 9
  m = 0
  for i, (c, d) in enumerate(cd):
    x = abs(a - c) + abs(b - d)
    if x < n:
      n = x
      m = i + 1
      
  print(m)

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

string s;

int main() {
	cin >> s;
	string ans;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0')ans.push_back('0');
		else if (s[i] == '1')ans.push_back('1');
		else {
			if (ans.size() == 0)continue;
			else ans.pop_back();
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//NAME-ADITYYA OJHA
                                               /*
                                                      GURU(MENTOR)-AARADHYA
                                               */
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define forin for(int i=0;i<n;i++)
#define forjn for(int j=0;j<n;j++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  f   first
#define  s   second
#define mod 1000000007
 const int N=2e5+ 5;
 const ll N1=1e15 + 5;

using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting



int main()
{
  fast;
    ll x,y;
    cin>>x>>y;
    for(int i=0;i<=100;i++)
    {
        for(int j=0;j<=100;j++)
        {
            ll z= 4*i + 2*j;
            if(z==y &&(i+j)==x)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;


}





Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
using namespace std;

const int MAX = 1e5;
char s[MAX + 1];

int main() {
    scanf("%s", s);
    const int n = strlen(s);
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            printf("%d %d\n", i + 1, i + 2);
            return 0;
        }
        if (i + 2 < n && s[i] == s[i + 2]) {
            printf("%d %d\n", i + 1, i + 3);
            return 0;
        }
    }

    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

	if((A == B && B != C) || (B == C && B != A) || (A == C && C != B))
	{printf("Yes\n");}

	else
	{printf("No\n");}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int H,W;
    cin>>H>>W;
    int a[H][W];
    rep(i,H){
        rep(j,W){
            cin>>a[i][j];
        }
    }
    int x=0;
    int y=0;
    vector<pair<int,int>> p{};
    vector<pair<int,int>> q{};
    int co=0;
    rep(i,H){
        rep(j,W){
            bool z=false;
            if(i==H-1&&j==W-1) break;
            y=j;
            if(i%2==1) {
                y=W-1-j;
                z=true;
            }
            if(a[i][y]%2==0)continue;

            if(z){
                if(y!=0){
                    a[i][y-1]++;
                    p.push_back(make_pair(i+1,y+1));
                    q.push_back(make_pair(i+1,y));
                }else{
                    p.push_back(make_pair(i+1,y+1));
                    q.push_back(make_pair(i+2,y+1));
                    a[i+1][y]++;
                }
            }else{
                if(j!=W-1){
                    a[i][j+1]++;
                    p.push_back(make_pair(i+1,j+1));
                    q.push_back(make_pair(i+1,j+2));
                }else{
                    p.push_back(make_pair(i+1,j+1));
                    q.push_back(make_pair(i+2,j+1));
                    a[i+1][j]++;
                }
            }
            co++;

        }
    }
    cout << co << endl;
    rep(i,co){
        cout << p[i].first << " " << p[i].second << " " << q[i].first << " " << q[i]. second << endl;
    }



}


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

int main() {
	int N, M, C;
	cin >> N >> M >> C;

	vector<int> A(M);
	for(int i =0; i < M; i++) cin >> A.at(i);

    vector<vector<int>> B(N, vector<int>(M));

     for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          cin >> B.at(i).at(j);
        }
      }	
  
  	int ans = 0;
  
  	for (int i = 0; i < N; i++) {
      int score = 0;
        for (int j = 0; j < M; j++) {
          score += A.at(j)* B.at(i).at(j);
        }
      	if(score + C > 0) ans++; 
      }	
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long n, k, x, y;
  cin >> n >> k >> x >> y;

  if (n <= k) cout << n * x << endl;
  else cout << k * x + (n-k) * y << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

long double dist(vector<int> x, vector<int> y, int i, int j) {
  return sqrt(pow(x.at(j) - x.at(i), 2) + pow(y.at(j) - y.at(i), 2));
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) cin >> x.at(i) >> y.at(i);
  long double sum = 0;
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++) sum += dist(x, y, i, j);
  cout << fixed << setprecision(8) << sum * 2 / n << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
S_list = list(S)

numbers = []

for i in range(0, 10):
    for j in range(0, 10):
        for k in range(0, 10):
            numbers.append( str(i) + str(j) + str(k))

result = 0
for number in numbers:
    first = number[0]
    second = number[1]
    third = number[2]

    if first in S_list:
        first_index = S_list.index(first)

        if second in S_list[(first_index+1):]:
            second_index = (S_list[(first_index+1):]).index(second) + first_index + 1

            if third in S_list[(second_index+1):]:
                result += 1

    else:
        continue

print(result)

Measured memory_bytes: 3700
import sys
N,M=map(int,input().split())
A=[]
B=[]
A+=[str(input()) for i in range(N)]
B+=[str(input()) for i in range(M)]
for i in range(N-M+1):
  for j in range(N-M+1):
    ans=1
    for k in range(M):
      for l in range(M):
        if B[k][l]!=A[i+k][j+l]:
          ans=0
    if ans:
      print("Yes")
      sys.exit()
print("No")

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

int main(){
    int n, m;
    int f;
    int count = 0;
    cin >> n >> m;
    multimap<int, int>mm;
    for(int i=1; i<=n; ++i){
        int c;
        cin >> c;
        for(int j=1; j<=c; ++j){
            cin >> f;
            mm.emplace(f, i); 
        }
    }
    /*
    for(auto& k: mm){
        cout << k.first << " : " << k.second << endl;
    }
    */
    size_t t = mm.count(3);
    /*
    cout << t << endl;
    */
    for(int i=1; i<=m; ++i){
        size_t t = mm.count(i);
        /*
        cout << i << " : " << t << endl;
        */
        if(t==n) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <regex>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	regex r("A?KIHA?BA?RA?");
	string s;
	cin >> s;

	if(regex_match(s,r)) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c=0,i,d;
while(1){
scanf("%d %d\n",&a,&b);
if(a==0 && b==0){
break;
}
else{
c=a+b;
d=0;
for(i=1;i<5;i++){
scanf("%d %d\n",&a,&b);
if(c<a+b){
c=a+b;
d=i;
}
}
}
if(d==0){
printf("A %d\n",c);
}
else if(d==1){
printf("B %d\n",c);
}
else if(d==2){
printf("C %d\n",c);
}
else if(d==3){
printf("D %d\n",c);
}
else if(d==4){
printf("E %d\n",c);
}
}
return 0;
}



Measured memory_bytes: 1940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    string s;
    cin >>s;
    int cnt=0;

    rep(i,3){
        if(s[i]=='o'){
            cnt++;
        }
    }
    cout << 700 + 100*cnt << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if 0 <= z <= 2000 and 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3064
#include<cstdio>  
#include<cstdlib>
#include<cstring>
 
struct Node{
int key;
Node *next,*prev;
};
 
Node *nil;
 
Node* listSearch(int key){
Node *cur=nil->next;
while(cur!=nil&&cur->key!=key){
cur=cur->next;
}
return cur;
}
 
void init(){
nil=(Node *)malloc(sizeof(Node));
nil->next=nil;
nil->prev=nil;
}
 
void printList(){
Node *cur=nil->next;
int isf=0;
while(1){
if(cur==nil) break;
if(isf++>0) printf(" ");
printf("%d",cur->key);
cur=cur->next;
}
printf("\n");
}
 
void deleteNode(Node *t){
if(t==nil) return;
t->prev->next=t->next;
t->next->prev=t->prev;
free(t);
}
 
void deleteFirst(){
deleteNode(nil->next);
}
 
void deleteLast(){
 deleteNode(nil->prev);
 }
  
 void deleteKey(int key){
  
 deleteNode(listSearch(key));
 }
  
 void insert(int key){
 Node *x=(Node *)malloc(sizeof(Node));
 x->key=key;
 x->next=nil->next;
 nil->next->prev=x;
 nil->next=x;
 x->prev=nil;
 }
  
 int main(){
 int key,n,i;
 int size=0;
 char com[20];
 int np=0,nd=0;
 scanf("%d",&n);
 init();
    for(i=0;i<n;i++){
 scanf("%s%d",com,&key);
 if(com[0]=='i'){ insert(key);np++;size++;
}
else if(com[0]=='d'){
if(strlen(com)>6){
if(com[6]=='F') deleteFirst();
else if(com[6]=='L') deleteLast();
}else{
deleteKey(key);nd++;
}
size--;
}
}
 
printList();
 
return 0;
}


Measured memory_bytes: 33820
#include<iostream>
using namespace std;
int s[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
  int k;
  cin >> k;
  cout << s[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
n = gets.to_i
if hon.count(n % 10) > 0
    puts "hon"
elsif pon.count(n % 10) > 0
    puts "pon"
else
    puts "bon"
end

Measured memory_bytes: 14280
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int a[3][3];
	int n;
	int b[20] = { 0 };
	int bingo[3][3] = { 0 };
	int flag = 0;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", &b[i]);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (b[i] == a[j][k]) {
					bingo[j][k] = 1;
					break;
				}
			}
		}
	}

	for (int i = 0; i < 3; i++) {
		if (bingo[i][0] + bingo[i][1] + bingo[i][2] == 3)
			flag = 1;
	}
	for (int i = 0; i < 3; i++) {
		if (bingo[0][i] + bingo[1][i] + bingo[2][i] == 3)
			flag = 1;
	}
	if (bingo[0][0] + bingo[1][1] + bingo[2][2] == 3)flag = 1;
	if (bingo[0][2] + bingo[1][1] + bingo[2][0] == 3)flag = 1;
	if (flag)printf("Yes");
	else printf("No");
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int inv2=(mod+1)/2;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int n,a[200005],tree[200005],tree2[200005],num[200005],pos[200005];
long long sum=1,S[200005],D[200005],invD[200005];
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
void add(int x,int v)
{
	while(x<=n) tree[x]=(tree[x]+v)%mod,tree2[x]++,x+=(x&-x);
}
int ask(int x)
{
	int ans=0;
	while(x) ans=(ans+tree[x])%mod,x-=(x&-x);
	return ans;
}
int ask2(int x)
{
	int ans=0;
	while(x) ans+=tree2[x],x-=(x&-x);
	return ans;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),num[a[i]]++;
	for(int i=n;i>=1;i--) num[i]+=num[i+1];
	for(int i=1;i<=n;i++) num[i]-=(n-i);
	for(int i=1;i<=n;i++) sum=sum*num[i]%mod;
	if(!sum){puts("0");return 0;}
	S[0]=D[0]=1;
	for(int i=1;i<=n;i++)
	{
		long long x=1ll*(num[i]-1)*ksm(num[i],mod-2)%mod;
		if(!x) pos[i]=pos[i-1]+1,S[pos[i]]=i,D[i]=D[i-1];
		else pos[i]=pos[i-1],D[i]=D[i-1]*x%mod;
		invD[i]=ksm(D[i],mod-2);
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=(ans+1ll*(ask(a[i])-ask(S[pos[a[i]]]-1)+mod)*D[a[i]]%mod*sum%mod*inv2%mod)%mod;
		add(a[i],invD[a[i]]);
	}
	memset(tree,0,sizeof(tree));memset(tree2,0,sizeof(tree2));
	for(int i=n;i;i--)
	{
		ans-=1ll*(ask(a[i]-1)-ask(S[pos[a[i]]]-1)+mod)*D[a[i]]%mod*sum%mod*inv2%mod;ans=(ans%mod+mod)%mod;
		ans=(ans+1ll*ask2(a[i]-1)*sum%mod)%mod;
		add(a[i],invD[a[i]]);
	}
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 12336
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, t;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> k >> t;
    rep(i, t) cin >> a[i];
    while (1)
    {
        sort(a, a + t);
        reverse(a, a + t);
        if (a[1] == 0)
            break;
        a[0]--;
        a[1]--;
        ans++;
    }
    Cout(max(a[0] - 1, 0LL));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m, X, Y;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m >> X >> Y;
    vii x(n), y(m);
    rep(i, 0, n) cin >> x[i];
    rep(i, 0, m) cin >> y[i];
    int ans = 0;
    erep(i, X+1, Y) {
        if (*max_element(all(x)) < i && i <= *min_element(all(y))) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
template<typename T> istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec)	is >> x;
	return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
	os << "[";
	rep(i, vec.size())	os << (i ? ", " : "") << vec[i];
	os << "]";
	return os;
}
template<typename T> istream& operator >> (istream& is, pair<T, T>& p) {
	is >> p.first >> p.second;
	return is;
}
template<typename T> ostream& operator << (ostream& os, pair<T, T>& p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ld infl = 1e100;
const ll mod = 1e9+7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n, k;	cin >> n >> k;
	vll x(n);	cin >> x;
	ll ret = inf;
	rep(i, n) {
		int j = i + k - 1;
		if (j >= n)	continue;
		if (x[i]>0^x[j]>0) {
			ret = min(ret, llabs(x[i]) + llabs(x[j]) + min(llabs(x[i]), llabs(x[j])));
		}
		else {
			ret = min(ret, max(llabs(x[i]), llabs(x[j])));
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

int main(){
  ll n;
  cin >> n;
  map<ll,int> m = prime_factor(n);
  cout << n << ":";
  for(auto p : m){
    rep(i,0,p.second) cout << " " << p.first;
  }
  cout << endl;


  return 0;
}



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

int main(){
    long long h;
    cin>>h;
    if(h==1){
        cout<<1<<endl;
        return 0;
    }
    long long a=1;
    long long ans=1;
    while(h!=1){
        h/=2;
        a*=2;
        ans+=a;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
s = int(input())


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


p = {s: 1}
m = 1
while True:
    s = f(s)
    m += 1
    if s in p:
        print(m)
        break
    else:
        p[s] = m


Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N >> T;
    cin >> A;
    ll cnt = 0;
    ll before = 0;
    ll remain = T;
    for (ll i = 1; i < N; ++i) {
        ll current;
        cin >> current;
        ll diff = current - before;
        if (remain > diff) {
            cnt += diff;
        } else {
            cnt += remain;
        }
        remain = T;
        //cout << before << " " << current << " " << remain << endl;
        before = current;
    }

    cout << cnt + T << endl;

    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

using namespace std;

LL A, B, C;

LL dp[3];

int main()
{

  cin >> A >> B >> C;

  if(A%2 == 1 || B % 2 == 1 || C % 2 == 1){
    cout << 0 << endl;
    return 0;
  }

  if(A == B && C == B){
    cout << -1 << endl;
    return 0;
  }

  dp[0] = A;
  dp[1] = B;
  dp[2] = C;

  int ans = 0;
  while(true){
    bool ansFlag = false;
    for (int i = 0; i < 3; i++) {
      if(dp[i] % 2 == 1){
        ansFlag = true;
        break;
      }
    }

    if(ansFlag){
      break;
    }

    LL nDp[3];

    for (int i = 0; i < 3; i++) {
      nDp[i] = 0;
    }

    for (int i = 0; i < 3; i++) {
      int ni = (i+1) % 3, nii = (i+2) % 3;
      nDp[ni] += dp[i]/2; nDp[nii] += dp[i]/2;
    }

    for (int i = 0; i < 3; i++) {
      dp[i] = nDp[i];
    }

    ans++;

    if(ans > 1145141919){
      cout << -1 << endl;
      return 0;
    }

  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    const int MX = 1e6;
    vector<vector<int>> primes(MX+1);
    for(int i=2; i<=MX; i++) if(primes[i].size() == 0){
        for(int j=i; j<=MX; j+=i) primes[j].push_back(i);
    }

    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) scanf("%d", &A[i]);

    int G = 0;
    for(int a : A) G = gcd(G, a);
    if(G > 1){
        cout << "not coprime" << endl;
        return 0;
    }

    vector<bool> exist(MX+1);
    for(int a : A) for(int p : primes[a]){
        if(exist[p]){
            cout << "setwise coprime" << endl;
            return 0;
        }
        exist[p] = true;
    }

    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 62536
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 30 + 10;
ll n, dp[MXN], sum;
string s;
ll num(ll l, ll r){
    ll nn = 0;
    for(int i = l; i <= r; i ++){
        nn *= 10;
        nn += (s[i] - '0');
    }
    return nn;
}
ll Pw(ll x){
    if(x <= 0) return 1;
    return (1LL << (x - 1));
}
ll solve(ll p){
    if(p == 0) return 0;
    if(dp[p]) return dp[p];
    ll ans = 0;
    for(int i = 1; i <= p; i ++){
        ll nnw = (solve(i - 1) + Pw(i - 1) *  num(i, p));
        ans += nnw;
    }
    return dp[p] = ans;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> s; n = s.size(), s = "@" + s;
    cout << solve(n);
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC154D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            decimal N = decimal.Parse(NK[0]);
            decimal K = decimal.Parse(NK[1]);
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(N.ToString());
            decimal[] p = new decimal[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = decimal.Parse(input[i]);
            }
            decimal[] kitai = new decimal[n];
            for (int i = 0; i < n; i++)
            {
                kitai[i] = (decimal.Parse(p[i].ToString()) + 1) / 2;
            }
            int k = int.Parse(K.ToString());
            decimal sum = 0m;
            for (int i = 0; i < k; i++)
            {
                sum += kitai[i];
            }
            int matubi = k;
            decimal max = sum;
            while (matubi < n)
            {
                sum = sum - kitai[matubi - k] + kitai[matubi];
                if (sum > max)
                {
                    max = sum;
                }
                //Console.WriteLine(sum);
                //Console.WriteLine(kitai[matubi - k]);
                //Console.WriteLine(kitai[matubi]);
                matubi += 1;
            }
            //Console.WriteLine(string.Join(" ", kitai));
            Console.WriteLine(max);

        }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////

int main(){
	string s;
	cin >> s;
	string t[4] = {"dreamer", "dream", "eraser", "erase" };

	while(s != ""){
	   // cout << s << endl;
        rep(i,0,4){
            int index = s.rfind(t[i]);
            if(index != -1 && index == (int)s.size()-(int)t[i].size()){
                s.erase(index);
                break;
            }
            if(i == 3){
                cout << "NO" << endl;
                return 0;
            }
        }
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 512
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: MarathonForces #1

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

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
#define eps 1e-7
bool eq (double a, double b) {
	return fabs(a-b) <= eps;
}
int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	
	cout << fixed << setprecision(12) << w*h/2 << ' ';
	cout << ((eq(w/2,x) && eq(h/2,y)) ? '1' :'0');
	
	
	return 0;
}










Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

#define SPACE string(" ")

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

	string str;
	cin >> ws;
	getline(cin, str);

	string::size_type spos = 0;
	string::size_type epos = 0;

	vector<int> v;
	int num;
	long long sum = 0;
	while ((epos = str.find(SPACE, spos)) != string::npos) {
		num = atoi(str.substr(spos, epos - spos).c_str());
		sum += num;
		v.push_back(num);
		spos = epos + SPACE.length();
	}
	num = atoi(str.substr(spos).c_str());
	sum += num;
	v.push_back(num);

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

	cout << v[0] << SPACE << v[v.size() - 1] << SPACE << sum << endl;

	return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N;
    vector<int> a;
    cin >> N;
    int ans = 0;
    for (size_t i = 0; i < N; i++) {
        int x;
        cin >> x;
        ans += x;
    }
    ans -= N;
    cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> dp(3, 0), act(3), new_dp(3, 0);
  while(n--){
    for(int i=0; i<3; i++) cin>>act[i];
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        if(i!=j){
          new_dp[j] = max(new_dp[j], dp[i] + act[j]);
        }
      }
    }
    dp = new_dp;
  }
  cout<<max(dp[0], max(dp[1], dp[2]));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
int main(){
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  
  if(u==s)cout<<a-1<<" "<<b<<endl;
  else if(u==t)cout<<a<<" "<<b-1<<endl;
  else cout<<a<<" "<<b<<endl; 



}

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

using namespace std;

int main(){
	string s,t;cin>>s>>t;int f=0;
	for(int i=0;i<=s.size()-1;i++){
		if(s[i]!=t[i])f=1;
	}
	if(f==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3632
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define ll long long
#define mod 1000000007
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
const int N=1e5+10;
const int M=1e7+10;
int a[N];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int ans=1,x,pre,flag=-1;
        for(int i=0; i<n; i++)
        {
            x=read();
            if(i>0){
                if(flag==-1){
                    if(x>pre) flag=0;
                    else if(x<pre) flag=1;
                }
                else{
                    if(x>pre&&flag==1){
                        ans++;
                        flag=-1;
                    }
                    if(x<pre&&flag==0){
                        ans++;
                        flag=-1;
                    }
                }
            }
            pre=x;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define lp(i, x, y) for(int i = x ; i < y ; i++)
#define lp_rev(i, x, y) for(int i = x ; i >= y ; i--)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(v)  v.begin(), v.end()
#define vll vector<long long int>
#define vi vector<int>
#define Fasttt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
typedef unsigned long long ull;
typedef long long ll;
#define endl "\n"
ll mod = 1000000007;

int main()
{
	int r;
	cin>> r;
	cout<< r*r;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner( System.in );
        double vector[][] = new double[2][3];
        int i, j;
        while( scan.hasNext() ) {
            for( i = 0; i < 2; i ++ ) {
                for( j = 0; j < 3; j++ ) {
                    vector[i][j] = scan.nextFloat();
                }
            }
            Gaus(vector);
        }
    }
    
    private static void Gaus(double[][] vector) {
        int i;
        double x, y, k;
        
        if( vector[0][0] == 0 ) {
            double[] temp;
            temp = vector[0];
            vector[0] = vector[1];
            vector[1] = temp;
        }
        
        k = vector[1][0] / vector[0][0];
        for( i = 0; i < 3; i++ ) {
            vector[1][i] -= k * vector[0][i];
        }
        y = vector[1][2] / vector[1][1];
        x = (vector[0][2] - vector[0][1] * y) / vector[0][0];
        
        System.out.printf( "%.3f %.3f%n", x, y );
    }
    
}

Measured memory_bytes: 28500
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 150;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int G[MAX_N][MAX_N] = {};
    for(int i = 0; i < n; i++)
    {
        int u, k; cin >> u >> k;
        for(int j = 0; j < k; j++)
        {
            int v; cin >> v;
            G[u][v] = 1;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++) 
        {
            if(j == 1) cout << G[i][j];
            else cout << " " << G[i][j];
        }
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3300