akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n), cnt(200005, 0);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  vector <int> b = a;
  sort(a.begin(), a.end());
  int f = a[n - 1], s = a[n - 2];
  for(int i = 0; i < n; i++) {
    if(b[i] == f) {
      if(cnt[b[i]] > 1) {
        cout << f << '\n';
      }
      else {
        cout << s << '\n';
      }
    }
    else if(b[i] == s) {
      cout << f << '\n';
    }
    else {
      cout << f << '\n';
    }
  }
}

Measured memory_bytes: 3968
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
typedef long long ll;
using namespace std;

int n, a[200000], a2[200000], b[200000], b2[200000], cnt[30], l, r, ans;

int main() {
	cin >> n;
	lp(n)
		cin >> a[i];
	lp(n)
		cin >> b[i];
	lp(30)
		cnt[i] = 0;
	lp(29) {
		LP(n,j) {
			a2[j] = a[j] % (1 << (i + 1));
			b2[j] = b[j] % (1 << (i + 1));
		}
		sort(b2, b2 + n);
		LP(n, j) {
			l = -1;
			r = n;
			while (l + 1 != r) {
				if (b2[(l + r) / 2] + a2[j] < 1 << i)l = (l + r) / 2;
				else r = (l + r) / 2;
			}
			cnt[i] -= l;
			l = -1;
			r = n;
			while(l+1!=r){
				if (b2[(l + r) / 2] + a2[j] < 1 << (i + 1))l = (l + r) / 2;
				else r = (l + r) / 2;
			}
			cnt[i] += l;
			l = -1;
			r = n;
			while (l + 1 != r) {
				if (b2[(l + r) / 2] + a2[j] < (1 << i) + (1 << (i + 1)))l = (l + r) / 2;
				else r = (l + r) / 2;
			}
			cnt[i] += n - 1 - l;
		}
	}
	ans = 0;
	lp(30)
		if (cnt[i] % 2)ans += 1 << i;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define REP(i, x, y) for (int i = x; i < y; i++)

const int8_t INFC = 0x3f;
const int16_t INFS = 0x3f3f;
const int32_t INF = 0x3f3f3f3f;
const int64_t INFL = 0x3f3f3f3f3f3f3f3fLL;

const int MAXN = 3e5;
int dp[MAXN][2];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    dp[0][0] = s[0] != '#';
    dp[0][1] = s[0] != '.';
    for (int i = 1; i < s.size(); i++)
    {
        dp[i][0] = dp[i][1] = 1e9;
        dp[i][0] = min(dp[i][0], dp[i - 1][1] + int(s[i] != '#'));
        dp[i][0] = min(dp[i][0], dp[i - 1][0] + int(s[i] != '#'));
        dp[i][1] = min(dp[i][1], dp[i - 1][1] + int(s[i] != '.'));
    }
    cout << min(dp[s.size() - 1][0], dp[s.size() - 1][1]) << endl;
    return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18


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

    vector<int> B = A;
    sort(B.begin(), B.end());
    unordered_map<int, int> Cnt;
    Cnt[B[0]] = 1;
    for (size_t i=1; i<N; i++) {
        if (B[i-1] == B[i]) {
            Cnt[B[i]]++;
        }
        else {
            Cnt[B[i]] = 1;
        }
    }

    llong total = 0;
    for (auto &c: Cnt) {
        llong M = c.second;
        total += (M * (M - 1)) / 2;
    }

    for (size_t i=0; i<N; i++) {
        int key = A[i];
        llong M = Cnt[key];
        if (M <= 1) {
            cout << total << endl;
        }
        else {
            llong a = (M * (M - 1)) / 2;
            llong b = ((M - 1) * (M - 2)) / 2;
            cout << total - a + b << endl;
        }
    }
}


Measured memory_bytes: 9160
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let vs: Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let cs: Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut ans = 0;
    for i in 0..n {
        ans += cmp::max(0, vs[i] - cs[i]);
    }

    println!("{}", ans);
}


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

