akhauriyash/Code-Regression huggingface dataset:
def bellman_ford(edges, start, n):
    inf = float('INF')
    costs = [inf] * n
    # predecessors = [-1] * n
    costs[start]= 0

    for e in edges:
        u,v,c = e
        if costs[v] > costs[u] + c:
            costs[v] = costs[u] + c
            # predecessors[v] = u

    ans = costs[-1]
    for u,v,c in edges:
        if costs[v] > costs[u] + c:
            costs[v] = costs[u] + c

    return -ans if costs[-1] == ans else 'inf'

n,m = map(int, input().split())
edges = []
for _ in range(m):
    a,b,c = map(int, input().split())
    edges.append((a-1,b-1,-c))
print(bellman_ford(edges, 0, n))


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vvb table(n, vb(10, false));
    rep(i, n) {
        rep(j, 10) {
            Int(tmp);
            table[i][j] = tmp;
        }
    }
    vvi score(n, vi(11, 0));
    rep(i, n) {
        rep(j, 11) {
            cin >> score[i][j];
        }
    }

    int ans = -INF;
    Rep(i, 1 << 10) {
        vb yui(10, false);
        rep(j, 10) {
            yui[j] = (i & (1 << j));
        }
        int sum = 0;
        rep(j, n) {
            int cnt = 0;
            rep(k, 10) {
                cnt += (table[j][k] == yui[k] && table[j][k]);
            }
            sum += score[j][cnt];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<string>v;
    int count = 0;
    rep(i, 0, max(0, n-m+1)){
        string temp = s;
        bool a = true;
        rep(j, 0, m){
            if(i+j+1>n) break;
            if(temp[i+j] == '?' || temp[i+j] == t[j]){
                temp[i+j] = t[j];
            }else break;

            if(j == m-1){
                rep(k, 0, n){
                    if(temp[k] == '?')temp[k]='a';
                }
                v.push_back(temp);
            }
        }
    }
    if(v.size() == 0){
        cout << "UNRESTORABLE" <<endl;
        return 0;
    }
    sort(v.begin(), v.end());
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]

def make_sfp(N):
    F = [False] * (N + 1)
    P = [10 ** 7] * (N + 1)
    for i in range(2, N + 1):
        if F[i]:
            continue

        P[i] = i
        for j in range(i, N + 1, i):
            F[j] = True
            P[j] = min(P[j], i)
    return P


def dev_p(P, n):
    S = set()
    while n != 1:
        S.add(P[n])
        n //= P[n]
        
    return S


def main():
    N = int(input())
    A = read_list()
    D = dict()
    P = make_sfp(max(A))

    for a in A:
        S = dev_p(P, a)
        for s in S:
            D[s] = D.setdefault(s, 0) + 1
    
    is_pairwise = True
    for v in D.values():
        if v == N:
            print("not coprime")
            return
        elif v >= 2:
            is_pairwise = False
    
    print("pairwise coprime" if is_pairwise else "setwise coprime")
        

if __name__ == "__main__":
    main()



Measured memory_bytes: 202684
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
const int N=55556;
vector<int> isprime(N,1);
vector<int> prime;
void  solve(){
	rep(i,2,N){
		for(int j=2*i;j<N;j+=i) isprime[j]=0;
	}
	rep(i,2,N) if(isprime[i]) prime.pb(i);
	int n,i=0;
	cin>>n;
	while(n>0 && i<prime.size()){
		if(prime[i]%5==4) cout<<prime[i]<<" ",n--;
		i++;
	}
	cout<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3576
# https://atcoder.jp/contests/abc157/tasks/abc157_e
# セグメント木
# 各文字をビットに対応させる(セグ木を26本持っても良い)
import sys
read = sys.stdin.readline


def read_a_int():
    return int(read())


class SegmentTree:
    def __init__(self, ls: list, segfunc, identity_element):
        '''
        セグ木 (下書き)
        一次元のリストlsを受け取り初期化する。O(len(ls))
        区間のルールはsegfuncによって定義される
        identity elementは単位元。e.g., 最小値を求めたい→inf, 和→0, 積→1, gcd→0
        [単位元](https://ja.wikipedia.org/wiki/%E5%8D%98%E4%BD%8D%E5%85%83)
        '''
        self.ide = identity_element
        self.func = segfunc
        n = len(ls)
        self.num = 2 ** (n - 1).bit_length()  # n以上の最小の2のべき乗
        self.tree = [self.ide] * (2 * self.num - 1)  # −1はぴったりに作るためだけど気にしないでいい
        for i, l in enumerate(ls):  # 木の葉に代入
            self.tree[i + self.num - 1] = l
        for i in range(self.num - 2, -1, -1):  # 子を束ねて親を更新
            self.tree[i] = segfunc(self.tree[2 * i + 1], self.tree[2 * i + 2])

    def update(self, i, x):
        '''
        i番目の要素をxに変更する(木の中間ノードも更新する) O(logN)
        '''
        i += self.num - 1
        self.tree[i] = x
        while i:  # 木を更新
            i = (i - 1) // 2
            self.tree[i] = self.func(self.tree[i * 2 + 1],
                                     self.tree[i * 2 + 2])

    def query(self, l, r):
        '''
        区間[l,r)に対するクエリをO(logN)で処理する。例えばその区間の最小値、最大値、gcdなど
        '''
        if r <= l:
            return ValueError('invalid index (l,rがありえないよ)')
        l += self.num
        r += self.num
        res = self.ide
        while l<r:  # 右から寄りながら結果を結合していくイメージ
            if l & 1:
                res = self.func(res, self.tree[l-1])
                l+=1
            if r & 1:
                r -= 1
                res = self.func(res, self.tree[r-1])
            l >>=1
            r >>=1
        return res


def segfunc(x, y):
    # 処理したい内容
    return x | y


def moji_to_bit(a):
    return 1 << (ord(a) - ord('a'))


def bit_to_sum(n):
    return sum([(n >> i) & 1 for i in range(n.bit_length())])


N = read_a_int()
S = read()[:-1]
S_bit = [moji_to_bit(s) for s in S]

# build segment tree
st = SegmentTree(S_bit, segfunc, 0)

Q = read_a_int()
for q in range(Q):
    com, a, b = read().split()
    if int(com) == 1:
        i, c = int(a) - 1, b
        st.update(i, moji_to_bit(c))
    else:
        l, r = int(a) - 1, int(b)
        print(bit_to_sum(st.query(l, r)))


Measured memory_bytes: 48460
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val h = Array.fill(N)(sc.nextInt())

    // dp[i] := iの足場にたどり着くまでに支払うコストの総和の最小値
    val INF = Int.MaxValue
    val dp = Array.fill(N)(INF)
    dp(0) = 0
    for (i <- 0 until N - 1) {
      dp(i + 1) = dp(i + 1) min (dp(i) + (h(i) - h(i + 1)).abs)
      if (i < N - 2) {
        dp(i + 2) = dp(i + 2) min (dp(i) + (h(i) - h(i + 2)).abs)
      }
    }

    println(dp(N-1))
  }

}


