akhauriyash/Code-Regression huggingface dataset:
X, Y = map(int, input().split())
res = 0
if X == 1:
  res += 300000
elif X == 2:
  res += 200000
elif X == 3:
  res += 100000

if Y == 1:
  res += 300000
elif Y == 2:
  res += 200000
elif Y == 3:
  res += 100000
  
if X == 1 and Y == 1:
  res += 400000
print(res)





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

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
#        for line in sys.stdin:
#            lines.append(line)
        lines.append(input())
    else:
        debug = False
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, b, x) = [int(e) for e in lines[0].split(" ")]

    return (a, b, x)

def solve(l, h, v):


    max_v =  l * l * h
    tan = 0
    if v > 0.5 * max_v:
        tan = 2*h/l - 2*v/(l*l*l) 
    else:
        tan = h*h*l/(2*v)

    theta = math.atan(tan)

    return math.degrees(theta)

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
import sys

n, k = map(int, input().split())
w = [int(sys.stdin.readline()) for i in range(n)]
l = max(w)
r = sum(w)

while l < r:
    m = (l + r) // 2
    stack = car = 0
    for i in w:
        stack += i
        if stack > m:
            stack = i
            car += 1
    if car < k:
        r = m
    else:
        l = m + 1
print(l)

Measured memory_bytes: 11140
#include <iostream>
#include <cstdio>

using std::cin;using std::cout;using std::endl;

