akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    { 
        static void Main(string[] args)
        {
            //[summary]B - Cakes and Donuts
            int n = int.Parse(Console.ReadLine());

            if (CanBuyCakesAndDonuts(n))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool CanBuyCakesAndDonuts(int n)
        {
            for (int i = 0; i * 7 <= n; i++)
            {
                if ((n - i * 7) % 4 == 0)
                {
                    return true;
                }
            }

            return false;
        }
    }
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    vector<pair<long long, int>> v;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
        v.push_back(make_pair(A[i] + B[i], i));
    }
    sort(v.begin(), v.end(), greater<pair<long long, int>>());

    long long ans = 0;
    for (int i = 0; i < v.size(); i++)
    {
        if (i % 2 == 0)
        {
            ans += A[v[i].second];
        }
        else
        {
            ans -= B[v[i].second];
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int H, W;
	
	cin >> H >> W;
	
	char s[H+1][W+1];
	
	for(int i=1; i<=H; i++){
		for(int j=1; j<=W; j++)
			cin >> s[i][j];
	}
	
	for(int i=1; i<=H; i++){
		for(int j=1; j<=W; j++){
			if(s[i][j] == '#'){
				if(s[i][j-1] != '#' && s[i][j+1] != '#' && s[i-1][j] != '#' && s[i+1][j] != '#'){
					cout << "No";
					return 0;
				}
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  int all=a*b;
  int e=a*d+b*c;
  int subs=c*d;
  printf("%d",all-e+subs);
  return 0;
}


Measured memory_bytes: 128
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
point = 0

for i in t[:k]:
    if i == "r":
        point += p
    elif i == "s":
        point += r
    else:
        point += s

for i in range(k,n):
    if t[i-k] == t[i]:
        t[i] = "x"
        continue
    if t[i] == "r":
        point += p
    elif t[i] == "s":
        point += r
    else:
        point += s

print(point)

Measured memory_bytes: 4648
#include<iostream>

using namespace std;

int main()
{
	int x, y, z;
	int cnt = 1,res;
	int flag = 0;

	cin >> x >> y >> z;

	while (1)
	{
		res = x - ((y*cnt) + (z*(cnt + 1)));
		if (res >= 0)
		{
			cnt++;
		}
		else
		{
			break;
		}
	}
	cout << cnt-1 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int r = 12,c=6;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

char m[r][c];
bool vis[r][c];
bool willerase[r][c];
//fall down
void fall(){
  for(int i=r-1;i>=0;i--){
    rep(j,c){
      int now=i;
      if (m[now][j] == '.')continue;
      while(now+1 < r && m[now+1][j] == '.')swap(m[now+1][j],m[now][j]),now++;
    }
  }
}

//find ojama
void erase(int y,int x,char tar){
  if (vis[y][x])return;
  vis[y][x]=true;
  m[y][x]='.';
  rep(i,4){
    int ney=y+dy[i],nex=x+dx[i];
    if (ney == -1 || nex == -1 || ney == r || nex == c)continue;
    if (m[ney][nex] == 'O')m[ney][nex]='.';
    else if (m[ney][nex] == tar)erase(ney,nex,tar);
  }
}

//dousyoku4ko
void check(int y,int x,char tar,int &cnt){
  if (vis[y][x])return;
  vis[y][x]=true;
  cnt++;
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (nex == -1 || ney == -1 || nex == c || ney == r || m[ney][nex] != tar)
      continue;
    check(ney,nex,tar,cnt);
  }
}

int solve(){
  int ret=0;
  while(true){
    bool isok=false;
    rep(i,r)rep(j,c)vis[i][j]=false,willerase[i][j]=false;
    rep(i,r){
      rep(j,c)if (!vis[i][j] && m[i][j] != '.' && m[i][j] != 'O'){
	int tmp=0;
	check(i,j,m[i][j],tmp);
	if (tmp >= 4)willerase[i][j]=true,isok=true;
      }
    }
    if (!isok)break;
    rep(i,r)rep(j,c)vis[i][j]=false;
    rep(i,r){
      rep(j,c)if (willerase[i][j])erase(i,j,m[i][j]);
    }
    fall();
    ret++;
  }
  return ret;
}

main(){
  int te;
  cin>>te;
  while(te--){
    rep(i,r)cin>>m[i];
    cout << solve() << endl;
  }
  return false;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;
#define REP(i,N) for(ll i=0;i<N;++i)

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	REP(i,N) cin >> a[i];
	// となりあう要素が同一の色とならないように色を変える
	// even:2n  => n
	// odd: 2n+1=> n
	//
	// input ; 0, 1, 2, 3, 4, ...
	// output: 0, 0, 1, 1, 2, ... 
	// m / 2 
	ll n_conseq = 1;
	ll count = 0;
	for (ll i=1; i<N; ++i) {
		if (a[i] == a[i-1]) {
			n_conseq++;
		} else {
			count += n_conseq/2;
			n_conseq = 1;
		}
	}
	count += n_conseq/2;
	cout << count << endl;
	return 0;
}



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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int D;
    cin >> D;
    if(D == 25) OUT("Christmas");
    if(D == 24) OUT("Christmas Eve");
    if(D == 23) OUT("Christmas Eve Eve");
    if(D == 22) OUT("Christmas Eve Eve Eve");
    NL;
}

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

using namespace std;

const int MAXN = 100000 + 10;

int a[MAXN * 2], b[MAXN * 2], c[MAXN * 2];
int n;

int median(int a, int b, int c) {
    int x[] = {a, b, c};
    sort(x, x + 3);
    return x[1];
}

bool solve() {
    cin >> n;
    /*vector<int> p(n + n + 10);
    for(int i = 1; i <= n + n - 1; i++) p[i] = i;
    for(int i = 1; i <= n + n - 1; i++) {
        int j = rand() % (n + n - 1 - (i - 1));
        j++;
        a[i] = p[j];
        p[j] = p[n + n - 1 - (i - 1)];
    }
    for(int i = 1; i <= n + n - 1; i++) cout << a[i] << " "; cout << endl;*/
    for(int i = 1; i <= n + n - 1; i++) cin >> a[i];
    int low = 1, high = n + n - 1;
    while (low <= high) {
        int mid = (low + high) / 2;
        for(int i = 1; i <= n + n - 1; i++) b[i] = (a[i] >= mid);
        for(int i = 2; i < n + n - 1; i++) c[i] = (b[i - 1] + b[i] + b[i + 1] >= 2);
        int l = n, r = n;
        while ((l > 2) && (c[l - 1] != c[l])) l--;
        while ((r < n + n) && (c[r + 1] != c[r])) r++;
        int f = (n - l < r - n) ? c[l] : c[r];
        if (f == 1) low = mid + 1; else high = mid - 1;
    }
    /*for(int i = 1; i < n; i++) {
        for(int j = i + 1; j <= (n + n - 1) - i; j++) b[j] = median(a[j - 1], a[j], a[j + 1]);
        for(int j = 1; j <= n + n - 1; j++) a[j] = b[j];
    }*/
    //cout << "res " << low - 1 << " " << a[n] << endl;
    //return (low - 1 == a[n]);
    cout << low - 1 << endl;
}

int main()
{
    /*for(int i = 1; i <= 6; i++) {
        n = i;
        bool ok = solve();
        if (!ok) {
            cout << n << " stop\n" << endl;
        }
    }*/
    solve();
}


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

long long N, L[1000009];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> L[i];

	sort(L + 0, L + N);

	long long ret = 0;
	for (int i = N - 1; i >= 0; i -= 2) {
		if (i > 0) {
			ret += (L[i] - L[i - 1]);
		}
		else {
			ret += L[i];
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3068
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll a,b,c;
 sc(a);sc(b);sc(c);
 if(b-a==c-b)pY;
 else pN;
 
return 0;}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=1;i<n+1;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  ll n; cin>>n;
  ll a[n+2],b[n+2],c[n+2],dp[n+1][5];
  
  rep(i,n){cin>>a[i]>>b[i]>>c[i];}
  
  dp[1][1]=a[1]; dp[1][2]=b[1]; dp[1][3]=c[1];
  
  rep(i,n){
    dp[i+1][1]=max(dp[i][2],dp[i][3])+a[i+1];
    dp[i+1][2]=max(dp[i][1],dp[i][3])+b[i+1];
    dp[i+1][3]=max(dp[i][1],dp[i][2])+c[i+1];
  }
  cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;
}

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

typedef long long ll;
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n, k;	cin >> n >> k;
	ll p[n], c[n];
	REP(i, n){
		cin >> p[i];
	}
	REP(i, n){
		cin >> c[i];
	}

	vector<bool> list(n, 0);
	vector<ll> loop[n];
	REP(i, n){
		if( !list[i] ){
			ll j = i;
			do{
				loop[i].push_back(c[p[j] - 1]);
				list[p[j] - 1] = true;
				j = p[j] - 1;
			}while(j != i);
		}
	}

	ll sum, score, ck;
	ll ans = -1000000000;
	REP(i, n){
		sum = 0;
		score = 0;
		ck = k;

		REP(j, loop[i].size()){
			sum += loop[i][j];
		}

		if( sum > 0 && ck > (ll)loop[i].size() ){
			score = sum * (ck / loop[i].size());
			ck %= loop[i].size();

			if( k % loop[i].size() == 0 ){
				score -= sum;
				ck += loop[i].size();
			}
		}

		vector<ll> s(2 * loop[i].size() + 1, 0);
		s[0] = 0;
		REP(j, loop[i].size()){
			s[j+1] = s[j] + loop[i][j];
		}
		REP(j, loop[i].size()){
			s[j+loop[i].size()+1] = s[j+loop[i].size()] + loop[i][j];
		}

		ll tmp = -1000000000;
		for(ll left=0; left < 2 * (ll)loop[i].size() + 1; left++)
		for(ll right=left + 1; right < 2 * (ll)loop[i].size() + 1; right++){
			if( right - left <= ck ){
				tmp = max(tmp, s[right] - s[left]);
			}
		}

		ans = max(ans, score + tmp);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3936
def main():
    L = input().rstrip()
    MOD = 10**9 + 7
    dp = [[0 for equal in range(2)] for digit in range(len(L) + 1)]
    dp[0][0] = 1
    for digit in range(len(L)):
        x = int(L[digit])
        if x == 1:
            dp[digit+1][1] += dp[digit][0] + dp[digit][1]
            dp[digit+1][0] += dp[digit][0] * 2
            dp[digit+1][1] += dp[digit][1] * 2
        else:
            dp[digit+1][0] += dp[digit][0]
            dp[digit+1][1] += dp[digit][1]
            dp[digit+1][1] += dp[digit][1] * 2
        dp[digit+1][0] %= MOD
        dp[digit+1][1] %= MOD
    print((dp[len(L)][0] + dp[len(L)][1])%MOD)

if __name__ == "__main__":
    main()

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

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

fn main() {
    let mut done: bool = false;

    while !done {
        let a: i32 = read();
        let op: String = read();
        let op = op.as_bytes()[0] as char;
        let b: i32 = read();
        match op {
            '+' => println!("{}", a + b),
            '-' => println!("{}", a - b),
            '*' => println!("{}", a * b),
            '/' => println!("{}", a / b),
            _ => done = true,
        }
    }
}



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

public class Main{
	public static void main(String[] args) throws IOException {

		// ??\?????????
		InputStreamReader is = new InputStreamReader(System.in);
		
		// ??\??????Buffer???????´?
		BufferedReader br = new BufferedReader(is);
		
		// String?????§1?????????????????????
		String str = br.readLine();
		
		// ????????????int??????????????????????´?
		int input = Integer.parseInt(str);
		
		// 3???????????????
		System.out.println(input*input*input);
		

	}
}

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

using namespace std;

int main()
{

	string n;

	cin >> n;

	char c1 = '1' , c9 = '9';

	for(int i=0;i<n.size();i++)
	{
		if(n[i] == c1)
		{
			n[i] = c9;
		}
		else if(n[i] == c9)
		{
			n[i] = c1;
		}
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
using namespace std;
class Light{
    private:
        int j;
        vector<int> s;

    public:
        void set_s(int s){
            this -> s.push_back(s);
        }
        void set_j(int j){
            this -> j = j;
        }
        bool isFlash(int judge){
            int count = 0;
            for(const auto &e: s){
                if((e & judge) != 0)
                    count ++;
            }
            return (count % 2) == j;
        }
};

int main(void){
    int N, M, tmp1, tmp2, count = 0;
    int bits = 1;
    scanf("%d%d", &N, &M);

    vector<Light> l(M);
    for(int i = 0; i < M; i++){
        scanf("%d", &tmp1);
        for(int j = 0; j < tmp1; j++){
            scanf("%d", &tmp2);
            tmp2 = 1 << (tmp2 - 1);
            l[i].set_s(tmp2);
        }
    }

    for(int i = 0; i < M; i++){
        scanf("%d", &tmp1);
        l[i].set_j(tmp1);
    }

    bits = 1 << N;
    for (int i = 0; i < bits; i++){
        for(auto &e:l){
            if(!e.isFlash(i))
                goto BREAK;
        }
        count++;
    BREAK:;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (n < i * r + j * g) continue;
			if ((n - i * r - j * g) % b == 0) {
				//cout << i << ' ' << j << endl;
				ans++;
			}
		}
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func count(a []int, s, N int) int {
	cnt := 0
	for i := s + s; i <= N; i += s {
		cnt += a[i]
	}
	return cnt
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N+1)
	b := make([]int, N+1)
	ans := 0
	for i := 1; i <= N; i++ {
		a[i] = getInt()
		if i > N/2 {
			b[i] = a[i]
			if a[i] == 1 {
				ans++
			}
		}
	}

	for i := N / 2; i > 0; i-- {
		c := count(b, i, N)
		if a[i] != c%2 {
			b[i] = 1
			ans++
		}
		//		out(i, c)
	}

	//out(a)
	//out(b)
	out(ans)
	if ans != 0 {
		for i := 1; i <= N; i++ {
			if b[i] == 1 {
				fmt.Print(i, " ")
			}
		}
		out()
	}
}


Measured memory_bytes: 6144
def main():
  N, M = map(int, input().split())
  inf =  10**15
  p = 1<<N
  dp = [inf]*p
  dp[0] = 0
  for i in range(M):
    a, b = map(int, input().split())
    c = sum(1<<(i-1) for i in map(int, input().split()))
    for j in range(p):
      dp[c|j] = min(dp[j]+a, dp[c|j])
  if dp[-1] == inf:
    print(-1)
  else: 
    print(int(dp[-1]))
  
if __name__ == "__main__":
  main()
        

Measured memory_bytes: 3188
A,B,C=map(int,input().split())
if A==B==C:
    print(0 if A%2 else -1)
else:
    count=0
    while A%2==B%2==C%2==0:
        A,B,C=(B+C)/2,(C+A)/2,(A+B)/2
        count+=1
    print(count)

Measured memory_bytes: 9164
n,m = map(int,input().split())
s1 = set()
sn = set()
for _ in range(m):
    a,b = map(int,input().split())
    if a==1:
        s1.add(b)
    elif b==n:
        sn.add(a)

for x in s1:
    if x in sn:
        print("POSSIBLE")
        exit(0)
print("IMPOSSIBLE")


Measured memory_bytes: 18892
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)



function main()

capacitys = zeros(Int, 5)
N = parseInt(readline())

for i in 1:5
    capacitys[i] = parseInt(readline())
end

println(cld(N, minimum(capacitys)) + 4)

end


main()

Measured memory_bytes: 165916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int dp[333][333];

int rec(int l,int r,vector<int>& a){
    if(dp[l][r]>=0)return dp[l][r];
    if(l+1>=r)return dp[l][r]=0;int ans=0;
    REP(i,l+1,r)ans=max(ans,rec(l,i,a)+rec(i,r,a));
    if(rec(l+1,r-1,a)==r-l-2&&abs(a[l]-a[r-1])<=1)ans=r-l;
    return dp[l][r]=ans;
}

int solve(int n){
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    rep(i,333)rep(j,333)dp[i][j]=-1;
    return rec(0,n,a);
}
int main(){
    int n;
    while(cin>>n,n!=0){
        cout<<solve(n)<<endl;
    }

    return 0;
}


Measured memory_bytes: 3504
def is_prime(n):
    if n <2:
        return False
    elif n ==2:
        return True
    else:
        for i in range(2,n):
            if n %i ==0:
                return False
        else:
            return True
x =int(input())

while is_prime(x) is False:
    x +=1
print(x)

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


def main():
    from math import cos
    from math import pi
    from math import sqrt
    import sys
    input = sys.stdin.readline

    a, b, h, m = map(int, input().split())

    # KeyInsight:
    # 時針: h + m / 60時間で動いた角度 = 分針が動いた分も考慮する必要がある
    # 余弦定理
    hour = (60 * h + m) / 720 * 2 * pi
    minute = m / 60 * 2 * pi
    angle = abs(hour - minute)

    c = (a ** 2) + (b ** 2) - 2 * a * b * cos(angle)
    print(sqrt(c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9368
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

from collections import Counter

acnt = Counter(a)

ans = 0
temp = 0
for ai in sorted(a,reverse=True):
    pair = (1<<(ai.bit_length())) - ai
    
    if acnt[ai] > 0 and acnt[pair] > 0:
        if ai == pair:
            temp = (acnt[ai] // 2)
            ans += temp
            acnt[ai] -= (2*temp)
            
        elif ai > pair:
            temp = min(acnt[ai], acnt[pair])
            ans += temp
            acnt[ai] -= temp
            acnt[pair] -= temp
            
print(ans)

Measured memory_bytes: 33404
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 10000000000000000LL
#define MOD 1000000007LL
using namespace std;
typedef pair <long long int, int> P;
struct edge {
	int to;
	long long int cost;
};

int main()
{
	int n, m, s, t, u, v;
	long long int d;
	vector<edge> G[100000];
	long long int dmins[100000], dmint[100000], num1[100000], num2[100000];
	scanf("%d %d", &n, &m);
	scanf("%d %d", &s, &t);
	s--;
	t--;
	for(int i=0; i<m; i++){
		scanf("%d %d %lld", &u, &v, &d);
		u--;
		v--;
		edge g;
		g.cost=d, g.to=v;
		G[u].push_back(g);
		g.to=u;
		G[v].push_back(g);
	}

	priority_queue<P, vector<P>, greater<P> > que;
	fill(dmins, dmins+n, INF);
	dmins[s]=0;
	que.push(P(0, s));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v1=p.second;
		if(dmins[v1]<p.first) continue;
		for(int i=0; i<G[v1].size(); i++){
			edge e=G[v1][i];
			if(dmins[e.to]>dmins[v1]+e.cost){
				dmins[e.to]=dmins[v1]+e.cost;
				que.push(P(dmins[e.to], e.to));
			}
		}
	}
	fill(dmint, dmint+n, INF);
	dmint[t]=0;
	que.push(P(0, t));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v1=p.second;
		if(dmint[v1]<p.first) continue;
		for(int i=0; i<G[v1].size(); i++){
			edge e=G[v1][i];
			if(dmint[e.to]>dmint[v1]+e.cost){
				dmint[e.to]=dmint[v1]+e.cost;
				que.push(P(dmint[e.to], e.to));
			}
		}
	}
	long long int x=dmins[t];

	fill(num1, num1+n, 0);
	num1[s]=1;
	for(int i=0; i<n; i++){
      que.push(P(dmins[i], i));
    }
	while(!que.empty()){
		P p=que.top();
		que.pop();
        int v1=p.second;
		for(int i=0; i<G[v1].size(); i++){
			edge e=G[v1][i];
			if(dmins[v1]==dmins[e.to]+e.cost){
				num1[v1]=(num1[e.to]+num1[v1])%MOD;
			}
		}
	}
	fill(num2, num2+n, 0);
	num2[t]=1;
	for(int i=0; i<n; i++){
      que.push(P(dmint[i], i));
    }
	while(!que.empty()){
		P p=que.top();
		que.pop();
        int v1=p.second;
		for(int i=0; i<G[v1].size(); i++){
			edge e=G[v1][i];
			if(dmint[v1]==dmint[e.to]+e.cost){
				num2[v1]=(num2[e.to]+num2[v1])%MOD;
			}
		}
	}
	long long int ans=0;
	for(int k=0; k<n; k++){
		if(2*dmins[k]<x){
			for(int i=0; i<G[k].size(); i++){
				edge e=G[k][i];
				if(2*dmint[e.to]<x && dmint[e.to]+dmins[k]+e.cost==x){
					ans=(ans+num1[k]*num1[k]%MOD*num2[e.to]%MOD*num2[e.to]%MOD)%MOD;
				}
			}
		}else if(2*dmins[k]==x && 2*dmint[k]==x){
			ans=(ans+num1[k]*num1[k]%MOD*num2[k]%MOD*num2[k]%MOD)%MOD;
		}
	}
	ans=(num1[t]*num1[t]%MOD+MOD-ans)%MOD;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 18164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] list1 = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				list1[i][j] = sc.nextInt();
			}
		}
		int[][] list2 = new int[m][l];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				list2[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				long sum = 0;
				for (int k = 0; k < m; k++) {
					sum += list1[i][k] * list2[k][j];
				}
				if (j == 0) {
					System.out.print(sum);
				} else {
					System.out.print(" " + sum);
				}
			}
                        System.out.println();
		}
	}
}


Measured memory_bytes: 53596
fun main(args: Array<String>) {
    val (H, W, A, B) = readInputLine().split(" ").map { it.toInt() }
    
    for (i in 1..B) {
        println("0".repeat(A) + "1".repeat(W - A))
    }
    for (i in 1..H - B) {
        println("1".repeat(A) + "0".repeat(W - A))
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 39588
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>
#include <string>

int main(){
	std::string a;
	std::string b;
	std::cin >> a;
	if(a=="A") b = "T";
	if(a=="T") b = "A";
	if(a=="C") b = "G";
	if(a=="G") b = "C";
	std::cout << b << std::endl;
	return 0;
}


Measured memory_bytes: 256
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/

void solve()
{
	ll n,m,p;
	cin>>n>>m>>p;
	vector<pll> g[n+1];
	vector<ll> g1[n+1];
	ll i,j,x,y,c;
	vector<pair<pll,ll>> ed;
	rep(i,0,m){
		cin>>x>>y>>c;
		g[x].pb({y,p-c});
		g1[y].pb(x);
		ed.pb({{x,y},p-c});
	}
	ll d[n+1];
	rep(i,1,n+1)
	d[i]=1e18;
	d[1]=0;
	queue<ll> q;
	q.push(n);
	ll reach[n+1]={};
	reach[n]=1;
	while(!q.empty()){
		ll cur=q.front();
		q.pop();
		for(auto j:g1[cur]){
			//cout<<j<<" ";
			if(!reach[j]){
				reach[j]=1;
				q.push(j);
			}
		}
	}
	/*rep(i,1,n+1)
	cout<<reach[i]<<" ";*/
	ll k;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=0;k<sz(g[j]);k++){
				if(d[j]==1e18)
				continue;
				ll u=j;
				ll v=g[j][k].F;
				ll cst=g[j][k].S;
				if(d[v]>d[u]+cst)
				d[v]=d[u]+cst;
			}
		}
	}
	rep(i,1,n+1){
		for(int j=0;j<sz(g[i]);j++){
			ll v=g[i][j].F;
			ll c=g[i][j].S;
			if(d[i]!=1e18 && d[v]>d[i]+c && reach[v]){
				cout<<-1<<'\n';
				return;
			}
		}
	}
	ll ans=max(0ll,-d[n]);
	cout<<ans<<'\n';
}
int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 896
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let q = it.next().unwrap().parse::<usize>().unwrap();
    let mut g = vec![Vec::new(); n];
    for _ in 0..n-1 {
        let a = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = it.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
    }
    let mut res = vec![0; n];
    for _ in 0..q {
        let p = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let x = it.next().unwrap().parse::<i64>().unwrap();
        res[p] += x;
    }
    let mut qu = VecDeque::new();
    qu.push_back(0);
    let mut visit = vec![0; n];
    visit[0] = 1;
    while !qu.is_empty() {
        let p = qu.pop_front().unwrap();
        for &t in &g[p] {
            if visit[t] == 1 { continue }
            visit[t] = 1;
            res[t] += res[p];
            qu.push_back(t);
        }
    }
    print!("{}", res[0]);
    for i in 1..n { print!(" {}", res[i]); }
    println!("");
}


