akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };



ll f(ll A, ll B) {
	if (A == B)return 1;
	ll x = 1;
	while (x * 2 <= B)x *= 2;
	if (A&x)return f(A^x, B^x);
	ll y = 1;
	while (y <= (B^x))y *= 2;
	ll ret = x - A;
	if (x + y - 1 < x + A)ret += (x + y - 1 - x + 1) + (2 * x - 1 - (x + A) + 1);
	else ret += (2 * x - 1 - x) + 1;
	return ret;
}

void solve() {
	ll A, B; cin >> A >> B;
	print(f(A, B));
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int x, n;
vector<int> vec;

int test(int i, int j){
	// int a = find(vec.begin(), vec.end(), i);
	// int b = find(vec.begin(), vec.end(), j);
	if(find(vec.begin(), vec.end(), j) == vec.end()){
		return j;
	}else if(find(vec.begin(), vec.end(), i) == vec.end()){
		return i;
	}else{
		i++;
		j--;
		return test(i ,j);
		
	}
}
int main(){
	cin >> x >> n;
	for(int i = 0;i < n;i++){
		int s;	
		cin >> s;
		vec.push_back(s);
	}

	cout << test(x, x) << endl;;
	
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 16
#define LL long long
char s[MAXN];
int digit[MAXN];
LL ans,N;
LL Pow(int x)
{
	LL res=1;
	while(x--)
		res*=10;
	return res;
}
int Abs(int x)
{
	if(x>0) return x;
		else return -x;
}
void dfs(int pos,LL sum,LL last)
{
	if(pos>N)
	{
		ans=ans+sum+last;
		return ;
	}
	dfs(pos+1,sum,last*10+digit[pos]);
	dfs(pos+1,sum+last,digit[pos]);
}
int main()
{
	scanf("%s",s+1);
	N=strlen(s+1);
	for(int i=1;i<=N;i++)
		digit[i]=s[i]-'0';
	dfs(2,0,digit[1]);
	//注意第一种情况确定，第一个数前面不能加'+'，第一位一定是第一个加数的第一位
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
import sys
import random
import time
import math
import bisect

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def prob(e1,e2,T):
    if e2 < e1:
        return 1
    else:
        return math.exp((e1-e2)/T)

def solve():
    m = 26
    start = time.time()
    dT = 0.993
    T = 500
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    H = [None]*D
    for i in range(D):
        g = [s[i][j] + 25 * c[j] for j in range(m)]
        y = min(g)
        h = sum(g) - m * y
        g = [(x-y)/h for x in g]
        for j in range(1, m):
            g[j] += g[j-1]
        H[i] = g

    def calc(sche, m=26):
        last = [-1] * m
        ans = 0
        for i in range(D):
            t = sche[i]
            ans += s[i][t]
            last[t] = i
            for j in range(m):
                ans -= c[j] * (i - last[j])
        return ans

    def change(d, q, sc):
        b = sche[d]
        fq, bq = -1, D
        fb, bb = -1, D
        for i in range(d):
            if sche[i] == q:
                fq = i
            if sche[i] == b:
                fb = i
        for i in range(D-1, d, -1):
            if sche[i] == q:
                bq = i
            if sche[i] == b:
                bb = i
        sc += ((bb - d) * (bb - d - 1) // 2 + (d - fb) * (d - fb - 1) // 2) * c[b]
        sc += ((bq - fq) * (bq - fq - 1) // 2) * c[q]
        sc -= s[d][b]
        sc -= ((bq - d) * (bq - d - 1) // 2 + (d - fq) * (d - fq - 1) // 2) * c[q]
        sc -= ((bb - fb) * (bb - fb - 1) // 2) * c[b]
        sc += s[d][q]
        return sc

    sche = [0] * D
    for i in range(D):
        sche[i] = s[i].index(max(s[i]))
    sc = calc(sche)
    bestst = sche[:]
    best = sc

    while time.time() - start < 1.85:
        for _ in range(200):
            d = random.randint(0, D-1)
            q = bisect.bisect(H[d], random.random())
            nsc = change(d, q, sc)
            if best < nsc:
                bestst = sche[:]
                best = nsc
            if random.random() < prob(-sc, -nsc, T):
                sche[d] = q
                sc = nsc
        T *= dT
    prn([1 + x for x in bestst])
    return

solve()


Measured memory_bytes: 84596
NK = list(map(int, input().split()))
A = list(map(int, input().split()))

first = 0
last = 0

for i in range(NK[1], NK[0]):
    first = A[i - NK[1]]
    last = A[i]
    if (first < last):
        print("Yes")
    else:
        print("No")


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

int main()
{
  int e, x;
  while(cin >> e && e > 0){
    int m = 1e6;
    for(int z=0; z<=1e2; z++){
      for(int y=0; y<=1e3; y++){
        x = e - z*z*z - y*y;
        if(x < 0){
          continue;
        }
        if(x+y+z<m){
          m = x + y + z;
        }
      }
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
#define LEN 100000

typedef struct proc
{
  char name[100];
  int t;
}process;

int n;
int head = 0, tail = 0;
process queue[LEN + 1];

void enqueue(process x)
{
  queue[tail] = x;
  if(tail + 1 == LEN) tail = 0;
  else tail++;
}

void dequeue()
{
  if(head + 1 == LEN) head = 0;
  else head++;
}

int main()
{
  int elaps = 0;
  int i, q;
  process tmp;

  scanf("%d %d", &n, &q);

  for(i = 0; i < n; i++)
    {
      scanf("%s", tmp.name);
      scanf("%d", &tmp.t);
      enqueue(tmp);
    }

  while(head != tail)
    {
      queue[head].t -= q;
      if(queue[head].t <= 0){
    	elaps += q + queue[head].t;
    	printf("%s %d\n", queue[head].name, elaps);
    	dequeue();
      }
      else{
        elaps += q;
    	enqueue(queue[head]);
    	dequeue();
      }
    }
  return 0;
}

Measured memory_bytes: 10752
x=int(input())
p=[1 for i in range(100010)]
for i in range(2,100011):
    k=2*i
    while k<=100009:
        p[k]=0
        k+=i
z=x
f=0
while f==0:
    if p[z]==1:
        print(z)
        f=1
    z+=1

    
    


    
        
        
    
    
    
    
        


Measured memory_bytes: 9912
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[][] stores = new int[n][2];

    for (int i = 0; i < n; ++i) {
      stores[i][0] = sc.nextInt();
      stores[i][1] = sc.nextInt();
    }

    stores = mergeSort(stores);

    int sum = 0;
    long cost = 0;
    int i = 0;
    while (sum < m) {
      if (stores[i][1] == 0)
        ++i;
      --stores[i][1];
      ++sum;
      cost += stores[i][0];
    }

    System.out.println(cost);
  }

  public static int[][] mergeSort(int[][] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[][] left = new int[mid][2];
    int[][] right = new int[a.length - mid][2];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];
    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge(mergeSort(left), mergeSort(right));
  }

  public static int[][] merge(int[][] l, int[][] r) {
    int[][] a = new int[l.length + r.length][2];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i][0] < r[j][0] || l[i][0] < r[j][0] && l[i][1] >= r[i][1])
        a[k++] = l[i++];
      else
        a[k++] = r[j++];
    }

    while (i < l.length)
      a[k++] = l[i++];
    while (j < r.length)
      a[k++] = r[j++];

    return a;
  }
}

Measured memory_bytes: 98632
#include<stdio.h>

int main(void){
  
  int i;
  int j = 0;
  char Out[100];
  char S[100];
  scanf("%s", S);

  while(S[i] != '\0'){
    if(S[i] == '0'){
      Out[j++] = '0';
    }
    if(S[i] == '1'){
      Out[j++] = '1';
    }
    if(S[i] == 'B'){
      if (j != 0){
        Out[--j] = '\0';
      }
    }
    i++;
  }
  if(j-1 != '\0')
    Out[j] = '\0';

  printf("%s\n", Out);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int d[2002];
int main(){
	int n;
	int x,y;
	cin>>n>>x>>y;
	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			int dist = j-i;
			//x,y를 경우하는 방법과 비교 
			dist = min(dist,abs(x-i)+1+abs(y-j));
			d[dist]++;		
		}
	}
	for(int i=1; i<n; i++) cout<<d[i]<<'\n';
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(void)
{
    char n[4];
    scanf("%s",n);
    while((10>atoi(n))||(atoi(n)>99))
    {
        scanf("%s",n);
    }
    if((n[0]=='9')||(n[1]=='9'))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s = list(input())
ans = []
alpha = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')

for i in s:
    ans.append(alpha[(alpha.index(i)+n)%26])
print(''.join(ans))

Measured memory_bytes: 3188
# 

from sys import stdin
input = lambda: stdin.readline().rstrip()


X, N = map(int, input().split())
P = list(map(int, input().split()))

def solve(A, B):
    if A not in P:
        print(A)
        return

    if B not in P:
        print(B)
        return
    
    solve(A-1, B+1)

solve(X,X)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while (true) {
        int h, w;
        cin >> w >> h;
        if (w == 0 && h == 0)
            return 0;
        vector<string> s(h);
        for (int i = 0; i < h; ++i) {
            cin >> s[i];
        }
        int sy, sx;
        [&] {
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    if (s[i][j] == '@') {
                        sy = i;
                        sx = j;
                        return;
                    }
                }
            }
        }();
        queue<pair<int, int>> q;
        q.emplace(sy, sx);
        const int dx[4] = {-1, 1, 0, 0};
        const int dy[4] = {0, 0, -1, 1};
        auto inside     = [&](int y, int x) { return 0 <= y && y < h && 0 <= x && x < w; };
        int ret         = 1;
        while (q.size() != 0) {
            auto p = q.front();
            q.pop();
            for (int i = 0; i < 4; ++i) {
                int nx = p.second + dx[i];
                int ny = p.first + dy[i];
                if (inside(ny, nx) && s[ny][nx] == '.') {
                    ret++;
                    s[ny][nx] = '#';
                    q.emplace(ny, nx);
                }
            }
        }
        cout << ret << "\n";
    }
    return 0;
}


Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int N = in.nextInt(), K = in.nextInt();
            if (N % K == 0) {
                out.println(0);
            } else {
                out.println(1);
            }
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
 
int cnt[10][10];
 
int main() {
    int x, y, s; char c;
    while(cin >> x >> c >> y >> c >> s) {
        for(int i = 0; i < 10; i ++)
            for(int j = 0; j < 10; j ++)
                if(s == 2) {
                    if(abs(x - i) <= 1 && abs(y - j) <= 1)
                        cnt[i][j] ++;
                } else {
                    if(abs(x - i) + abs(y - j) <= s / 2 + 1)
                        cnt[i][j] ++;
                }
    }
    auto a = (int*)cnt;
    cout << count(a, a + 100, 0) << '\n';
    cout << *max_element(a, a + 100) << '\n';
    return 0;
}


Measured memory_bytes: 3100
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			int z = stdIn.nextInt();
			if(x == 0 && y == 0 && z == 0) break;
			int n = stdIn.nextInt();
			double c1 = Math.sqrt(x * x + y * y);
			double c2 = Math.sqrt(x * x + z * z);
			double c3 = Math.sqrt(y * y + z * z);
			for(int i = 0; i < n; i++) {
				double r = stdIn.nextDouble();
				r *= 2.0;
				boolean isC = false;
				if(r > c1) isC = true;
				if(r > c2) isC = true;
				if(r > c3) isC = true;
				System.out.println((isC)?"OK":"NA");
			}
			
		}
		
	}

}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int X, N, p, ans, diff = 1;
    cin>>X>>N;
    set<int> s;
    while(N--){
        cin>>p;
        s.insert(p);
    }
    ans = X;
    bool flag = false;
    while(!flag){
        if(s.find(ans)==s.end())
            flag = true;
        else{
            if(ans>=X) ans-=diff;
            else ans+=diff;
            diff++;
        }
    }
    cout<<ans;
    return 0;
}

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