int main(){
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H*W)-(h*W)-(w*H)+(w*h);

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
  var S string
  m := make(map[rune]int)
  fmt.Scan(&S)

  for _, s := range S {
    m[s]++
  }
  
  if len(m) != 2 {
		fmt.Println("No")
  } else {
    for _, v := range m {
      if v != 2 {
        fmt.Println("No")
        return
      }
    }
    fmt.Println("Yes")
  }
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    ll x;
    cin >> x;

    ll sum = x / 11;
    ll cnt = sum * 2;
    ll amari = x % 11;

    while (amari > 0) {
        amari -= 6;
        sum += 6;
        cnt++;

        if (amari <= 0) break;

        amari -= 5;
        sum += 5;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#define MX 105
#define MOD 1'000'000'007
#define set(N,pos) (N | (1LL<<(pos)))
#define clear(N,pos) (N & (~(1LL<<(pos))))
#define is_set(N,pos) (N & (1LL<<(pos)))
#define all(v) (v).begin(),(v).end()
#define F first
#define S second

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false); cin.tie(0);

    int n;
    cin >> n;
    map<string,int> mp;
    string s;
    for(int i=0; i<n; i++)
    {
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for(auto &x: mp)
    {
        mx = max(mx,x.S);
    }
    for(auto &x: mp)
    {
        if(x.S == mx)
            cout << x.F << '\n';
    }

    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>

#define ll long long
#define VL vector<ll>
#define VI vector<int>
#define FOR(i,b) for(int i= 0; i<((int)b); ++i)
#define FOR_(i,a,b) for(int i= a; i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define COUT(x) cout << x << endl;
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define EPS 1e-14
#define DIM2(R,C,arr) vector<vector<int>> arr(R);FOR(i,R) (arr)[i].resize(C);
#define DIM2INIT(R,C,arr) FOR(i,R)FOR(j,C)arr[i][j]=0;
#define MAPGEN(R,C,visited,map) char map[R][C]; FOR(i,R){string s;cin>>s;FOR(j,C){visited[i][j]=0;map[i][j]=s[j];}}
#define Point pair<int,int>
#define POINT(x,y,arr) arr[y][x]
#define SORT(a)  sort(a.begin(),a.end());
using namespace std;







int main() {
    //*** ---------------------------------------------------------------------------*//
    //
    //                            Variables and Initialize
    //
    //*----------------------------------------------------------------------------- *//
    
    int N;
    
    cin >> N ;
    VI L(2*N);
    FOR(i,2*N)cin >>L[i];
    SORT(L);
    int ans=0;
    FOR(i,N){
        ans+=L[i*2];
    }
    COUT(ans);
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, j, k, N, K;
	scanf("%d %d", &N, &K);
	if (K > (N - 1) * (N - 2) / 2) printf("-1\n");
	else {
		printf("%d\n", N * (N - 1) / 2 - K);
		for (i = 1, k = 0; i < N; i++) {
			for (j = i + 1; j <= N; j++) {
				printf("%d %d\n", i, j);
				k++;
				if (k >= N * (N - 1) / 2 - K) break;
			}
			if (j <= N) break;
		}
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1728
import Data.List

main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  putStrLn $ if 0 < check (sort as) then "NO" else "YES"

foldlPairwise :: (a -> b -> b -> a) -> a -> [b] -> a
foldlPairwise f a l = foldl (\a (z, x) -> f a z x) a $ zip l (tail l)

check as = foldlPairwise step 0 as
    where step a z x = a + if z == x then 1 else 0


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

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

    int cnt = 0;

    for (int i = 0; i < n; i++)
    {
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2){
            cnt++;
        }else{
            cnt = 0;
        }
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    // B shibh308
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a){
        char c;
        cin >> c;
        x = (c == 'T');
    }
    function<bool(bool,bool)> f = [&](bool x, bool y){
        return (!x) | y;
    };
    bool fl = a[0];
    for(int i = 1; i < n; ++i){
        fl = f(fl, a[i]);
    }
    cout << (fl ? "T" : "F") << endl;
}



Measured memory_bytes: 3120
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int nm(int a,int b){
    if(a<b) swap(a,b);
    return (a-1)*(a-2)/2+b-1;
}

struct edge{
    ll dm,cd,ct;
    edge(ll a,ll b,ll c){dm=a;cd=b;ct=c;};
};

template <class T> bool BF(int n,int m,vector<edge>& es,vector<T>& d,int s,int t){
    T x=numeric_limits<T>::max()/2;
    d.resize(n,x);
    d[s]=0;
    T mx;
    fr(i,2*n){
        fr(j,m){
            edge e=es[j];
            if(d[e.cd]>d[e.dm]+e.ct){
                d[e.cd]=d[e.dm]+e.ct;
                if(i>=n-1&&d[e.cd]<x/2) d[e.cd]=-x;
            }
        }
    }
    return d[t]==-x;
}



class ELeague {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m;
        in>>n;
        m=n*(n-1)/2;
        vector<int> h(m);
        vector<vector<int>> a(n+1,vector<int>(n-1));
        vector<vector<int>> v(n*(n-1)/2),iv(n*(n-1)/2);
        Fr(i,n) fr(j,n-1) in>>a[i][j];
        Fr(i,n){
            fr(j,n-2){
                v[nm(i,a[i][j])].emplace_back(nm(i,a[i][j+1]));
                iv[nm(i,a[i][j+1])].emplace_back(nm(i,a[i][j]));
            }
        }
        stack<int> st;
        fr(i,m) if((h[i]=iv[i].size())==0) st.push(i);
        vector<int> ts;
        while(!st.empty()){
            int i=st.top();st.pop();
            ts.emplace_back(i);
            for(auto&j:v[i]){
                --h[j];
                if(h[j]==0) st.push(j);
                if(h[j]<0){

                }
            }
        }
        if(ts.size()!=m){
            out<<-1<<endl;
            return;
        }
        vector<int> it(m);
        fr(i,m) it[ts[i]]=i;
        vector<int> dp(m);
        int ans=0;
        fr(i,m){
            ans=max(ans,dp[i]);
            for(auto j:v[ts[i]]){
                dp[it[j]]=max(dp[it[j]],dp[i]+1);
            }
        }
        out<<ans+1<<endl;
    }
};