Measured memory_bytes: 30840
import sys
from io import StringIO
import unittest


def resolve():
    n, k = map(int, input().split())

    ans = []

    for i in range(2 * k):
        if i % 2 == 1:
            tmp = list(map(int, input().split()))
            ans.append(tmp)
        else:
            hoge = input()

    ans = [i for a in ans for i in a]
    print(n - len(set(ans)))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 2
2
1 3
1
3"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 3
1
3
1
3
1
3"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 16352
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename E>
struct SkewHeap{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  SkewHeap *l,*r;
  T val;
  F &f;
  G &g;
  E add,e;
  
  SkewHeap(T val,F &f,G &g,E e):val(val),f(f),g(g),add(e),e(e){l=r=NULL;}
  
  void eval(){
    if(add==e) return;
    if(l) l->add=g(l->add,add);
    if(r) r->add=g(r->add,add);
    val=f(val,add);
    add=e;
  }
  
  T top(){
    return f(val,add);
  }
  
};

template<typename T, typename E>
SkewHeap<T, E>* meld(SkewHeap<T, E> *a,SkewHeap<T, E> *b){
  if(!a) return b;
  if(!b) return a;
  if(a->top() > b->top())  swap(a,b);
  a->eval();
  a->r=meld(a->r,b);
  swap(a->l,a->r);
  return a;
}

