akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,n;
    cin>>a>>b>>n;
    long long int k=0;
    if(n+1<b)
    k=n;
    else
    k=b-1;
    cout<<(a*k)/b;
    return 0;
}

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

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n+1);
    for(int i = 1;i <= n;i++)    cin >> a[i];
    LL ans = 1000000000000000;
    for(int sel = 0;sel < 2;sel++){
        LL count = 0;
        LL sum = 0;
        for(int i = 1;i <= n;i++){
            sum += a[i];
            if(sel == 0){
                if(i&1 && sum <= 0){
                    count += -sum+1;
                    sum = 1;
                }else if((i+1)&1 && sum >= 0){
                    count += sum+1;
                    sum = -1;
                }
            }else{
                if(i&1 && sum >= 0){
                    count += sum+1;
                    sum = -1;
                }else if((i+1)&1 && sum <= 0){
                    count += -sum+1;
                    sum = 1;
                }
            }
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int C = in.nextInt();
            int[] B = new int[M];
            for (int i = 0; i < M; i++) {
                B[i] = in.nextInt();
            }
            int[][] A = new int[N][M];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < M; j++) {
                    A[i][j] = in.nextInt();
                }
            }

            int count = 0;
            for (int i = 0; i < N; i++) {
                int sum = C;
                for (int j = 0; j < M; j++) {
                    sum += A[i][j] * B[j];
                }
                if (sum > 0) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(k);
	int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	pll(arr[k-1]); nl;
}


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