Measured memory_bytes: 51888
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)




int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int need = 1, ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == need) {
			need++;
		}
		else {
			ans++;
		}
	}
	cout << (ans == n ? -1 : ans);
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i], --a[i];
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; i++)
        cnt[a[i]]++;
    int cur = 0;
    for (int i = 0; i < n; i++){
        if (cnt[i] != 0)
            ++cur;
    }
    int ans = 0;
    sort(cnt.begin(), cnt.end());
    for (int i = 0; i < n; i++) {
        if (cnt[i] != 0) {
           if (cur > k)
           {
               ans += cnt[i];
               cur--;
           } else break;
        }
    }
    cout << ans << "\n";
    

    return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public 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);
        AKCity solver = new AKCity();
        solver.solve(1, in, out);
        out.close();
    }

    static class AKCity {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.nextInt() - 1;
            int w = in.nextInt() - 1;
            out.print(h * w);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

        public void close() {
        }

    }
}



Measured memory_bytes: 21076
import java.util.*;

public class Main {
	static int N = 1000001;

	// array to store inverse of 1 to N
	static long[] factorialNumInverse = new long[N + 1];

	// array to precompute inverse of 1! to N!
	static long[] naturalNumInverse = new long[N + 1];

	// array to store factorial of first N numbers
	static long fact[] = new long[N + 1];