template<typename T, typename E>
SkewHeap<T, E>* pop(SkewHeap<T, E>* a){
  a->eval();
  return meld(a->l,a->r);
};

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    r[x]+=r[y];
    p[y]=x;
  }
};


struct Arborescence{
  using P = pair<int, int>;
  using Heap = SkewHeap<P, int>;
  Heap::F f=[](P a,int b){return P(a.first+b,a.second);};
  Heap::G g=[](int a,int b){return a+b;};
  
  struct edge{
    int from,to,cost;
    edge(){}
    edge(int from,int to,int cost):from(from),to(to),cost(cost){}
  };
  
  int n;
  UnionFind uf;
  vector<edge> edges;
  vector<Heap*> come,pool;
  vector<int> used,from,cost;
  
  Arborescence(int n):n(n),uf(n),come(n,NULL),
		      used(n,0),from(n,-1),cost(n,-1){};

  void add_edge(int from,int to,int cost){
    edges.emplace_back(from,to,cost);
  }

  void input(int m,int offset=0){
    for(int i=0;i<m;i++){
      int u,v,c;
      cin>>u>>v>>c;
      add_edge(u+offset,v+offset,c);
    }
  }

  int build(int r){
    used[r]=2;
    pool.resize(edges.size(),NULL);
    for(int i=0;i<(int)edges.size();i++){
      edge &e=edges[i];
      pool[i]=new Heap(P(e.cost,i),f,g,0);
      come[e.to]=meld(come[e.to],pool[i]);
    }
    
    int res=0;
    for(int i=0;i<n;i++){
      if(used[i]) continue;
      int v=i;
      vector<int> l;
      while(used[v]!=2){
	used[v]=1;
	l.emplace_back(v);
	if(!come[v]) return -1;
	from[v]=uf.find(edges[come[v]->val.second].from);
	cost[v]=come[v]->top().first;
	come[v]=pop(come[v]);
	if(from[v]==v) continue;

	if(0){
	  cout<<v<<endl;
	  cout<<"from:"<<from[v]<<endl;
	  cout<<"cost:"<<cost[v]<<endl;
	  cout<<"come:"<<come[v]<<endl;
	}

	res+=cost[v];
	if(used[from[v]]==1){
	  int p=v;
	  do{
	    if(come[p]) come[p]->add-=cost[p];
	    if(p!=v){
	      uf.unite(v,p);
	      come[v]=meld(come[v],come[p]);
	    }
	    p=uf.find(from[p]);
	  }while(p!=v);
	}else{
	  v=from[v];
	}
      }
      for(int u:l) used[u]=2;
    }
    return res;
  }
  
};
//END CUT HERE
signed main(){
  int n,m,r;
  cin>>n>>m>>r;
  Arborescence G(n);
  G.input(m);
  cout<<G.build(r)<<endl;
  return 0;
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll x, ll n, ll mod=INF) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

