akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,c,d,e;
int main(){
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(isdigit(s[i]))a=a*10+(s[i]-'0'),d*=10;
    else if(s[i]=='.')d++;
    else while(isdigit(s[++i]))b=b*10+(s[i]-'0'),c=c*10+9;
  }
  if(c)a=b+a*c,d=d*c;
  cout<<a/__gcd(a,d)<<'/'<<d/__gcd(a,d)<<endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<long long> x(m);
    for(int i = 0; i < m; i++){
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    vector<long long> y(m-1);
    for(int i = 0; i < m-1; i++){
        y[i] = x[i+1] - x[i];
    }
    
    sort(y.begin(), y.end());
    long long ans = x[m-1] - x[0];
    for(int i = 0; i < n - 1; i++){
        ans -= y[m-2-i];
    }
    cout << ans <<endl;


}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include<math.h>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<unordered_map>
#include<set>
#include <algorithm>
#include <utility>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::set;

typedef unsigned long long ull;
typedef long long ll;

#define Prime1 1000000007
#define Prime2 9999973

int i, j, k, l, m, n;
int H, W, N, M, Q;
int a, b, c;


int main()
{
	cin >> N >> M;
	set<int> before, after;
	for (i = 0; i < M; i++)
	{
		cin >> a >> b;
		if(a==1)
		{
			before.insert(b);
		}
		else if(b==N)
		{
			after.insert(a);
		}
	}
	for (auto itr = after.begin(); itr != after.end(); itr++)
	{
		if (before.find(*itr) != before.end())
		{
			cout << "POSSIBLE\n";
			return 0;
		}
	}
	cout << "IMPOSSIBLE\n";
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> p[i];
  }
  int result = 0;
  for (i = 0; i < n - 1; i++) {
    if (p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      result++;
    }
  }
  if (p[n - 1] == n) {
    swap(p[n], p[n - 1]);
    result++;
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

int main(void)
{
  
  vector<long long> L; // Lunlun 数

  // 1 桁
  for (long long i = 0; i < 9; i++)
  {
    long long newL = i + 1;
    L.push_back(newL);
  }

  // 2 桁以降

  long long start = 0; // 1 桁の Lunlun 数の初めのインデックス
  long long goal = 9; // 1 桁の Lunlun 数の最後のインデックス + 1

  while ( L.size() <= 100001 )
  { // Lunlun 数の個数が 100001 を超えたらストップ

    // 桁数が n のとき

    int count = 0; // n 桁の Lunlun 数を数える

    for (long long i = start; i < goal; i++) // n-1 桁の Lunlun 数についてループ
    {
      long long x = L.at(i); // n-1 桁の i 番目の Lunlun 数
      for (int j = 0; j<10; j++) // 新たに n 桁目に加える数
      {
        long long one = x % 10; // x の 1 の位
        if (one == j-1 || one == j || one == j+1) // もし隣接する数字なら
        {
          long long newL = 10 * x + j; // 新しい Lunlun 数
          L.push_back(newL); // 新しい Lunlun 数を追加
          count++; // n 桁の Lunlun 数の個数を追加
        }
      }
    }
    start = goal; // n 桁の Lunlun 数の最初のインデックス
    goal = goal + count; // n 桁の Lunlun 数の最後のインデックス + 1
  }


  long long K; // 入力
  cin >> K;
  cout << L.at(K - 1) << endl; // K 番目（1はじめ）の Lunlun 数
}


Measured memory_bytes: 2420
n=str(input())
H=n[0]
T=n[-1]
keta=len(n)
n=int(n)
ans=0
if keta==1:
    print(1)
    exit()
elif keta==2:
    for i in range(1,n+1):
        s=str(i)
        for j in range(1,n+1):
            S=str(j)
            if S[0]==s[-1] and S[-1]==s[0]:
                ans+=1    
else:
    for i in range(1,n+1):
        s=str(i)
        h=s[0]
        t=s[-1]
        if h!="0" and t!="0":
            ans+=(10**(keta-2)-1)//9
            if h==t:
                ans+=1
            if int(t)<int(H):
                ans+=(10**(keta-2))*(int(H)-int(t))
            elif int(t)==int(H):
                ans+=max(0,((n-10**(keta-1)*int(H)-int(h))//10)+1)
            
print(ans)




Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }// Your code here!
    for(int j=n-1;j>=0;j--){
        if(j==n-1){
            cout<<a[j];
        }else{
            cout<<" "<<a[j];
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
typedef long long unsigned int ll;
#define REP(i,n) for(int i=0;i<n;i++)
int main() {
    int n,m,ans,t[2];
    scanf("%d %d", &n,&m);
  t[0] = 0;
  t[1] = n;
    int l[m],r[m];
    REP(i,m){
        scanf("%d %d",&l[i],&r[i]);
    	t[0] = max(t[0],l[i]);
      	t[1] = min(t[1],r[i]);
    }
  	t[2] = min(n,t[1]);
  	if (t[1] - t[0] <0) ans = 0;
  	else ans = t[1] -t[0] +1;
    printf( "%d\n", ans );
    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

pii pp[MAXN];

void solve(){
	int n, a;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &a);
		pp[i] = mp(a, i);
	}
	sort(pp, pp + n);
	int ans = 0;
	REP(i, 0, n){
		if ((pp[i]._2 ^ i) & 1){
			ans++;
		}
	}
	printf("%d\n", ans / 2);
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

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

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

//aからbへの双方向隣接リスト（木構造）
vector<vector<int>> graph;
//各頂点のカウンター
vector<int> counter;

void dfs(int v, int pre){
    if(pre != -1) counter[v] += counter[pre];
    for(int nv : graph[v]){
        if(nv == pre) continue;
        dfs(nv, v);
    }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    //外部配列として呼び出しているので、要素数を指定してあげる
    graph.resize(N);
    counter.resize(N);
    rep(i, N-1){
        int a, b;
        cin >> a >> b;
        //入力では1~N頂点なので、配列で扱いやすいように、0~N-1頂点とした
        a--; b--;
        //グラフの情報を書き込む
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    rep(i, Q){
        int p, x;
        cin >> p >> x;
        //0-indexより
        p--;
        //指定された部分木の根の部分のカウンターを加算する
        counter[p] += x;
    }
    //dfs開始
    dfs(0, -1);

    rep(i, N) cout << counter[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 24300
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    long long int lis[100001];
    for(int i=0;i<N;i++)cin>>lis[i];
    sort(lis,lis+N);
    long long int now=lis[0];
    long long int ans=0;
    for(int i=1;i<N;i++){
        if(now*2<lis[i])ans=i;
        now+=lis[i];
    }
    cout<<N-ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";

int main() {
	cin >> S;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] == '1') {
			S[i] = '9';
		}
		else if(S[i] == '9') {
			S[i] = '1';
		}
	}
	cout << S;
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));
$a = array_map("intval", explode(" ", trim(fgets(STDIN))));
sort($a);
$c = $a[0];
for($i = 1; $i < $n; $i++){
  $c = ($c + $a[$i])/2;
}
echo $c;

Measured memory_bytes: 5112
import numpy as np
inputs = open(0).readlines()
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, row in zip(range(h), grid):
            for j, val in zip(range(w), row):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, row)) for row in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

def z_iterate(x, y, w):
    if y % 2:
        if x == 0:
            y += 1
        else:
            x -= 1
    else:
        if x == w-1:
            y += 1
        else:
            x += 1
    return x, y

h, w = map(int, inputs[0].split())
*A, = map(int, inputs[2].split())
grid = Grid(np.zeros((h, w), dtype=np.int))

x = y = 0
for i, a in enumerate(A, 1):
    for _ in range(a):
        grid[y, x] = i
        x, y = z_iterate(x, y, w)
print(grid)

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

int main() {
	int n, k, cnt = 0;
	cin >> n >> k;
	string s;
	cin >> s;
	s += '#';
	vector < pair < int, char > > a;
	vector < pair < int, int > > b;
	for ( int i = 0; i < n; i++ ) {
		cnt++;
		if ( s[i] != s[i + 1] ) {
			a.push_back( { cnt, s[i] } );
			cnt = 0;
		}
	} 
	a.push_back( { 0, '#' } );
	for ( int i = 0; i < (int)a.size(); i++ ) {
		if ( a[i].second == '0' ) {
			if ( i != 0 ) {
				b.push_back( { a[i - 1].first + a[i].first, i } );
			}
			else {
				b.push_back( { a[i].first, i } );	
			}
		}
	}
	if ( (int)b.size() <= k ) {
		cout << n;
		return 0;
	}
	int t = 0, ans = 0;
	for ( int i = 0; i < k - 1; i++ ) {
		t += b[i].first;
	}
	int i = 0, j = k - 1;
	for ( ; j < (int)b.size();  ) {
		t += b[j].first;
		ans = max( ans, t + a[ b[j].second + 1 ].first );
		t -= b[i].first;
		i++;
		j++;
	}
	ans = max( ans, t );
	cout << ans;
}


Measured memory_bytes: 2036
#include <stdio.h>

int main(void)
{
	int kazu;
	scanf("%d", &kazu);				//入力

	if (1 <= kazu && kazu <= 100) { //1以上100以下で動く
		kazu = kazu * kazu * kazu;
		printf("%d\n", kazu);			//3乗表示

	}

	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int myabs(int n)
{
    return n < 0 ? n*-1 : n;
}
int main()
{
    int N;
    while(cin>>N)
    {
        vector<int> vec(N+5),dp(N+5);
        for(int i=0;i<N;i++)
        {
            cin>>vec[i];
        }
        dp[0] = 0;
        dp[1] = myabs(vec[1] - vec[0]);
        for(int i = 2 ; i < N ; i++)
        {
            dp[i] = min(myabs(vec[i] - vec[i-1]) + dp[i-1] , myabs(vec[i] - vec[i-2]) + dp[i-2]  );
        }
        cout<<dp[N-1]<<'\n';
    }
}


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

using namespace std;

int main(void){
  int n;
  cin >> n;
  bool ok = false;
  
  int temp = n;
  while(temp > 0){
    if(temp % 10 == 9) ok = true;
    temp /= 10;
  }
  
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        x: isize,
        y: isize,
    }
    // m + n = x
    // 4m + 2n = y
    let m = (y - 2 * x)/2; 
    let n = (4 * x - y)/2;
    let yes = x == (m + n) && m >= 0 && n >= 0;
    println!("{}", if yes { "Yes" } else { "No" });
}


Measured memory_bytes: 2136
N, K = map(int, input().split())


def factorial(n):
    ans = 1
    for i in range(1, n + 1):
        ans *= i
    return ans


def combination(n, r):
    return factorial(n) // (factorial(r) * factorial(n - r))


def answer(N, K, i):
    if N - K + 1 < i:
        return 0
    else:
        return (combination(N - K + 1, i) * combination(K - 1, i - 1))


for i in range(1, K + 1):
    ans = answer(N,K,i)
    print(ans %(10**9+7))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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; }

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    bool operator==(const mint a){
        return (x == a.x);
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
mint pow2(mint x, ll t) {return x.pow(t);}
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

//nが非常に大きく、aが小さい場合
mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main(){

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

    int N; cin >> N;

    mint ans = pow2(10,N);
    ans -= pow2(9,N)*2;
    ans += pow2(8,N);
    cout << ans << endl;    
}

Measured memory_bytes: 3604
import math
while 1:
    n = int(raw_input())
    if not n:
        break
    ans = 0
    for p in xrange(1, int(math.sqrt(2*n))+1):
        if 2*n % p ==0:
            q = 2*n / p
            if p>1 and (p+q)%2:
                ans += 1
    print ans

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

int main() {
    int n;
    map<string, int> mp;
    while (~scanf("%d", &n)) {
        char seq[15];
        mp.clear();
        bool flag = true;
        char tag;
        for (int i = 0; i < n; ++i) {
            scanf("%s", seq);

            if (mp.find(seq) != mp.end() || (i && tag != seq[0])) flag = false;
            mp[seq]++;
            tag = seq[strlen(seq) - 1];
        }

        printf("%s\n", flag ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc049/tasks/arc065_b
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K, L;
    cin >> N >> K >> L;
    UnionFind uf1(N), uf2(N);
    REP(i, K) {
        int a, b;
        cin >> a >> b;
        uf1.unite(a - 1, b - 1);
    }
    REP(i, L) {
        int a, b;
        cin >> a >> b;
        uf2.unite(a - 1, b - 1);
    }
    map<pii, int> mp;
    REP(i, N) mp[{uf1.root(i), uf2.root(i)}]++;
    REP(i, N)
    cout << mp[{uf1.root(i), uf2.root(i)}] << (i == N - 1 ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 13568
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int b=gi();
	    //System.out.print();
	    if (a+b==15) {
	    	System.out.print("+");
	    }else if(a*b==15) {
	    	System.out.print("*");
	    } else {
	    	System.out.print("x");
	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

INPUT = input()
N = int(INPUT.split()[0])
# N_list = [int(x) for x in list(str(N))]
# K = int(INPUT.split()[1])
D_list = map(int, input().split())

DIGITS = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
# usable_digits = list(DIGITS - set(D_list))
usable_digits = DIGITS - set(D_list)

while True:
    N_set = set([int(x) for x in list(str(N))])
    if N_set <= usable_digits:
        break
    N += 1

print(N)

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

using ll = int64_t;

constexpr ll COM_MAX = (ll)1e5;
constexpr long long MOD = (1e9+7);
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
// 前処理
void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
// 二項係数計算
ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
// 重複組み合わせ
ll nHk(ll n,ll k){
  return comb(n+k-1,n-1);
}

template<ll MOD=ll(1e9+7)>
ll mod_pow(ll n,ll p){
  ll ans=1LL;
  while(p){
    if(p&1)ans*=n;
    n*=n;
    p>>=1;
    ans%=MOD;
    n%=MOD;
  }
  return ans;
}

signed main(){

  comb_init();
  ll n,k;
  cin>>n>>k;
  n -= k;
  cout<<comb(n+k-1,n)<<endl;

}


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
int mod=1000000007;
int main()
{
    int n,k;
    cin>>n;
    cin>>k;
    int dp[100005]={0};
    dp[0]=1;
  //  dp[1]=-1;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        int add[100005]={0};
        for(int j=k;j>=0;j--)
        {
            add[j+1]=add[j+1]+dp[j];
            if(add[j+1]<0)
            add[j+1]+=mod;
            else
            add[j+1]=add[j+1]%mod;
            if(j+a+1<=k)
            {
            add[j+a+1]-=dp[j];
            if(add[j+a+1]<0)
            add[j+a+1]+=mod;
            else
            add[j+a+1]=add[j+a+1]%mod;
            }
        }
        for(int g=1;g<=k;g++)
        {
            add[g]+=add[g-1];
            if(add[g]<0)
            add[g]+=mod;
            else
            add[g]=add[g]%mod;
        }
        for(int g=1;g<=k;g++)
        {
        dp[g]+=add[g];
        dp[g]=dp[g]%mod;
        }
        /*for(int i=1;i<=k;i++)
    {
        dp[i]+=dp[i-1];
    }*/
    }
 /*   for(int i=1;i<=k;i++)
    {                          
        dp[i]+=dp[i-1];
    }*/
    cout<<dp[k];
    return 0;
}



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

typedef unsigned long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A;
    char C[4] = {0};
    string B;

    cin >> A >> B;

    C[0] = B[0];
    C[1] = B[2];
    C[2] = B[3];

    ll B1 = atoi(C);

    ll ANS = A*B1;

    cout << (ANS/100) << endl;
}


Measured memory_bytes: 3620
n = gets.to_i
a = [0,0,0,0]
n.times do
    s = gets.chomp
    a[0] += 1 if s == "AC"
    a[1] += 1 if s == "WA"
    a[2] += 1 if s == "TLE"
    a[3] += 1 if s == "RE"
end
puts "AC x #{a[0]}"
puts "WA x #{a[1]}"
puts "TLE x #{a[2]}"
puts "RE x #{a[3]}"

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

int main(){
  string str;
  int sum;
  while(cin >> str && str != "0"){
    sum = 0;
    for (int i=0, l=str.size();i<l;i++){
      sum += str[i] - '0';
      if(sum==0) break;
    }
    cout<<sum<<endl;
  }
  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

bool compare(pair<string, int> p1, pair<string, int> p2) {
	if(p1.first.size() == p2.first.size()) return p1.first < p2.first;
	return p1.first.size() < p2.first.size();
}

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

	map<string, int> m;
	string s, t;
	int d;

	rep(i, n) {
		cin >> s >> d;
		m[s] += d;
	}

	vector<pair<string, int> > v;
	map<string, int>::iterator ite;
	for(ite = m.begin(); ite != m.end(); ite++) {
		v.push_back(mp(ite->first, ite->second));
	}

	sort(v.begin(), v.end(), compare);

	rep(i, v.size()) {
		cout << v[i].first << " " << v[i].second << endl;
	}


	return 0;
}

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

using namespace std;

int main()
{

	int N;
	int ans = 0;
	cin >> N;

	int a;
	for (int ni = 0; ni < N; ni++) {
		cin >> a;
		ans += a;
	}

	ans -= N;

	printf("%d",ans);

    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
ss = [[] for _ in range(N)]

for i in range(M):
    p, y = map(int, input().split())
    ss[p-1].append((i, y))

ls = [''] * M
for p in range(N):
    s = ss[p]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(p+1).zfill(6)
        ds = str(d+1).zfill(6)
        ls[i] = ps+ds

for l in ls:
    print(l)


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &e : a) cin >> e;
  sort(begin(a), end(a));
  for (int i = 0; i < n - 1; i += 2) {
    if (a[i] + a[i + 1] < 0) {
      a[i] *= -1;
      a[i + 1] *= -1;
    }
  }
  ll r = 0;
  for (auto e : a) r += e;
  cout << r << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  int a,b; cin>>a>>b;
  cout<<a*b-(a+b)+1<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
#define ld long double
int power_mod(int num,int g)
{
    if(g==0)return 1;
    if(g%2==1)return (num*power_mod((num*num)%mod,g/2))%mod;
    return power_mod((num*num)%mod,g/2);
}
int power(int num,int g)
{
    if(g==0)return 1;
    if(g%2==1)return (num*power((num*num),g/2));
    return power((num*num),g/2);
}
int32_t main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    

    int x,y;
    cin>>x>>y;
    if(x==1 || y==1){
        cout<<1<<endl;
        return 0;
    }
    x*=y;
    cout<<(x+1LL)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<double,double>
#define PP pair<P,P>
using namespace std;

double di(double a, double b, double c, double d){
    double disx=c-a;
    double disy=d-b;
    double ans=sqrt(disx*disx+disy*disy);
    return ans;
}

int main(){
    int n; cin >> n;
    vector<P> re(n);
    rep(i,n) cin >> re[i].first >> re[i].second;

    auto g = [&](double x){
        double lg=0;
        double rg=1000;
        double maxd=0;
        double maxd2=0;
        double res=(double)INF;
        rep(i,50){
            maxd=0;
            maxd2=0;
            double nl=(lg*2+rg)/3;
            double nr=(lg+2*rg)/3;
            rep(j,n){
                maxd=max(maxd,di(x,nl,re[j].first,re[j].second));
                maxd2=max(maxd2,di(x,nr,re[j].first,re[j].second));
            }
            //printf("%.20lf\n",nl);
            if(maxd>maxd2) lg=nl;
            else rg=nr;
            res=min(res,min(maxd,maxd2));
        }
        return res;
    };

    double l=0.5;
    double r=1000;
    rep(i,50){
        double nl=(l*2+r)/3;
        //printf("%.20lf\n",nl);
        double nr=(l+2*r)/3;
        if(g(nl)>g(nr)) l=nl;
        else r=nr;
    }
    //printf("%.20lf\n",l);
    double ans=g(l);
    printf("%.20lf",ans);
return 0;
}



Measured memory_bytes: 256
import math
#def main(S, b):
if __name__ == '__main__':
    a, b, h, m = map(int, input().split())

    hun = m / 60
    zi = (h * 60 + m) / (60 * 12)

    theta = abs(hun - zi)
    #print(theta)
    C = math.cos(min(theta, 1 - theta) * 2 * math.pi)
    ans = math.sqrt(a * a + b * b - 2 * a * b * C)
    print(ans)


Measured memory_bytes: 9496
#include <iostream>
using namespace std;
int main(void){
    int h;
    int m;
    int s;
    int x;
 std::cin >>x;
 
 s = x%60;

 m = (x-s)/60%60;
 
 h = x/3600;

 std::cout <<  h << ":" << m <<":" << s << std::endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> s(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s.at(i).at(j);
    }
  }
  int dx[8]={1,1,1,0,0,-1,-1,-1},dy[8]={1,0,-1,1,-1,1,0,-1};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int count=0;
      if(s.at(i).at(j)=='.'){
        for(int k=0;k<8;k++){
          if(i+dx[k]>=0&&i+dx[k]<h&&j+dy[k]>=0&&j+dy[k]<w){
            if(s.at(i+dx[k]).at(j+dy[k])=='#'){
              count++;
            }
          }
        }
      s.at(i).at(j)='0'+count;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<s.at(i).at(j);
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
a = int(input())
#h, w = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

            
print(a+a**2+a**3)         
    
    













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

int main() {
  int n; cin >> n;
  int cnt = 0;
  bool ans = false;
  rep(i,n) {
    int a,b; cin >> a >> b;
    if (a==b) cnt++;
    else cnt = 0;
    if (cnt==3) ans = true;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3652
require 'pp'

N = gets.to_i
s = gets.chomp.chars.map(&:to_i)
# p s

size = 10
a1 = Array.new(size, false)
a2 = Array.new(size) { Array.new(size, false) }
a3 = Array.new(size) { Array.new(size) { Array.new(size, false) } }

s.each do |n|
  # p a1
  # p a2
  # p a3
  # puts

  size.times do |i|
    size.times do |ii|
      if a2[i][ii]
        a3[i][ii][n] = true
      end
    end
  end

  size.times do|i|
    if a1[i]
      a2[i][n] = true
    end
  end
  a1[n] = true # 最後に
end

pp a3.flatten.count{|x|x}


# 3 17 329


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int N,K,A[SIZE],B[SIZE];
LL an;
void solve(int mask){
    LL v=0;
    REP(i,N){
        if((A[i]&mask)==A[i])v+=B[i];
    }
    an=max(an,v);
}
int main(){
    RII(N,K);
    REP(i,N)RII(A[i],B[i]);
    solve(K);
    int now=0;
    REP(i,30){
        if((K>>i)&1)solve((K^(1<<i))|now);
        now|=1<<i;
    }
    printf("%lld\n",an);
    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>

int main(void){
  int A,B,C,D,count;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  do{
    C-=B;
    if(C<=0){
      count=1;
      break;
    }
    A-=D;
    if(A<=0){
      count=0;
      break;
    }
  }while(A>0&&C>0);
  
  if(count)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll a,b,c;
	vector<ll> v;
	cin>>a>>b>>c;
	v.pb(a);v.pb(b);v.pb(c);
	sort(v.begin(),v.end());
	if( (  v[2] - v[0] ) % 2 == (  v[2] - v[1] ) % 2 ){
		cout<< (v[2]+v[2]-v[1]-v[0])/2 <<endl;
	}
	else{
		cout<< (v[2]+v[2]-v[1]-v[0])/2 + 2 <<endl;
	}
	return 0;
}

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

if 0 in A:
  if len(set(A)) == 1:
    print("Yes")
    exit()
  elif len(set(A)) == 2:
    if A.count(0) *2 == (len(A)-A.count(0)):
      print("Yes")
      exit()
elif len(set(A)) == 3:
  temp =  list(set(A))
  if A.count(temp[0]) == A.count(temp[1]) == A.count(temp[2]):
    if (temp[0] ^ temp[1]) == temp[2]:
      print("Yes")
      exit()
print("No")

  
  


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define ALL(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }

#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

template<class T> void sort3a(T& a,T& b,T& c) {if (a>b) swap(a,b); if (b>c) swap(b,c); if (a>b) swap(a,b);}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int H,W; cin >> H>>W;
    vector<string> canvas(H); cin>>canvas;
    //cout_v(canvas);
    bool f = true;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (canvas[h][w] == '#'
             && (h != 0 && canvas[h-1][w] != '#')
             && (h != H-1 && canvas[h+1][w] != '#')
             && (w != 0 && canvas[h][w-1] != '#')
             && (w != W-1 && canvas[h][w+1] != '#')
            ) {
                f = false;
                break;
            } 
        }
    }
    Yes(f);
}


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

int main()
{
	char S[12];
	int tmp = 0;
	int ans = 0;

	cin >> S;
	int len = strlen(S);
	for (int i = 0; i < len; i++) {
		if (S[i] == 'A') {
			tmp++;
		}
		else if (S[i] == 'T') {
			tmp++;
		}
		else if (S[i] == 'C') {
			tmp++;
		}
		else if (S[i] == 'G') {
			tmp++;
		}
		else {
			ans = max(ans, tmp);
			tmp = 0;
		}
	}

	ans = max(ans, tmp);
	cout << ans << endl;
}


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

int main(){
  int a;
  cin >> a;
  for ( int i=1; i < 10; i++){
     for(int j=1; j< 10; j++){
        if(a==i*j){
           cout << "Yes";
           return 0;
        }

     }

  }
  cout << "No";
   
        }

Measured memory_bytes: 256
#include <cstdio>

int a[3];

int main(){
    scanf("%d %d %d", &a[0], &a[1], &a[2]);

    for(int i = 0; i < 3; i++){
        if(a[(1 + i) % 3] == a[(2 + i) % 3]){
            printf("%d\n", a[i]);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 128
n ,m = map(int,input().split())
L = list(map(int, input().split()))


ans = 0
sumL = sum(L)
for i in range(n):
    if L[i] >= sumL/(4*m):
        ans += 1
      
        
if ans >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;


fn main() {
    let line = read_vector::<usize>();
    let (a, b, c) = (line[0], line[1], line[2]);
    println!("{}", min(b / a, c));
}

#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int i = 0;
  bool ok = true;
  if(s[i] == 'A') i++;
  if(s[i] != 'K') ok = false;
  if(s[i + 1] != 'I' or s[i + 2] != 'H') ok = false;
  if(s[i + 3] == 'A') i++;
  if(s[i + 3] != 'B') ok = false;
  if(s[i + 4] == 'A') i++;
  if(s[i + 4] != 'R') ok = false;
  if(i + 5 < s.size() and s[i + 5] != 'A' or i + 6 < s.size()) ok = false;
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

int main(void){
  int n; cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  rep(i,n-1){
    if(a[i] == a[i+1]){
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 60, MOD = (int)(1e9 + 7);
char s[2][N];
int n, las;
long long ans;
int main() {
  scanf("%d",&n);
  scanf("%s%s",s[0]+1,s[1]+1);
  ans = 1;
  int p;
  if (s[0][1] == s[1][1])
    p = 2, las = 1, ans = 3;
  else p = 3, ans = 6, las = 2;
  for (int i = p ; i <= n ; ++ i) {
    if (s[0][i] == s[1][i]) {
      if (las == 1) (ans *= 2) %= MOD;
      else ans = ans;
      las = 1;
    } else {
      if (las == 1) (ans *= 2) %= MOD;
      else (ans *= 3) %= MOD;
      las = 2;
      ++ i;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String str=sc.next();
		if(n%2!=0)
			System.out.println("No");
		else {
			boolean same=true;
			
			for(int i=0;i<n/2;++i) {
				if(str.charAt(i)!=str.charAt(i+n/2)) {
					same=false;
					break;
				}
			}
			if(same)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n,cnt=0; cin>>n;
    vector<ll> s(n+1,0);
    map<ll,ll> mp;
    rep(i,n){
        ll a; cin>>a;
        s[i+1]=s[i]+a;
    }
    rep(i,n+1) mp[s[i]]++;
    for(auto x:mp) cnt += x.second*(x.second-1)/2;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 17016
from math import *


if __name__ == "__main__":
    n = int(input())
    arr = [int(x) for x in input().split(' ')]
    if(arr[0] > 1):
        print("-1")
    else:
        if(n == 0):
            print("1")
        else:
            dp = [0] * (n + 1)
            fl = True
            active_node, dp[0] = 1 - arr[0], 1
            i = 1
            while(fl and i < n):
                max_node = active_node * 2
                if(arr[i] > max_node):
                    fl = False
                else:
                    dp[i] = max_node
                    active_node = max_node - arr[i]
                i = i + 1
            if(fl):
                ans = 0
                max_node = active_node * 2
                if(arr[n] > max_node):
                    print("-1")
                else:
                    dp[-1] = max_node
                    min_req, max_req = 0, 0
                    i = n
                    while(fl and i >= 0):
                        min_req, max_req = min_req + arr[i], max_req + arr[i]
                        if(dp[i] < min_req):
                            fl = False
                        else:
                            curr_node = min(dp[i], max_req)
                            min_req, max_req = curr_node // 2, curr_node
                            ans = ans + curr_node
                        i = i - 1
                    print(ans if(fl) else "-1")
            else:
                print("-1")


Measured memory_bytes: 674264
#include <cstdio>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int as[100000+10];
int bs[100000+10];
int cs[100000+10];

ll bbs[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &as[i]);
  }
  REP(i, n) {
    scanf("%d", &bs[i]);
  }
  REP(i, n) {
    scanf("%d", &cs[i]);
  }

  sort(as, as + n);
  sort(bs, bs + n);
  sort(cs, cs + n);

  {
    int ia = 0;
    REP(ib, n) {
      int b = bs[ib];
      while(ia < n && as[ia] < b) {
        ++ia;
      }
      bbs[ib] = (ib == 0 ? 0 : bbs[ib-1]) + ia;
      // cerr << ">> " << bbs[ib] << endl;
    }
  }

  ll res = 0;
  {
    int ib = 0;
    REP(ic, n) {
      int c = cs[ic];
      while(ib < n && bs[ib] < c) {
        ib++;
      }
      res += ib-1 < 0 ? 0 : bbs[ib-1];
      // cerr << "> " << res << endl;
    }
  }

  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        if(n%2==0)
            printf("%d\n",n);
        else
            printf("%d\n",n*2);
    }
    return 0;
}

Measured memory_bytes: 256
loop do
  a, op, b = gets.chomp.split(" ")
  a, b = a.to_i, b.to_i

  case op
  when "+"
    puts a + b
  when "-"
    puts a - b
  when "*"
    puts a * b
  when "/"
    puts a / b
  when "?"
    break
  else
    exit 1
  end
end

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

int main(){
    int Llist[100] = {0};
    int N, X;
    cin >> N >> X;
    for(int i=0; i<N; i++){
        cin >> Llist[i];
    }
    int d = 0;
    for(int i=1; i<=N; i++){
        d += Llist[i-1];
        if(d > X){
            cout << i;
            return EXIT_SUCCESS;
        }
    }
    cout << N+1;
    return EXIT_SUCCESS;
}

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

int N;
string S;

int main(void) {
	cin >> N >> S;
	int r_cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'R')
			++r_cnt;
	}
	int ans = 0;
	if (r_cnt != 0 && r_cnt != N) {
		for (int i = 0; i < r_cnt; ++i) {
			if (S[i] == 'W')
				++ans;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3704
#include<cstdio>
using namespace std;
int main()
{
	int n,m,s;
	scanf("%d%d%d",&n,&m,&s);
	for (int i=1;i<=m;i++) printf("%d ",s);
	for (int i=m+1;i<=n;i++) printf("%d ",s%1000000000+1);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GeTAC | diff GeTAC.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GeTAC.cpp && ./a.out

/*
 
 5/9/2019
 
 16:17-
 
 */

const int MAX_N=1e6+1;
string S;
int N,Q,A[MAX_N],cum[MAX_N];

void solve(int L, int R) {
  --L;
  int res=cum[R]-cum[L];
  if(L>0&&S[L]=='C'&&S[L-1]=='A') --res;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>Q>>S;
  ZERO(cum);
  FOR(i,1,N) if(S[i]=='C'&&S[i-1]=='A') A[i]=1;
  REP(i,N) cum[i+1]=cum[i]+A[i];
  REP(i,Q) {
    int l,r; cin>>l>>r;
    solve(l,r);
  }
  
  return 0;
}


Measured memory_bytes: 7248
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll commemo[1000][1000];
ll dp[500][500];
ll bsum[500][500];

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

int main()
{
    ll n, c;
    cin >> n >> c;
    ll a[500], b[500];
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    for(int j = 0; j <= c; j++){
        for(int i = 1; i <= 400; i++){
            bsum[i][j] = (bsum[i - 1][j] + modpow(i, j)) % MOD;
        }
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= c; j++){
            for(int k = 0; k <= j; k++){
                dp[i][j] = (dp[i][j] + dp[i - 1][k] * ((bsum[b[i]][j - k] + MOD - bsum[a[i] - 1][j - k])) % MOD) % MOD;
            }
        }
    }
    cout << dp[n][c] << endl;
}

Measured memory_bytes: 3968
a,b = map(str,input().split())
dic = {"2":1,"3":2,"4":3,"5":4,"6":5,"7":6,"8":7,"9":8,"10":9,"11":10,"12":11,"13":12,"1":13}

if dic[a] > dic[b]:
  print("Alice")
elif dic[a] < dic[b]:
  print("Bob")
else:
  print("Draw")

Measured memory_bytes: 3064