	// Function to precompute inverse of numbers
	static void InverseofNumber(long p) {
		naturalNumInverse[0] = naturalNumInverse[1] = 1;
		for (int i = 2; i <= N; i++)
			naturalNumInverse[i] = naturalNumInverse[(int) (p % i)] * (p - p / i) % p;
	}

	// Function to precompute inverse of factorials
	static void InverseofFactorial(long p) {
		factorialNumInverse[0] = factorialNumInverse[1] = 1;

		// precompute inverse of natural numbers
		for (int i = 2; i <= N; i++)
			factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
	}

	// Function to calculate factorial of 1 to N
	static void factorial(long p) {
		fact[0] = 1;

		// precompute factorials
		for (int i = 1; i <= N; i++) {
			fact[i] = (fact[i - 1] * i) % p;
		}
	}

	// Function to return nCr % p in O(1) time
	static long Binomial(int N, int R, long p) {
		// n C r = n!*inverse(r!)*inverse((n-r)!)
		long ans = ((fact[N] * factorialNumInverse[R]) % p * factorialNumInverse[N - R]) % p;
		return ans;
	}

	// Driver Code

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int m = (2 * x - y) / 3;
		int n = (2 * y - x) / 3;

		if ((2 * x - y) % 3 == 0 && (2 * y - x) % 3 == 0) {
			if (n == 0 || m == 0)
				System.out.println(1);
			else {
				long p = 1000000007;
				InverseofNumber(p);
				InverseofFactorial(p);
				factorial(p);
				long sum = 0;
				for (int i = 1; i <= Math.min(m + 1, n); i++) {
					sum += (Binomial(m + 1, i, p) * Binomial(n - 1, i - 1, p)) % p;
					sum %= p;

				}
				System.out.println(sum);
			}
		} else {
			System.out.println(0);
		}

	}

	public static int c(int n, int r) {
		return 1;
	}

}


Measured memory_bytes: 47444
#include <bits/stdc++.h>
using namespace std;
main(){
  int n;cin >> n;
  vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];
  int ans=0;
  for(int i=0;i<n;i++){
    if(i+1<n && a[i]==a[i+1]){
      while (i+1<n && a[i]==a[i+1]) i++;
    }
    
    if(i+1<n && a[i]<a[i+1]){
      while(i+1<n && a[i]<=a[i+1]) i++;
    } else {
      while(i+1<n && a[i]>=a[i+1]) i++;
    }
    ans++;
  }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 3748
#include <cstdio>

const int INF = 1000000002;

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

    int sum = -1;
    int low = INF;
    int high = 0;
    int more_low = INF;
    for (int i = 0; i < N; ++i)
    {
        int r;
        scanf("%d", &r);
        if (low <= high && r > high) {
            high = r;
        }
        if (r - more_low > sum) {
            low = more_low;
            high = r;
        }
        if (r < low) {
            if (low == INF)
                low = r;
            if (r < more_low)
                more_low = r;
        }
        sum = high - low;
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 1028
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		String s = sc.next();
		String t = sc.next();
		sc.close();
		int cnt=0;
		for (i = 0; i < n; i++) {
			if(s.substring(i).equals(t.substring(0, n-i))) {
				cnt=n-i;
				break;
			}
		}
		out.println(n * 2 - cnt);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MAX 110
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n,m,t,ans=0;
  int a[MAX];

  cin>>n>>m>>t;
  FOR(i,0,n)cin>>a[i];
  ans+=a[0]-m;
  FOR(i,1,n){
    if(2*m<=a[i]-a[i-1])ans+=(a[i]-a[i-1])-2*m;
  }
  ans+=max(t-a[n-1]-m,0);
  cout<<ans<<endl;
  return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    pair<int, pair<int, int>> boarder = make_pair(31, make_pair(5, 1));
    while(true){
        string S; cin >> S;
        if(S == "#") break;
        pair<int, pair<int, int>> op;
        int y, m, d; cin >> y >> m >> d;
        op = make_pair(y, make_pair(m, d));
        if(op < boarder) cout << S << " " << y << " " << m << " " << d << endl;
        else cout << "?" << " " << y-30 << " " << m << " " << d << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
N, M, X, Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
x.sort()
y.sort()

if x[N] < y[0]:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i).first;
    A.at(i).second=i+1;
  }
  sort(A.begin(),A.end());
  cout<<A.at(0).second;
  for(int i=1;i<N;i++)
    cout<<" "<<A.at(i).second;
  cout<<endl;
}