def solve(N: int, S: str, K: int):
    S = list(S)
    t = S[K-1]
    for i in range(len(S)):
        if(S[i] != t):
            S[i] = '*'
        
    print(''.join(S))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(N, S, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long M = 1e9+7;
long long power(long long a, long long p)
    {
        if(p==0) return 1;
        long long ans= power(a,p/2);
        ans =(ans * ans) % M;
        if(p%2) ans = (ans*a) % M;
        return ans;
    }

    bool isPrime(long long n)
    {
        if (n <= 1)
            return false;
        for (long long i = 2; i < n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
    long long SieveOfEratosthenes(long long n, long long a)
    {
        bool prime[n+1];
        memset(prime, true, sizeof(prime));
        for (long long p=2; p*p<=n; p++)
        {
            if (prime[p] == true)
            {
                for (long long i=p*p; i<=n; i += p)
                    prime[i] = false;
            }
        }
        for (long long p=2; p<=n; p++)
           if (prime[p])
           {
               if(a%p==0)
               {
                   return (a-p);
               }
           }
    }
    long long nCr(int n, int r)
    {
        if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
        long long ans = 1;
        int i;
        for(i = 1; i <= r; i++) {
            ans *= n - r + i;
            ans /= i;
        }
        return ans;
    }
int main()
{
    IOS;
    long long a,b,c,d,e,h,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
    // vector<string>vs;
    // vector<string>vs1;
    vector<char>vc;
    //map<long long,long long>mp;
    map<char,int>mp1;
    //set<long long>s;
    set<long long>s1;
    queue<long long> q;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
    // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={0,1,-1,1,-1,1,-1,0};
    cin>>str;
    if(str[2]==str[3] && str[5]==str[4])
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CReplacingInteger solver = new CReplacingInteger();
        solver.solve(1, in, out);
        out.close();
    }

    static class CReplacingInteger {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();

            if (k == 0) {
                out.println(n);
            } else {
                out.println(Math.min(n % k, k - n % k));
            }

        }

    }
}



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

int main(){

    string S;
    cin >> S;

    int ans = 0;
    bool flag = true;
    while(flag && S.length() != 0){
        flag = false;
        for(int i = 0; i < S.length() - 1; i++){
            if(S[i] != S[i + 1]){
                S.erase(i, 2);
                ans += 2;
                flag = true;
                i -= 2;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    string s1, s2;
    int length;
    int answer = 0;
    cin>> s1>> s2;
    length  = (int)(s1.length());
    //cout<<s1<<s2<<length<<endl;
    for(int i = 0; i<length; i++){
        //cout<<s1[i]<<s2[i]<<endl;
        if (s1[i]!=s2[i]) {
            //cout<<s1[i]<<s2[i]<<endl;
            answer++;
        }
    }
    cout<< answer<<endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

	int d = n / 100;
	int t = 100 * d + 10 * d + d;

	if(n <= t){
		cout << t << endl;
	}else{
		cout << t + 111 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	ll N, ans = 0;
	cin >> N;
	if (N & 1) {
		cout << 0 << endl;
		return 0;
	}
	N /= 2;
	while (N) {
		ans += N / 5;
		N /= 5;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream> 
#include <stdio.h> 
using namespace std; 
int main(){
	long long A,B,X;
	cin>>A>>B>>X;
	if(A%X==0){
		cout<<(B / X) - (A / X) + 1;
	}else{
		cout<<(B / X) - (A / X); 
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
S = input()
T = input()


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


k = n * m // gcd(n, m)


for i in range(k, n * m + 1, k):
    g = i * i // n // m // gcd(i // n, i // m)
    flag = True
    for c in range(0, i, g):
        if S[c * n // i] != T[c * m // i]:
            flag = False
            break
    if flag:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 43628
#include <stdio.h>

int main(void)
{
	int n, m;
	int maxi;
	
	scanf("%d %d", &n, &m);
	maxi = m;
	while (n-- > 0){
		int in, out;
		
		scanf("%d %d", &in, &out);
		m += (in - out);
		if (maxi < m) maxi = m;
		if (m < 0){
			puts("0");
			return 0;
		}
	}
	printf("%d\n", maxi);
	
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> divVec = divisor(N);
    ll ans = LONG_MAX;
    REPV(iter, divVec)
    {
        ll a = *iter, b = N / *iter;
        ans = min(ans, a - 1 + b - 1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 11000

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	int N;
	int ans = 0;
	
	int cona = 0, conb = 0, conab = 0;
	static string s[MAX];
	vector<pair<int,int>> p;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>s[i];
		for(int j = 0; j < s[i].size(); j++){
			if(j && s[i][j-1] == 'A' && s[i][j] == 'B') ans++;
		}
		bool a = false, b = false;
		
		if(s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A'){
			conab++;
		} else if(s[i][0] == 'B'){
			conb++;
		} else if(s[i][s[i].size() - 1] == 'A'){
			cona++;
		}
	}
	
	if(cona && conab){
		ans++;
		cona--;
	}
	if(conb && conab){
		ans++;
		conb--;
	}
	
	ans += max(conab-1, 0ll);
	
	ans += min(cona, conb);
	// cout<< min(cona, conb)<<endl;
	int t =  min(cona, conb);
	
	cona -= t;
	conb -= t;
	
	
	if(conab) conab = 1;
	
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
  const ll md = 1000000007;
  ll n, m;
  cin >> n >> m;

  ll ans;
  if (abs(n - m) >= 2) {
    ans = 0;
  } else {
    ll mx = max(n, m);
    ll fact[mx + 1];
    fact[0] = 1;
    for (int i = 1; i <= mx; i++) {
      fact[i] = fact[i - 1] * i % md;
    }

    if (abs(n - m) == 1) {
      ans = fact[n] * fact[m] % md;
    } else {
      ans = fact[n] * fact[m] * 2 % md;
    }
  }

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


Measured memory_bytes: 4272
#include <bits/stdc++.h>
//<(") 
#define ll long long   
using namespace std;
 
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
 
const ll mod = 1e9 + 7;
const ll siz = 3e3 + 10;
const ll base = 32;
const ll MAXX = 1e18;

ll n, m, k;
ll res[siz][siz][4];
ll val[siz][siz];

ll dp(ll x, ll y, ll rem) {
	if (x > n || y > m) {
		return -MAXX;
	}
	if (x == n && y == m) {
		return 0;
	}
	ll &ans = res[x][y][rem];
	if (ans != -1) {
		return ans;
	}
	ans = 0;
	if (y + 1 <= m) {
		ans = max(ans, dp(x, y + 1, rem));
		if (rem > 0 && val[x][y + 1]) {
			ans = max(ans, dp(x, y + 1, rem - 1) + val[x][y + 1]);
		}
	}
	if (x + 1 <= n) {
		ans = max(ans, dp(x + 1, y, 3));
		if (val[x + 1][y]) {
			ans = max(ans, dp(x + 1, y, 2) + val[x + 1][y]);
		}
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	cin >> n >> m >> k;
	for (ll i = 0; i < k; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		val[a][b] = c;
	}
	memset(res, -1, sizeof(res));
	ll ans = dp(1, 1, 3);
	if (val[1][1]) {
		ans = max(ans, dp(1, 1, 2) + val[1][1]);
	}
	cout << ans << '\n';
	return 0;
} 

Measured memory_bytes: 357672
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

scr = 0
for i in A[:K]:
    scr += math.log10(i)

for i in range(K, N):
    scr_new = scr + math.log10(A[i]) - math.log10(A[i-K])
    if scr_new > scr: print('Yes')
    else: print('No')

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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}



int main()
{
    string S;;
    cin >>  S;


    if(S=="ARC"){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

 
    return 0;

}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int a[10800],sum = 0, result = 0, i, test, j, temp;

    while( scanf("%d",&test) != EOF )
    {

        for( i = 0; i < test; i++ )
        {
            scanf("%d", &a[i]);
        }
        for( i = 0; i < test; i++ )
        {
            for( j = 0; j < test; j++ )
            {
                if( a[i] < a[j] )
                {
                    temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
        }

        sum = result = 0;

        for( i = 0; i < test; i++ )
        {
            sum = sum + a[i];
            result = result + sum;
        }
        printf("%d\n", result);

    }
    return 0;
}

Measured memory_bytes: 608
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          Input.ScanInt();
          var a = Input.ScanIntArray();
          
          Out(a.Max() - a.Min());
        }
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int DistanceL1(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = Math.Abs(a[i]-b[i]);
            return c.Sum();
        }

        public static double DistanceL2(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = (a[i]-b[i])*(a[i]-b[i]);
            return Math.Sqrt(c.Sum());
        }
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int oddCount = 0;
            for (int i = 0; i < n; ++i) {
                oddCount += in.nextInt() % 2;
            }
            out.println(oddCount % 2 == 1 ? "NO" : "YES");
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 23360
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
    long long N,ans=10000000000000;
    cin>>N;
    for(long long i=1;i<=sqrt(N);i++){
        if(N%i==0){
            ans=min(ans,i+N/i-2);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll a[200001],b[200001],MOD=1e9+7,n,k,ans;
int main(void){
    cin>>n>>k;
    for(ll i=1LL;i<=200000;i++){
        a[i]=a[i-1]+i;
        a[i]%=MOD;
    }
    b[0]=n;
    for(ll i=1LL;i<=n;i++){
        b[i]=n-i+b[i-1];
        b[i]%=MOD;
    }
    for(int i=k-1;i<=n;i++){
        ans+=b[i]-a[i]+1;
        //cout<<b[i]<<" "<<a[i]<<endl;
        ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
}


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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x)
{
	bool f = 0;
	x = 0;
	char c = getchar();
	while(c != '-' && (c < '0' || c > '9')) c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	if(f) x = -x;
	return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
	scf(x);
	return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
	scf(x);
	scf(y);
	return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
	scf(x);
	scf(y);
	scf(z);
	return scf(w);
}

inline char mygetchar()
{
	char c = getchar();
	while(c == ' ' || c == '\n') c = getchar();
	return c;
}

template <typename T> inline bool chkmax(T &x, const T &y)
{
	return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y)
{
	return y < x ? x = y, 1 : 0;
}

#ifdef King_George
#define DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 1e5 + 100;

int n;
int cnt[3];

int main()
{
	scf(n);
	while(n--)
	{
		int x;
		scf(x);
		int y = 0;
		if(x % 2 == 0) ++y, x /= 2;
		if(x % 2 == 0) ++y, x /= 2;
		++cnt[y];
	}
	if(cnt[0] > cnt[2])
	{
		if(cnt[0] == cnt[2] + 1)
		{
			if(!cnt[1])
			{
				puts("Yes");
				return 0;
			}
			puts("No");
			return 0;
		}
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

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

typedef pair<int64_t, int64_t> P;
const int64_t INF = 1e18;

vector<int64_t> dijkstra(int N, int s, vector<P> edges[]){
    vector<int64_t> dist(N, INF);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, s});
    while(que.size()){
        auto p = que.top(); que.pop();
        int i = p.second;
        int64_t d = p.first;
        if(d > dist[i]) continue;
        for(auto& e : edges[i]){
            int j = e.first;
            int64_t d2 = d + e.second;
            if(d2 < dist[j]){
                dist[j] = d2;
                que.push({d2, j});
            }
        }
    }
    return dist;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> es(M);
    vector<map<int, int>> st(1e6);
    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--, c--;
        st[c][a] = st[c][b] = 0;
        es[i] = {a, b, c};
    }
    static vector<P> edges[500000];
    int E = N;
    for(int c=0; c<1e6; c++) for(auto p : st[c]){
        edges[E].emplace_back(p.first, 0);
        edges[p.first].emplace_back(E, 1);
        st[c][p.first] = E++;
    }
    for(auto& e : es){
        int a = e[0], b = e[1], c = e[2];
        int va = st[c][a], vb = st[c][b];
        edges[va].emplace_back(vb, 0);
        edges[vb].emplace_back(va, 0);
    }
    auto dist = dijkstra(500000, 0, edges);
    int64_t ans = dist[N-1];
    if(ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 128624
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

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

    int N, D;
    cin >> N >> D;
    cout << round_up(N, (2 * D + 1));

    return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();
    let mut l: Vec<usize> = Vec::new();
    let mut r: Vec<usize> = Vec::new();
    for _ in 0..k {
        let li: usize = iterator.next().unwrap().parse().unwrap();
        let ri: usize = iterator.next().unwrap().parse().unwrap();
        l.push(li);
        r.push(ri);
    }

    const MOD: usize = 998244353;

    let mut dp: Vec<usize> = vec![0; n + 1];
    let mut dpsum: Vec<usize> = vec![0; n + 1];
    dp[1] = 1;
    dpsum[1] = 1;
    for i in 2..=n {
        for j in 0..k {
            let li = i as isize - r[j] as isize;
            let ri = i as isize - l[j] as isize;
            if ri < 0 {
                continue;
            }
            let li = max(li, 1) as usize;
            let ri = ri as usize;
            dp[i] = if (dp[i] + dpsum[ri]) % MOD >= dpsum[li - 1] % MOD {
                (dp[i] + dpsum[ri]) % MOD - dpsum[li - 1] % MOD
            } else {
                MOD - (dpsum[li - 1] % MOD - (dp[i] + dpsum[ri]) % MOD)
            };
        }
        dpsum[i] = (dpsum[i - 1] + dp[i]) % MOD;
    }
    dp[n].to_string()
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

long long power(long long x,long long y){
   long long ans=1;
   x %= MOD;
   if(y < 0) return 0;
   while(y){
      if(y & 1) ans = (ans*x) %MOD;
      x = x*x % MOD;
      y /= 2;
   }
   return ans;
}
 
long long inv(long long x){
   return power(x,MOD-2);
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   int ans = 0;
   vector<int> A(k+1);
   A[1] = power(k,n);
   for(int i=k;i>=2;i--){
      int mul = k/i;
      A[i] += power(mul,n);
      A[i] %= MOD;
      for(int j=2;j*j<=i;j++){
         if(i%j == 0){
            A[j] -= A[i];
            A[j] += MOD;
            A[j] %= MOD;
            if(i/j != j){
               A[i/j] -= A[i];
               A[i/j] += MOD;
               A[i/j] %= MOD;
            }
         }
      }
      A[1] -= A[i];
      A[1] += MOD;
      A[1] %= MOD;
   }
   f(i,1,k+1){
      ans += i*A[i];
      ans %= MOD;
   }
   cout << ans << '\n';

   return 0;
} 

Measured memory_bytes: 3960
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define S second
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e10, MOD=998244353;
     
ll n, q=1, a[N], b[N], c[N], f[N], m, x, y, z, o=3, h, w, mx, mn, ans, Ans;
string s, S;
vector <ll> v[N];
pair<ll, ll> p[N];


main(){ios_base::sync_with_stdio(false), cin.tie(0);
                    
    cin>>n;
    for (int i=1; i<=n; i++){
    	if(i%5&&i%3)ans+=i;
	}
	cout<<ans;
}

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


int main(){
	/*input*/
	int n;
	int k;
	cin >> n >> k;

	/*calc*/
	double ans = 0;
	for(double i = 1; i <= n; i++){
		double ans_tmp = 1.0 /n;
		double num = i;
		while( num < k){
			ans_tmp /= 2.0;
			num *= 2;
		}
		ans += ans_tmp;
	}
    /*output*/
	printf("%.12f\n", ans);
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

#define NO { cout << "No\n"; exit(0); }
#define YES { cout << "Yes\n"; exit(0); }

int main() {
  int N; cin >> N;
  vector<int64_t> a(N); cin >> a;
  vector<int64_t> b(N); cin >> b;
  int64_t acnt = 0;
  rep(i, a.size()) {
    if (a[i] < b[i]) {
      auto num = (b[i] - a[i] + 1) / 2;
      a[i] += 2LL * num;
      acnt += num;
    }
  }

  int64_t bcnt = 0;
  rep(i, b.size()) {
    if (b[i] < a[i]) {
      auto num = a[i] - b[i];
      b[i] += num;
      bcnt += num;
    }
  }

  if (acnt < bcnt) NO;
  if (acnt == bcnt) {
    if (a == b) YES;
    NO;
  }
  YES;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int X = scanner.nextInt();

    int A[] = new int[N + 1];

    for (int i = 1; i <= M; i++) {
      A[scanner.nextInt()] = 1;
    }

    int to0 = 0;
    for (int i = 0; i < X; i++) {
      to0 += A[i];
    }
    int toN = 0;
    for (int i = X; i < N; i++) {
      toN += A[i];
    }
    if (to0 > toN) {
      System.out.println(toN);
    } else {
      System.out.println(to0);
    }

  }

}


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

int main() {
    long long N;
    string S;

    cin >> N;
    cin >> S;

    long long m = 0;
    for(int i=1; i<S.length(); ++i) {
	long long c = 0;

	for(int j=0; j<S.length()-i; ++j) {
	    if (S[j] == S[j+i]) {
		++c;
		if (c > m && c <= i) {
		    m = c;
		}
	    } else {
		c = 0;
	    }
	}
    }

    cout << m << endl;


    return 0;
}


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

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

  int g = 0, p = 0;
  for(auto it : s) {
    if(it == 'g') g++;
    if(it == 'p') p++;
  }

  cout << (g - p) / 2 << '\n';
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	#define mp make_pair
	lli mcd(lli a,lli b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}		
	int arr[MaxN];
int main(){
	lli N,K,i,j,res=0,ans=0;
	string word;	
	cin>>word;	
	N=word.size();
	char aux;
	for(i=0;i<N;i++){
		aux=word[i];
		if(aux=='0')arr[i]=0;
		else arr[i]=1;
	}
	lli in=0;
	for(i=0;i<N;i++){
		if(in!=arr[i])res+=1;
		in=in^1;
	}
	in=1;
	ans=res;
	res=0;
	for(i=0;i<N;i++){
		if(in!=arr[i])res+=1;
		in=in^1;
	}
	cout<<min(res,ans);
	
}

Measured memory_bytes: 832
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int top=0;
    int last=0;
    for (int i = 0; i < s.length(); i++){
      if (s.charAt(i) == 'A'){
        top = i;
        break;
      }
    }
    for (int j = s.length() - 1; j > top ; j--){
      if(s.charAt(j) == 'Z'){
        last = j;
        break;
      }
    }
    System.out.println(last - top + 1);
  }
}

Measured memory_bytes: 28536
// Try AtCoder
// author: Leonardone @ NEETSDKASU

let solve n =
   seq { 1 .. 3500 }
   |> Seq.tryPick (fun a ->
          seq { 1 .. 3500}
          |> Seq.tryPick (fun b ->
                   if n*a*b%(4*a*b-a-b) = 0 then
                       Some(a,b)
                   else
                       None))

[<EntryPoint>]
let main _ =
   let n = int <| stdin.ReadLine()
   if n % 2 = 0 then
      printfn "%d %d %d" n n (n / 2)
   else
      let (a,b) = Option.get <| solve n
      printfn "%d %d %d" (a*n) (b*n) (n*a*b/(4*a*b-a-b))
   0

Measured memory_bytes: 14044
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
ll a[114514];
map<int, int>mp;
signed main() {
	ll n, ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)mp[a[i]]++;
	rep(i, n) {
		if (mp[a[i]] % 2 == 1)ans++;
		mp[a[i]] = 728;
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 5760
N = int(input())
dic = {}
for i in range(N):
  a = int(input())
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
count = 0
for v in dic.values():
  if v % 2 == 1:
    count += 1
print(count)

Measured memory_bytes: 15076
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}

#define maxn 55
#define maxm 105
#define maxs 5005

ll n, m, s, a[maxm] = {0}, b[maxm] = {0}, c[maxn] = {0}, d[maxn] = {0}, cost[maxn][maxs] = {0};
vector<pair<int,int> > adj[maxn], g[maxn][maxs];
set<pair<ll, pair<int, int> > >  pq;

int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    for (int i = 0; i < maxn; i++){
        for (int j = 0; j < maxs; j++){
            cost[i][j] = LLONG_MAX;
        }
    }
    cin>>n>>m>>s;
    s = min(s, maxs-1);

    for (int i = 0; i < m; i++){
        int u, v;
        cin>>u>>v>>a[i]>>b[i];
        u--;
        v--;
        adj[u].push_back(make_pair(v,i));
        adj[v].push_back(make_pair(u,i));
    }
    for (int i = 0; i < n; i++){
        cin>>c[i]>>d[i];
    }

    pq.insert(make_pair(0,make_pair(0,s)));

    while (!pq.empty()){
        pair<ll, pair<int, int> > top = *pq.begin();
        pq.erase(pq.begin());
        ll time = top.first;
        int u = top.second.first, S = top.second.second;
        for (int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i].first, id = adj[u][i].second;
            if ((S>=a[id]) && (time+b[id]<cost[v][S-a[id]])){
                if (cost[v][S-a[id]]!=LLONG_MAX) pq.erase(make_pair(cost[v][S-a[id]], make_pair(v,S-a[id])));
                cost[v][S-a[id]] = time + b[id];
                pq.insert(make_pair(cost[v][S-a[id]], make_pair(v,S-a[id])));
            }
        }
        if ((S+c[u]<maxs) && (time+d[u]<cost[u][S+c[u]])){
            if (cost[u][S+c[u]]!=LLONG_MAX) pq.erase(make_pair(cost[u][S+c[u]], make_pair(u,S+c[u])));
            cost[u][S+c[u]] = time+d[u];
            pq.insert(make_pair(cost[u][S+c[u]], make_pair(u,S+c[u])));
        }
    }

    for (int i = 1; i < n; i++){
        ll ans = LLONG_MAX;
        for (int j = 0; j < maxs; j++){
            ans = min(ans, cost[i][j]);
        }
        cout<<ans<<"\n";
    }

    return 0;
}





Measured memory_bytes: 18228
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	static boolean[] targetNumbers;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int n = S.length();
		int count = 0;
		for (int i=0; i<n/2; i++) {
			if (S.charAt(i)!=S.charAt(n-i-1)) {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	auto H = readAs!(int[]);
	alias Pair = Tuple!(int, "A", int, "B");
	Pair[] pairs;
	int[][] paths = new int[][](N);
	foreach(i; 0..M) {
		auto ip2 = readAs!(int[]), A = ip2[0], B = ip2[1];
		paths[A-1] ~= B-1;
		paths[B-1] ~= A-1;
	}
	
	ulong res;
	foreach(i; 0..N) {
		debug writeln;
		bool flag = true;

		foreach(v; paths[i]) {
			debug "%d %d".writefln(i, v);
			if(H[v] < H[i]) {
			} else flag = false;
		}
		if(flag) {
			res++;
			debug "ok".writeln;
		}
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    int32 ans = 0;
    REP(i,n){
        int32 a;
        cin >> a;
        while(a % 2 == 0){
            ans++;
            a/=2;
        }
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<vector>
#define ll long long
//#define int long long
#define MOD(x) ((x)>=mod?(x)-mod:(x))
using namespace std;
const int maxn=500010, mod=1e9+7;
struct tjm{int too, pre;}e[maxn<<1];
struct poi{int f[3];};
int n, x, ans, tot, tott;
int last[maxn], root[maxn];
vector<poi>q[maxn];
inline void read(int &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-' && (f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}
inline void add(int x, int y){e[++tot]=(tjm){y, last[x]}; last[x]=tot;}
inline int merge(int x, int y)
{
	if(q[x].size()<q[y].size()) swap(x, y);
	int nx=q[x].size()-1, ny=q[y].size()-1;
	for(int i=0;i<=ny;i++) 
	{
		int sum0=0, sum1=0, sum2=0;
		sum0=1ll*q[x][nx-i].f[0]*q[y][ny-i].f[0]%mod;
		sum1=(1ll*q[x][nx-i].f[1]*q[y][ny-i].f[0]+1ll*q[x][nx-i].f[0]*q[y][ny-i].f[1])%mod;
		for(int j=0;j<3;j++)
			for(int k=2;j+k>=2;k--)
				sum2=(1ll*sum2+1ll*q[x][nx-i].f[j]*q[y][ny-i].f[k])%mod;
		q[x][nx-i].f[0]=sum0; q[x][nx-i].f[1]=sum1; q[x][nx-i].f[2]=sum2;
	}
	q[y].clear(); return x;
}
void dfs(int x, int fa)
{
	if(!last[x]) root[x]=++tott; int dep=0;
	for(int i=last[x], too;i;i=e[i].pre)
	if((too=e[i].too)!=fa)
	{
		dfs(too, x);
		if(!root[x]) root[x]=root[too];
		else dep=max(dep, (int)min(q[root[x]].size(), q[root[too]].size())), root[x]=merge(root[x], root[too]);
	}
	int nx=q[root[x]].size()-1; 
	for(int i=0;i<dep;i++) 
		q[root[x]][nx-i].f[0]=MOD(q[root[x]][nx-i].f[0]+q[root[x]][nx-i].f[2]), q[root[x]][nx-i].f[2]=0;
	poi tmp; tmp.f[1]=tmp.f[0]=(mod+1)>>1; tmp.f[2]=0; q[root[x]].push_back(tmp);
}
inline int power(int a, int b)
{
	int ans=1;
	for(;b;b>>=1, a=1ll*a*a%mod)
	if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
//#undef int
int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(x), add(x, i);
	dfs(0, -1); 
	for(int i=0;i<q[root[0]].size();i++) ans=MOD(ans+q[root[0]][i].f[1]);
	printf("%lld\n", 1ll*ans*power(2, n+1)%mod);
}

Measured memory_bytes: 44020
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+7;
int a[MAXN],b[MAXN],c[MAXN];

int32_t main(){
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];sort(a,a+n);
	for(int i=0;i<n;i++)cin>>b[i];//sort(b,b+n);
	for(int i=0;i<n;i++)cin>>c[i];sort(c,c+n);
	long long res=0;
	for(int i=0;i<n;i++){
		int pa=lower_bound(a,a+n,b[i])-a;
		int pc=upper_bound(c,c+n,b[i])-c;
		res+=1ll*(n-pc)*pa;
	}
	cout<<res;
}

Measured memory_bytes: 1536
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double c = scanner.nextDouble();
        double x = scanner.nextDouble();
        double y = scanner.nextDouble();
        double max = Math.max(x,y)*2;

        double prev = Double.MAX_VALUE;
        for(int i = 0; i <= max; i+=2){
            //if(x < 0 || y < 0){break;}
            double cur = a * x + b * y + c * i;
            //System.out.println("x : " + x + " y : " + y + " i : " + i + " total : " + cur);
            if(x > 0){x--;}
            if(y > 0){y--;}
            if(prev <= cur){break;}
            else{prev = cur;}
        }
        System.out.println((int)prev);
    }
}



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

using namespace std;

typedef long long LL;

const LL N = 1234567;

inline LL read()
{
  LL p=0; LL f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

int main()
{

  LL n=read(); LL k=read();
  
  LL ans = 0;
  for(LL b=k+1;b<=n;b++)
  {
    LL tim = n/b; LL s = 0;
    s += tim * (b-k);

    LL bb = n - tim * b;
    if(k) s += max( bb - k + 1, 0LL); 
    else if(bb) s+=bb;

    // prLLf("%d : %d\n",b,s);
    ans+=s;
  }
  return printf("%lld\n",ans),0;
}

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

int main() {
    int g[12]={
        0,2,0,1,0,1,0,0,1,0,1,0
    };
    int x,y; cin >> x >> y;
    if(g[x-1]==g[y-1])cout << "Yes" <<endl;
    else cout << "No" << 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);                                
         
        String s = sc.next();
        
        int start = 0;
        int   end = s.length() - 1;
        boolean flag = true;        
        for(int i = 0;i < s.length();i++){
            if(s.charAt(i) == 'A' && flag){
                 start = i;
                 flag  = false;
            }
            if(s.charAt(i) == 'Z'){
                 end  = i;
            }
        }
        
        System.out.println(end - start + 1);

    }            
}
        

Measured memory_bytes: 26296