int main () {
  int n, m;
  cin >> n >> m;
  vi s(m), c(m);
  rep(i,m) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  //showv(s);

  //for (int i = (n == 1 ? 0 : mod_pow(10,n-1)); i < mod_pow(10,n); ++i) {
  rep(i,1000) {
    string k = to_string(i);
    if (k.size() != n) continue;
    bool ok = true;
    rep(j,m) {
      if (k[s[j]] != c[j]+'0') ok = false;
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, m, a, b;
long long res;
vector<vector<int>> v;
priority_queue<int> pq;
int main() {
    DAU
    cin >> n >> m;
    v.resize(m + 1);
    while (n--) {
        cin >> a >> b;
        if (a <= m)
            v[a].emplace_back(b);
    }
    for (int i = 1; i <= m; ++i) {
        for (const int& x : v[i])
            pq.emplace(x);
        if (!pq.empty())
            res += pq.top(), pq.pop();
    }
    cout << res;
    PLEC
}


Measured memory_bytes: 8408
n = gets.chomp.to_i
ans = 0
n.downto(1) do |i|
    j = i
    while 
        amari = j % 2
        if amari == 0
            j = j /2
        else
            if j <= 1
                puts i
                exit
            end
            break
        end
    end
end

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

bool prime[10000010];

int main() {
	for(int i = 0; i < 10000010; i++) prime[i] = true;
	prime[0] = prime[1] = false;
	for(int i = 2; i < 10000010; i++) {
		if(prime[i]) {
			for(int j = i * 2; j < 10000010; j += i)
				prime[j] = false;
		}
	}
	vector<int> v;
	for(int i = 10000010; i; i--) {
		if(prime[i] && prime[i-2] && prime[i-6] && prime[i-8]) {
			v.push_back(i);
		}
	}
	int n;
	while(cin >> n, n) {
		cout << *lower_bound(v.begin(), v.end(), n, greater<int>()) << endl;
	}
}

Measured memory_bytes: 10988
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    P = [list(map(int, input().split())) for i in range(M)]
    G = [True]*N
    for a,b in P:
        if H[a-1] >= H[b-1]:
            G[b-1] = False
        if H[a-1] <= H[b-1]:
            G[a-1] = False
    print(G.count(True))

if __name__ == '__main__':
    main()

Measured memory_bytes: 91500
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	
    ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll ans=0;
	if(a>=k)
	{
	    ans=k;
	    
	}
	else
	{
	    ans=a;
	    k=k-a;
	}
	if(b<k)
	{
	    k=k-b;
	}
	else k=0;
	ans=ans-min(k,c);
	cout<<ans<<endl;

}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int c = a/b;
		int d = a%b;
		double e = (double)a / (double)b;
		
		String str = String.format("%.5f", e);
		
		System.out.println(c +" "+ d +" "+ str);
		
	    
	}
}

