akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int,input().split()))

di = 10**9+7
lis = [0 for i in range(61)]

for i in a:
    for j in range(61):
        if (i>>j & 1):
            #print(i,j)
            lis[j]+=1

#print(lis)

su = 0
for j in range(61):
    su+=lis[j]*(n-lis[j])*2**j
    su=su%di

print(su)


Measured memory_bytes: 122936
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
t = inp
w2 = [0]
w1 = [0]
s1 = 0
s2 = 0
n.times do |i|
  if i%2 == 0
    s1 += t[i]
    w1 << s1
  else
    s2 += t[i]
    w2 << s2
  end
end
w2 << s2
ans = -1e20
if (n%2 == 0)
  (0...(w1.size)).each do |i|
    ans = big(ans,w1[i]+(w2[-1]-w2[i]))
  end

else
  dp = na2(4,2,-1e20)
  dpn = na2(4,2,-1e20)
  dp[0][0] = 0
  n.times do |i|
    dpn = na2(4,2,-1e20)
    dpn[2][1] = dp[2][0] + t[i]
    dpn[1][1] = dp[1][0] + t[i]
    dpn[0][1] = dp[0][0] + t[i]
    dpn[2][0] = [dp[2][1],dp[1][0]].max
    dpn[1][0] = [dp[1][1],dp[0][0]].max
    dpn[0][0] = dp[0][1]
    dp = dpn
  end
  p dp.flatten.max
  exit
end
p ans


Measured memory_bytes: 38600
import math

n, k = map(int,input().split())
l = list(map(int,input().split()))

ans = float('inf')

for i in range(k-1,n):
    bns=min(abs(l[i]-l[i-k+1])+abs(l[i]),abs(l[i]-l[i-k+1])+abs(l[i-k+1]))
    ans=min(ans,bns)
print(ans)