int main() {
    ELeague solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

constexpr int MAXN = 505;
constexpr int dirX[] = {1, 0, -1, 0}, dirY[] = {0, 1, 0, -1};
int n;
int P[MAXN * MAXN];
int dis[MAXN][MAXN];
bool use[MAXN][MAXN];

queue<pair<int, int>> que;

bool inG(int x, int y) { return 1 <= x && x <= n && 1 <= y && y <= n; }

void BFS() {
  while (!que.empty()) {
    auto [x, y] = que.front();
    que.pop();
    for (int i = 0, d = dis[x][y] + use[x][y]; i < 4; ++i) {
      if (int nx = x + dirX[i], ny = y + dirY[i];
          inG(nx, ny) && dis[nx][ny] > d) {
        dis[nx][ny] = d;
        que.emplace(nx, ny);
      }
    }
  }
}

pair<int, int> id_to_pos(int id) {
  return {(id - 1) / n + 1, (id - 1) % n + 1};
}

int calc() {
  for (int i = 1; i <= n; ++i) fill_n(dis[i] + 1, n, n * n);
  for (int i = 1; i <= n; ++i) fill_n(use[i] + 1, n, true);
  for (int i = 1; i <= n; ++i) dis[i][1] = dis[i][n] = 0;
  for (int i = 2; i < n; ++i) dis[1][i] = dis[n][i] = 0;
  for (int i = 1; i <= n; ++i) {
    que.emplace(i, 1);
    que.emplace(i, n);
  }
  for (int i = 2; i < n; ++i) {
    que.emplace(1, i);
    que.emplace(n, i);
  }
  BFS();
  int ret = 0;
  for (int i = 1; i <= n * n; ++i) {
    auto [x, y] = id_to_pos(P[i]);
    ret += dis[x][y];
    use[x][y] = false;
    que.emplace(x, y);
    for (int i = 0; i < 4; ++i) {
      if (int nx = x + dirX[i], ny = y + dirY[i]; inG(nx, ny))
        que.emplace(nx, ny);
    }
    BFS();
  }
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n * n; ++i) scanf("%d", &P[i]);
  printf("%d", calc());
}


Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  int n = s.size();

  set<string> st;
  rep(l,1,6){
    rep(i,n-l+1) st.insert(s.substr(i,l));
  }

  auto itr = st.begin();
  rep(i,k-1) itr++;

  cout << *itr << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 62;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