Measured memory_bytes: 26436
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,m;
    long k;
    scanf("%d %d", &n, &m);
    scanf("%ld", &k);
    long ai[n + m];
    for(int i = 0; i < n; i++){
        long a;
        scanf("%ld", &a);
        ai[n - 1 - i] = a;
    }
    for(int i = 0; i < m; i++){
        long b;
        scanf("%ld", &b);
        ai[n + i] = b;
    }
    
    int nReadMax = 0;
    long iSumTime = 0;
    for(int i = 0; i < n; i++){
        iSumTime += ai[i];
    }
    int i = 0;
    int j = n - 1;
    while(i <= n && j < n + m - 1){
        if(iSumTime > k){
            iSumTime -= ai[i];
            i++;
            if(iSumTime <= k){
                nReadMax = max(nReadMax, j - i + 1);
            }
        } else {
            nReadMax = max(nReadMax, j - i + 1);
            iSumTime += ai[j + 1];
            j++;
            if(iSumTime <= k){
                nReadMax = max(nReadMax, j - i + 1);
            }
        }    
    }
    printf("%d", nReadMax);
    return 0;
}


Measured memory_bytes: 6352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
	freopen("C:\\code\\input.txt", "r", stdin);
#endif
	//freopen("C:\\code\\output.txt","r",stdin);
	ll x = readll();
	ll base = 101;
	ll ans = 1ll;
	while (base < x)
	{
		ans++;
		base += base / 100;
	}
	printf("%lld\n", ans );
	return 0;
}




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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int ans = 0;
	if (A + B > C * 2) {
		if (X > Y) {
			ans += Y * C * 2;
			int div = X - Y;
			ans += min(div * A, C * 2 * div);
		}
		else {
			ans += X * C * 2;
			int div = Y - X;
			ans += min(div * B, C * 2 * div);
		}
	}
	else {
		if (X > Y) {
			ans += Y * A;
			ans += Y * B;
			int div = X - Y;
			ans += min(div * A, C * 2 * div);
		}
		else {
			ans += X * A;
			ans += X * B;
			int div = Y - X;
			ans += min(div * B, C * 2 * div);
		}
	}
	cout << ans << endl;
	return 0;
}


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