int main() {
	int a,b;
	cin>>a>>b;
	string arr[a];
	for (int i=0; i<a; i++){
		cin >> arr[i];
	}
	for (int i=0; i<b+2; i++){
		cout << '#';
	}cout <<'\n';
	
	for (int i=0; i<a; i++){
		cout<< '#' << arr[i] << "#\n";
	}
	for (int i=0; i<b+2; i++){
		cout << '#';
	}cout <<'\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    int cnt[200005];

    cin >> n;
    rep(i, n) cnt[i] = 0;
    rep(i, n - 1) {
        int a;
        cin >> a;
        cnt[a - 1]++;
    }
    rep(i, n) {
        cout << cnt[i] << endl;
    }

    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N + 1);
  vector<int> par(N + 1), deg(N + 1);
  rep(i, 0, N + M - 1) {
    int s, t;
    cin >> s >> t;
    G[s].push_back(t);
    deg[t]++;
  }
  queue<int> Q;
  rep(i, 1, N + 1) if (!deg[i]) Q.push(i);
  while(!Q.empty()) {
    int v = Q.front(); Q.pop();
    for(auto p : G[v]) {
      deg[p]--;
      par[p] = v;
      if(!deg[p]) Q.push(p);
    }
  }
  rep(i, 1, N + 1) cout << par[i] << endl;
  return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int n,k;
    cin>>n>>k;
    if(n%k>k/2)
    {
        cout<<k-n%k;
    }
    else
    cout<<n%k;
}

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

int main() {
    int64_t A,B,K;
    cin >> A>>B>>K;
    int64_t countB,countA = A-K;
    if(countA <=0){
     countA=0;
     countB= B + (A-K);
     if(countB <=0)countB =0;
    }
    else {
        countA = A-K;
        countB =B;
    }
    cout << countA << " "<<countB<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int cnt = 0;
		for(int i = a; i <= b; i++ ) {
			String s = String.valueOf(i);
			if(s.charAt(0)==s.charAt(s.length()-1) && s.charAt(1) == s.charAt(s.length()-2)) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 27600
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
int main()
{
	ll l,r; cin>>l>>r;
	int ans=0; 
	while(l<=r)
	{
		ans++; 
		l*=2; 
	}cout<<ans<<endl;
	return 0; 
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

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

    vector<int> a(m);
    vector<int> b(m);
    for(int im=0;im<m;im++) {
        cin >> a.at(im) >> b.at(im); a.at(im)--; b.at(im)--;
    }

    int ans = 0;
    UnionFind u(n);
    for(int im=0;im<m;im++) {
        u.merge(a.at(im), b.at(im));
    }
    for(int in=0;in<n;++in) {
        chmax(ans, u.size(in));
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    int cnt = 0, cntt = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]- '0' != i%2)
            cnt++;
    }
    for(int i=0;i<s.size();i++){
        if(s[i]-'0' != ((i%2)+1)%2){
            cntt++;
        }
    }
    
    cout << min(cnt, cntt) << '\n';

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
	int a, b, c, k;
	int ans=0;
	cin >> a >> b >> c >> k;
	if (a > k) {
		ans += k; k = 0;
	}
	else ans += a; k -= a;
	if (b > k)k = 0;
	else k -= b;
	ans -= k;
	cout << ans << endl;
}

Measured memory_bytes: 3192
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    A=LIST()
    for i in range(n-k):
        #print(A[i],A[i+k])
        if A[i]<A[i+k]:
            print('Yes')
        else:
            print('No')
        
    
    
if __name__ == '__main__':
    do()

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