vll divisor(ll x) {
    map<ll, ll> mp;
    for(ll i = 2; i * i <= x; i++) {
        while(x % i == 0) {
            mp[i]++;
            x /= i;
        }
    }
    if(x > 1) mp[x]++;
    vll ret(1, 1);
    for(auto i = mp.begin(); i != mp.end(); i++) {
        ll base = 1;
        ll size = ret.size();
        for(ll j = 1; j <= i->second; j++) {
            base *= i->first;
            for(ll k = 0; k < size; k++) {
                ret.push_back(ret[k] * base);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

void solve() {
    ll n;
    cin >> n;
    vll div = divisor(2 * n);
    ll ans = INFL;
    vll r = {0, -1};
    rep(i, div.size()) {
        vll m = {div[i], 2 * n / div[i]};
        pll p = crt(r, m);
        if(p.first != 0) chmin(ans, p.first);
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3812
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

int main() {
	int n;
	cin >> n;
    
	vector<int> vi(n);
	string sp="", sq="";

	for (int i = 0; i < n; i++) {
		vi[i] = i + 1;
		string s;
		cin >> s;
		sp += s;
	}
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sq += s;
	}

	int p = stoi(sp);
	int q = stoi(sq);

	int idx = 1;
	int pIdx = 0;
	int qIdx = 0;
	do {
		int num = 0;
		for (int i = 0; i < n; i++) {
			num += pow(10,n-i-1)*vi[i];
		}
		if (num == p) {
			pIdx = idx;
		}
		if (num == q) {
			qIdx = idx;
		}
		idx++;
	}while(next_permutation(vi.begin(), vi.end()));

	cout << abs(pIdx-qIdx) << endl;
}


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

string pre[] = {"yotta", "zetta", "exa", "peta", "tera", "giga", "mega", "kilo", "hecto", "deca", "deci", "centi", "milli", "micro", "nano", "pico", "femto", "ato", "zepto", "yocto"};
int expo[] = {24, 21, 18, 15, 12, 9, 6, 3, 2, 1, -1, -2, -3, -6, -9, -12, -15, -18, -21, -24};

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

    while(--d >= 0){
        string s, unit;
        cin >> s >> unit;

        int a = 0;
        if(find(pre, pre+20, unit) != pre+20){
            a = expo[find(pre, pre+20, unit) - pre];
            cin >> unit;
        }

        if(s[0] == '0'){
            int i = s.find_first_not_of('0', 2);
            a -= i - 1;
            s = '.' + s.substr(i);
            swap(s[0], s[1]);
        }else if(s.find('.') == string::npos){
            a += s.size() - 1;
            s = '.' + s;
            swap(s[0], s[1]);
        }else{
            int i = s.find('.');
            a += i - 1;
            s.erase(i, 1);
            s = '.' + s;
            swap(s[0], s[1]);
        }
        if(s.size() == 2)
            s = s.substr(0, 1);

        cout << s << " * 10^" << a << ' ' << unit << endl;
    }

    return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(struct Card A[], int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(struct Card A[], int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ )
    if ( A[j].value <= x.value ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n - 1);

  for ( i = 0; i < n; i++ )
    if ( A[i].suit != B[i].suit ) stable = 0;

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ )
    printf("%c %d\n", B[i].suit, B[i].value);

  return 0;
}


Measured memory_bytes: 4044
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  if (a == b && b == c && a %2 == 0) {
    cout << -1 << endl;
    return EXIT_SUCCESS;
  }

  ll i;
  for (i = 0; a % 2 == 0 && b % 2 == 0 && c % 2 == 0; ++i) {
    ll a2 = a;
    ll b2 = b;
    ll c2 = c;
    a = (b2 + c2) / 2;
    b = (a2 + c2) / 2;
    c = (a2 + b2) / 2;
  }

  cout << i << endl;
}


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

int main(){
  int N;
  long long sum=0;
  cin >> N;
  vector<long long> A(3*N);
  for(int i=0;i<3*N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  for(int i=0;i<2*N;i++){
    if(i%2==1){
      sum+=A.at(i);
    }
  }
  cout << sum << endl;
}
    


Measured memory_bytes: 2560
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		// 入力値の取得
		int N = sc.nextInt();
		
		Set<String> S = new HashSet<>();
		for (int i = 0; i < N; i++) {
			S.add(sc.next());
		}
		
		// 結果の出力
		System.out.println(S.size());

		sc.close();
	}
}


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

int main()
{
  int n, m = 0;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = n - 1; i >= 0; i--) {
    b.at(i) = (a.at(i) + b.at(i)) % 2;
    m += b.at(i);
    if (b.at(i) == 0) continue;
    for (int j = 1; j * j <= i + 1 && j <= i; j++) {
      if ((i + 1) % j == 0) {
        b.at(j - 1)++;
        if (j > 1 && j * j < i + 1) {
          b.at((i + 1) / j - 1)++;
        }
      }
    }
  }
  int balls = 0;
  cout << m << endl;
  if (m == 0) return 0;
  for (int i = 0; i < n; i++) {
    if (b.at(i) == 1) {
      cout << i + 1;
      balls++;
      if (balls == m) {
        cout << endl;
      } else {
        cout << " ";
      }
    }
  }
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  int cnt[101000] = {0};
  int ans = 1;
  int tmp;
  rep(i,N){
    cin >> tmp;
    cnt[tmp]++;
  }
  for(int i=2;i<=100000;i++){
    ans = max(ans, cnt[i-2]+cnt[i-1]+cnt[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main() {

	int a, b,c;

	std::cin >> a;
	std::cin >> b;
	std::cin >> c;

	if ((a < b) && (b < c))
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

	return 0;

}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

struct event {
    ll moment, query, place;
    // query
    // insert == -1
    // delete == 0
    // check == 1
    // 同じ時間にinsert,check,deleteのクエリが来たときは
    // insert -> delete -> check の順に操作(工事が終わるのと始めるのは一瞬早い)
};

bool comp(const event &a, const event &b) {
    if(a.moment == b.moment) {
        if(a.query == b.query) {
            return a.place < b.place;
        }
        return a.query < b.query;
    }
    return a.moment < b.moment;
}

int main() {
    ll n, m, i, j, k;
    ll q;
    cin >> n >> q;
    vector<event> v;
    for(i = 0; i < n; i++) {
        ll s, t, x;
        cin >> s >> t >> x;
        v.push_back({s - x, -1, x});
        v.push_back({t - x, 0, x});
    }
    vector<pair<ll, ll>> people;
    for(i = 0; i < q; i++) {
        ll d;
        cin >> d;
        v.push_back({d, 1, i});
    }
    sort(v.begin(), v.end(), comp);
    vector<ll> ret(q, 0);
    multiset<ll> ms;
    i = 0;
    for(event e : v) {
        if(e.query == -1) {
            ms.insert(e.place);
        } else if(e.query == 0) {
            ms.erase(ms.lower_bound(e.place));
            // ms.erase(const ll x) でeraseをするとxがすべて消える
            // ms.erase(lower_bound(const ll x)) で1つだけ消去できる
        } else {
            ret[i++] = ms.empty() ? -1 : *ms.begin();
        }
    }
    for(i = 0; i < q; i++) {
        cout << ret[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 26984
import java.util.Scanner;
 
public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int val = scan.nextInt();
		int base = (val / 100);
		if (val <= getVal(base)) {
			System.out.println(getVal(base));
		} else {
			base++;
			System.out.println(getVal(base));
		}
	}
	public static int getVal(int base) {
		return base * 100 + base * 10 + base;
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a >= 3200) {
        cout << s << endl;
        return 0;
    } else {
        cout << "red" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int max = a < b ? b : a;
	int min = a < b ? a : b;
	if(min < c && c < max){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    string s, t; 
    cin >> s >> t;
    auto ret = t.compare(0, s.size(), s) == 0 ? "Yes" : "No"; 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3620
#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>;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator() (int n, int k) {
        if ( k < 0 || k > n ) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
    mint p(int n, int k) {
        return fact[n] * ifact[n-k];
    }
} c(1000005);

int main() {
    int n, m;
    cin >> n >> m;
    mint ans = 0;
    rep(i,n+1) {
        mint now = c(n, i);
        now *= c.p(m,n);
        now *= c.p(m-i, n-i);
        if (i&1) now = -now;
        ans += now;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18648
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
for i in range(M):
    x.append(list(map(int, input().split())))

ans = float('Inf')
ans = min(a) + min(b)
#ans
for xi in x:
    ans = min(ans, a[xi[0] - 1] + b[xi[1] - 1] - xi[2])
print(ans)

Measured memory_bytes: 38560
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            for(var i=1;i<10;i++)
            {
                for (var j = 1; j < 10; j++)
                {
                    if(i*j==N)
                    {
                        WriteLine("Yes");
                        return;
                    }
                }

            }
                        WriteLine("No");
        }
    }
}


Measured memory_bytes: 18836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<functional>
#include<cstring>
#define N (1<<17)
  
using namespace std;
typedef long long ll;
ll dat[1000001];
int id[1000001];
int n,r,l;
int d[1000001],t[1000001],x[1000001];
int timel[100001];
 
void init(){
  memset(dat,0,sizeof(dat));
  for(int i=N;i<N*2;i++)id[i]=i-N;
}
  
void update(int k,ll a){
  k+=N-1;
  dat[k]+=a;
  while(k>0){
    k=(k-1)/2;
    if(dat[k*2+1]>=dat[k*2+2]){//子供の左右の大小比較
      dat[k]=dat[k*2+1];
      id[k]=id[k*2+1];
    }else{
      dat[k]=dat[k*2+2];
      id[k]=id[k*2+2];
    }
  }
}
 
int main(){
  scanf("%d %d %d",&n,&r,&l);
  for(int i=0;i<r;i++)scanf("%d%d%d",&d[i],&t[i],&x[i]);
  int nt=0;
  init();
  for(int i=0;i<r;i++){
    timel[id[0]]+=t[i]-nt;//今レコードされた時間からその前にレコードされた時間を引いたもの
    nt=t[i];
    update(d[i]/*チーム番号*/,x[i]/*獲得した得点*/);
  }
  timel[id[0]]+=l-nt;//最後のレコードチームに残り時間すべてを加算
  int sum=0,rid=0;
  for(int i=0;i<n;i++){//一番合計時間の高いチームの探索
    if(sum<timel[i]){
      sum=timel[i];
      rid=i;//チームID確保
    }
  }
  printf("%d\n",rid+1);
  return 0;
}

Measured memory_bytes: 24760
#include<bits/stdc++.h>
using namespace std;
/*********ANISH***********ANISH*************ANISH***********ANISH******/
#define pb push_back
#define ll long long
#define ff first
#define ss second
ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
ll min(ll a,ll b)
{
    if(a<b) return a;
    return b;
}
int lcm(int a, int b)  
{  
    return (a*b)/__gcd(a, b);  
}  
/********ANISH************ANISH*************ANISH**********ANISH*********/
int main()
{
  int test;
  test=1;
  while(test--)
  {
     int x;
     cin>>x;
     if(x>=30) cout<<"Yes";
     else cout<<"No";
  }
}


Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
#define INF 2147483647
using namespace std;

int n,q;
int com;
int tree[411111]; 

void init();
void update(int i, int x);
int segtree_find(int x, int y, int now, int left, int right);

int main(){

  scanf(" %d %d",&n,&q);

  init();

  for(int i=0;i<q; i++){
    scanf(" %d",&com);

    if(com){
      int x,y;
      scanf(" %d %d",&x,&y);
      printf("%d\n",segtree_find(x, y, 0, 0, n-1));
    } else {
      int x, y;
      scanf(" %d %d",&x,&y);
      update(x, y);
    }
  }

  return 0;
}


void init(){

  int m = n;
  n = 1;
  while(n < m)n = (n<<1);

  fill(tree, tree+n*2, INF);

  return;
}

void update(int i, int x){
  i = i + n - 1;
  tree[i] = x;

  while(i > 0){
    i = (i - 1) / 2;
    tree[i] = min(tree[i * 2 + 1], tree[i * 2 + 2]);
  }

  return;
}

int segtree_find(int x, int y, int now, int left, int right){

  if(right < x || y < left)return INF;


  if(x <= left && right <= y)return tree[now];

  if(now > n * 2)return -1;

  int find_left = segtree_find(x, y, (now * 2 + 1), left, ((right + left) / 2));
  int find_right = segtree_find(x, y, (now * 2 + 2), ((right + left) / 2 + 1), right);

  return min(find_left, find_right);
}

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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 1006
#define mod 1000000007
#define mod2 998244353
#define inf 1e18




int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif

    int h,w;
    cin >> h >> w;
    vector <vector <int>> dp(h+1,vector <int> (w+1,0));

    dp[0][0]=1;
    char a[h+1][w+1];
    int i,j;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            cin >> a[i][j];
        }
    }

    for(i=1;i<w;i++)
    {
        if(a[0][i]=='.')
        {
            dp[0][i]=dp[0][i-1];
        }
        else
            break;
    }

    for(i=1;i<h;i++)
    {
        if(a[i][0]=='.')
        {
            dp[i][0]=dp[i-1][0];
        }
        else
            break;
    }

    for(i=1;i<h;i++)
    {
        for(j=1;j<w;j++)
        {
            if(a[i][j]=='.')
            {
                int tmp=(dp[i-1][j]+dp[i][j-1])%mod;
                dp[i][j]=tmp;
            }

        }
    }




    cout << dp[h-1][w-1]<< endl;
}

Measured memory_bytes: 9088
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next;
    while (cur != nil && cur ->key != key){
        cur = cur->next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while(1){
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d" , cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev =nil;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d" , &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i'){
            insert(key); np++; size++;
        }
        else if (com[0] == 'd'){
            if (strlen(com) > 6){
                if (com[6] == 'F')deleteFirst();
                else if (com[6] == 'L') deleteLast();
            }
            else{
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    
    return 0;
}


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

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

typedef long long ll;

int main(){
    ll A[3];
    int cnt = 0;
    rep(i,3){
        cin >> A[i];
        if (A[i] % 2 == 0) cnt++;
    }
    sort(A,A+3);
    //cout << A[0] << endl;
    if (cnt){
        cout << 0 << endl;
        return 0;
    }
    if (!cnt){
        //cout << 1 << endl;
        cout << A[0] * A[1] << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    a,b,c,d = LI()
    if a+b > c+d:
        print("Left")
    elif a+b == c+d:
        print("Balanced")
    else:
        print("Right")
    return

#B
def B():
    def digit_sum(n):
        res = 0
        m = n
        while m:
            res += m%10
            m//=10
        return res
    n,a,b = LI()
    ans = 0
    for i in range(1,n+1):
        if a <= digit_sum(i) <= b:
            ans += i
    print(ans)
    return

#C
def C():
    x,y = LI()
    ans = 1
    for i in range(10000000000000):
        x *= 2
        if x > y:break
        ans += 1
    print(ans)

#D
def D():
    s = S()
    n = len(s)
    ans = n
    for i in range(n-1):
        if s[i] != s[i+1]:
            ans = min(ans,max(i+1,n-i-1))
    print(ans)

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


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

int a[100005] = {0};

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

  int k;
  for(int i=0; i<n; i++){
    cin >> k;

    a[k]++;
    if(k!=0) a[k-1]++;
    if(k!=100000)a[k+1]++;
  }

  int maxv = 0;
  for(int i=0; i<100002; i++){
    maxv = max(maxv, a[i]);
  }
  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int ans;
int n;
int power[40];
vector<vector<int> > g;
void solve(ll S, int now, int sum) {
  if (now == n) {
    ans = max(ans, sum);
    return;
  }
  int t = 0;
  for (int i=now; i<n; ++i) t += power[i];
  if (sum + t < ans) return;
  bool f = 0;
  FOR(it, g[now]) {
    if (S>>*it&1) {
      f = 1;
      break;
    }
  }
  if (!f) {
    // use
    solve(S|1LL<<now, now+1, sum+power[now]);
  }
  solve(S, now+1, sum);
}

int main() {
  while(cin>>n,n) {
    map<string,int> mp;
    int num = 0;
    g = vector<vector<int> >(n);
    REP(i,n) {
      string A;
      int B,C;
      cin >> A >> B >> C;
      if (mp.count(A) == 0) mp[A] = num++;
      power[mp[A]] = B;
      REP(j,C) {
        string D; cin >> D;
        if (mp.count(D) == 0) mp[D] = num++;
        g[mp[A]].push_back(mp[D]);
        g[mp[D]].push_back(mp[A]);
      }
    }
    ans = 0;
    solve(1,1,power[0]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 964
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

bool possible(int A[3], int &cnt){
  if ((A[0]%2) || (A[1]%2) || (A[2]%2)) return false;

  sort(A,A+3);
  int a=A[0],b=A[1],c=A[2];
  A[0] = (a+b)/2;
  A[1] = (a+c)/2; 
  A[2] = (c+b)/2;

  cnt++;
  return (!(A[0]%2) &&  !(A[1]%2)  && !(A[2]%2));
}

int main(){
  int A[3]; cin >> A[0] >> A[1] >> A[2];

  int cnt = 0;
  while (possible(A,cnt)){
    if (A[0]==A[2]){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[10000+5];
 
 int main()
 {
   int n;
   long long int min=10000000000;
   long long int max=-10000000000;
   long long int sum=0;
   cin>>n;
   for(int i=0;i<n;i++) cin>>arr[i];
   for(int i=0;i<n;i++)
   {
     if(arr[i]<min) min=arr[i];
     if(arr[i]>max) max=arr[i];
     sum+=arr[i];         
   }
   cout<<min<<" "<<max<<" "<<sum<<endl;
   //while(1);
   return 0;
 }
 
 

Measured memory_bytes: 3088
#include<stdio.h>
int main(){
 
	int n,i,j,k,d=0,c;
	char s[101];
 
	scanf("%d%s",&n,s);
 
	for(i=1;i<n-1;i++){
		char x[27]={},y[27]={};
 
		for(j=0;j<n;j++){
			if(j<i)
				x[s[j]-'a']=1;
			else
				y[s[j]-'a']=1;
		}
		c=0;
		for(k=0;k<27;k++){
			if(x[k]==y[k])
				c+=x[k];
		}
		if(c>d)
			d=c;
	}
	printf("%d",d);
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n;
    ll k;
    cin >> n >> k;

    vector<ll> v(n + 1);
    for (int i = 1; i <= n; i++) cin >> v[i];
    partial_sum(v.begin(), v.end(), v.begin());
    for (int i = 1; i <= n; i++) {
        (v[i] -= i) %= k;
        if (v[i] < 0) v[i] += k;
    }

    ll res = 0;
    map<ll, int> cnt;

    for (int i = 0; i <= n; i++) {
        if (i >= k) cnt[v[i - k]]--;
        res += cnt[v[i]];
        cnt[v[i]]++;
    }

    cout << res << '\n';
}

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

typedef long long ll;

const int MOD = 1e9+7;
const int limit=1e3;
bool sosuu[limit+1];
int yakusu[limit+1];

void eratosthenes(int);
void setyakusu(int);
int main(){
  int n; cin >> n;

  eratosthenes(n);
  setyakusu(n);

  ll ans=1;
  for(int i=1; i<=n; i++){
    if(yakusu[i]){
      (ans *= (yakusu[i]+1)) %= MOD;
    }
  }

  cout << ans << endl;

  return 0;
}

void eratosthenes(int n){
  for(int i=1; i<=n; i++) sosuu[i] = true;
  sosuu[1] = false;

  for(int i=1; i*i<=n; i++){
    if(sosuu[i]){
      for(int j=2; i*j<=n; j++) sosuu[i*j] = false;
    }
  }
}

void setyakusu(int n){
  for(int i=1; i<=n; i++){
    int now = i;
    for(int j=1; j<=i; j++){
      while(sosuu[j] && now%j == 0){
        now /= j;
        yakusu[j]++;
      }
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,m,n;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a==b)
	{
		m=b;
	}
	else if(a>b||a<b)
	{
		if(a>b)
		{
			m=b;
		}
		else if(a<b)
		{
			m=a;
		}
	}
	if(c==d)
	{
		n=d;
	}
	else if(c>d||c<d)
	{
		if(c>d)
		{
			n=d;
		}
		else if(c<d)
		{
			n=c;
		}
	}
	printf("%d",n+m);
	return 0;
}

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

typedef pair<int, int> pii;
typedef long double lf;

pii P[3];
lf A[3];

lf dist(pii a, pii b) {
    int dx = a.first - b.first;
    int dy = a.second - b.second;
    return sqrt(dx*dx + dy*dy);
}

int main() {
    for(int i = 0; i < 3; i++) {
        scanf("%d %d", &P[i].first, &P[i].second);
    }

    for(int i = 0; i < 3; i++) {
        pii v1 = pii(P[(i + 1)%3].first - P[i].first, P[(i + 1)%3].second - P[i].second);
        pii v2 = pii(P[(i + 2)%3].first - P[i].first, P[(i + 2)%3].second - P[i].second);

        A[i] = acos(((lf) v1.first * v2.first + (lf) v1.second * v2.second) / dist(P[i], P[(i + 1)%3]) / dist(P[i], P[(i + 2)%3]));
    }

    lf ans = 0;

    for(int i = 0; i < 3; i++) {
        lf tmp = dist(P[i], P[(i + 1)%3]) / (2 + 1/tan(A[i] / 2) + 1/tan(A[(i + 1)%3] / 2));
        ans = max(ans, tmp);
    }

    cout<<fixed;
    cout.precision(20);
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int h[11];
	for(int i=0;i<10;i++){
		cin >> h[i];
	}
	for(int i=0;i<9;i++){
		for(int j=i+1;j<10;j++){
			if(h[i]<h[j]){
				h[10] = h[i];
				h[i] = h[j];
				h[j] = h[10];
			}
		}
	}
	for(int i=0;i<3;i++){
		cout << h[i] << endl;
	}
	return 0;
}

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

using namespace std;

vector<string>v;
int k;
string s;

int main(){
  cin>>s>>k;
  for(int i=0;i<s.size();){
    for(int j=1;i+j<=s.size();j++){
      v.push_back(s.substr(i,j));
      if(v.back().size()==k+1){
        break;
      }
    }
    i++;
  }
  sort(v.begin(),v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());

  cout<<v[k-1]<<endl;
}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
main()
{
    fast;
    ll n,m,k;
    cin>>n>>m>>k;
    string a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans = 0;
    ll k1 =1;
    for(ll i= 1;i<= n ;i++)
    k1 = k1*2;
    ll k2 = 1;
    for(ll i= 1;i<= m ;i++)
    k2 = k2*2;
    for(ll i=0; i<= k1 ;i++)
    {
        map<ll,ll>mp1;
        string s = bitset<30>(i).to_string();
        // cout<<s<<"\n";
        ll  f= 0;
        for(ll j= 30-n ; j < 30 ; j++)
        {
            if(s[j] == '1' )
            {
                f++;
                // // cout<<j<<" ";
                // cout<<j-30+n<<"\n";
                mp1[j - 30+n]++;
            }
        }
        // cout<<mp1.size()<<"\n";
        if(mp1.size() == 0 && i != 0)
        break;
        for(ll j=0 ;j <= k2 ;j++)
        {
            string s2 =  bitset<30>(j).to_string();
            map<ll,ll>mp2;
            for(ll j1= 30-m ; j1 < 30 ; j1++)
            {
                if(s2[j1] == '1')
                {
                    mp2[j1 - 30+m]++;
                }
            }
            if(mp2.size() == 0 && j != 0)
            break;
            ll cnt =0;
            for(ll j1 =0 ; j1 < n; j1++ )
            {
                for(ll j2 = 0;j2<m; j2++)
                {
                    if(mp1[j1] == 0 && mp2[j2] == 0)
                    {
                        if(a[j1][j2] == '#')
                        cnt++;
                    }
                }
            }
            // cout<<s2<<"\n";
            // cout<<cnt<<" ";
            if(cnt == k)
            ans++;
            // cout<<ans<<"\n";
            // cout<<"\n";
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a,b;
	cin>>a>>b;
	if(a<=8&&b<=8){
		cout<<"Yay!"<<endl;
	}
	else{
		cout<<":("<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
res = [0]*n
A=[int(i) for i in input().split()]
for i in range(n):
    res[i]=(A[i]-(i+1))
res.sort()

if n%2==1:
    ans = sum([abs(i-res[n//2]) for i in res])
else:
    b0 = (res[n//2-1]+res[n//2])//2
    b1 = (res[n//2-1]+res[n//2])
    ans = min(sum([abs(a-b0) for a in res]), sum([abs(a-b1) for a in res]))
print(ans)


Measured memory_bytes: 29476