Measured memory_bytes: 20312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int main() {
	int k, n;
	cin >> k >> n;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	VSORT(v);
	
	vector<int> len(n);
	ll sum = 0, ans = 1e18;
		
	for(int i = 0; i < n-1; i++) {
		len[i] = v[i+1] - v[i];
		sum += len[i];
	}
		
	len[n-1] = k - (v[n-1] - v[0]);
	sum += len[n-1];
		
	for(int i = 0; i < n; i++)
		ans = min(ans, sum-len[i]);
		
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define next nxt

int n,k,d[N],x[N],y[N],next[N],p[N],h[N],ans[N];

void add(int a,int b){
	x[++k]=a;y[k]=b;next[k]=p[a];p[a]=k;d[a]^=1;
	x[++k]=b;y[k]=a;next[k]=p[b];p[b]=k;d[b]^=1;
}

void travel(int x){
	for (int t=p[x];t;t=p[x]){
		p[x]=next[t];
		if (!h[t/2]){
			h[t/2]=1;
			if (y[t]==x+n&&y[t]!=2*n+1) ans[x]=1;
			if (x==y[t]+n&&x!=2*n+1) ans[y[t]]=-1;
			travel(y[t]);
		}
	}
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();k=1;
	for (int i=1;i<=n;i++){
		int x=read();
		add(i,(x==-1)?2*n+1:x);
	}
	for (int i=1;i<=n;i++){
		int x=read();
		add(n+i,(x==-1)?2*n+1:n+x);
	}
	for (int i=1;i<=n;i++)
		if (d[i]!=d[n+i])
		{printf("IMPOSSIBLE\n");return 0;}
	printf("POSSIBLE\n");
	for (int i=1;i<=n;i++)
		if (d[i]) add(i,n+i);
	travel(2*n+1);
	for (int i=1;i<=n;i++)
		printf((i!=n)?"%d ":"%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 30720
h,w = map(int, input().split())

if h%3 == 0 or w%3 == 0:
    print(0)
    exit()

ans = min(w,h)

for hi in range(1,h):
    top = hi*w
    bottom_big = (h-hi)*((w+1)//2)
    bottom_small = (h-hi)*(w//2)
    smax = max(top,bottom_big)
    smin = min(top,bottom_small)
    ans = min(ans, smax-smin)


for wi in range(1,w):
    top = wi*h
    bottom_big = (w-wi)*((h+1)//2)
    bottom_small = (w-wi)*(h//2)
    smax = max(top,bottom_big)
    smin = min(top,bottom_small)
    ans = min(ans, smax-smin)

print(ans)

Measured memory_bytes: 69420
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
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()
{
	int n; cin >> n;
	vector<ll>a(n);
	ll ma = 0;
	rep(i, n)
	{
		cin >> a[i];
		chmax(ma, a[i]);
	}
	int k = 0;
	while (ma>0)
	{
		ma = ma >> 1;
		k++;
	}
	ll ans = 0;
	rep(i, k)
	{
		ll n0 = 0, n1 = 0;
		rep(j, n)
		{
			if (a[j] & ((ll)1 << i))n1++;
			else n0++;
		}
		ll tmp = ((ll)1<<i);
		tmp %= mod;
		tmp *= (n0* n1% mod);
		tmp %= mod;
		ans += tmp;
		ans %= mod;
	}
	co(ans);
	return 0;
}

Measured memory_bytes: 2560
using static System.Console;
using System.Linq;
using System.Diagnostics;
using System;
using System.Collections.Generic;

public static class Program
{
    public static void Main()
    {
        var stopwatch = new Stopwatch();
        var maxD = int.Parse(ReadLine());
        var cArray = ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var sTable = new List<List<int>>();
        var lastList = Enumerable.Repeat(0, 26).ToList();
        var sequenceList = Enumerable.Repeat(0, maxD).ToList();
        int happiness = 0;
        for (int i = 0; i < maxD; ++i)
        {
            sTable.Add(ReadLine().Split(' ').Select(x => int.Parse(x)).ToList());
        }

        stopwatch.Restart();
        Random random = new Random();
        for(int d = 0; d < maxD; ++d)
        {
            var currentContest = random.Next(26);
            lastList[currentContest] = d + 1;
            sequenceList[d] = currentContest;
            happiness += sTable[d][currentContest];
            happiness -= Enumerable.Range(0, 26).Select(i => cArray[i] * ((d + 1) - lastList[i])).Sum();
        }
        while(stopwatch.ElapsedMilliseconds < 1900)
        {
            var ranD = random.Next(maxD);
            var old = sequenceList[ranD];
            sequenceList[ranD] = random.Next(26);
            var newHappiness = calcHappiness();
            if (happiness > newHappiness) sequenceList[ranD] = old;
            else happiness = newHappiness;
        }
        for(int i = 0; i < maxD; ++i)
        {
            WriteLine(sequenceList[i] + 1);
        }

        int calcHappiness()
        {
            var res = 0;
            var lastList1 = Enumerable.Repeat(0, 26).ToList();
            for (int d = 0; d < maxD; ++d)
            {
                lastList1[sequenceList[d]] = d + 1;
                res += sTable[d][sequenceList[d]];
                res -= Enumerable.Range(0, 26).Select(i => cArray[i] * ((d + 1) - lastList1[i])).Sum();
            }
            return res;
        }
    }
}

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



int check(int A[],int k,long long p,int n){
    //ワークの重量を内含する配列Aと、各トラックの最大積載量pをINPUTとし、
    //積載できるワークの数を返す関数。（ワークの積み込みは頭からとする。）
    long long w;
    int i=0;
    for (int track=0;track<k;track++){
        w=0;
        while(w+A[i]<=p){
            w+=A[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

long long bi_search(int A[],int k,int n){
    long long p_left=-1,p_mid,p_right=100000*10000;
    while(p_right-p_left>1){
        p_mid=p_left+(p_right-p_left)/2;
        if(check(A,k,p_mid,n)>=n) p_right=p_mid;
        else p_left=p_mid;
    }
    return p_right;
}


int main(){
    int n,k;
    int A[100000];
    cin>>n>>k;

    rep(i,n) scanf("%d",&A[i]);

    cout<<bi_search(A,k,n)<<endl;
    
    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#define MAXN 1006010
#define LL long long 
using namespace std;

const LL P=998244353;

LL getPow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P;
		y>>=1;
	}
	return res;
}

int n,n1,n2,sizew;
LL fac[MAXN],invfac[MAXN];
LL *a[MAXN],b[MAXN];

void init(){
	static char s1[MAXN],s2[MAXN];
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	int len=strlen(s1+1);
	for(int i=1;i<=len;i++)
		if(s1[i]=='1' && s2[i]=='1') n1++;
		else if(s1[i]=='1' || s2[i]=='1') n2++;
	n2/=2;
	n=n1+n2;
	fac[0]=1;
	for(int i=1;i<MAXN;i++) fac[i]=fac[i-1]*i%P;
	invfac[MAXN-1]=getPow(fac[MAXN-1],P-2);
	for(int i=MAXN-2;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%P;
}

void FFT(LL *a,int len,int flag){
	static int rev[MAXN];
	for(int i=1;i<len;i++){
		rev[i]=rev[i>>1]>>1|((i&1)?(len>>1):0);
		if(i<rev[i]) swap(a[i],a[rev[i]]);
	}
	for(int l=2;l<=len;l<<=1){
		LL w=getPow(3,(P-1)/l);
		int l2=l/2;
		for(int i=0;i<len;i+=l){
			LL temp=1;
			for(int j=0;j<l2;j++){
				LL t1=a[i+j],t2=a[i+j+l2]*temp;
				a[i+j]=(t1+t2)%P;
				a[i+j+l2]=(t1-t2)%P;
				temp=temp*w%P;
			}
		}
	}
	if(flag==-1){
		LL invn=getPow(len,P-2);
		for(int i=1;i<len;i++) if(i<len-i) swap(a[i],a[len-i]);
		for(int i=0;i<len;i++) a[i]=(a[i]*invn%P+P)%P;
	}
}

void mul(LL *a,LL *b,int len){
	static LL t1[MAXN],t2[MAXN];
	for(int i=0;i<len;i++) t1[i]=a[i],t2[i]=b[i],t1[i+len]=t2[i+len]=0;
	FFT(t1,len<<1,1); FFT(t2,len<<1,1);
	for(int i=0;i<(len<<1);i++) t1[i]=t1[i]*t2[i]%P;
	FFT(t1,len<<1,-1);
	for(int i=0;i<(len<<1);i++) a[i]=t1[i];
}

void getInv(LL *b,LL *a,int len){
	if(len==1){
		b[0]=1;
		return;
	}
	static LL t1[MAXN],t2[MAXN];
	getInv(t1,a,len>>1);
	for(int i=(len>>1);i<len;i++) t1[i]=0;
	for(int i=0;i<len;i++) t2[i]=a[i];
	FFT(t1,len<<1,1); FFT(t2,len<<1,1);
	for(int i=0;i<(len<<1);i++) t1[i]=(2*t1[i]-t2[i]*t1[i]%P*t1[i]%P+P)%P;
	FFT(t1,len<<1,-1);
	for(int i=0;i<len;i++) b[i]=t1[i];
}

LL getC(int x,int y){
	return fac[x]*invfac[y]%P*invfac[x-y]%P;
}

LL gao(){
	for(sizew=1;sizew<=n1 || sizew<=n2;sizew<<=1);
	static LL space[MAXN];
	for(int i=1;i<=sizew;i++){
		a[i]=space+(i-1)*2;
		a[i][0]=1;
		if(i<=n2) a[i][1]=-i;
	}
	for(int l=2;l<=sizew;l<<=1)
		for(int i=1;i<=sizew;i+=l)
			mul(a[i],a[i+l/2],l);
	getInv(b,a[1],sizew);
	assert(b[0]==1);
	LL ans=0;
	for(int i=0;i<=n1;i++){
		LL temp=getC(n1,i)*b[i]%P*fac[i]%P*fac[n2]%P*fac[n2]%P*fac[n1-i]%P*fac[n1-i]%P*getC(n1+n2,n1-i)%P;
		ans=(ans+temp)%P;
	}
	return ans;
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	init();
	LL ans=(gao()+P)%P;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 33024
lines=gets.split('')
newlines=[]


 lines.each  do |time|
    
  	if time=="D" 
      newlines.push("D")
    end
 	if time=="P"   		
      newlines.push("P")
    end
    if time=="?"
      newlines.push("D")

 	
	end
 
end

  print newlines.join




Measured memory_bytes: 39620
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<ll> > dp(5000, vector<ll> (5000, 0));
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll num = 0;
    ll ret = 0, blue = 0;
    string s;
    cin >> s;
    ll n = s.length();
    for(int i=0;i<n;i++){
    	if(s[i] == '1') num++;
    	else if(s[i] == '2') num += 2;
    }
    dp[0][0] = 1;
    for(int i=0;i<n*2;i++){
    	if(i < n){
    		if(s[i] == '0') ret += 2;
    		else if(s[i] == '1') ret++, blue++;
    		else blue += 2;
    	}
    	for(int j=0;j<n*2;j++){
    		if(i-j+1 <= ret)(dp[i+1][j] += dp[i][j]) %= mod;
    		if(j+1 <= blue) (dp[i+1][j+1] += dp[i][j]) %= mod;
    	}
    }
    cout << dp[n*2][num] << endl; 
    return 0;
}


Measured memory_bytes: 195968
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in) ;
    int n = sc.nextInt();
    int[] p = new int[n];
    int count =0;
    for (int i =0; i<n; i++) {
      p[i] = sc.nextInt();
    }
    for (int i=1; i<n-1; i++) {
      if(p[i] > Math.min(p[i-1],p[i+1]) && p[i] <= Math.max(p[i-1],p[i+1])) {
        count++;
      }
    }  
    System.out.println(count);
  }
}

Measured memory_bytes: 22740
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 1010


int main(void){
int n,m;
vector<int>b;
vector<int>c;
vector<int>d;
vector<int>e;
int bb,cc,dd,ee;
bool ans=true;
bool a[1000][1000];
int x,y,z;
scanf("%d %d",&m,&n);
f(i,n){
f(j,m){
scanf("%d",&x);
if(x==0)a[i][j]=false;
else a[i][j]=true;
}
}
f(i,n){
if(a[i][0])b.push_back(i);
else c.push_back(i);
}
f(i,m){
if(a[0][i])d.push_back(i);
else e.push_back(i);
}
bb=b.size();
cc=c.size();
dd=d.size();
ee=e.size();
if(abs(bb-cc)>1){
printf("no\n");
return 0;
}
if(abs(dd-ee)>1){
printf("no\n");
return 0;
}
f(i,b.size()){
f(j,d.size()){
if(a[b[0]][d[0]]!=a[b[i]][d[j]])ans=false;
}
}
f(i,b.size()){
f(j,e.size()){
if(a[b[0]][e[0]]!=a[b[i]][e[j]])ans=false;
}
}
f(i,c.size()){
f(j,d.size()){
if(a[c[0]][d[0]]!=a[c[i]][d[j]])ans=false;
}
}
f(i,c.size()){
f(j,e.size()){
if(a[c[0]][e[0]]!=a[c[i]][e[j]])ans=false;
}
}
if(a[b[0]][d[0]]!=a[c[0]][e[0]])ans=false;
if(a[b[0]][e[0]]!=a[c[0]][d[0]])ans=false;
if(a[b[0]][d[0]]==a[b[0]][e[0]])ans=false;
if(ans)printf("yes\n");
else printf("no\n");


return 0;
}


Measured memory_bytes: 3600
l=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n=int(input())
for i in range(n):
	a,b,c,d=list(map(int,input().split()))
	l[a-1][b-1][c-1]+=d
for i in l[:-1]:
	for j in i:
		print(" "+" ".join(list(map(str,j))))
	print("####################")

for j in l[-1]:
	print(" "+" ".join(list(map(str,j))))

Measured memory_bytes: 7696
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let A = scan.word::<i64>();
    let V = scan.word::<i64>();
    let B = scan.word::<i64>();
    let W = scan.word::<i64>();
    let T = scan.word::<i64>();

    let ok = V >= W && (V - W) * T >= (A - B).abs();

    println!("{}", if ok { "YES" } else { "NO" });
}


Measured memory_bytes: 2112
#include <stdio.h>
#include <string.h>
#include <math.h>


int main(void)
{	
	int n,m,i,a[50],b[50];
	int count[50]={0};
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<=m-1;i++){
		scanf("%d %d",&a[i],&b[i]);
		count[a[i]]++;
		count[b[i]]++;
	}
	
	for(i=1;i<=n;i++){
		printf("%d\n",count[i]);
	}
	return 0;
}


Measured memory_bytes: 128
import sys
N = int(input())
A = list(map(int, input().split()))

if N == 0:
    if A[0] == 1:
        print(1)
    else:
        print(-1)
    sys.exit()

capacity = [1 - A[0]]
for i in range(N):
    capacity += [2 * (capacity[-1] - A[i])]


corr_flag = 1
if A[-1] > capacity[-1]:
    corr_flag = 0
curr = A[-1]
ans = A[-1]
for i in range(N-1, -1, -1):
    curr = min(capacity[i], A[i] + curr)
    ans += curr
if corr_flag:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 674468
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


        EXPLAINATION BELOW->
        Read Editorial first
      
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
 
    ll n,i;cin>>n;
    ll sum=0;
    fo(i,1,n+1)
    {
        if((i%3==0)||(i%5==0)){}
        else sum+=i;
    }
    cout<<sum<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

Measured memory_bytes: 3528
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Supplier<IntStream> repn=  ()-> IntStream.range(0,n);
//    IntStream repn = IntStream.range(0,n);
    Integer[] a =repn.get().map(x-> sc.nextInt())
                           .boxed()
                           .toArray((i) -> new Integer[i]);
    Integer[] b =repn.get().map(x-> sc.nextInt())
                           .boxed()
                           .toArray((i) -> new Integer[i]);
    int value =  repn.get().map(i-> a[i]-b[i])
                           .filter(x-> x>0)
                           .sum();
    System.out.println(value);
}}

Measured memory_bytes: 30676
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int n;
    cin >> n;
    ll a[n], x[n];
    rep(i,n){
        cin >> a[i];
        a[i] -= i+1;
        x[i] = a[i];
    }
    sort(x, x+n);
    
    ll ans = 0;
    if (n%2==1) {
        ll b = x[n/2];
        rep(i,n) ans += abs(a[i]-b);
    }
    else{
        ll b1, b2;
        b1 = x[n/2 -1];
        b2 = x[n/2];
        ll res1 = 0, res2 = 0;
        rep(i,n) res1 += abs(a[i]-b1);
        rep(i,n) res2 += abs(a[i]-b2);
        ans = min(res1, res2);
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using pint = pair<int, int>;
#define repi(n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int n;
  cin >> n;
  vint a(n);
  repi(n) cin >> a[i];
  cout << lis(a.begin(), a.end(), true, true).size() << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
int main(){
    ll a[5];
    rep(i,5)cin >> a[i];
    sort(a,a+5,[](ll x,ll y){return (x+9)%10<(y+9)%10;});
    rep(i,5){
        if(i!=0)a[0]+=(a[i]+9)/10*10;
    }
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
h,w = gets.split.map(&:to_i)
a,b = 2.times.map{(1..h).map{gets.split.map(&:to_i)}}
ab = a.zip(b).map{|ta,tb|ta.zip(tb).map{|ua,ub|(ua-ub).abs}}

max = ab.map(&:max).max
zero = 1 << (h+w)*max/2

dp = [zero]
predp = [0]*w

ab.each{|abi|
  w.times{|tw|
    d = abi[tw]
    s = predp[tw] | dp[tw-1]
    dp[tw] = (s << d) | (s >> d)
  }
  predp,dp = dp,predp.clear.push(0)
}
ans = predp[-1]
p (0..max).find{|i|ans & ((zero << i)|(zero >> i)) > 0}

Measured memory_bytes: 21372
#include <iostream>

using namespace std;

int a[1000000], n;

int binary_search(int k){
  int l = 0, r = n , m;
  while(l < r){
    m = (l + r) / 2;
    if(k == a[m])return 1;
    if(k > a[m])l = m + 1;
    else if(k < a[m])r = m;
  }
  return 0;
}


int main(void){
  int q,k,s = 0;
  cin>>n;
  for(int i = 0 ; i < n ; i ++){
    cin>>a[i];
  }

  cin>>q;
  for(int i = 0 ; i < q ; i ++){
    cin>>k;
    if(binary_search(k))s ++;
  }

  cout<<s<<endl;

}

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

int main(){
  int a, b, count=0;
  cin >> a >> b;
  for(int i=a;i<=b;i++){
    string c = to_string(i);
    if(c[0]==c[4] && c[1]==c[3]){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    long long int k[n+1][W+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=W;j++)
        {
            if(i==0 || j==0) k[i][j]=0;
            else if(j<w[i-1]) k[i][j]=k[i-1][j];
            else k[i][j]=max((v[i-1]+k[i-1][j-w[i-1]]),k[i-1][j]);
        }
    }
    cout<<k[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 79104
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007LL;
const int MAX_N = 21;

int n;
bool a[MAX_N][MAX_N];
ll dp[MAX_N + 1][1 << MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			int x; cin >> x;
			a[i][j] = x == 1;
		}

	int maxMask = 1 << n;
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int k = 0; k < n; k++)
			if (a[i][k])
				for (int j = 0; j < maxMask; j++)
					if ((j & (1 << k)) == 0)
					{
						int nextJ = j | (1 << k);
						dp[i + 1][nextJ] += dp[i][j];
						if (dp[i + 1][nextJ] >= MOD)
							dp[i + 1][nextJ] -= MOD;
					}
	cout << dp[n][maxMask - 1] << endl;
}

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

int main() { 	
 int r,D,x,xx;
 cin >>r>>D>>x;
  
   
  for(int i=0;i<10;i++){
  xx=r*x-D;
    cout <<xx<<endl;
    x=xx;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int OA=0,BO=0,BOA=0;
	int N;
	cin>>N;
	string S;
	long long sub=0;
	for(int i=0;i<N;i++){
		cin>>S;
		if(S[0]=='B'){
			if(S[S.size()-1]=='A')BOA++;
			else BO++;
		}
		else if(S[S.size()-1]=='A')OA++;
		for(int i=0;i<S.size()-1;i++){
			if(S[i]=='A'&&S[i+1]=='B')sub++;
		}
	}
	if(BOA>0){
		sub+=BOA-1;
		if(BO>0){sub++;BO--;}
		if(OA>0){sub++;OA--;}
	sub+=min(OA,BO);
	}
	else{
		sub+=min(OA,BO);
	}
	cout<<sub<<endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N, Z, W;
llvec dp[2];
llvec a;

ll dpf(ll X, ll n){
  if(dp[X][n]==-1){
    ll ans = 0;
    if(X==0){
      ll y = W;
      if(n!=0){
        y = a[n-1];
      }
      ll ans = abs(y - a[N-1]);
      for(ll i=n;i<N-1;i++){
        ans = max(ans, dpf(1, i+1));
      }
      dp[X][n]=ans;
      return ans;
    }else{
      ll x = a[n-1];
      ll ans = abs(x - a[N-1]);
      for(ll i=n;i<N-1;i++){
        ans = min(ans, dpf(0, i+1));
      }
      dp[X][n]=ans;
      return ans;
    }
  }
  return dp[X][n];
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N >> Z >> W;
  a = llvec(N);
  rep(i, N)cin >> a[i];
  dp[0] = llvec(N, -1);
  dp[1] = llvec(N, -1);
  cout << dpf(0, 0);
  
  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    stack<char> stk;
    for(int i=0;i<s.length();i++){
        if(stk.empty()){
            stk.push(s[i]);
            continue;
        }
        if(stk.top()=='S'&&s[i]=='T')stk.pop();
        else
            stk.push(s[i]);
    }
    cout<<stk.size();

}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<ll> A(1001),B(1001),C(1001);
  rep(i,X) cin>>A[i];
  rep(i,Y) cin>>B[i];
  rep(i,Z) cin>>C[i];
  vector<ll> D(X*Y),E(Z*K);
  rep(i,X) rep(j,Y) D.push_back(A[i]+B[j]);
  sort(all(C));
  reverse(all(C));
  sort(all(D));
  reverse(all(D));
  rep(i,Z) rep(j,K) E.push_back(C[i]+D[j]);
  sort(all(E));
  reverse(all(E));
  rep(i,K) cout<<E[i]<<endl;
}

Measured memory_bytes: 64632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  int a,b,c,d,e;
  a=A%10;
  b=B%10;
  c=C%10;
  d=D%10;
  e=E%10;
  int aa,bb,cc,dd,ee;
  aa=(A-1)%10;
  bb=(B-1)%10;
  cc=(C-1)%10;
  dd=(D-1)%10;
  ee=(E-1)%10;
  cout << A+B+C+D+E-aa-bb-cc-dd-ee+min({aa,bb,cc,dd,ee})+36 << endl;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

struct Edge {
    ll cost, from, to;
    bool operator<(const Edge &another) const { return cost < another.cost; };
    bool operator>(const Edge &another) const { return cost > another.cost; };
};
ll H, W;
vector<Edge> es;
ll d[10][10];
map<ll, ll> dic;
ll num = 10;

void warshall_floyd() {
    REP(k, num) REP(i, num) REP(j, num) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
}

int main() {
    cin >> H >> W;
    REP(i, 10) REP(j, 10) { d[i][j] = IN(); }
    REP(i, H) REP(j, W) { dic[IN()]++; }
    warshall_floyd();
    ll ans = 0;
    REP(i, 10) { ans += dic[i] * d[i][1]; }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
long A[100001];
int main(){
long a,b,N,K,x=0;
int i;
scanf("%ld%ld",&N,&K);
for(i=0;i<N;i++){
scanf("%ld%ld",&a,&b);
A[a]+=b;
}
for(i=1;i<=100000;i++){
x+=A[i];
  if(x>=K){
  printf("%ld\n",i);
  break;
  }
}    	
return 0;
}

Measured memory_bytes: 896
a=list(input())
if int(str(a[0]+a[1]+a[2]))<=int(str(a[0]+a[0]+a[0])):
  print(int(str(a[0]+a[0]+a[0])))
else:
  b=int(a[0])+1
  print(str(b)+str(b)+str(b))

Measured memory_bytes: 3060
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	double ans=0;
	int n;
	cin>>n;
	rb(i,1,n){
		double ai;
		cin>>ai;
		ans+=1.0/ai;
	}
	printf("%.10f\n",1.0/ans);
	return 0;
}

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

using namespace std;

int ar[1010];
map <int, int > m;

int main()
{
    int n, ans = 0;
    cin >> n;
    for(int i = 0; i < 2*n; i++) {
        cin >> ar[i];
    }
    sort(ar, ar + 2*n);

    for(int i = 0; i < 2*n; i+=2) {
        ans += ar[i];
    }

    cout << ans;

	return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,k;cin>>n>>k&&n|k;){
		vi a(n);
		rep(i,n) cin>>a[i];

		vi b(n),c(n);
		rep(i,n){
			repi(j,i,n)
				b[i]+=a[i]>a[j];
			rep(j,n)
				c[i]+=a[i]>a[j];
		}

		ll res=0;
		rep(i,n){
			res+=(ll)k*b[i]%MOD;
			res+=((ll)k*(k-1)/2%MOD)*c[i]%MOD;
			res%=MOD;
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 256
#pragma warning (disable: 4996)
#include <iostream>
using namespace std;
int main(void) {
	char c[2][3];
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < 3; ++i) {
		if (c[0][i] != c[1][2 - i]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 3010, P = 998244353;
int n, m, a[maxn], dp[2][maxn];

int main() {
  cin >> n >> m;
  rep(i, 1, n) a[i] = read();
  int sel = 1, res = 0;
  rep(i, 1, n) {
    memset(dp[sel], 0, sizeof dp[sel]);
    if (a[i] <= m) dp[sel][a[i]] = i;
    rep(j, 0, m) {
      dp[sel][j] = (dp[sel][j] + dp[sel ^ 1][j]) % P;
      if (j >= a[i]) dp[sel][j] = (dp[sel][j] + dp[sel ^ 1][j - a[i]]) % P;
    }
    if (a[i] <= m) {
      res = (res + 1ll * (n - i + 1) * (dp[sel ^ 1][m - a[i]] + (m == a[i]) * i)) % P;
    }
    sel ^= 1;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)

using namespace std;

int main(){
	unsigned long long A, B, N, x,maxNum=0;
	cin >> A >> B >> N;
	if(N>=B)x = B - 1; 
	else x = N;
	
	maxNum = (A*x)/B - A*(x/B);

	cout << maxNum << endl;
	return 0;
}

Measured memory_bytes: 3192
#include"bits/stdc++.h"
#include<cassert>
#define fr first
#define sc second
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 62;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	int n, a; cin >> n >> a;
	cout << n*n - a << endl;
}

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

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

int main(void)
{
    int vis_bucket[8];
    int age;
    int n, i;

    while (scanf("%d", &n), n){
        memset(vis_bucket, 0, sizeof(vis_bucket));
        for (i = 0; i < n; i++){
            scanf("%d", &age);
            vis_bucket[IMIN(6, age / 10)]++;
        }
        for (i = 0; i <= 6; i++){
            printf("%d\n", vis_bucket[i]);
        }
    }
    return (0);
}

Measured memory_bytes: 600
# coding: utf-8
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]

satisfy = sum(B)
for i, a in enumerate(A):
    if i == 0:
        continue
    if a - A[i-1] == 1:
        satisfy += C[A[i-1] - 1]
print(satisfy)

Measured memory_bytes: 3064
from math import ceil
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = None

n = i_in()
ans = -n + ceil(n/1000) * 1000

print(ans)

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

int main()
{

	int H, W;
	while (true)
	{
		cin >> H >> W;
		if (H == 0 && W == 0)
		{
			break;
		}
		//start row
		for (int col = 0; col < W; col++)
		{
			cout << "#";

		}
		cout << endl;
		for (int row = 1; row < H-1; row++)
		{
			cout << "#";
			for (int col = 1; col < W-1; col++)
			{
				cout << ".";
			}
			cout << "#" << endl;
		}
		//end row
		for (int col = 0; col < W; col++)
		{
			cout << "#";

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


Measured memory_bytes: 3112
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

S = input()

cnt = 0
ans = 0
for i in range(3):
    if S[i] == 'R':
        cnt += 1
    else:
        cnt = 0
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 9520
from collections import deque
 
s = input()
q = int(input())
ans = deque(s)
cnt = 0
for i in range(q):
    f = [i for i in input().split()]
    if f[0] == '1':
        cnt += 1
    else:
        if f[1] == '1':
            if cnt % 2 == 0:
                ans.appendleft(f[2])
            else:
                ans.append(f[2])
        else:
            if cnt % 2 == 0:
                ans.append(f[2])
            else:
                ans.appendleft(f[2])
if cnt % 2 != 0:
    ans.reverse()
print(''.join(map(str,ans)))

Measured memory_bytes: 8688
#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
ll C(ll n,ll m,ll p){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

char s[N];
int main(){
    in>>s;
    ll sum=0;
    int i=0;
    while(s[i])sum+=s[i++]-'9';
    if(sum%9==0)out<<"Yes";
    else out<<"No";
    return 0;
}

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

int f(int n) {
  return n * (n + 1) / 2;
}

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

  int answer = 0;
  for (int i = 1; i <= n; i++) {
    answer += i * f(n / i);
  }
  cout << answer << '\n';
}


Measured memory_bytes: 3632
#include <stdio.h>

#define sq(x) ((x) * (x))

#define EPS 1e-5

int main(void) {
	int i;
	int n, q, x[50], y[50], z[50], r[50];
	long long l[50];

	scanf("%d %d", &n, &q);
	for (i = 0; i < n; i++)
		scanf("%d %d %d %d %lld", x + i, y + i, z + i, r + i, l + i);

	while (q--) {
		int xa, ya, za, xb, yb, zb;
		long long ans;

		scanf("%d %d %d %d %d %d", &xa, &ya, &za, &xb, &yb, &zb);

		ans = 0;
		for (i = 0; i < n; i++) {
			const double k = (double)((x[i] - xa) * (xb - xa) + (y[i] - ya) * (yb - ya) + (z[i] - za) * (zb - za)) / (sq(xb - xa)  + sq(yb - ya) + sq(zb - za));
			const double len_sq = sq(xa + k * (xb - xa) - x[i]) + sq(ya + k * (yb - ya) - y[i]) + sq(za + k * (zb - za) - z[i]);
			if (len_sq - sq(r[i]) < EPS)
				if (k > 0 && k < 1)
					ans += l[i];
		}

		printf("%lld\n", ans);
	}

	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#pragma GCC optimize ("O2")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int l[101];
int main(){
	int i,n,sum=0;
	int ans=0;
	int m;
	cin>>m>>n;
	for(i=1;i<=m;i++){
		cin>>l[i];
	}
	for(i=0;i<=m;i++){
		sum+=l[i];
		if(sum<=n){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
float L;
cin>>L;
float ans=(L/3.0)*(L/3.0)*(L/3.0);

cout<<fixed<<setprecision(9)<<ans<<endl;
//system("pause");
return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int r, d, x; cin >> r >> d >> x;

  rep(i, 10) {
    x = r * x - d;
    cout << x << '\n';
  }
}


Measured memory_bytes: 384
#include<stdio.h>

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

  int a[n];
  for(int i=0; i<n; i++){
    scanf("%d",&a[i]);
  }

  int max=0;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(a[i]-a[j]>max){
        max=a[i]-a[j];
      }
    }
  }

  printf("%d",max);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

    int vn = 3;

    vector<int> v(vn,0);

    for(int i = 0; i < vn; i++){
        int tmp;
        cin >> tmp;

        v[i] = tmp;
    }

    int sum = v[0] + v[1] + v[2];
    int m = max(v[0], max(v[1], v[2]));
    cout << sum - m << endl;
    
 
    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 a = sc.nextInt();		
        int b = sc.nextInt();
		int c = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        while(b<=a){b*=2;count++;}
        while(c<=b){c*=2;count++;}
		if(count<=k){System.out.println("Yes");}
        else{System.out.println("No");}
	}
}


Measured memory_bytes: 35692