ll to_scalar(tlll d, tlll vec)
{
    ll res = 0;
    res += (ll) get<0>(d) * get<0>(vec);
    res += (ll) get<1>(d) * get<1>(vec);
    res += (ll) get<2>(d) * get<2>(vec);
    return res;
}
int main()
{
    int n, m;
    cin >> n >> m;
    tlll xyz[n];
    rep(i, n) 
        cin >> get<0>(xyz[i]) >> get<1>(xyz[i]) >> get<2>(xyz[i]);
    
    ll ans = 0;
    rep(i,8)
    {
        tlll direction = make_tuple(
            ((i >> 0) & 1)? 1: -1,
            ((i >> 1) & 1)? 1: -1,
            ((i >> 2) & 1)? 1: -1
        );
        vector<ll> values(n + 1);
        rep(j,n) values[j + 1] = to_scalar(direction, xyz[j]);
        values[0] = 0;
        ll dp[2][n + 1];
        rep(j, n + 1) dp[0][j] = dp[1][j] = 0;

        for (int j = 1; j <= m; j++)
        {
            int now = j % 2;
            int prev = (j + 1) % 2;

            dp[now][j] = dp[prev][j-1] + values[j];
            for (int k = j + 1; k <= n; k++)
                dp[now][k] = max(
                    dp[now][k - 1], 
                    dp[prev][k - 1] + values[k]);
        }
        if (ans < dp[m %2][n])
            ans = dp[m %2][n];
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

void exec()
{
	int edge[100][100]={0};
	int n,k;
	cin >> n >> k;
	if(n==0&&k==0)exit(0);
	for(int i=0;i<k;i++){
		int a,b,c;
		cin >> a >> b >> c;
		b--;
		c--;
		if(a==0){
			priority_queue<P, vector<P>, greater<P> > q;
			q.push(P(0,b));
			int dist[100];
			fill(dist,dist+n,INT_MAX);
			dist[b]=0;
			while(q.size()){
				int f=q.top().second;
				int d=q.top().first;
				q.pop();
				if(f==c)break;
				if(dist[f]<d)continue;
				for(int j=0;j<n;j++){
					if(edge[f][j]&&d+edge[f][j]<dist[j]){
						dist[j]=d+edge[f][j];
						q.push(P(dist[j],j));
					}
				}
			}
			if(dist[c]!=INT_MAX){
				cout << dist[c] << endl;
			}
			else
			{
				cout << -1 << endl;
			}
		}
		else
		{
			int d;
			cin >> d;
			if(edge[b][c]==0||d<edge[b][c]){
				edge[b][c]=d;
				edge[c][b]=d;
			}
		}
	}
}
int main() {
	while(1)exec();
}

Measured memory_bytes: 1248
s = input()

count_a = 0
count_b = 0

for i in range(0, len(s)):
    if int(s[i])%2 == i%2:
        count_a += 1
    if int(s[i])%2 != i%2:
        count_b += 1

print(min(count_a, count_b))


Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys


def solve(N: int):
    if N == 0:
        print(0)
        return
    result = ""
    div = 2
    while N != 0:
        divided = N % div
        N -= divided
        if divided != 0:
            result = "1" + result
        else:
            result = "0" + result
        div *= -2
    print(result)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    solve(N)


if __name__ == '__main__':
    main()


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

int N, M;
int MAX = 1010;
vector<vector<int>>  D(MAX, vector<int>(MAX));
vector<vector<char>> S(MAX, vector<char>(MAX));
vector<int> dx = { 0, 1,  0, -1 };
vector<int> dy = { 1, 0, -1,  0 };
queue<pair<int, int>> Q;

int main()
{
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> S.at(i).at(j);
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (S.at(i).at(j) == '#') {
				Q.push({ i,j });
			}
		}
	}

	int ans = 0;
	while (!Q.empty()) {
		int x = Q.front().first, y = Q.front().second;
		Q.pop();
		int d = D.at(x).at(y);
		ans = d;
		for (int k = 0; k < 4; k++) {
			int px = x + dx.at(k);
			int py = y + dy.at(k);
			if (px < 0 || px >= N || py < 0 || py >= M) continue;
			if (S.at(px).at(py) == '.') {
				Q.push({ px,py });
				S.at(px).at(py) = '#';
				D.at(px).at(py) = d + 1;
			}
		}
	}

	cout << ans << endl;
}

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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

std::string s;
int main()
{
	std::cin >> s;

	int ans = 0;
	int res = 0;
	for (size_t i = 0, end = s.size(); i < end; ++i)
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			++res;
			ans = std::max(ans, res);
		}
		else
			res = 0;

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main()
{
	int t;
	t=1;
	while(t--)
	{
		int a,b,c;
		cin>>a>>b>>c;
		int k;
		cin>>k;
		int a1=0,b1=0;
		if(a+1>b)
		{
			while(a+1>b)
			{
				b=b*2;
				a1++;
			}


		}
		
		
		if(b+1>c)
		{
			while(b+1>c)
			{
				c=c*2;
				b1++;
			}
		}
		if(a1+b1<=k)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
    }
 }

