akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;



int main(void){
	ll a,b,c,d;
	char test[4];
	scanf("%s",test);
	a=test[0]-'0';
	b=test[1]-'0';
	c=test[2]-'0';
	d=test[3]-'0';
	if(a==b){
		if(b==c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		if(b==c&&c==d){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
'''input
1000 1234000
'''
import sys
n,y = map(int,raw_input().split())
for i in range(2001):
	for j in range(2001):
		if i+j > n:
			continue
		z = i*(10**4)+j*(5000)+(n-i-j)*(1000)
		if z == y:
			print i,j,n-i-j
			sys.exit(0)
print "-1 -1 -1"

Measured memory_bytes: 30956
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = float("inf")
for i in range(n-k+1):
    res = x[i+k-1] - x[i] + min(abs(x[i+k-1]), abs(x[i]))
    ans = min(ans, res)

print(ans)


Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	string s_input, s1 = {}, s2 = {}; 
	cin >> s_input;
	for(int i = 0; i < s_input.size(); i++){
		if(i%2 == 0){
			s1 += '1';
			s2 += '0';
		}else if(i%2 == 1){
			s1 += '0';
			s2 += '1';
		}
	}
	int ans = 0, temp_ans1 = 0, temp_ans2 = 0;
	for(int i = 0; i < s_input.size(); i++){
		if(s_input[i] != s1[i])temp_ans1 += 1;
		if(s_input[i] != s2[i])temp_ans2 += 1;
	}
	ans = min(temp_ans1, temp_ans2);
	cout << ans << endl;
}



Measured memory_bytes: 768
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt();
        double d = readLong();
        d *= d;
        int c = 0;
        for (int i = 0; i < n; i++) {
            double x = readLong(), y = readLong();
            x *= x;
            y *= y;
            if (x + y <= d) c++;
        }

        System.out.print(c);
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 50964
#include <iostream>
#include <string.h>

long long int mod = 1e9 + 7;

int main()
{
    int n, m;
    std::cin >> n >> m;

    char a[1010][1010];
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            std::cin >> a[i][j];


    long long int dp[1010][1010] = { 0 };
    dp[1][1] = 1;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            if (i == 1 && j == 1)
                continue;
            if (a[i][j] == '.')
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }

    std::cout << dp[n][m];
}


Measured memory_bytes: 9216
#include <cstdio>

const int MAX_N = 1000000;
long N;

int main()
{
	scanf("%ld", &N);
	long long sum = 0;

	for(long i = 1; i <= N; i++) {
		bool fizz = ((i % 3) == 0);
		bool buzz = ((i % 5) == 0);
		if(fizz || buzz) {
			continue;
		} else {
			// printf("i=%d\n", i);
			sum += i;
		}
	}
	printf("%lld", sum);

	return 0;
}

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

const int INF = 1 << 28;

int main() {
    int N, sum = 0; cin >> N;
    vector<int> T(N);
    for (auto &i : T) cin >> i, sum += i;

    vector<vector<vector<int>>> dp(51, vector<vector<int>>(1000, vector<int>(1000, INF)));
    dp[0][0][0] = 0;

    int res = INF;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 1000; j++) {
            for (int k = 0; k < 1000; k++) {
                if (!dp[i][j][k]) {
                    if (j + T[i] < 1000) dp[i+1][j + T[i]][k] = 0;
                    if (k + T[i] < 1000) dp[i+1][j][k + T[i]] = 0;
                    res = min(res, max(j + T[i], max(k, sum - (j + k + T[i]))));
                    res = min(res, max(j, max(k + T[i], sum - (j + k + T[i]))));
                    dp[i+1][j][k] = 0;
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 208000
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while(cin>>n,n) {
    int M = 256;
    int I[n]; FOR(i,0,n) cin >> I[i];
    int ans[3];
    double mn = 1e18;
    FOR(S,0,16) {
      FOR(A,0,16) {
        FOR(C,0,16) {
          int R[n+1];
          R[0] = S;
          FOR(i,1,n+1) R[i] = (A * R[i-1] + C) % M;
          int O[n];
          FOR(i,0,n) O[i] = (I[i] + R[i+1]) % M;
          double H = 0;
          int num[300]; CLR(num);
          FOR(i,0,n) num[O[i]]++;
          FOR(i,0,300) {
            if(num[i] == 0) continue;
            H += num[i] * log((double)num[i] / n);
          }
          H = -H;
          if(H + 1e-9 < mn) {
            ans[0] = S;
            ans[1] = A;
            ans[2] = C;
            mn = H;
          }
        }
      }
    }
    FOR(i,0,3) {
      if(i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
 
int main()
{
  int N;
  vector<int> a(100001), b(100001);
  cin >> N;
  rep(i,N){cin >> a.at(i);}
  b.at(0)=a.at(0);
  rep(j,N)
  {
    if(j>0)
    {
      b.at(j)=a.at(b.at(j-1)-1);
    }
    if(b.at(j)==2)
    {
      cout << j+1 << endl;
      return 0;
    }
  }
  rep(i,N)
  {
    if((b.at(N)-1)!=2)
    {
      cout << -1 << endl;
      break;
    }
  }
}

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

int main() {
    char num;
    for (int i = 0; i < 3; i++) {
        cin >> num;
        if (num == '1') {
            cout << '9';
        } else {
            cout << '1';
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, S: str, K: int):
    kth = S[K-1]
    s = list(S)
    for i in range(N):
        if s[i] != kth:
            s[i] = "*"
    print("".join(s))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(N, S, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;


public class Main{
    static long MOD = 998244353L;
    static long [] fac;
    static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    static long lMax = 0x3f3f3f3f3f3f3f3fL;
    static int iMax = 0x3f3f3f3f;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            n = n % 10;
            if(n == 3)
                out.println("bon");
            else if(n < 2 || n == 6 || n == 8)
                out.println("pon");
            else out.println("hon");
        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long gcd(long a, long b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 32768
import java.util.*;

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 = sc.nextInt();
		int mem = 0 ;
		
		if (a>b) {
			mem = a;
			a = b;
			b = mem;
		}
		if (b>c) {
			mem = b;
			b = c;
			c = mem;
		}
		if (a>b) {
			mem = a;
			a = b;
			b = mem;
		}
		
		System.out.println(a + " " + b + " " + c);
	}

}


Measured memory_bytes: 26176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    int N;cin >> N;
    long long T;
    cin >> T;
    vector<long long> t(N);
    rep(i,N)cin >> t[i];
    long long ans = 0;
    long long sum = t[0]; //お湯が出ない時間の合計
    rep(i,N-1){
        if(t[i+1]-t[i] > T)sum += t[i+1]-t[i]-T;
    }
    ans = t[N-1] + T - sum;
    cout << ans << endl;
}

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

int main() {
  int r, D, x1, x;
  cin >> r >> D >> x1;
  REP(i,10) {
    x=r*x1-D;
    cout << x << endl;
    x1=x;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        h: [i64; n],
    }
    let mut h = h;
    h.push(1 << 40);
    let mut tbl = vec![0; n + 1];
    for i in (0..n).rev() {
        if h[i] < h[i + 1] {
            tbl[i] = 0;
        } else {
            tbl[i] = tbl[i + 1] + 1;
        }
    }
    puts!("{}\n", tbl.iter().max().unwrap());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 5001;

pair<int, int> get(int x) {
	int f = -1, l = -1;
	while (x) {
		if (f == -1) f = x % 10;
		l = x % 10;
		x /= 10;
	}
	return { f, l };
}

void solve() {
	int n;
	cin >> n;
	map<pair<int, int>, int> mp;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		mp[get(i)]++;
	}

	for (auto& p : mp) {
		auto pp = p.first;
		if (pp.first == pp.second) ans += p.second * p.second;
		else ans += p.second * mp[{pp.second, pp.first}];
	}
	cout << ans;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	solve();
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

vector<int> z_algorithm(string s){
    vector<int> z(s.size());
    z[0] = s.size();

    int i = 1, j = 0;
    while(i < (int)s.size()){
        while(i + j < (int)s.size() && s[j] == s[i+j]){
            j++;
        }
        z[i] = j;

        if(j == 0){
            i++;
            continue;
        }

        int k = 1;
        while(i + k < (int)s.size() && k + z[k] < j){
            z[i+k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return z;
}

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

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    rep(i, n){
        string t = s.substr(i, n - i);
        auto za = z_algorithm(t);

        for(int j = 1; j < n - i; j++){
            ans = max(ans, min(za[j], j));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    int* p;
    NEW(p,N);
    for(int i=0;i<N;i++){
        scanf("%d",&p[i]);
    }

    int ans=0;
    for(int i=0;i<N;i++){
        if(p[i]-1==i){
            ans++;
            if(i==N-1) SWAP(int, p[i],p[i-1]);
            else SWAP(int, p[i],p[i+1]);
        }
    }
    printf("%d\n",ans);

    return 0;
}

//そうすれば最適にswapできるかという規則をコードを書くまえに見つけ出せるかどうか次第

Measured memory_bytes: 512
def upper_or_lower(i):
    if A[i] < A[i + 1]:
        return "upper"
    elif A[i] > A[i + 1]:
        return "lower"
    else:
        return upper_or_lower(i + 1)


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

state = "upper"  # state が upper か lower で判定
ans = 1

# i = 0 の処理
if (len(A) > 2) and (A[0] > A[1]):
    state = "lower"

for i in range(2, N):
    if (state == "upper") and (A[i - 1] > A[i]):
        ans += 1
        if i < N - 1:
            state = upper_or_lower(i)
    elif (state == "lower") and (A[i - 1] < A[i]):
        ans += 1
        if i < N - 1:
            state = upper_or_lower(i)
    else:
        continue

print(ans)


Measured memory_bytes: 14428
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct event{
  int c; //イベントの種類1: 通行止め終了 2:通行止め開始 3:人がいる
  int t; //時間 人なら歩き出す時間
  int d; //通行止めの位置 or 人の番号

  bool operator<(const event &r) const {
    return t==r.t ? c<r.c : t<r.t;
  }
};
vector<event> v;
set<int> stop;

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

  int s, t, x, d;
  REP(i, n){
    cin>>s>>t>>x;
    s=2*s-1;
    t=2*t-1;
    event temp;
    temp.c=2;
    temp.t=s-2*x;
    temp.d=x;
    v.push_back(temp);
    temp.c=1;
    temp.t=t-2*x;
    v.push_back(temp);

  }
  REP(i, q){
    cin>>d;
    d*=2;
    event temp;
    temp.c=3;
    temp.t=d;
    temp.d=i;
    v.push_back(temp);
  }
  sort(v.begin(), v.end());
  int ans[q];

  for(int i=0; i<2*n+q; ++i){
    //cout<<v[i].c<<" "<<v[i].t<<" "<<v[i].d<<endl;
    if(v[i].c==2) stop.insert(v[i].d);
    else if(v[i].c==1) stop.erase(v[i].d);
    else{
      if(stop.empty()){
        ans[v[i].d]=-1;
      }
      else{
        auto out = stop.begin();
        ans[v[i].d] = *out;
      }
    }
  }

  REP(i, q){
    cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 19816
#include<stdio.h>
int main(void)
{
	int a,b,c,x=0,y=0,z=0;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b;
	y=b+c;
	z=a+c;
	if(x<=y && x<=z) printf("%d\n",x);
	else if(y<=x && y<=z) printf("%d\n",y);
	else if(z<=x && z<=y) printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
string s,t;
ll ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s;
	s+="***";
	for(int i=0;i<s.size();i++)if(s[i]=='?')s[i]='D';
	for(int i=0;i<s.size();i++){
		if(s[i]=='*')break;
		t+=s[i];
	}
	cout<<t;
//	for(int i=0;i<s.size();i++){
//		if(s[i]=='D')ans++;
//		else if(s[i+1]=='D')ans++;
//	}
	return 0;
}



Measured memory_bytes: 3812
#include <stdio.h>
int main(void) {
	long long h, count = 0;
	scanf("%lld", &h);
	while (h != 0) {
		h /= 2;
		count++;
	}
	long long binary = 1;
	for (int i = 0; i < count; i++)
		binary *= 2;
	printf("%lld\n", binary - 1);
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    t = input().strip()
    ans = []
    for i in range(len(s) - len(t) + 1):
        ok = True
        # print(s[i:i+len(t)])
        for j in range(len(t)):
            if s[i+j] == t[j] or s[i+j] == "?":
                pass
            else:
                ok = False
                break
        if ok:
            ans.append((s[:i] + t + s[i+len(t):]).replace("?", "a"))
    if len(ans) > 0:
        print(min(ans))
    else:
        print("UNRESTORABLE")



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <cstdio>

int n, m, q;
int tuple[50][4];
int array[10];

int dfs(int index, int last)
{
	if (index >= 0)
	{
		array[index] = last;

		if (index == n - 1)
		{
			int r = 0;
			for (int i = 0; i < q; ++i)
			{
				if (array[tuple[i][1] - 1] - array[tuple[i][0] - 1] == tuple[i][2])
				{
					r += tuple[i][3];
				}
			}
			return r;
		}
	}

	int r = 0;
	for (int i = last; i <= m; ++i)
	{
		int v = dfs(index + 1, i);
		if (v > r)
		{
			r = v;
		}
	}
	return r;
}

int main()
{
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < q; ++i)
	{
		scanf("%d%d%d%d", tuple[i], tuple[i] + 1, tuple[i] + 2, tuple[i] + 3);
	}
	int ans = dfs(-1, 1);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1696
using System;
using System.Collections.Generic;
using System.Linq;
class a{
  public static void Main(){
    int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    int h1 = num[0];
    int m1 = num[1];
    int h2 = num[2];
    int m2 = num[3];
    int k = num[4];
    int ans = (h2-h1)*60 + (m2-m1) - k;
    if(ans < 0){
      ans = 0;
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 19000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
vector<ii> range;
vector<int> len;
vector<ll> val;
int n, k;

const ll MOD = 1e9 + 7;

ll bnd(vector<ll> &v, vector<ll> &psum, int len) {
    int lo = 0, hi = range.size() - 1;
    while(lo < hi) {
        int mi = (lo + hi + 1)/2;
        if(len >= range[mi].first)
            lo = mi;
        else
            hi = mi - 1;
    }
    //cout << range[lo].first << " <= " << len << " <= " << range[lo].second << endl;
    ll ans = (lo ? psum[lo - 1] : 0), ct = (len - range[lo].first + 1);
    //cout << ans << endl;
    ct = (ct * v[lo])%MOD;
    return (ans + ct)%MOD;
}

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

    cin >> n >> k;
    int pos = 1;
    while(pos <= n) {
        int x = n / pos, y = n / x;
        range.push_back({pos, y});
        len.push_back(x);
        val.push_back(1);
        pos = y + 1;
    }
    //for(int i = 0; i < range.size(); i++)
    //    cout << "(" << range[i].first << ", " << range[i].second << ") " << len[i] << '\n';
    for(int i = 0; i < k - 1; i++) {
        vector<ll> cv = val;
        vector<ll> psum(cv);
        for(int j = 1; j < psum.size(); j++)
            psum[j] = (psum[j]*(range[j].second - range[j].first + 1) + psum[j - 1]) % MOD;
        for(int j = 0; j < val.size(); j++) {
            //cout << len[j] << " " << bnd(cv, psum, len[j]) << endl;
            val[j] = bnd(cv, psum, len[j]);
        }
    }
    ll ans = 0;
    for(int i = 0; i < range.size(); i++) {
        ll len = range[i].second - range[i].first + 1;
        ans = (ans + len * val[i]) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2800
#include<iostream>
#include<vector>
using namespace std;
/*
  親が子の和になる二分木

  最深部は1bit目が1、その上は1bit目0で2bit目が1...
  となる様にインデックス付け
*/


/*
  注意 : Index [1...n]
 */
typedef int BIT_T;
class BIT
{
private:
  vector<BIT_T> bit;
public:
  BIT(int n)
  {
    bit.resize(n+1,0);
  }
  
  //index 0 to i の和を返す
  BIT_T sum(int i)
  {
    BIT_T s=0;
    while(i>0){
      s+=bit[i];
      i-=i& (-i);//i& -i はiの最小1bit  <- 2^kを引く
    }
    return s;
  }
  
  //index i to j の和
  BIT_T sum(int i,int j)
  {
    return sum(j)-sum(i-1);
  }

  //index i に x をたす
  void add(int i,BIT_T x){
    while(i<=bit.size()){
      bit[i]+=x;
      i+=i& (-i);
    }
  }
};


int main()
{
  int n,q;
  cin>>n>>q;
  BIT bit(n);
  for(int i=0;i<q;i++)
    {
      int com,x,y;
      cin>>com>>x>>y;
      if(com)
	cout<<bit.sum(x,y)<<endl;
      else
	bit.add(x,y);
    }
  return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  vector<int> l(3);
  l[0]=a+b;l[1]=a-b;l[2]=a*b;
  sort(l.begin(),l.end());
  cout<<l[2]<<endl;
  return 0;
}

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

int main(){
    string s;
    int a=0;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s.at(i)=='o'){
            a++;
        }
    }
    cout<<700+100*a;
    return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var s = ReadLine();
            var (x, y) = Slice2<long>();
            var xyF = Enumerable.Repeat(0, 2).Select(_ => new List<long>()).ToArray();
            for (int i = 0, j = 0; i < s.Length; ++i, ++j)
            {
                var cnt = 0;
                while (i < s.Length && s[i] != 'T')
                {
                    ++cnt;
                    ++i;
                }
                xyF[j % 2].Add(cnt);
            }
            var posXY = Enumerable.Repeat(0, 2).Select(_ => new HashSet<long>() { 0 }).ToArray();
            if (s[0] != 'T') { posXY[0].Remove(0); posXY[0].Add(xyF[0][0]); xyF[0][0] = 0; }
            for (var i = 0; i < 2; ++i)
            {
                foreach (var d in xyF[i])
                {
                    var pos = new HashSet<long>();
                    foreach (var p in posXY[i])
                    {
                        pos.Add(p + d);
                        pos.Add(p - d);
                    }
                    posXY[i] = pos;
                }
            }
            if (posXY[0].Contains(x) && posXY[1].Contains(y))
                WriteLine("Yes");
            else
                WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

int main() {
	int h,w,a,b;
	cin>>h>>w;
	vector<vector<string>>s(h,vector<string>(w));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s.at(i).at(j);
			if(s.at(i).at(j)=="snuke"){
				a=j;
				b=i+1;
			}
		}
	}
	char c=65+a;
	cout<<c<<b<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int c[3][3];

    rep(i,3){
        rep(j,3) {
            cin >> c[i][j];
        }
    }
    string ans = "Yes";
    int b[3]={c[0][0],c[0][1],c[0][2]};
    int a[3]={0};
    a[1] = c[1][2]-b[2];
    a[2] = c[2][2]-b[2];

    rep(i,3){
        rep(j,3) {
            if(a[i]+b[j] != c[i][j])
                ans = "No";
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  ll n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  ll t = 0;
  rep(i, m) t += b[i];
  ll ans = 0;
  ll j = m;
  rep(i, n + 1) {
    while (j > 0 && t > k) {
      j--;
      t -= b[j];
    }
    if (t > k) break;
    ans = max(ans, i + j);
    if (i == n) break;
    t += a[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4844
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,T=map(int,input().split())
    t=list(map(int,input().split()))
    ans=0
    tmp=0
    for x in t:
        if x>=tmp:
            ans+=T
        else:
            ans+=T-(tmp-x)
        tmp=x+T
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77936
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,h,w;
  cin >> n >> h >> w;
  n++;
  cout << (n-h)*(n-w) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string a, b, c;
  cin >> a >> b >> c;
  cout << "A" << b[0] << "C" << endl;
}
int main(void) { solve(); }

Measured memory_bytes: 3576
#include <stdio.h>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;
int main(){
  int N,K;
  vector<long long> h;
  cin>>N>>K;
  for(int i=0;i<N;++i){
    long long tmp; 
    cin>>tmp;
    h.push_back(tmp);
  }
  sort(h.begin(),h.end());
  auto endi =h.end()-(K-1);
  long long min=LLONG_MAX;
  for(auto itr=h.begin();itr!=endi;++itr){
    long long dif=*(itr+(K-1))-*itr;
    if(min>dif)min=dif;
  }
  cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 1400
n, m, x, y = map(int, input().split())

xl = list(map(int, input().split()))
yl = list(map(int, input().split()))

for z in range(x + 1, y + 1):
  if max(xl) < z and min(yl) >= z:
    print("No War")
    break
else:
  print("War")

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int64 N;
  cin >> N;
  cout << 180*(N-2) << endl;
}


Measured memory_bytes: 892
import java.util.Arrays

const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toInt()}

    val cnt = Array(n, {0})
    for (i in a) {
        cnt[i]++
    }

    if (n%2 == 0) {
        for (i in 0..n-1) {
            if (i%2 == 0 && cnt[i] > 0) {
                println(0)
                return
            }
            if (i%2 == 1 && cnt[i] != 2) {
                println(0)
                return
            }
        }
    } else {
        if (cnt[0] != 1) {
            println(0)
            return
        }
        for (i in 1..n-1) {
            if (i%2 == 0 && cnt[i] != 2) {
                println(0)
                return
            }
            if (i%2 == 1 && cnt[i] > 0) {
                println(0)
                return
            }
        }
    }

    var ans = 1L
    for (i in 0..n/2-1) {
        ans = (ans * 2) % MOD
    }
    println(ans)
}


Measured memory_bytes: 49776
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

string s, t;
ii dp[3000][3000];

int f(int i, int j)
{
    if (i == s.size() || j == t.size()) return 0;
    if (dp[i][j].first != -1) return dp[i][j].first;
    ii bst = max(ii{f(i + 1, j), 0}, ii{f(i, j + 1), 1});
    if (s[i] == t[j])
        bst = max(bst, {1 + f(i + 1, j + 1), 2});
    return (dp[i][j] = bst).first;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    f(0, 0);
    int i = 0, j = 0;
    while (i != s.size() && j != t.size())
    {
        switch (dp[i][j].second)
        {
            case 0: ++i; break;
            case 1: ++j; break;
            case 2: cout << s[i]; ++i; ++j; break;
        }
    }
}


Measured memory_bytes: 71296
#include <iostream>

using namespace std;

int main(){
  int W, a, b;
  cin >> W >> a >> b;
  int ans;
  if(a+W < b){
    ans = b - (a+W);
  }else if( b + W < a ){
    ans = a - (b+W);
  }else{
    ans = 0;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll H;cin>>H;
  ll ans = 0;
  ll bi = 1;
  while(H>0){
    H = H >> 1;
    ans += bi;
    bi = bi << 1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,c,p,a,sum,i;
	scanf("%d %d",&n,&c);
	sum=0;
	for(i=1;i<=c;i++){
		scanf("%d",&p);
		sum=sum+p;
	}
	n=n+1;
	if(sum%n==0){
		printf("%d\n",sum/n);
	}
	else{
		printf("%d\n",sum/n+1);
	}
	return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();

            if(H==0 && W==0) break;

            for(int i=0;i<H;i++){
                if(i%2 == 0){
                    for(int j=0;j<W;j++){
                        if(j%2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                    System.out.println("");
                }else{
                    for(int j=1;j<W+1;j++){
                        if(j%2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                    System.out.println("");
                }
            }
            System.out.println("");
        }
        sc.close();
    }
}


Measured memory_bytes: 33072
while True:
    n,k = map(int,input().split())
    if n==k==0:
        break
    a =[]
    for i in range(n):
        a.append(int(input()))
    ans = sum(a[0:k:])
    tmp = ans
    for i in range(n-k):
        tmp += a[k+i]
        tmp -= a[i]
        if ans < tmp:
            ans = tmp
    print(ans)


Measured memory_bytes: 9868
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int j =1, over = 1, bRank = 0, passed = 0;
        String s = sc.next();
        for(int i=0;i<s.length();i++) {
            int k = i+1;
            if (s.charAt(i) == 'a' && passed < (a+b)) {
                j = j+1;
                passed += 1;
                System.out.println("Yes");
            }
            else if (s.charAt(i) == 'b' && passed < (a+b) && (bRank) < b) {
                over = over +1;
                bRank += 1;
                passed += 1;
                System.out.println("Yes");
            }
            else if (s.charAt(i) == 'c') {
                System.out.println("No");
            }
            else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 36664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n+2),b(n+1);
    FOR(i,1,n+2) cin>>a[i];
    FOR(i,1,n+1) cin>>b[i];
    ll ans=0;
    FOR(i,1,n+1){
      if(b[i]>=a[i]){
        ans+=a[i];
        b[i]-=a[i];
        a[i]=0;
        //cout<<b[i]<<endl;
        ans+=min(b[i],a[i+1]);
        a[i+1]-=b[i];
        if(a[i+1]<0){
          a[i+1]=0;
        }
      }else{
        a[i]-=b[i];
        ans+=b[i];
      }
      //cout_vec(a);
    }
    cout<<ans<<endl;
}

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


int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();

  int dp[n][m];

  int D[n][m];

  if(s[0] == t[0])
  {
    dp[0][0] = 1;
  }
  else 
    {
      dp[0][0] = 0;
    }

  for (int i = 1; i < n; ++i)
  {
     if(s[i] == t[0])
     {
       D[i][0] = 2;
       dp[i][0] = 1;
     }
     else 
      {
        D[i][0] = 0;
        dp[i][0] = dp[i-1][0];
      }
  }
  


  for (int i = 1; i < m; ++i)
  {
     if(t[i] == s[0])
     {
       D[0][i] = 2;
       dp[0][i] = 1;
     }
     else 
      {
        D[0][i] = 1;
        dp[0][i] = dp[0][i-1];
      }
  }

  

  for (int i = 1; i < n; ++i)
  {
     for (int j = 1; j < m; ++j)
     {
        int A = dp[i-1][j];
        int B = dp[i][j-1];

        dp[i][j] = max(A, B);

        int d = -1;

        if(A > B) d = 0;
        else d = 1;

        int C;
        if(s[i] == t[j]) 
        {
           C = 1 + dp[i-1][j-1];
           dp[i][j] = max(dp[i][j], C);
           if(C > A && C > B) d = 2;
        }

        D[i][j] = d;
     }
  }

  
  int ans = -1;

  int  rm, cm;

  for (int i = 0; i < n; ++i)
  {
     for (int j = 0; j < m; ++j)
     {
       if(dp[i][j] >= ans)
       {
          ans = dp[i][j];
          rm = i;
          cm = j;
       }
     }
  }

  // cout << ans  << " " << rm <<  " " << cm <<  endl;;

  // cout << D[3][4] << endl;
  string str = "";

  while(1)
  {
    if(rm < 0 || cm < 0 ) break;
    if(rm == 0 && cm == 0)
    {
      if(s[rm] == t[cm]) str += s[rm];
      break;
    }
    if(D[rm][cm] == 0)
    {
       rm -= 1;
       continue;
    }

    if(D[rm][cm] == 1)
    {
      cm -= 1;
      continue;
    }

    if(D[rm][cm] == 2)
    {
      str += s[rm];
      rm -= 1;
      cm -= 1;
      continue;
    }
  }

  reverse(str.begin(), str.end());

  for (int i = 0; i < str.length(); ++i)
  {
     cout << str[i];
  }

 


  return 0;
}

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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007

//container-use 

typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< ll,ll > pll;
typedef vector<pair<ll,ll > > vpl;
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define rep(i,a,b) for (int i = a; i <= b; i++)

//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n,r;
    cin>>n>>r;
    if(n<10)
    {
        cout<<r+100*(10-n);
    }
    else
        cout<<r<<"\n";
  return 0;
 }

Measured memory_bytes: 256