akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
   int x;
   cin>>x;

   x = x;


   cout<<(360)/(__gcd(x,(int)360))<<endl; 
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3632
L, R = map(int, input().split())
  
if R - L >= 2018:
  print(0)
  exit()
  
lst = []
for i in range(L,R+1):
  lst.append(i%2019)
  
lst.sort()

if lst[0] == 0:
  print(0)
  exit()
  
rlt = 2020
for i in range(len(lst)):
  for j in range(i+1,len(lst)):
    rlt = min(rlt, (lst[i]*lst[j])%2019)
    
print(rlt)

Measured memory_bytes: 65416
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  int ans = 1000000000;
  
  rep(i, N) {
    int m=0;
    while(A[i]%2 == 0 && A[i] != 0) {
      A[i] /= 2;
      m++;
    }
    ans = min(ans, m);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(void){
    for(int i = 1; ; ++i){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        cout << min(x, y) << " " << max(x, y) << endl;
    }
    return 0;
}


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

int n, m;
bool graph[9][9];
int res = 0;


int main(){
  rep(i, 9)rep(j, 9)graph[i][j] = false;
  cin >> n >> m;
  rep(i, m){
    int a, b;
    cin >> a >> b; a--; b--;
    graph[a][b] = true;
    graph[b][a] = true;
  }
  vector<int> seq(n);
  rep(i, n)seq[i] = i;
  //rep(i, n){rep(j, n)cout << graph[i][j]; cout << endl;}
  do{
    if(seq[0] != 0) break;
    int cnt = 0;
    while(cnt < n - 1 && graph[seq[cnt]][seq[cnt+1]]){
      cnt++;
    }
    if(cnt == n-1) res++;
    //rep(i, n)cout << seq[i];cout << endl;
  }while(next_permutation(seq.begin(), seq.end()));
  
  //res /= 2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s < t) cout << "Yes\n";
  else cout << "No\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dot cout<< setprecision(20)<<endl;
#define vsor(x) sort(x.begin(),x.end());
#define vrev(x) reverse(x.begin(),x.end());
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define bit(b,n) for(int b=0;b<(1<<(ll)(n));b++)

using namespace std;

int main(){
string s,t;
cin>>s>>t;
int ans=0;
rep(i,s.size()){
    if(s.at(i)!=t.at(i)){
    ans++;
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 3856
#include<iostream>
using namespace std;
int main()
{
  unsigned long long int FACTORIAL[21];
  FACTORIAL[0] = 1;
  for(int i=1; i<21; i++) FACTORIAL[i] = FACTORIAL[i-1]*i;
  string s;
  int odd=0;
  cin>>s;
  int num[26]={};
  unsigned long long int ans;
  for(int i=0; i<s.size(); i++){
    num[s[i]-'a']++;
  }
  for(int i=0; i<26; i++){
    odd+=num[i]&1;
  }
  if(odd>1){
    cout<<0<<endl;
  }else{
    ans = FACTORIAL[s.size()/2];
    for(int i=0; i<26; i++){
      ans/=FACTORIAL[num[i]/2];
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1180
#!/usr/bin/env perl

use strict;
use warnings;

chomp(my $input = <STDIN>);
my ($n, $p) = split(/ /, $input);

if ($n == 1){
    print "$p\n";
    exit;
}

my $ans = 1;
my $i = 2;
my $pp = $p;
while ($i ** 2 <= $p){
#    print "$p % $i = " . ($p % $i) ."\n";
    if ($pp % $i == 0){
        if ($pp % ($i ** $n) == 0){
            $ans *= $i;
            $pp /= ($i ** $n);
        }
        else{
            $pp /= $i;
        }
    }
    else{
        $i++;
    }
}

print "$ans\n";


Measured memory_bytes: 640
#! /usr/bin/python3
""" いっしょ / Be Together """

N = int(input())
a = list(map(int, input().split()))
# 1≦N≦100, −100≦ai≦100

test = False

def calc_cost(l):
    """ コストを全探索してリストで返す関数 """
    cost = []
    max_l = max(l)
    min_l = min(l)

    for i in range(min_l, max_l + 1):
        temp_cost = 0
        for x in l:
            temp_cost += (x-i)**2
        if test:
            print('i =', i, end='\t')
            print('temp_cost =', temp_cost)
        cost.append(temp_cost)

    if test:
        print('cost         =', cost)
        print('sorted(cost) =', sorted(cost))
    return cost


def main():
    """ 最小コストを出力する関数 """
    answer = min(calc_cost(a))
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1

const int maxn = 2e5 + 7;
const LL INF = 1e18;

vector<LL>v1,v2;
LL k;

bool check(LL x) {
//    cout << "x = " << x << endl;
    int len1 = v1.size() , len2 = v2.size();
    LL ans = 0;
    /// < * <
    for(int i = 0 ; i < len1 ; i++) {
        LL l = i + 1 , r = len1 - 1;
        LL res = len1;
//        cout << "i = " << i << endl;
        while(l <= r) {
            LL mid = (l + r + 1LL) >> 1LL;
//            cout << "mid = " << mid << endl;
            if(v1[i] * v1[mid] <= x) {
//                cout << "YES" << " mid = " << mid << " " << v1[i] << " " << v1[mid] << " val = " << v1[i] * v1[mid] << endl;
                res = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
//        cout << "res = " << res << endl;
        ans += len1 - res;
    }
//    cout << "ans1 = " << ans << endl;
    /// > * >
    for(int i = 0 ; i < len2 ; i++) {
        LL l = i + 1 , r = len2 - 1;
        LL res = i;
        while(l <= r) {
            LL mid = (l + r + 1LL) >> 1LL;
            if(v2[i] * v2[mid] <= x) {
                res = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        ans += res - i;
    }
//    cout << "ans2 = " << ans << endl;
    /// < * >
    for(int i = 0 ; i < len1 ; i++) {
        LL l = 0 , r = len2 - 1;
        LL res = len2;
        while(l <= r) {
            LL mid = (l + r + 1LL) >> 1LL;
            if(v1[i] * v2[mid] <= x) {
                res = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        ans += len2 - res;
    }
//    cout << "ans3 = " << ans << endl;
    return ans >= k;
}

int main() {
    int n;
    while(~scanf("%d%lld",&n,&k)) {
        v1.clear(),v2.clear();
        for(int i = 1 ; i <= n ; i++) {
            LL x;
            scanf("%lld",&x);
            if(x < 0) v1.push_back(x);
            else v2.push_back(x);
        }

        sort(v1.begin(),v1.end());
        sort(v2.begin(),v2.end());

//        for(int i = 0 ; i < v1.size() ; i++) {
//            cout << v1[i] << " ";
//        }
//        cout << endl;
//        for(int i = 0 ; i < v2.size() ; i++) {
//            cout << v2[i] << " ";
//        }
//        cout << endl;

        LL l = -INF , r = INF;
        LL ans = 0;
        while(l <= r) {
            LL mid = (l + r + 1LL) >> 1LL;
            if(check(mid)) {
                ans = mid;
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


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

int main()
{
   int N, L;
   cin >> N >> L;
   vector<int> apple(N);
   int sum = 0;
   for(int i = 0; i < N; i++)
   {
      apple[i] = L + i;
      sum += apple[i];
   }
   int min_diff = abs(apple[0]);
   int ans = sum - apple[0];
   for(int i = 0; i < N; i++)
   {
      int diff = abs(apple[i]);
      if(min_diff > diff)
      {
         min_diff = diff;
         ans = sum - apple[i]; 
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    deque<char> S;
    string str; cin >> str;

    for(auto i : str) S.emplace_back(i);

    int n; cin >> n;

    bool reverse = false;
    rep(i, n) {
        int buffer; cin >> buffer;
        if(buffer == 1) {
            reverse = !reverse;
            continue;
        }

        int fuck; cin >> fuck;

        if(fuck == 1) {
            char input; cin >> input;
            if(reverse) S.emplace_back(input);
            else        S.emplace_front(input);
        } else {
            char input; cin >> input;
            if(reverse) S.emplace_front(input);
            else        S.emplace_back(input);
        }
    }

    if(reverse) {
        for(auto i = rbegin(S); i != rend(S) ; ++i) cout << *i;
    }else {
        for(auto i = begin(S); i != end(S); ++i) cout << *i;
    }
}

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

ll gcd(ll a, ll b){
    //cout << "a : " << a << "b : " << b << endl;
    if(b == 0)
        return a;
    else
        return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
    int n;
    cin >> n;
    set<int>  s;
    if (n == 2){
        ll a, b;
        cin >> a >> b;
        ll g = gcd(a, b);
        for (int i = 1; i <= sqrt(g); i++){
            if(g % i==0){
                s.insert(i);
                s.insert(g / i);
            }
        }
        for (auto itr = s.begin(); itr != s.end(); itr++){
            cout << *itr << endl;
        }
    }else{
        ll a, b, c;
        cin >> a >> b >> c;
        ll g = gcd(a, b);
        //cout << g << endl;
        g = gcd(g, c);
        //cout << g << endl;
        for (int i = 1; i <= sqrt(g); i++)
        {
            if(g % i==0){
                s.insert(i);
                s.insert(g / i);
            }
        }
        for (auto itr = s.begin(); itr != s.end(); itr++){
            cout << *itr << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a < c && c < b)
    {
        cout << "Yes" << endl;
    }
    else if (b < c && c < a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#define Max(x,y) ((x)>(y)?(x):(y))

static int **verlist;
static int edgef(unsigned int u, unsigned int v){
	int rtn;
	
	if(u < v){
		unsigned int tmp;
		tmp = u;
		u = v;
		v = tmp;
	}
	rtn = verlist[v][u-v-1];

	return rtn;
}

static struct _graph{
	unsigned int vertex;
	int (*edge)(unsigned int, unsigned int);
};
typedef struct _graph Graph;

unsigned int CntPath(Graph *gp, unsigned int visiting, int *visited){
	unsigned int i, cnt, flag, rtn;
	cnt = 0;
	flag = 1;

	visited[visiting] = 1;
	for(i = 0; i < gp->vertex; i++){
		if(!(visited[i])){
			flag = 0;
			if(gp->edge(visiting, i)){
				cnt += CntPath(gp, i, visited);
			}
		}
	}
	visited[visiting] = 0;

	rtn = Max(cnt, flag);
	return rtn;
}

int main(){
	unsigned int N, M, i, j, a, b;
	char line[32];
	int *visited;
	Graph *gp1;

	fgets(line, 32, stdin);
	sscanf(line, "%u %u", &N, &M);
	verlist = (int **)malloc(sizeof(int *)*(N-1));
	for(i = 0; i < N-1; i++){
		unsigned int sfx = N-i-1;
		verlist[i] = (int *)malloc(sizeof(int)*sfx);
		for(j = 0; j < sfx; j++) verlist[i][j] = 0;
	}
	for(i = 0; i < M; i++){
		fgets(line, 32, stdin);
		sscanf(line, "%u %u", &a, &b);
		verlist[a-1][b-a-1] = 1;
	}

	gp1 = (Graph *)malloc(sizeof(Graph));
	gp1->vertex = N;
	gp1->edge = edgef;
	visited = (int *)malloc(sizeof(int)*N);
	for(i = 0; i < N; i++) visited[i] = 0;
	printf("%u\n", CntPath(gp1, 0, visited));

	free(visited);
	free(gp1);
	for(i = 0; i < N-1; i++) free(verlist[i]);
	free(verlist);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


			var data = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			long n = data[0];
			long a = data[1];
			long b = data[2];

			var list = new List<long>();

			long ans = 0;

			for (int i = 1; i <= n; ++i) {
				long digit = GetDigit(i);
				long ans2 = 0;
				for (int j = 1; j <= digit; ++j) {
					ans2 += Digit(i, j);
				}

				if (ans2 >= a && ans2 <= b) {
					ans += i;
				}
			}

            Console.WriteLine(ans.ToString());

            Console.Out.Flush();
        }

		static public long Digit(long n, int d)
		{
			return (int)(n / (long)Math.Pow(10, d - 1) % 10);
		}

		static public long GetDigit(long n)
		{
			return (int)Math.Log10(n) + 1;
		}
    }
}


Measured memory_bytes: 11604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r = x;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        x -= m;
        r = min(r, m);
    }

    cout << n + x / r << endl;

    return 0;
}

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

int main()
{
    for(;;){
        int n, y;
        cin >> n >> y;
        if(n == 0)
            return 0;

        int ret;
        double maxMoney = 0.0;
        for(int i=0; i<n; ++i){
            int b, r, t;
            cin >> b >> r >> t;
            double money;
            if(t == 1)
                money = 1.0 + y * r / 100.0;
            else
                money = pow(1.0 + r / 100.0, y);
            if(money > maxMoney){
                maxMoney = money;
                ret = b;
            }
        }

        cout << ret << endl;
    }
}

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

int main ()
{
    int i=0 ;
    double n=0 ,cmp=0 ;
    double s[1001] = {0} ;
    double a2=0 ;
    double m=0 ;

    while(1)
    {
        a2=0 ;
        cmp=0 ;
        m=0 ;
        scanf("%lf" ,&n) ;

        if (n == 0) break ;

        for (i=0 ;i < n ;i++)
        {
            scanf("%lf" ,&s[i]) ;
            cmp = cmp + s[i] ;
        }
        m = cmp / n ;

        for (i=0 ;i < n ;i++)
        {
            a2 = a2 + pow((s[i] - m) ,2) / n ;
        }

        printf("%f\n" ,sqrt(a2)) ;
    }

    return 0 ;
}

Measured memory_bytes: 656
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());
    map<int, int> valcount;
    int sum = 0;
    for (auto &&i : a) {
        valcount[i]++;
        sum += i;
    }

    int q;
    cin >> q;
    for (int qi = 0; qi < q; qi++) {
        int b, c;
        cin >> b >> c;

        sum += (c - b) * valcount[b];
        valcount[c] += valcount[b];
        valcount[b] = 0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 9948
eval'A=#'+`tr ' ' ,`
c=[0]*-~t=10**6
A.map{c[_1]+=1}
$><<((2..t).any?{|i|(1..t/i).sum{c[_1*i]}>1}?A.reduce(:gcd)>1?"not":"setwise":"pairwise")<<" coprime"

Measured memory_bytes: 139016
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,temp;
    cin>>n;
    map<int,int> m;
    for(int i=1;i<n;i++){
        cin>>temp;
        m[temp]++;
    }
    for(int i=1;i<=n;i++){
        if(m.find(i)!=m.end()){
            cout<<m[i]<<endl;
        }else
        {
            cout<<0<<endl;
        }
        
    }
    return 0;
}

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

int main(){
	int n,m;
	while(1){
		int a[1000]={},ans=0;
		cin>>n>>m;
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(a[i]+a[j]<=m)ans=max(ans,a[i]+a[j]);
			}
		}
		if(ans)cout<<ans<<"\n";
		else cout<<"NONE\n";
	}
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb 	push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
const int N=2e3+5;
int gcd(int a,int b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
main()
{
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	deque<int>dq;
	for(int i=0;i<n;i++)
	{
		int p=lower_bound(all(dq),a[i])-dq.begin();
		// cout<<p<<" ";
		if(p==0)dq.push_front(a[i]);
		else dq[p-1]=a[i];
	}
	// for(auto i:dq)cout<<i<<" ";cout<<endl;
	cout<<dq.size()<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int res = 0;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        res += s[i] - '0';
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] > '0') {
            s[i]--;
            for (int j = i + 1; j < n; j++) {
                s[j] = '9';
            }
            int ss = 0;
            for (int ii = 0; ii < n; ii++) {
                ss += s[ii] - '0';
            }
//            cout << s;
            res = std::max(res, ss);
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var success = false
    for (i in 0 .. n/4) {
        for (j in 0 .. n / 7) {
            if (4 * i + 7 * j == n) {
                success = true
                break
            }

        }
    }

    val result = if (success) "Yes" else "No"
    print(result)
}

Measured memory_bytes: 31828
K = gets.to_i

def f(n)
  n.to_f / n.to_s.split(//).map(&:to_i).inject(:+)
end

n, i = 1, 0
K.times do
  puts n
  i += 1 if f(n + 10**i) > f(n + 10**(i + 1))
  n += 10**i
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int dp[100001],in[100001];


int main()
{
    vector<vector<int>> e;
    int n,m;
    queue<int> que;
    cin>>n>>m;
    e.resize(n+1);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        e[x].emplace_back(y);
        ++in[y];
    }
    for(int i=0;i<=n;i++)
        if(!in[i]) que.push(i);
    while(que.size())
    {
        int v=que.front();
        que.pop();
        for(auto& u:e[v])
        {
            --in[u];
            dp[u]=max(dp[u],dp[v]+1);
            if(!in[u]) que.push(u);
        }
    }
    int mx=0;
    for(int i=0;i<=n;i++)
        mx=max(mx,dp[i]);
    cout<<mx;
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a==1&&b!=1)cout<<"Alice";
else if(b==1 &&a!=1)cout<<"Bob";
else if(a>b)cout<<"Alice";
else if(b>a)cout<<"Bob";
else if(a==b) cout<<"Draw";

}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,d,a;
cin>>n>>d>>a;
vector<p>v;
vector<ll>num;
for(ll i=0;i<n;i++)
{
    ll a,b;
    cin>>a>>b;
    v.pb({a,b});

}
sort(v.begin(),v.end());
vector<ll>bomb(n,0);
ll ans=0;

for(ll i=0;i<n;i++)
{
    ll b=v[i].se;
    ll no=ceil(b/(1.0*a));
    num.pb(no);
}
vector<p>arr;
for(ll i=0;i<n;i++)
{
    ll x=v[i].fi;
    arr.pb({x,i});
    arr.pb({x+2*d+1,i});
}
sort(arr.begin(),arr.end());
set<ll>s;
ll pre=0;
for(ll i=0;i<arr.size();i++)
{
    ll cal=arr[i].fi;
    ll ind=arr[i].se;
    //cout<<ind<<" ";
    if(s.find(ind)!=s.end())
    {
        s.erase(ind);
        pre-=num[ind];
    }else
    {
        s.insert(ind);
        if(num[ind]<=pre)
        {
            num[ind]=0;
        }else
        {
            ll extra=num[ind]-pre;
            num[ind]=extra;
            ans+=extra;
            pre+=extra;
        }
    }
}
cout<<ans<<endl;



return 0;
}


Measured memory_bytes: 22760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[40],t,now;
int ans=0,n;
int main()
{
	cin>>t;
	a[0]=0;
	for(int i=1;i<=35;i++)
	{
		a[i]=2*pow(3,i-1)-2;
		if(a[i]>t)
		{
			n=i-1;
			break;
		}
	}
	//cout<<n<<endl;
	ans+=2*n-2;
	t-=a[n];
	now=pow(3,n-1);
	while(t)
	{
		ans+=t/now;
		t%=now;
		now/=3;
	}
	cout<<ans<<endl;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  vi a(n);
  rep(i, n) {
    std::cin >> a[i];
  }
  int ans = inf;
  rrep(p, 100) {
    int tmp = 0;
    for (auto &x : a) {
      tmp += (x - p) * (x - p);
    }
    chmin(ans, tmp);
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int c[105];

int main(){
    int n;
    cin >> n;
    rep(i,10)rep(j,10)c[i*j]=1;
    if(c[n])cout << "Yes" << endl;
    else cout << "No" << endl;
} 

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

int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int p=max({a,b,c});
	for(int i=0;i<k;i++){
		p*=2;
	}
	cout<<p+a+b+c-max({a,b,c})<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
N, K, Q = [int(v) for v in input().split()]



A = np.zeros(Q, dtype = 'int64')
for i in range(Q):
    A[i] = int(sys.stdin.readline())

pt = np.zeros(N, dtype = 'int64')

for q in range(Q):
    pt[A[q] - 1] += 1

for n in range(N):
    if pt[n] > Q - K:
        print('Yes')
    else:
        print('No')
    



Measured memory_bytes: 20784
// -_-
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
#define  sort1(v) sort(v.begin(), v.end()) 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;

 
signed main() 
{

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	int ans = 0;
	fori(i, 1, n)
	{
		int c = 0;
		for(int j = i; j > 0; j = j/10)
		c++;
		if(c%2 == 1) ans++;
		
	}
	cout << ans;
	

	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, ok[250009];
int main() {
	while (cin >> m >> n, m) {
		fill(ok, ok + 250000, -1);
		for (int i = 0; i < m; i++) ok[i >> 5] &= ~(1 << (i & 31));
		for (int i = m; i < 7368800; i++) {
			if (!(ok[i >> 5] & (1 << (i & 31)))) continue;
			for (int j = i * 2; j < 7368800; j += i) ok[j >> 5] &= ~(1 << (j & 31));
			if (n-- == 0) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

public class Main {
    
    static int n;
    static int m;
    static int count=0;
    static Set<Integer>[]  a;
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(st.nextToken());
        m=Integer.parseInt(st.nextToken());
        a=new Set[n];
        int aa,bb;
        for(int i=0;i<n;i++){ a[i]=new HashSet<>(); }
        for(int i=0;i<m;i++){
            st=new StringTokenizer(br.readLine());
            aa=Integer.parseInt(st.nextToken())-1;
            bb=Integer.parseInt(st.nextToken())-1;
            a[aa].add(bb);
            a[bb].add(aa);
        }
        
        /*
        for(int i=0;i<n;i++){
            System.out.println(i);
            for(int nn:a[i]){ System.out.print(nn+" "); }
            System.out.println();
        }*/
        
        boolean[] dp=new boolean[n];
        Arrays.fill(dp,false);
        dp[0]=true;
        dfs(dp,0);
        System.out.println(count);
    }
    
    static void dfs(boolean[] dp,int index){
        int c=0;
        while(c<dp.length&&dp[c]){ c++; }
        if(c==dp.length){ count++; return; }
        boolean[] table=Arrays.copyOf(dp, dp.length);
        for(int next:a[index]){
            if(!table[next]){
                table[next]=true;
                dfs(table,next);
                table[next]=false;
            }
        }
    }
    
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

  
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define re(n) for (int i = 0; i < n; ++i)
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define eb emplace_back

//OutPut
#define ps(x) cout << x << endl;
#define ps_end(x) {ps(x); return;}


const int md = 998244353; //998244353 ;
const int dir[4][2] = {{-1,0}, {1, 0}, {0, -1}, {0, 1}};
template<class T> bool ckmin(T& a, const T& b) { 
  return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
  return a < b ? a = b, 1 : 0; }
ll pw(auto x, auto y) {  ll s = 1; while(y) { if (y & 1) s = s * x % md; x= 1LL * x * x % md; y /= 2; } return s;}

const int maxn = 1e6 + 10;

int n, m, nq, nk;
string str;

void task() {
  cin >> n;
  cin >> nk;
  vi l(nk), r(nk);
  vector<long long> sum(nk);
  re(nk) cin >> l[i] >> r[i];
  vector<ll>  dp(n + 1);
  dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j < nk; ++j) {
      if (i - l[j] >= 1) sum[j] += dp[i - l[j]], sum[j] %= md;
      if (i - r[j] - 1 >= 1) sum[j] -= dp[i - r[j] - 1], sum[j] %= md;
    }
    for (int j = 0; j < nk; ++j) {
      dp[i] += sum[j];
      dp[i] %= md;
    }
  } 
  dp[n] = (dp[n] %md + md) % md;
  cout << dp[n] << endl;
  //Read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  int T = 1;
 // cin >> T;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
  * write down
*/


Measured memory_bytes: 4776
#retryを宮崎さんの回答を元に修正
def changeSecond(time)
  splitedTime = time.split(":").map(&:to_i)
  secondTime = 60*60*splitedTime[0] + 60*splitedTime[1] + splitedTime[2]
  return secondTime
end

oneDaySecond = 60*60*24
loop do
  n = gets.chomp.to_i
  break if n == 0

  s = Array.new(oneDaySecond,0)
  (0..n-1).each do |i|
    start, finish = gets.chomp.split(" ").map(&:to_s)
    start = changeSecond(start)
    finish = changeSecond(finish)
    s[start] += 1
    s[finish] += -1
  end 
  (0...oneDaySecond-1).each do |j|
    s[j+1] += s[j]
  end
  p s.max
end



Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
string s;
int main(){
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]=='L'){
				cout << "No" << endl;
				return 0;
			}
		}else{
			if(s[i]=='R'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;
bool DEBUG = false;

int main(){
    int n;
    long long k;
    cin >> n >> k;
    vector<int> a(n);
    int t1;
    for(auto& ai:a){
        cin >> t1;
        ai = t1-1;
    }

    int p=0;
    vector<int> cities;
    cities.push_back(0);
    map<int, int> v;
    v.insert(make_pair(0, 0));
    /*
    while(true){
        p = a.at(p);
        if(p==0) break;
        else cities.push_back(p);
    }*/

    int beg=0, end=0;
    int i =1;
    while(true){ 
        p = a.at(p);
        if(DEBUG)cout << p << endl;
        if(p==0){
            beg = 0;
            end = i;
            break;
        }
        if(v[p]){
            
            if(DEBUG) cout << "p, v[p]" << p << v[p] <<endl;
            beg = v[p];
            end = i;
            break;
        }else{
            if(DEBUG) cout << "p, v[p]" << p << v[p] <<endl;
            v[p] = i;
            i++;
        }
    }
    
    if(DEBUG) cout << beg << end << endl;
    vector<int> vlist(end);
    for(const auto& vi : v)vlist.at(vi.second) = vi.first;
    if(DEBUG){
    for(auto& vi: vlist) cout << vi;
    cout << endl;}
    if(k<beg){
        cout << vlist.at(k)+1 << endl;
    }else{
        cout << vlist.at((k-beg)%(end-beg) + beg)+1 << endl;
    }

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
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 (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, X, M;
    cin >> N >> X >> M;

    V<V<ll>> D(40, V<ll>(M, 0));
    V<V<ll>> S(40, V<ll>(M, 0));

    REP(i, M){
        D[0][i] = (i*i)%M;
        S[0][i] = i;
    } 

    REP(i, 39){
        REP(j, M){
            D[i+1][j] = D[i][D[i][j]]; 
            S[i+1][j] = S[i][j] + S[i][D[i][j]];
        }
    }

    ll res = 0;
    ll now = X;
    REP(i, 40){
        if(N>>i & 1){
            res += S[i][now];
            now = D[i][now];
        }
    }

    cout << res << endl;

    // dump(res)
    // dump(now)

    return 0;
}

Measured memory_bytes: 66664
def insertion_sort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            cnt += 1
            j -= g
        A[j+g] = v

    return A, cnt


def shell_sort(A, n):
    cnt = 0
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    m = len(G)

    for g in G:
        A, cnt = insertion_sort(A, n, g, cnt)

    return m, G, cnt, A


n = int(input().rstrip())
A = []
for _ in range(n):
    A.append(int(input().rstrip()))

m, G, cnt, A = shell_sort(A, n)

print(m)
print(' '.join(list(map(str, G))))
print(cnt)
print('\n'.join(list(map(str, A))))


Measured memory_bytes: 125972
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    var A = lines[1].split(" ").map(i => Number(i))
    var B = lines[2].split(" ").map(i => Number(i))
    var C = lines[3].split(" ").map(i => Number(i))

    A.sort((a, b) => a - b); // console.log(A)
    B.sort((a, b) => a - b); // console.log(B)
    C.sort((a, b) => a - b); // console.log(C)


    var ans = 0;

    for (var b = 0; b < N; b++) {
        var x = binary_search_A(B[b], A, -1, N) + 1;
        var y = N - binary_search_C(B[b], C, -1, N);

        // console.log(x, y)
        ans += x * y;
    }
    console.log(ans)
});

function binary_search_A(target, array, l, r, ab) {
    var center = Math.floor((l + r) / 2);
    while (l + 1 < r) {
        if (array[center] < target) { l = center; center = Math.floor((l + r) / 2); }
        else { r = center; center = Math.floor((l + r) / 2); }
    }
    return (center);
}

function binary_search_C(target, array, l, r, ab) {
    var center = Math.ceil((l + r) / 2);
    while (l + 1 < r) {
        if (array[center] <= target) { l = center; center = Math.ceil((l + r) / 2); }
        else { r = center; center = Math.ceil((l + r) / 2); }
    }
    return (center);
}


Measured memory_bytes: 56040
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n,k;
	cin>>n>>k;
	vl a(n);
	cin>>a;
	vl dp(k+1);
	for(int i=0;i<=a[0];i++) dp[i]=1;
	for(int i=1;i<n;i++){
		vl tmp=dp;
		vl pre(k+1);
		pre[0]=dp[0];
		for(int j=1;j<=k;j++) pre[j]=(pre[j-1]+dp[j])%mod;
		for(int l=1;l<=k;l++){
			if(a[i]>=l) tmp[l]=(tmp[l]+pre[l-1])%mod;
			else tmp[l]=(tmp[l]+pre[l-1]-pre[l-a[i]-1]+mod)%mod;
		}
		dp=tmp;
	}
	cout<<dp[k];
	
	
 
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 2648
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    ll A, B;
    cin >> A >> B;

    vector<int> digits;
    ll twos = 1;
    for (int i = 0; i < 42; i++) {
        ll one_cnt_a = 0, one_cnt_b = 0;

        one_cnt_a += (A - 1) / (twos * 2) * twos;
        one_cnt_a += max(0LL, (A - 1) - (((A - 1) / (twos * 2) * (twos * 2)) + twos) + 1);

        one_cnt_b += B / (twos * 2) * twos;
        one_cnt_b += max(0LL, B - ((B / (twos * 2) * (twos * 2)) + twos) + 1);

#ifdef DEBUG
        printf("i: %d, one_cnt_a: %lld, one_cnt_b: %lld\n", i, one_cnt_a, one_cnt_b);
#endif

        ll one_cnt = one_cnt_b - one_cnt_a;

        if (one_cnt % 2 == 1) {
            digits.push_back(1);
        } else {
            digits.push_back(0);
        }

        twos *= 2;
    }

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

#ifdef DEBUG
    printf("0b");
    for (int i = 0; i < (int) digits.size(); i++) {
        cout << digits[i];
    }
    cout << endl;
#endif

    ll ans = 0;
    for (int i = 0; i < (int) digits.size(); i++) {
        ans *= 2;
        if (digits[i]) {
            ans += 1;
        }
    }
    cout << ans << endl;

    return 0;
}


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

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

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int r = in.nextInt();
            out.println(3*r*r);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 21460
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main()
{

	int ans;
	int n=2;
	vector<int>vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
	}

	ans = vec[0] - vec[1] * 2;
	if (0 >= ans) {
		ans = 0;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256