Measured memory_bytes: 3632
N=int(input())
o=0
from heapq import heappop,heappush
q=[]
for a in map(int,input().split()):
    heappush(q,-a)
while -q[0]+o>=N:
    a=heappop(q)
    x,y=(-a+o)//N,(-a+o)%N
    o+=x
    heappush(q,-y+o)
print(o)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <iomanip>

using namespace std;

int main(){
  int N;
  cin >> N;
  double p[N];
  for(int i = 0 ;i < N; i++ ) cin >> p[i];
  double dp[N+1][N+1];
  for(int i = 0; i <= N; i++)for(int j = 0;j <=N; j++) dp[i][j] = 0;
  dp[0][0] = 1;
  for(int i = 1 ; i <= N; i++){
     for(int j = 0 ; j <= min((N+1)/2,i); j++){
        if( j==(N+1)/2 ){
            dp[i][j] = dp[i-1][j];
        }
        else{
            dp[i][j] = dp[i-1][j] * (1-p[i-1]);
        }

        if( j > 0 ){
           dp[i][j] += dp[i-1][j-1] * p[i-1];
        }
     }
  }
  cout << fixed << setprecision(15)<< dp[N][(N+1)/2];
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<long long> vec(n + 1);
  vec[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> vec[i];
    vec[i] += vec[i-1];
  }
  
  vector<long long> subt(n - k + 1);
  for (int i = 0; i < n - k + 1; i++) {
    subt[i] = vec[i+k] - vec[i];
  }
  double ans = 0;
  for (int i = 0; i < n - k + 1; i++) {
    double ave = (subt[i] + k) / 2.0;
    if (ans < ave) {
      ans = ave;
    }
  }
  //cout << ans << endl;
  printf("%lf\n",ans);
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int k,x;
  cin>>k>>x;
  reep(i,x-k+1,k+x-1){
    cout<<i;
    if(i!=k+x-1)
      cout<<' ';
  }
  cout<<endl;
  return 0;
}

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

int main(){
 
    int N,L;
    int nijou;
    int hozon=10000000000000;
    int num=0;
    int wa=0;
    
    cin >> N >> L;
    
    for(int i=1;i<=N;i++){
        nijou = pow(L+i-1,2);
        wa += L+i-1;
        
        if(hozon>nijou){
            hozon=nijou;
            num=i;
        }
    }
    
    cout << wa-(L+num-1);
    
    
    
    
 
 
}

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

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

const int N = 50 + 1;

int n;
int a[N], b[N];
int dp[N][N][N];

int f(int x, int y, int i, ll mask) {
	if(x == y)
		return 1;
	if(i <= 0)
		return 0;
	int &r = dp[x][y][i];
	if(r != -1) return r;
	r = 0;
	if(mask & (1LL << i))
		r |= f(x % i, y, i - 1, mask);
	r |= f(x, y, i - 1, mask);
	return r;
}

bool ok(ll mask) {
	memset(dp, -1, sizeof(dp));
	for(int i = 1; i <= n; i++)
		if(!f(a[i], b[i], 50, mask))
			return 0;
	return 1;
}

int main() {

	scanf("%d", &n);

	for(int i = 1; i <= n; i++)
		scanf("%d", a + i);

	for(int i = 1; i <= n; i++)
		scanf("%d", b + i);

	ll mask = 0;

	for(int i = 50; i >= 0; i--) {
		ll nw = mask | ((1LL << i) - 1);
		if(!ok(nw))
			mask |= 1LL << i;
	}

	if(!ok(mask))
		puts("-1");
	else
		printf("%lld\n", mask);

    return 0;

}



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