int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	int n, m;
	cin >> n >> m;


	vector<string>v1, v2;
	for (int i = 0; i < n; i++)
	{
		string s1;
		cin >> s1;
		v1.push_back(s1);
	}

	for (int i = 0; i < m; i++)
	{
		string s1;
		cin >> s1;
		v2.push_back(s1);
	}

	int i = 0;
	int j = 0;

	int flag = 0;
	int fn;
	while (i < n and j < m)
	{
		if (v1[i].find(v2[j]) == string::npos)
		{
			i++;
		}
		else {
			if (j == 0)
			{
				fn = 0;
				i++;
				j++;
			}
			else {
				if (i - fn == 1)
				{
					fn = i;
					i++;
					j++;
				}
				else {
					flag == 1;
					break;
				}
			}

		}
	}


	if (j == m and flag == 0)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}




	return 0;
}

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

int n, k, mx;

int main() {
	scanf("%d%d", &n, &k);
	mx = ((n / 4) << 1) + min(n % 4, 2);
	puts(k <= mx ? "YES" : "NO");
	return 0;
}

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

#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
typedef long long ll;

int r = 700;
string s;

signed main() {
	cin >> s;
	rep(i,3) if (s[i]=='o') r += 100;
	cout << r << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = m*(m-1)/2+n*(n-1)/2;
        System.out.println(ans);


    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N, M;


signed main(){
	cin >> N >> M;

	double ans = 0;

	rep(i, 1, 100010) ans += ((N-M)*100+M*1900)*i*pow(1-1/pow(2, M), i-1)/pow(2, M);

	cout << round(ans) << endl;

	return 0;
}

Measured memory_bytes: 512