int main() {
  int n; cin >> n;
  int t, a; cin >> t >> a;
  int ans = -1;
  double best = 100000000;

  rep1(i, n) {
    int h; cin >> h;
    double score = abs(a - (t - h * 0.006));
    if (score < best) {
      ans = i;
      best = score;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_V = 100005;
vector <ll> G[MAX_V];

ll color[MAX_V];
bool flag = true;
ll N,M;
bool dfs(ll v,ll c) {
	color[v] = c;
	FOR(i, 0, G[v].size()) {
		if (color[G[v][i]] == c)return false;
		if (color[G[v][i]] == 0 && !dfs(G[v][i], -c))return false;
	}
	return true;
}
int main(void) {
	cin >> N>>M;
	FOR(i, 0, M) {
		ll a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	FOR(i, 0, N) {
		if (color[i] == 0) {
			if (!(dfs(i, 1))) {
				ct(N*(N - 1) / 2 - M);
				return 0;
			}
		}
	}
	ll a = count(color+1, color + N+1, 1), b = count(color+1, color + N+1, -1);
	
	ct(a*b-M);

	return 0;
}

Measured memory_bytes: 7424
n = int(input())
lst = [0]*(10**5)

l = list(map(int,input().split()))
total = sum(l)  
for x in l:
  lst[x-1] += 1

  
m = int(input())  
for i in range(m):
  x,y = map(int,input().split())
  lst[y-1] += lst[x-1]
  total += (y-x) * lst[x-1]
  lst[x-1] = 0  
  print(total)



Measured memory_bytes: 84796
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (1e+9)+7;

int main(){
  string k;
  int d;
  cin >> k >> d;
  int n=k.size();
  vector<ll> kl(n);
  for(int i=0;i<n;i++){
    kl[i] = k[i] - '0';
  }
  ll dp[n+1][d+1][2] = {};  // dp[桁][%MOD][フラグ]
  dp[0][0][0] = 1;
  int flags[] = {0,1};
  for(int dig = 0;dig < n; dig++){
    for(int base = 0; base < d; base++){
      for(int less: flags){
        for(int x = 0; x<= (less?9:kl[dig]);x++){
          dp[dig+1][(base + x)%d][less | x < kl[dig]] += dp[dig][base][less];
          dp[dig+1][(base + x)%d][less | x < kl[dig]] %= MOD;
        }
      }
    }
  }
  cout << (dp[n][0][0] + dp[n][0][1] - 1 + MOD)%MOD  << endl; 
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
int main()
{
	bitset<maxn> b;
	b[0] = 1;
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int v;
		scanf("%d", &v);
		b |= b << v;
	}
	for(int i = maxn - 1; i; --i)
		if(b[i] && i % 10)
		{
			cout << i << endl;
			return 0;
		}
	puts("0");
	return 0;
}

Measured memory_bytes: 3764
while line = gets.chomp do
  a,op,b = line.split(" ")
  a = a.to_i
  b = b.to_i
  case op
  when "+" then
    ans = a + b
  when "-" then
    ans = a - b
  when "*" then
    ans = a * b
  when "/" then
    ans = a / b
  when "?" then
    break
  end
  printf("%d\n",ans)
end


Measured memory_bytes: 6884
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

num = []
for i in 1..10**5 do
  num.push(0)
end

sum_num = 0
for i in 1..N do
  n = lines[1][i-1]
  num[n-1] += 1
  sum_num += n
end

Q = lines[2][0]
for i in 1..Q do
  bi = lines[i+2][0]
  ci = lines[i+2][1]
  sum_num += (ci - bi) * num[bi-1]
  num[ci-1] += num[bi-1]
  num[bi-1] = 0
  puts sum_num
end

Measured memory_bytes: 23384
import sys
from bisect import bisect_left, bisect_right, insort

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

N = ir()
S = list('-' + sr())
d = [[] for _ in range(26)]
for i in range(1, N+1):
    s = S[i]
    o = ord(s) - ord('a')
    insort(d[o], i)

Q = ir()
for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].pop(bisect_left(d[prev], a))
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans)


Measured memory_bytes: 29192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];

	}
	if(n==1)
		{cout<<"Yes"<<endl;
			return 0;}
	for(int i=n-1;i>=1;i--)
	{
		if(arr[i]<arr[i-1])
		{
			 arr[i-1]--;
			if(arr[i]==arr[i-1])
				continue;
			else
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
package main

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

func main() {
	sc := NewScanner()
	A, B, _, K := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()
	if K%2 == 0 {
		fmt.Println(A - B)
	} else {
		fmt.Println(-A + B)
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=998244353;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Cb make_pair
#define Ll long long
#define Ull unsigned long long
#define Snf scanf
#define Prf prinf
#define Pb push_back
#define Stc stack
#define Vct vector
#define Ret return
#define Sz size
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1];
	Ret 0;
}

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

ll memo[55];

ll fib(int n) {
    if (memo[n]) return memo[n];
    if (n == 0 || n == 1) return memo[n] = 1;
    return memo[n] = fib(n - 1) + fib(n - 2);
}

int main() {
    fib(50);
    int n;
    cin >> n;
    cout << memo[n] << endl;
}


Measured memory_bytes: 3116
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, A = map(int, input().split())
    x = np.array(list(map(int, input().split())))
    x -= A
    MAX_ = max(1, max(x))

    dp = np.zeros((N+1, MAX_ * N * 2), dtype=int)
    dp[0][MAX_ * N] = 1

    for i in range(N):
        dp[i+1] += dp[i]
        if x[i] > 0:
            dp[i+1][x[i]:] += dp[i][:-x[i]]
        elif x[i] < 0:
            dp[i+1][:x[i]] += dp[i][-x[i]:]
        else:
            dp[i+1] += dp[i]
    
    print(dp[N][MAX_ * N] - 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14484
H,W = map(int, input().split())
Sn = [["." for i in range(W+2)]]
for _ in range(H):
  Sn.append(["."]+list(str(input()))+["."])
Sn.append(["." for i in range(W+2)])

for i in range(1,H+1):
  for j in range(1,W+1):
    if Sn[i][j] == '#':
      continue
    l = [Sn[i-1][j-1], Sn[i-1][j], Sn[i-1][j+1], Sn[i][j-1], Sn[i][j+1], Sn[i+1][j-1], Sn[i+1][j], Sn[i+1][j+1]]
    Sn[i][j] = str(l.count('#'))

for i in range(1,H+1):
  for j in range(1,W+1):
    print(Sn[i][j],end="")
  print()



Measured memory_bytes: 3572
#include <stdio.h>

int main(void) {

  long n,m,k;
  scanf("%ld %ld %ld", &n, &m, &k);
  long a[n],b[m];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  for (long i = 0; i < m; i++) {
    scanf("%ld", &b[i]);
  }
  long sum_a[n],sum_b[m];
  sum_a[0] = a[0];
  for (long i = 1; i < n; i++) {
    sum_a[i] = sum_a[i-1]+a[i];
  }
  sum_b[0] = b[0];
  for (long i = 1; i < m; i++) {
    sum_b[i] = sum_b[i-1]+b[i];
  }
  long time,read,cur = m-1;
  long max = 0;
  for (long i = m-1; i >= 0; i--) {
    if (sum_b[i] > k) {
      cur = i;
    } else {
      max = i+1;
      break;
    }
  }
  for (long i = 0; i < n; i++) {
    read = 0;
    time = sum_a[i];
    if (time > k) {
      break;
    }
    read = i+1;
    for (long j = cur; j >= 0; j--) {
      if (time+sum_b[j] > k) {
        cur = j;
      } else {
        read += j+1;
        break;
      }
    }
    if (read > max) {
      max = read;
    }
  }
  printf("%ld\n", max);

  return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n;
double dp[3001][3001], p[3000], ans;

int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> p[i];
	}
	dp[0][0] = 1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp[i][j] += dp[i-1][j]*(1-p[i]);
			dp[i][j+1] += dp[i-1][j]*p[i];
		}	
	}
	for(int i=(n+1)/2;i<=n;i++){
		ans += dp[n][i];
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}

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

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int a[100];
    int count=n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        count+=(d-1)/a[i];
    }
    cout << count+x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    string s;
    cin >> s;
    int x = 0;
    for (char c : s) {
        x += c - '0';
        x %= 9;
    }
    cout << (x % 9 ? "No" : "Yes") << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    int res = 0;

    while (true)
    {
        bool exist_odd = false;
        REP(i, N) {
            if (A[i] % 2 == 1) exist_odd = true;
        }
        if (exist_odd) break;

        REP(i, N) {
            A[i] /= 2;
        }
        res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = [1]
    temp = 1
    while temp <= N:
        temp *= 6
        L.append(temp)
    temp = 1
    while temp <= N:
        temp *= 9
        L.append(temp)
    L.sort()
    D = [i for i in range(N+1)]
    for i in L[1:]:
        for j in range(i, N+1):
            D[j] = min(D[j], D[j-i]+1)
    print(D[N])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13360
import itertools
N, M = (int(i) for i in input().split())

l = [[0] * N for i in range(M)]

for x in range(M):
    s = [int(i) for i in input().split()]
    for ind in range(1, s[0]+1):
        l[x][s[ind]-1] = 1

p = [int(i) for i in input().split()]

res = 0
all = list( itertools.product([0,1], repeat=N))

for pos in all:
    f = True
    for dn in range(M):
        r = 0
        for mm in range(len(pos)):
            r += pos[mm] * l[dn][mm]
            r = r % 2
        if p[dn] != r:
            f = False
    if f :
        res += 1


#print(all)
print(res)
#print(l)


Measured memory_bytes: 41840
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void solve(void)
{
  string str;cin>>str;
  stack<char> st;
  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] == 'B')
    {
      if(st.empty())continue;
      else st.pop();
    }
    else
    {
      st.push(str[i]);
    }
    
  }
  string res = "";
  while(!st.empty())
  {
    res += st.top();
    st.pop();
  }
  reverse(ALL(res));
  cout<<res<<endl;
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main(){
    ll h;
    cin>>h;
    ll ans=0;
    ll res=1;
    while(h>0){
        ans+=res;
        res*=2;
        h>>=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
   int n,i;
   scanf("%d",&n);
   char a[100];
   getchar();
   gets(a);
   int b=strlen(a);
   if(n>=b)   puts(a);
   else
   {
      for(i=0;i<n;i++)
      {
          printf("%c",a[i]);
      }
      printf("...");
   }
}


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

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

	char now=s[0];
	int ans=1;
	for(int i=1;i<n;i++){
		if(now!=s[i]){
			now=s[i];
			ans++;
		}
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

int n, w;
int W[100];
int V[100];
int dp[100001];

int main(){
  int i, j, r;
  scanf("%d%d", &n, &w);
  for(i=0;i<n;i++) scanf("%d%d", W+i, V+i);
  for(j=1;j<=100000;j++) dp[j] = -1;
  for(i=0;i<n;i++){
    for(j=100000;j>=V[i];j--)
      if(dp[j-V[i]] >= 0) dp[j] = MIN((unsigned) dp[j], (unsigned) (dp[j-V[i]]+W[i]));
  }
  r = 0;
  for(j=0;j<=100000;j++) if(dp[j] >= 0 && dp[j] <= w) r = j;
  printf("%d\n", r);
  return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Dominating Set
public class Main{

	int n, m, res, INF = 1<<29;
	List<Integer>[] adj;
	int[] cover;
	boolean[] special;
	
	void f(int k, int num){
		if(res <= num)return;
		if(k==n){
			boolean ok = true;
			for(int i=0;i<n&&ok;i++)ok&=cover[i]!=0;
			if(ok)res = Math.min(res, num);
			return;
		}
		if(special[k]){
			f(k+1, num); return;
		}
		for(int i=0;i<k;i++)if(cover[i]==0){
			boolean e = false;
			for(int x:adj[i])if(k<=x){
				e = true; break;
			}
			if(!e)return;
		}
		if(cover[k]==0 || n/5 <= adj[k].size()){
			cover[k]++;
			for(int x:adj[k])cover[x]++;
			f(k+1, num+1);
			cover[k]--;
			for(int x:adj[k])cover[x]--;
			f(k+1, num);
		}
		else{
			f(k+1, num);
			cover[k]++;
			for(int x:adj[k])cover[x]++;
			f(k+1, num+1);
			cover[k]--;
			for(int x:adj[k])cover[x]--;
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt(); m = sc.nextInt();
			if((n|m)==0)break;
			adj = new List[n];
			for(int i=0;i<n;i++)adj[i]=new ArrayList<Integer>();
			while(m--!=0){
				int s = sc.nextInt(), t = sc.nextInt();
				adj[s].add(t); adj[t].add(s);
			}
			cover = new int[n];
			special = new boolean[n];
			res = INF;
			int c = 0;
			for(int i=0;i<n;i++){
				if(adj[i].isEmpty()){
					c++;
					cover[i]++;
					special[i] = true;
					continue;
				}
				boolean f = false;
				for(int x:adj[i])if(adj[x].size()==1 && !special[x]){
					f = true; break;
				}
				if(f){
					c++;
					special[i] = true;
					cover[i]++;
					for(int x:adj[i])cover[x]++;
				}
			}
			f(0, c);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int gcd(int a,int b){

    if(b==0) return a;

    return gcd(b,a%b);
}

int main(){
    while(true){
        int a,b;
        cin>>a>>b;

        if(cin.eof()) break;

        int g =gcd(a,b);
        cout<<g<<' '<<a/g*b<<endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
typedef pair<int,pii>piii;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)
///#include<sstream>
///#include<cstring>
///#include<stack>
///#include<complex>

const int dy[6]={-1,-1,0,0,1,1};
const int dx[][6]={{-1,0,-1,1,-1,0},{0,1,-1,1,0,1}};
const int INF=1e9;
int W,H;
int s,t;
int x[10],y[10];
int p[10],q[10];
int nearest[10000];
vector<int>G[10000];
void getNearest(){
    fill_n(nearest,H*W,INF);
    queue<int>Q;
    rep(i,s){
        Q.push(y[i]*W+x[i]);
        nearest[y[i]*W+x[i]]=0;
    }

    while(!Q.empty()){
        int pos=Q.front();Q.pop();
        rep(i,G[pos].size()){
            int to=G[pos][i];
            if(nearest[to]!=INF)continue;
            nearest[to]=nearest[pos]+1;
            Q.push(to);
        }
    }
}


int solve(int start){
    int dist[10000];
    queue<int>Q;
    Q.push(q[start]*W+p[start]);
    fill_n(dist,H*W,INF);
    dist[q[start]*W+p[start]]=0;
    int ret=0;
    while(!Q.empty()){
        int pos=Q.front();Q.pop();
        rep(i,G[pos].size()){
            int to=G[pos][i];
            if(dist[to]!=INF)continue;
            dist[to]=dist[pos]+1;
            Q.push(to);
        }
    }

    rep(i,H*W)if(nearest[i]>dist[i])ret++;


    return ret;
}
int main(){
    while(scanf("%d%d",&W,&H),W||H){
        scanf("%d",&s);
        rep(i,s){
            scanf("%d%d",&x[i],&y[i]);
            x[i]--;y[i]--;
        }
        scanf("%d",&t);
        rep(i,t){
            scanf("%d%d",&p[i],&q[i]);
            p[i]--;q[i]--;
        }
        rep(i,10000)G[i].clear();

        rep(i,H)rep(j,W){
            rep(k,6){
                int ty=i+dy[k],tx=j+dx[i&1][k];
                if(ty<0||ty>=H||tx<0||tx>=W)continue;
                G[i*W+j].pb(ty*W+tx);
            }
        }
        getNearest();

        int ma=0;

        rep(i,t)ma=max(ma,solve(i));

        printf("%d\n",ma);
    }
    return 0;
}

Measured memory_bytes: 1588
using System;
using System.Collections.Generic;

namespace ABC138_C
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();

            List<double> list = new List<double>();
            double ans = 0;
            for (int i = 0; i < n; i++) {
                list.Add(double.Parse(input[i]));
                //Console.WriteLine(list[i]);
            }
            list.Sort();

            for (int i = 0; i < n - 1; i++) {
                //Console.WriteLine(list[0] + " " + list[1] + " " + list[2]);
                double keisan = (list[i] + list[i + 1]) / 2;
                ans = keisan;
                list[i + 1] = keisan; 
                list.Sort();

                
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

int n, A[MX];
pii B[MX];
int ans;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i], B[i]={A[i], i};
    sort(B+1, B+n+1);
    for(int i=1; i<=n; i++)
        ans+=(B[i].second%2!=i%2);
    cout<<ans/2;

    return 0;
}

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

int main(){
  int n;cin>>n;
  if(n==1){
    cout << "Hello World"<<endl;
  }else{
    int a,b;cin>>a>>b;
    cout << a+b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    int a,b;
    int data[100000];
    scanf("%d",&a);
    scanf("%d",&b);
    while(a != 0 || b != 0){
        for(int i=0;i<a;i++){
            scanf("%d",&data[i]);
        }
        int max=-10000000;
        int s=0;
        for(int i=0;i<a-b+1;i++){
            s=0;
            for(int j=i;j<b+i;j++){
                s+=data[j];
            }
            if(s>=max){
                max=s;
            }
        }
        printf("%d\n",max);
        scanf("%d",&a);
        scanf("%d",&b);
    }
}
    


Measured memory_bytes: 3588
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter<< endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var s = Console.ReadLine();
        s = string.Join("", s.Distinct().OrderBy(f => f));
        Console.WriteLine(s == "EW" || s == "NS" || s == "ENSW" ? "Yes" : "No");
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main(){
   
    int a, b;
    cin >> a >> b;
    double ans1=0.08;
    double ans2= 0.1;
    for(int i=0;i<=10000;i++){
        if(int(i*ans1)==a && int(i*ans2)==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

// 1テヲツ鳴?・ツュツ耀plit ティツヲツ《stream
vector<string> split(const string &str, char delim) {
	istringstream iss(str); string tmp; vector<string> res;
	while(getline(iss, tmp, delim)) res.push_back(tmp);
	return res;
}

int main(void) {
	string s;
	getline(cin, s);

	vector<string> ws = split(s, ' ');
	string max_len;
	
	map<string, int> ws_cnt;

	for (auto w : ws) {
		ws_cnt[w] = 0;
	}

	for (auto w : ws) {
		ws_cnt[w]++;
		if (max_len.size() < w.size()) {
			max_len = w;
		}
	}

	string max_cnt_str;
	int max_cnt = 0;
	for (auto m : ws_cnt) {
		if (max_cnt < m.second) {
			max_cnt = m.second;
			max_cnt_str = m.first;
		}
	}

	cout << max_cnt_str << " " << max_len << endl;
	
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int sum=0,k,i=0;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		sum+=s[i]-'0' ;
	}
	if(sum%9==0)
		cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
		

}


Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int A,B,C,D,E,F;
int main()
{
    while(~scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F)){
        bool flag=0;
        int w,s;
        double _max=0.0;
        for(int i=0;i*100*A<=F;i++){
            for(int j=0;i*100*A+j*100*B<=F;j++){
                if(!i&&!j) continue;
                for(int k=0;i*100*A+j*100*B+k*C<=F&&(k*C)*100<=E*(i*100*A+j*100*B);k++){
                    for(int l=0;i*100*A+j*100*B+k*C+l*D<=F&&(k*C+l*D)*100<=E*(i*100*A+j*100*B);l++){
                        double p=(k*C+l*D)*100.0/(i*100.0*A+j*100.0*B+k*C+l*D);
                        if(p>=_max){w=i*100.0*A+j*100*B;s=k*C+l*D;_max=p;}
                    }
                    if(flag) break;
                }
                if(flag) break;
            }
            if(flag) break;
        }
        printf("%d %d\n",w+s,s);



    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

manzoku = sum(B)

for x in range(N - 1):
  if A[x] + 1 == A[x + 1]:
    manzoku += C[A[x] - 1] 

print(manzoku)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

//===
template<typename Monoid>
struct SegmentTree {
    using OP = function<Monoid(Monoid, Monoid)>;
    
    vector<Monoid> tree;
    int size;
    const OP f; // bin' operation
    const Monoid e; // neutral element
    
    SegmentTree(int nmemb, const Monoid &e, const OP &f):
        f(f),
        e(e)
    {
        size = 1;
        while (size < nmemb) {
            size *= 2;
        }

        tree.assign(2 * size - 1, e);
    }

    void update(int k, Monoid dat)
    {
        k += size - 1;
        tree[k] = dat;
        
        while(k > 0) {
            k = (k - 1) / 2;
            tree[k] = f(tree[2 * k + 1], tree[2 * k + 2]);
        }
    }

    // [l, r)
    Monoid query(int l, int r)
    {
        l += size - 1;
        r += size - 1;

        Monoid d = e;
        while (l < r) {
            if (l % 2 == 0) {
                d = f(d, tree[l]);
                l++;
            }
            if (r % 2 == 0) {
                r--;
                d = f(d, tree[r]);
            }

            l = (l - 1) / 2;
            r = (r - 1) / 2;
        }

        return d;
    }

};
//===

struct Query { ll d, t, x; };
struct Team  { ll id, p;   };

ll point[100005];
ll t[100005];
ll n, r, l;
Query q[1000005];

int main()
{
    scanf("%lld %lld %lld", &n, &r, &l);

    q[0].d = 0, q[0].t = 0, q[0].x = 0;
    for (int i = 1; i <= r; i++) {
        scanf("%lld %lld %lld", &q[i].d, &q[i].t, &q[i].x);
    }
    q[r + 1].d = 0, q[r + 1].t = l, q[r + 1].x = 0;

    SegmentTree<Team> seg(n + 1, (struct Team){0, 0},
                          [](Team x, Team y) {
                              if (x.p > y.p) {
                                  return x;
                              }
                              else if (x.p == y.p) {
                                  if (x.id < y.id) {
                                      return x;
                                  }
                              }
                              return y;
                          });

    for (int i = 1; i <= n; i++) {
        seg.update(i, (struct Team){i, 0});
    }

    for (int i = 1; i <= r + 1; i++) {
        Team x = seg.query(1, n + 1);
        t[x.id] += q[i].t - q[i - 1].t;


        point[q[i].d] += q[i].x;
        seg.update(q[i].d, (struct Team){q[i].d, point[q[i].d]});
        
        //        printf("%lld %lld\n", x.id, x.p);
    }

    t[0] = -1;
    int mpos = 0;
    for (int i = 1; i <= n; i++) {
        if (t[mpos] < t[i]) {
            mpos = i;
        }
        //        printf("%lld\n", t[i]);
    }

    printf("%d\n", mpos);
    
    return 0;
}



Measured memory_bytes: 22176
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R+1):
    zan=N-R*i
    if zan==0:
        ans+=1
        continue
    for j in range(N//G+1):
        zan2=zan-G*j
        if zan2<0:
            break
        if zan2%B==0:
            ans+=1
print(ans)

Measured memory_bytes: 40556