namespace AtCoder.Grand016
{
    class A
    {
        static void Main(string[] args)
        {
            // 文字列の入力
            string input = Console.ReadLine();
            
            int maxDiffMin = int.MaxValue;

            char[] array = input.ToCharArray();
            for ( char c = 'a'; c <= 'z'; c++ )
            {
                if ( input.IndexOf( c ) == -1 )
                {
                    continue;
                }

                int maxDiff = 0;

                List<int> index = new List<int>();

                index.Add( -1 );

                int start = 0;
                while ( input.IndexOf( c, start ) != -1 )
                {
                    index.Add( input.IndexOf( c, start ) );
                    start = input.IndexOf( c, start ) + 1;
                }
                
                index.Add( input.Length );

                for ( int i = 0; i < index.Count - 1; i++ )
                {
                    maxDiff = Math.Max( index[i+1] - index[i] - 1, maxDiff );
                }

                maxDiffMin = Math.Min( maxDiffMin, maxDiff );

            }

            //出力
            Console.WriteLine( maxDiffMin );
            

#if DEBUG
            Console.WriteLine( "press Enter." );
            Console.ReadLine();
#endif

        }
        
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define    For(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    nl     "\n"
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

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

    //test
    {
        int sm=0;
        string s;
        cin>>s;
        fors(i,s)
        {
            sm+=s[i]-'0';
        }
        if(sm%9==0)cout<<"Yes"<<nl;
        else cout<<"No"<<nl;
    }
}


Measured memory_bytes: 3700
from sys import stdin
input = stdin.readline


class UnionFind:
    # この時点でそれぞれのノードは自分を親としている
    # 初期化時に問題が0の頂点を認めるかに注意すること
    def __init__(self, n):
        self.N = n
        self.parent = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    # xの根を返す関数
    def root(self, x):
        visited_nodes = []
        while True:
            p = self.parent[x]
            if p == x:
                # 縮約
                for node in visited_nodes:
                    self.parent[node] = x
                return x
            else:
                visited_nodes.append(x)
                x = p

    # 木の結合を行う。親の配下に入る
    def unite(self, x, y):
        if not self.root(x) == self.root(y):
            if self.rank[x] > self.rank[y]:
                self.parent[self.root(y)] = self.root(x)
            else:
                self.parent[self.root(x)] = self.root(y)
                if self.rank[x] == self.rank[y]:
                    self.rank[self.root(y)] += 1

    def ifSame(self, x, y):
        return self.root(x) == self.root(y)

    # 木の根に到達すまでにたどるノードの配列を返す
    def printDebugInfo(self):
        print([self.root(i) for i in range(self.N)])


N, M, K = map(int, input().split())
friend_tree = UnionFind(N)
like_array = [[] for _ in range(N)]
for _ in range(M):
    # 友人木を構築する
    A, B = map(int, input().split())
    like_array[B-1].append(A-1)
    like_array[A-1].append(B-1)
    if not friend_tree.ifSame(A-1, B-1):
        friend_tree.unite(A-1, B-1)

# friend_tree.printDebugInfo()

friend_groups = {}
for i in range(N):
    root = friend_tree.root(i)
    if root in friend_groups.keys():
        friend_groups[root] += 1
    else:
        friend_groups[root] = 1

# print(friend_groups)

dislike_array = [[] for _ in range(N)]
for _ in range(K):
    C, D = map(int, input().split())
    dislike_array[C-1].append(D-1)
    dislike_array[D-1].append(C-1)

# print(dislike_array)

answer = []
for i in range(N):
    root = friend_tree.root(i)
    friends_count = friend_groups[root] - 1

    blockd_friend = 0
    for dislike_person in dislike_array[i]:
        if friend_tree.ifSame(i, dislike_person):
            blockd_friend += 1

    kai = friends_count - blockd_friend - len(like_array[i])
    answer.append(str(kai))

print(" ".join(answer))


Measured memory_bytes: 55076
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var t=(Arr[0].split(" "))[1]-0;
Arr.shift();
var T=0;
while(Arr.length!=0){
   var arr=Arr[0].split(" ");
   Arr.shift();
   var a=arr[0];
   var b=arr[1]-0;
   if(b-t<=0){
      console.log(a+" "+(T+b));
      T+=b;
   }else{
      Arr.push(a+" "+(b-t));
      T+=t;
   }
}

Measured memory_bytes: 29668
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	long long int n, x = 0;
	cin >> n;
	long long int arr[n];
	rarr(arr, n);
	for(int i = 0; i < n; i++){
		x = arr[i] ^ x;
	}
	for(int i = 0; i < n; i++){
		arr[i] = arr[i] ^ x;
	}
	parr(arr, n);
} 

Measured memory_bytes: 5196
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int r=nextInt();
		int g=nextInt();