Measured memory_bytes: 1664
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
cnt = 0
p = 0
for i in range(n):
    cnt = 0
    tmp = s[i]
    for j in range(n):
        if s[j] == tmp:
            cnt += 1
    for k in range(m):
        if tmp == t[k]:
            cnt -= 1
    p = max(p,cnt)
print(p)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read();
signed main(){
	if(n%2==1){
		fz(i,1,m)	cout<<i<<" "<<2*m+1-i<<endl;
	}
	else{
		fz(i,1,m){
			if(i<=m/2)	cout<<i<<" "<<2*m+2-i<<endl;
			else		cout<<i<<" "<<2*m+1-i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n, m, d;
    cin >> n >> m >> d;

    double tmp = 2.0 * (n - d) / n / n;
    if (d == 0) tmp /= 2;
    cout << fixed << tmp * (m - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
//#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())

int32_t main()
{
    io
string s;
cin>>s;int n=s.length();
string p=s;
re(p);
if(p!=s)
{
  cout<<"No"<<endl;
}
else
{
  string r,t;
  r=s.substr(0,(n-1)/2);
  t=s.substr((n+3)/2-1,n-(n-1)/2);
  string x=r,y=t;
  re(r);
  re(t);
  if(r==x&&t==y)
  {
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

}

Measured memory_bytes: 3568
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;
char str[N][N];
int dx[] = { 1,1,1,-1,-1,-1,0,0 };
int dy[] = { -1,1,0,-1,1,0,-1,1 };
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> (str[i] + 1);
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (str[i][j] == '#') continue;
			int cnt = 0;
			for (int o = 0; o < 8; o++)
			{
				cnt += (str[i + dx[o]][j + dy[o]] == '#');
			}
			str[i][j] = cnt + '0';
		}
		cout << (str[i] + 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a_lst = set(int(input()) for i in range(m))
dp = [0]*(n+1)
dp[0] = 1
x = 10**9 + 7

for i in range(1,n+1):
    if i in a_lst:
        continue
    else:
        if i==1:
            dp[i] = dp[i-1]
        elif i>1:
            dp[i] = (dp[i-2] + dp[i-1]) % x

answer = dp[-1]

print(answer)

Measured memory_bytes: 58200
#include<iostream>
using namespace std;
typedef int integer;

integer dp[50];

int main() {
  int n;
  while (cin >> n and n) {
    for (int i = 0; i < 40; i++) {
      dp[i] = 0;
    }

    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
      dp[i] = dp[i+1] + dp[i+2] + dp[i+3];
    }
    cout << (dp[0] + 3649) / 3650 << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int n;
    cin >> n;
    vector <int> ar(n);
    for(auto &i : ar)
        cin >> i;
    int mn = tINF;
    int ans =0;
    for(int i = 0; i < n ; ++i){
        mn = min(ar[i],mn);
        if(ar[i] <= mn)
            ++ans;
    }
    cout << ans << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 1024
n, a, b = map(int, input().split())
s = input()
for i in range(n):
    if s[i] == "a" and 0 < a+b:
        print("Yes")
        a -= 1
    elif s[i] == "b" and 0 < b and 0 < a+b:
        print("Yes")
        b -= 1
    else:
        print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    if(s[k-1]=='A')
        s[k - 1] = 'a';
    if(s[k-1]=='B')
        s[k - 1] = 'b';
    if(s[k-1]=='C')
        s[k - 1] = 'c';
    cout << s << endl;

    return 0;
}

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

int main(){
  int N, K; cin >> N >> K;
  
  int counter = 0;
  int tmp = N;
  while (true){
    tmp /= K;
    counter++;
    if (tmp < K){
      if (N > K) counter++;
      break;
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if (a>=b){
        for (int i=0; i<a; i++){
            cout << b;
        }
    }
    else {
        for (int i=0; i<b; i++){
                cout << a;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

 

const int mod=1000000007;
//const int mod=998244353;
 

int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int t,m,k,q,x,a,b,c,d,w;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";
    
    return 0;
}


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

const int MOD = 1e9 + 7;

vector<long long> fact_inv, inv, Com;

/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}

/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}

int main() {
    long long n, k;
    cin >> n >> k;

    init_nCk(n - 1, 200000);

    int m = min(k, n - 1);
    int ans = 1;
    for (int i = 1; i < m + 1; i++) {
        ans += (nCk(i - 1) + nCk(i)) * nCk(n - i - 1) % MOD;
      	ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int pol[185];
vector<int> oddPol;
int minN[1000000];
int oddN[1000000];
int main(){
    for(int i=1;i<1000000;i++){
        minN[i]=5;
        oddN[i]=1000000;
    }
    for(int i=1;i<=180;i++){
        pol[i]=i*(i+1)*(i+2)/6;
        minN[pol[i]]=1;
        if(pol[i]%2==1){
            oddPol.push_back(pol[i]);
            oddN[pol[i]]=1;
        }
    }
    for(int i=1;i<1000000;i++){
        for(int j=1;pol[j]<=i && j<=180 && i+pol[j]<1000000;j++){
            minN[i+pol[j]]=min(minN[i+pol[j]],minN[i]+1);
        }
        for(int j=0;oddPol[j]<=i && j<oddPol.size() && i+oddPol[j]<1000000;j++){
            oddN[i+oddPol[j]]=min(oddN[i+oddPol[j]],oddN[i]+1);
        }
    }
    /*for(int i=1;i<=40;i++){
        cout<<i<<":"<<oddN[i]<<endl;
    }*/
    int n;
    while(cin>>n,n!=0){
        cout<<minN[n]<<" "<<oddN[n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 10952
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long dp[100005][3];
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    for (int i=1;i<=n;i++) {
        long long a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1]+b, dp[i-1][2]+c);
        dp[i][1]=max(dp[i-1][0]+a, dp[i-1][2]+c);
        dp[i][2]=max(dp[i-1][1]+b, dp[i-1][0]+a);
    }
    long long ans=max(dp[n][0], max(dp[n][1], dp[n][2]));
    cout<<ans<<'\n';
}


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

int main() {
	string s;
	int aaa;
	cin>>aaa;
	cin>>s;
	int bef[27],aft[27];
	int ans=0;
	for(int i=0;i<s.length()-1;i++){
	    for(int j=0;j<27;j++){
	        bef[j]=0;
	        aft[j]=0;
	    }
	    for(int cnt=0;cnt<=i;cnt++){
	        bef[s[cnt]-'a']++;
	    }
	    for(int cnt=s.length()-1;cnt>i;cnt--){
	        aft[s[cnt]-'a']++;
	    }
	    int hoge=0;
	    for(int j=0;j<27;j++){
	        if(aft[j]>0&&bef[j]>0)hoge++;
	    }
	    ans=max(ans,hoge);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define sz(s) (int) s.size()
#define pb push_back
#define rc(x) return cout<<x<<"\n",0

using namespace std;
    void solve()
    {
     long long a, b, c, k, ans = 0;
      cin >> a >> b >> c >> k;
      if (k <= a)
        cout << k;
      else
        if (a + b >= k)
        {
          if (k >= a) 
              cout << a;
            else
              cout << k;
        }
        else
          if ( a + b < k)
          {
            ans =  a;
            int dif = k - ( a + b);
            for (int i = 1; i <= dif; i++)
              ans = ans - 1;
            cout << ans;
          }
 }
               
    int main()
    {
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }
    }

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string.h>
#include <cstdlib>
using namespace std;

int top , S[1000];

void push(int x) {
	
top++;	S[top]=x;
}
int pop() {
	top--;
	return S[top + 1];
}
int main()
{
	int a, b;
	top = 0;
	char s[100];

	while (cin>>s) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);

		}
		else if(s[0]=='-'){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else push(atoi(s));
	}

	printf("%d\n", pop());



	return 0;
}


Measured memory_bytes: 3220
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#define ll long long
using namespace std;
int main()
{
    int n;
    set<int>s;
    cin>>n;
    for(int i = 0; i < n; i++){
        int t;
        cin>>t;
        s.insert(t);
    }
    int num = s.size();
    int more = n-num;
    int ans;
    if(more % 2 != 0)ans = num-1;
    else ans = num;
    cout<<ans;

    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()) {
    int c = (int)s[i] + n;
    if (c > (int)'Z') c -= 26;
    printf("%c", c);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3652
# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1216_arc087
# https://pitsbuffersolution.com/compro/atcoder/arc087d.php

# 最初の移動以外は、どんな操作手順後であっても、正負いずれの方向にも動けるのがミソ

def solve(s, x, y):
    X = 0
    Y = 1

    def update(move):
        st = set()
        for p in reachable[st_ind]:
            st.add(p + move)
            st.add(abs(p - move))
        reachable[st_ind] = st
        # 絶対値の等しい正負の値を取りうるので、正だけ扱う

    n = len(s)
    spl = map(len, s.split('T'))
    x -= next(spl)
    # ここでxを減らすと、
    # 個々のmove後のx,yは、原点対象になるので、正の座標の到達点だけ扱えばよくなる

    reachable = [{0}, {0}]
    st_ind = 1
    for move in spl:
        update(move)
        st_ind ^= 1

    return (abs(x) in reachable[X]) and (abs(y) in reachable[Y])
    # x,yが負であっても、それに対応した正の値が集合に含まれていれば、到達可能


if __name__ == '__main__':
    s = input()
    x, y = map(int, input().split())
    print('Yes' if solve(s, x, y) else 'No')


Measured memory_bytes: 47836
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;

  Yes(n%10==9||n/10==9);


}

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

namespace ALDS1_3
{
    class Program
    {
        static void Main(string[] args)
        {
            var stack = new Stack<int>();
            foreach (var op in Console.ReadLine().Split())
            {
                int num;
                if (int.TryParse(op, out num))
                {
                    stack.Push(num);
                }
                else
                {
                    stack.Push(Calc(op, stack.Pop(), stack.Pop()));
                }
            }

            Console.WriteLine(stack.Pop());
        }

        private static int Calc(string operat, int operand1, int operand2)
        {
            switch (operat)
            {
                case "+":
                    return operand2 + operand1;
                case "-":
                    return operand2 - operand1;
                case "*":
                    return operand2 * operand1;
                default:
                    throw new ArgumentException();
            }
        }

    }
}

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

int main()
{
	long long int X, Y;

	cin >> X >> Y;

	long long int a;

	a = X*(Y + 1);
	if (a%X == 0 && a%Y != 0 && a <= 1000000000000000000) {
		cout << a << endl;
		return 0;
	}

	a = X*(Y - 1);

	if (a%X == 0 && a%Y != 0 && a <= 1000000000000000000) {
		cout << a << endl;
		return 0;
	}
	cout << -1 << endl;

	return 0;
}

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

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

  if (n == m) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  long long cost = 1000000000;
  for (int ab = 0; ab <= 200000; ab += 2) {
    cost = min(cost, (ll)(c * ab) + (ll)(a * max(0ll, x - ab/2)) + (ll)(b * max(0ll, y - ab/2)));
  }
  cout << cost << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	string s,t,ans="";
	cin>>s>>t;
    ll n = s.length(), m = t.length();
    s = s[0] + s;
    t = t[0] + t;
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    /*
    State
    dp[i][j]: Denotes the length of the longest common subsequence of s[1...i] and t[1...j].
    Recurrence
    dp[i][j]: if s[i]==t[j], s[i],t[j] are the same and hence part of a common subssequence
    so dp[i][j] = dp[i-1][j-1] + 1
    else if s[i]!=t[j], we consider the length of the longest common subsequence obtained till now
    i.e dp[i][j] = max(dp[i-1][j],dp[i][j-1])
    */
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            if(s[i]==t[j])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll i = n, j = m;
    while(i && j){
        if(s[i]==t[j]){
            ans+=s[i];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans; 
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h> 
#define int long long
#define deb(x) cout<<#x <<" = "<<x<<"\n";
using namespace std; 

signed main() 
{
	
	int n, k; cin>>n>>k;
	double exp[n], p;
	for(int i=0; i<n; i++)
	{
		cin>>p;
		exp[i] = (p + 1.0)  / 2.0 ;
	}
	double ans = 0.0, sum = 0;
	for(int i=0; i<k; i++)
	{
		sum += exp[i];
	}
	ans = max(ans, sum);
	for(int i=k; i<n; i++)
	{
		sum += (exp[i] - exp[i-k]);
		ans = max(ans, sum);
	}
	cout<<fixed<<setprecision(9)<<ans<<"\n";
	
	
	
}


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

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

void solve() {                   
	int n, m;
	
	cin >> n >> m;
	
	if(n > 0){
		cout << "Positive";
		return;	
	}
	if(n <= 0 && m >= 0){
		cout << "Zero";
		return;
	}
 	if(n < 0 && m < 0){
 		if(n - m & 1){
 			cout << "Positive";
		 }
		 else{
		 	cout << "Negative";
		 }
	 }
	 else{
	 	cout << "Positive";
	 }

}    	

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
z['   '],i;main(j){for(;++i<2e3;)for(j=z[i>>5]&1<<i?1e7:-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;for(;~scanf("%d",&i);)for(j=i+1>>1;i;)z[--j>>5]&1<<j|z[j-1>>5]&1<<j-1|z[j-3>>5]&1<<j-3|z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);}

Measured memory_bytes: 1016
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


int main() {
    Int N;
    vi A,B;
    cin >> N;
    A = vi(N+1);
    B = vi(N);

    rep(i,N+1){
        cin>>A[i];
    }
    rep(i,N){
        cin>>B[i];
    }

    Int total = 0;

    rep(i,N){
        if(B[i]>A[i]){
            total+= A[i];
            B[i]=B[i]-A[i];
            A[i]=0;
        }else{
            total+= B[i];
            A[i] = A[i]-B[i];
            B[i]=0;
        }

        if(B[i]>A[i+1]){
            total+= A[i+1];
            B[i]=B[i]-A[i+1];
            A[i+1]=0;
        }else{
            total+= B[i];
            A[i+1] = A[i+1]-B[i];
            B[i]=0;
        }

    }

    cout << total << endl;

    return 0;
}

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

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

    vector<int> next(n);
    for(int i=0;i<n;i++){cin >> next[i]; next[i]--;}
    vector<int> array(n+1);
    array[0] = 0;
    for(int i=0;i<n;i++) array[i+1] = next[array[i]];

    int rest = 0;
    for(int i=0;i<n;i++){
        if(array[i]==array[n]){
            rest = i; break;
        }
    }
    int cir = n-rest;
    ll start = k-(n-1);
    if(k<n-1){cout << array[k]+1 << endl; return 0;}
    ll point = start%cir;
    
    if(rest+point-1>=0) cout << array[rest+point-1]+1 << endl;
    else cout << array[n-1]+1 << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
int _I(){ int x ; scanf("%d", &x); return x; }
void solve()
{
    int n = _I();
    int k = _I();
    if( k == 1 )
    {
        printf("0\n");
        return;
    }
    printf("%d\n", n-k );
}
int main()
{
    solve();
    return 0;
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;


void autoinput()
{
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
}

#define ll long long
#define scan(x) scanf("%lld ",&x)
#define pb push_back
#define mp make_pair
#define make_edge(xx,yy) v[xx].pb(yy);v[yy].pb(xx)
#define dbg(a) cout << #a << ": " << a << endl
#define debug(a) dbg(a)
#define pp(a,b) push_back(make_pair(a,b))
#define ff first
#define ss second
#define tff get<0>
#define tss get<1>
#define ttt get<2>
#define mt make_tuple
#define eps 0.0000001
#define sz size()
ll MOD = 1000000007;
ll mod = 1000000007;
long double gammay = 0.5772156649015328606065120;

// tff(name) for tuple //


//PBDS
/*
tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> Data[40];
*/



/*
ordered_set X;
    X.insert(1);
    X.insert(2);
    X.insert(4);
    X.insert(8);
    X.insert(16);

    cout<<*X.find_by_order(1)<<endl; // 2
    cout<<*X.find_by_order(2)<<endl; // 4
    cout<<*X.find_by_order(4)<<endl; // 16
    cout<<(end(X)==X.find_by_order(6))<<endl; // true

    cout<<X.order_of_key(-5)<<endl;  // 0
    cout<<X.order_of_key(1)<<endl;   // 0
    cout<<X.order_of_key(3)<<endl;   // 2
    cout<<X.order_of_key(4)<<endl;   // 2
    cout<<X.order_of_key(400)<<endl; // 5
*/

 //priority_queue<int, vector<int>, std::greater<int> > first;
inline ll add(ll _a, ll _b){
    if(_a < 0){ _a += MOD; }
    if(_b < 0){ _b += MOD; }
    if(_a + _b >= MOD){ return _a + _b - MOD; }
    return _a + _b;
}
inline ll mul(ll _a, ll _b){
    if(_a < 0){ _a += MOD; }
    if(_b < 0){ _b += MOD; }
    return ((ll)((ll)_a * (ll)_b)) % MOD;
}

ll Set(ll N,ll pos){return N=N | (1<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1<<pos));}
ll get_MSB_Pos(ll n){
    for(ll i = 60 ;;i--){
        if(check(n,i))
            return i;
    }
}

ll gcd(ll a, ll b)
{
    if(a<b)
        swap(a,b);
    if(b==0)
        return a;
    if(a%b==0)
        return b;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){

  return (a*b)/__gcd(a,b);
}

ll bigmod(ll N,ll P)
{
    if(P==0) return 1;
    if(P%2==0)
    {
        ll ret=bigmod(N,P/2);
        return ((ret%mod)*(ret%mod))%mod;
    }
    else return ((N%mod)*(bigmod(N,P-1)%mod))%mod;

}
bool isPrime(ll x)
{
    if(x<=1)
        return 0;
    if(x<=3)
        return 1;
    if(x%2==0)
        return 0;
    for(ll i = 3; i*i<=x;i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}

ll modInverse(ll a)
{
    return bigmod(a, MOD-2);
}
ll x,y;

ll func(ll n){
    ll a = n/2;
    if(n%2 == 0){
        return min(a*y , n*x);
    }
    return min(a*y+x, n*x);
}

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    #ifdef LOCAL
        autoinput();
    #endif
    ll h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2*60+m2)-(h1*60 + m1)-k;
    

}

Measured memory_bytes: 3640
#include <stdio.h>

int main(){
  int n;
  long int min = 1000000, max = -1000000, sum = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    int a;
    scanf("%d", &a);
    if(a < min) min = a;
    if(a > max) max = a;
    sum += a;
  }
  printf("%ld %ld %ld\n", min, max, sum);
}



Measured memory_bytes: 2748