		String ans = String.valueOf(r+g);
		if(r+g>=10){
			ans="error";
		}

		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include<stdio.h>
int main()
{
    int a;
    long b,n,ans;
    scanf("%d%ld%ld",&a,&b,&n);
    if(n<b)
    {
        ans=(a*n)/b;
        printf("%ld",ans);
    }
    else
    {
        ans=(a*(b-1))/b;
        printf("%ld",ans);
    }
}

Measured memory_bytes: 1736
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 05/31/20 18:19:58
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <typename T, T MOD>
class modint {
 private:
  T val_;

 public:
  constexpr modint() : val_(0) {}
  constexpr modint(T v) : val_(v%MOD) {}
  constexpr modint& operator=(T v) { val_ = v%MOD; return *this; }

  constexpr T val() const { return val_; }
  constexpr modint operator+(modint x) const { return (val() + x.val())%MOD; }
  constexpr modint operator+=(modint x) { return *this = *this + x; }
  constexpr modint operator++() { return *this += 1; }
  constexpr modint operator++(int) { modint c = *this; ++(*this); return c; }
  constexpr modint operator-(modint x) const { return (val() + MOD - x.val())%MOD; }
  constexpr modint operator-=(modint x) { return *this = *this - x; }
  constexpr modint operator--() { return *this -= 1; }
  constexpr modint operator--(int) { modint c = *this; --(*this); return c; }
  constexpr modint operator*(modint x) const { return (val() * x.val())%MOD; }
  constexpr modint operator*=(modint x) { return *this = *this * x; }
  friend constexpr modint pow(modint x, T p) {
    modint t = 1;
    modint u = x;
    while (p) {
      if (p & 1)
        t *= u;
      u *= u;
      p >>= 1;
    }
    return t;
  }
  constexpr modint operator/(modint x) const { return *this * pow(modint{x}, MOD-2); }
  constexpr modint operator/=(modint x) { return *this = *this / x; }

  constexpr bool operator==(modint x) const { return val() == x.val(); }
  constexpr bool operator!=(modint x) const { return val() != x.val(); }
  constexpr bool operator<(modint x) const { return val() < x.val(); };
  constexpr bool operator<=(modint x) const { return val() <= x.val(); };
  constexpr bool operator>(modint x) const { return val() > x.val(); };
  constexpr bool operator>=(modint x) const { return val() >= x.val(); };

  friend std::ostream& operator<<(std::ostream& os, const modint& x) {
    return os << x.val();
  }
  friend std::istream& operator>>(std::istream& is, modint& x) {
    return is >> x.val_;
  }

};

using mint = modint<ll, 998244353>;

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

  int n,s; cin>>n>>s;
  vector<int> A(n); for (auto& a:A) cin>>a;
  vector<mint> dp(s+1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int t = s; t >= 0; t--) {
      dp[t] *= 2;
      if (t >= A[i])
        dp[t] += dp[t-A[i]];
    }
  }
  cout << dp[s] << endl;

  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using INT = __int128;
ll a[100005];
int main(){
	ll n;
	cin>>n;
	INT ans = 1;
	bool flag = true;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(!a[i]) flag = false;
	}
	if(!flag) {
		cout<<0<<endl;
		exit(0);
	}
	for(ll i=0;i<n;i++){
		ll x = a[i];
		ans *= (INT) x;
		if(ans > (INT) 1e18) {
			cout<<-1<<endl;
			exit(0);
		}
	}
	cout<<(ll)ans<<endl;
	return 0;
}

Measured memory_bytes: 4416
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int cost[m];
    REP(i, m)
    {
        cin >> cost[i];
    }
    int ans = 0;
    int lans = 0;
    int rans = 0;
    for (int i = 0; i < m; i++)
    {
        if (cost[i] < x)
        {
            lans++;
        }
        else
        {
            rans++;
        }
    }
    ans = min(lans, rans);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    if(n==0||n==1){
        printf("1\n");
        return 0;
    }
    int data[n+1];
    int i;
    data[0]=1;
    data[1]=1;
    for(i=2;i<=n;i++){
        data[i]=data[i-1]+data[i-2];
    }
    printf("%d\n",data[n]);
    return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
    int n;cin>>n;
 
    vi p(n);cin_pl(n,p);
    vi q(n),o(n);
    int d=0;
    rep(i,n)
    {
        if(i==0)
        {q[i]=0;o[i]=0;}
        else
        {
            q[i]=p[i]-p[i-1];
            o[i]=q[i]+o[i-1];

        }
    }
    
    int count=0,minus=0;
    rep(i,n)
    {
        if(o[i]<=minus)
        {
            count++;minus=o[i];
        }
    }
    cout<<count;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N , M ;
  cin >> N >> M ;
  vector<string> A,B;
  rep(i,N){
    string inp; cin >> inp;
    A.pb(inp);
  }

  rep(i,M){
    string inp; cin >> inp;
    B.pb(inp);
  }

  for(ll i = 0 ; i < N-M+1 ;i++){    
    for(ll j = 0 ; j < N-M+1; j++ ){
      bool flag = true;

      rep(m,M)rep(n,M){
	if(A[i+m][j+n] != B[m][n]){
	  flag = false;
	  m= M , n= M;
	}
      }
      if(flag){
	cout << "Yes" << endl;
	return 0;
      }
      
    }
  }

  cout << "No" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

   int F[50];
   int i, j, n;

   scanf("%d", &n);

   F[0] = 1;
   F[1] = 1;

   for (i = 2; i <= n; i++) {
      F[i] = F[i - 1] + F[i - 2];
   }

   printf("%d\n", F[n]);

   return 0;
}


Measured memory_bytes: 2136
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string N;
  cin >> N;
  if(N == "SUN") cout << 7 << endl;
  else if(N == "MON") cout << 6 << endl;
  else if(N == "TUE") cout << 5 << endl;
  else if(N == "WED") cout << 4 << endl;
  else if(N == "THU") cout << 3 << endl;
  else if(N == "FRI") cout << 2 << endl;
  else if(N == "SAT") cout << 1 << endl;
return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a;
    int n = 1;
    while (true) {
        cin >> a;
        if (a != 0) {
            cout << "Case " << n << ": " << a << endl;
            n += 1;
        } else {
            return 0;
        }
    }
}


Measured memory_bytes: 3072
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			int[] cnts = new int[n];
			for (int i = 0; i < n; ++i) {
				int curr = (int) sc.scanLong();
				cnts[curr]++;
			}
			if (n % 2 == 0) {
				long res = 1;
				for (int i = 1; i < n; i += 2) {
					if (cnts[i] != 2) {
						System.out.println(0);
						return;
					}
					res *= 2;
					if (res >= MOD)
						res -= MOD;
				}
				System.out.println(res);
			}
			else {
				long res = 1;
				for (int i = 2; i < n; i += 2) {
					if (cnts[i] != 2) {
						System.out.println(0);
						return;
					}
					res *= 2;
					if (res >= MOD)
						res -= MOD;
				}
				System.out.println(res);
			}
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 33132
#include <stdio.h>
int main(void)
{
	int s;

	scanf("%d", &s);

	if((s >= 3600) && (s < 86400))
	{
		printf("%d:%d:%d\n", s / 3600, s % 3600 / 60, s % 3600 % 60);
	}
	if((s >= 60) && (s < 3600))
	{
		printf("0:%d:%d\n", s / 60, s % 60);
	}
	if ((s >= 0) && (s < 60))
	{
		printf("0:0:%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
const int m=1e9+7;
void solve()
{
    int n,k; cin>>n>>k;
    int dp[k+1]={0}; dp[0]=1;
   
    int a[n+1];
    for(int chld=1;chld<=n;chld++)
    {
        cin>>a[chld];
        vector<int> fake(k+1);
        for(int used=k;used>=0;used--)
        {
            int L=used+1;
            int R=used+min(a[chld],k-used);
            //for (int i = L; i < =R; i++)
            {
				if(L<=R){
                fake[L]=(fake[L]+dp[used])%m;
                if(R+1<=k)
                fake[R+1]=(fake[R+1]-dp[used]+m)%m;
                //dp[i]+=dp[used];
            }}
        }
        int pref=0;
        for(int i=0;i<=k;i++)
        {pref=(pref+fake[i])%m;
        dp[i]=(dp[i]+pref)%m;
        }

    }
cout<<dp[k]%m;

}


int main()
{
    solve();
}

Measured memory_bytes: 1024
"""
https://abc084.contest.atcoder.jp/tasks/abc084_b
"""
[a,b]=[int(i) for i in input().split()]
s=input()
c=1
for i in range(len(s)):
    if i==a:
        if s[i]=="-":
            c=c*1
        else:
            c=c*0
    else:
        if s[i]=="-":
            c=c*0
        else:
            c=c*1
if c==0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-8;
template<typename T>
inline void read(T &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
const int N=100010;
int n;
int head[N],nxt[N<<1],to[N<<1],lst=1;
inline void adde(int x,int y) {
	nxt[++lst]=head[x]; to[lst]=y; head[x]=lst;
}
int fa[N],rt=-1;
int Solve(int u) {
	int ret=0; bool fl=0;
	for(int i=head[u];i;i=nxt[i])
		if(to[i]!=fa[u]) {
			int v=to[i]; fa[v]=u;
			int val=Solve(v);
			if(!val && !fl) fl=1;
			else ret+=max(val,1);
		}
	return ret;
}
int in[N];
signed main()
{
	read(n);
	for(int i=1;i<n;i++) {
		int x,y; read(x); read(y); ++x; ++y;
		adde(x,y); adde(y,x);
		++in[x]; ++in[y];
	}
	for(int i=1;i<=n;i++)
		if(in[i]>=3) {
			rt=i; break;
		}
	if(rt==-1) {puts("1"); return 0;}
	printf("%d\n",Solve(rt));
	return 0;
}

Measured memory_bytes: 6400
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	string s;
	cin >> s;
	vector<int>v(s.size());
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')v[i]++;
		if(i)v[i] = v[i] * v[i - 1] + v[i];
	}
	cout << *max_element(v.begin(), v.end()) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>

#include <algorithm>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

ll res;

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

    ll N;
    cin >> N;
    res = 0;
    vector<ll> L(N);
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < i; j++)
        {
            for (int k = 0; k < j; k++)
            {
                if (L[k] != L[j] && L[i] != L[j] && L[k] + L[j] > L[i])
                {
                    res++;
                }
            }
        }
    }

    cout << res << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld; 
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;




#define F first
#define S second
#define pob pop_back
#define pb push_back
#define Time()	cerr << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define show(x)	cerr << #x << " = " << (x) << '\n'
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Test int T;cin>>T;while(T--)
#define REP(i,j,k) for(int i=(j);(i)<(k);(i)++)
//#define phi ((1+sqrt(5))/2)
#define endl '\n'
const int MxN = 1e9+7;
const double pi = 2*acos(0.0);
int main(){
	//cout.precision(15);
	FASTER;
	unordered_map<int,int> m;
	int n;
	cin>>n;
	vi v(n-1);
	//invec(v);
	for(int& x: v){
		cin>>x;
		m[x]++;
	}
	for(int i=0;i<n;i++){
		cout<<m[i+1]<<endl;
	}
	
}


Measured memory_bytes: 12280
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int s[10];
inline bool Check(int x)
{
    int cnt=0;
    while(x) s[++cnt]=x%10, x/=10;
    if(s[1]==s[5]&&s[2]==s[4]) return 1;
    return 0;
}
signed main()
{
    int a,b;
    a=read();
    b=read();
    int res=0;
    for(ri int i=a;i<=b;i++) if(Check(i)) res++;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3712