akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const ll inf = (ll) 1e18;

vector<vector<ll> > warshallFloyd(vector<set<Pii> > edge) {
  int n = edge.size();
  vector<vector<ll> > d(n, vector<ll>(n, inf));
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
    for (Pii x : edge[i]) {
      d[i][x.first] = x.second;
    }
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  return d;
}

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

  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r;
  for (int i = 0; i < R; i++) {
    int buf;
    cin >> buf;
    r.push_back(buf-1); // zero index
  }
  vector<set<Pii> > edge;
  for (int i = 0; i < N; i++) edge.push_back(set<Pii>());
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a-1].insert(Pii(b-1, c)); // zero index
    edge[b-1].insert(Pii(a-1, c)); // zero index
  }

  vector<vector<ll> > distanceMatrix = warshallFloyd(edge);
  ll shortest = inf;
  stack<vector<int> > st;
  st.push(vector<int>());
  while (!st.empty()) {
    vector<int> now = st.top();
    st.pop();
    if (now.size() == R) {
      ll dist = 0;
      for (int i = 0; i < R-1; i++) dist += distanceMatrix[now[i]][now[i+1]];
      if (dist < shortest) shortest = dist;
      continue;
    }
    set<int> contain;
    for (int x : now) contain.insert(x);
    for (int x : r) {
      auto it = contain.find(x);
      if (it == contain.end()) {
        vector<int> next = now;
        next.push_back(x);
        st.push(next);
      }
    }
  }

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


Measured memory_bytes: 4352
// https://atcoder.jp/contests/abc132/tasks/abc132_d

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define FORR(i,b,e) for(int i=(b); i>=(int)(e); i--)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")


//------------------------------------------------------------------------------
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

ll mod_inverse(ll x, ll mod) {
  return mod_pow(x, mod - 2, mod);
}

//------------------------------------------------------------------------------
const int F_MAX = 2000;

ll fact[F_MAX + 1];
ll fact_inv[F_MAX + 1];

void init_fact(int m) {
  fact[0] = 1;
  FOR(i, 1, F_MAX) fact[i] = fact[i - 1] * i % m;
  fact_inv[F_MAX] = mod_inverse(fact[F_MAX], m);
  FORR(i, F_MAX - 1, 0) fact_inv[i] = fact_inv[i + 1] * (i + 1) % m;
}

ll mod_comb_fast(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  ll a = fact[n];
  ll b = fact_inv[k] * fact_inv[n - k] % mod;
  ll ret = a * b % mod;
  // printf("%lld_C_%lld = %lld\n", n, k, ret);
  return ret;
}

//------------------------------------------------------------------------------
const int N_MAX = 2000;
const ll MOD = 1e9+7;
const int D[] = { -1, 0, 0, 1 };

int N, K;

void solve() {
  int M = N - K;
  init_fact(MOD);
  FOR(i, 1, K) {
    // i_H_(K-i) = (K-1)_C_(K-i)
    ll b = mod_comb_fast(K - 1, K - i, MOD);
    ll r = 0;
    if (M > 0) {
      for (int d : D) {
        int j = i + d;
        // j_H_(M-j) = (M-1)_C_(M-j)
        if (j <= M) r = (r + mod_comb_fast(M - 1, M - j, MOD)) % MOD;
      }
    } else {
      r = (i == 1);
    }
    ll ans = b * r % MOD;
    printf("%lld\n", ans);
  }
}

void input() {
  scanf("%d%d", &N, &K);
}

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


Measured memory_bytes: 256
from itertools import product
from collections import defaultdict, Counter
import sys
input = sys.stdin.readline
h,w,n = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
pls = defaultdict(int)
for x,y in a:
  for arx,ary in product(list(range(x-1,x+2)),list(range(y-1,y+2))):
    if 2<=arx<=h-1 and 2<=ary<=w-1:
      pls[(arx,ary)] += 1
c = Counter(pls.values())
print((h-2)*(w-2)-sum(c.values()))
for i in range(1,10):
  print(c[i])


Measured memory_bytes: 156028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    vel A(N), B(N); rep(i,N) cin >> A[i]; rep(i,N) cin >> B[i];

    ll suma = acc( all(A), 0LL );
    ll sumb = acc( all(B), 0LL );

    if( suma < sumb ) {
        cout << -1 << endl;
        return 0;
    }

    ll amari = 0LL;
    rep(i,N) if(A[i] > B[i]) amari += A[i] - B[i];

    if(amari == suma - sumb) {cout << 0 << endl; return 0;}
    rep(i,N) if(A[i] < B[i]) amari -= ( B[i] - A[i] );
    vel D(N); rep(i,N) D[i] = A[i] - B[i];
    sort(all(D));

    int res = 0;
    ll sum = 0LL;
    rep(i,N) {
        if(D[i] < 0) continue;
        else { sum += D[i]; res++; }
        if(sum > amari) break;
    }
    res--;
    cout << N - res << endl;
    return 0;
}

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

signed main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;

	int cnt = 0;

	for (int i = 0; i * r <= n; ++i) {
		for (int j = 0; i * r + j * g <= n; ++j) {
			int ex = n - i * r - j * g;
			if (ex > 0 and ex % b == 0 or ex == 0) cnt++;
		}
	}

	cout << cnt << endl;
}



Measured memory_bytes: 256
object Main extends App {
  override def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines().toStream
    println(solve(lines))
  }

  def solve(lines: Seq[String]): String = {
    val Array(a, b) = lines.head.split(" ").map(_.toInt)
    debug(a, b)
    if (a * b % 2 == 0) "Even" else "Odd"
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 27320
//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

int n, c, k, a[MAXN];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> c >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int cur = 1, mx = a[1] + k, p = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] > mx || p + 1 > c) {
			cur++;
			p = 1;
			mx = a[i] + k;
		}
		else
			p++;
	}
	cout << cur << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};



int main(){
    int N, K, L; cin >> N >> K >> L;

    UnionFind road(N), rail(N);

    for(int i=0; i<K; ++i){
        int p, q; cin >> p >> q;
        --p; --q;
        road.connect(p,q);
    }

    for(int i=0; i<L; ++i){
        int p, q; cin >> p >> q;
        --p; --q;
        rail.connect(p,q);
    }

    map<pair<int, int>, int> mp;

    for(int i=0; i<N; ++i) mp[make_pair(road.root(i), rail.root(i))]++;

    for(int i=0; i<N; ++i){
        if(i) cout << " ";
        cout << mp[make_pair(road.root(i), rail.root(i))];
    }
    cout << endl;
    
    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> ask(N), shu(2 * N);
    const auto& query = [&ask, &shu]() -> bool {
        cout << "? ";
        for(const auto& i : ask)cout << shu[i] << " ";
        cout << endl;
        string s;
        cin >> s;
        if(s[0] == '-')abort();
        return s[0] == 'R';
    };
    iota(ask.begin(), ask.end(), 0UL);
    iota(shu.begin(), shu.end(), 1UL);
    {
        random_device rdv{};
        mt19937 mt{rdv()};
        shuffle(shu.begin(), shu.end(), mt);
    }
    vector<unsigned long> res(2 * N), ans(2 * N);
    unsigned long idx{0}, r{N}, t{0UL + query()};
    res[0] = t;
    res[N] = 1 - t;
    while(idx + 1 < r){
        auto m = (idx + r) / 2;
        iota(ask.begin(), ask.end(), m);
        ((res[m] = 0UL + query()) == t ? idx : r) = m;
    }
    iota(ask.begin(), ask.end(), idx + 1);
    ans[idx] = res[idx];
    ans[N + idx] = res[idx + 1];
    for(unsigned long i = 0; i < idx; ++i){
        ask.back() = i;
        ans[i] = static_cast<unsigned long>(query());
    }
    for(unsigned long i = N + idx + 1; i < 2 * N; ++i){
        ask.back() = i;
        ans[i] = static_cast<unsigned long>(query());
    }
    ask.back() = idx + N;
    for(unsigned long i = 0; i + 1 < N; ++i){
        auto k = ask[i];
        ask[i] = idx;
        ans[k] = 1UL - static_cast<unsigned long>(query());
        ask[i] = k;
    }
    vector<unsigned long> a(2 * N);
    for(unsigned long i = 0; i < 2 * N; ++i)a[shu[i] - 1] = ans[i];
    cout << "! ";
    for(const auto& i : a)cout << (i ? 'R' : 'B');
    cout << endl;
    return 0;
}

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
int N, M,a,b;
vvi ns;
ll dp[100000+3];

ll solve(int idx){

    ll &ret=dp[idx];
    if(~ret) return ret;

    ret=0;
    int sz=ns[idx].size();
    for(int i=0;i<sz;i++){
        ret =max(ret, 1+solve(ns[idx][i]));
    }

    return ret;

}

int main(){
    scanf("%d%d",&N,&M);
    ns=vvi(N);
    for(int i=0;i<N;i++)dp[i]=-1;
    while(M--){
        scanf("%d%d",&a,&b);
        a--, b--;
        ns[a].push_back(b);
    }

    ll mx=0;
    for(int i=0;i<N;i++){
        mx=max(mx, solve(i));
    }

    printf("%lld\n", mx);


    return 0;
}


Measured memory_bytes: 11560
package main

import (
	"fmt"
	"sort"
)

var Lunluns map[int]bool

func main() {
	var K int
	fmt.Scan(&K)
	Lunluns = make(map[int]bool)
	for i := 1; i <= 10; i++ {
		genLunlun(i)
	}
	keys := []int{}
	for k, _ := range Lunluns {
		keys = append(keys, k)
	}
	sort.Ints(keys)
	fmt.Println(keys[K-1])
}

func genLunlun(n int) {
	if n <= 3234566667 {
		Lunluns[n] = true
		last := n % 10
		if last != 0 {
			genLunlun(n*10 + last - 1)
		}
		genLunlun(n*10 + last)
		if last != 9 {
			genLunlun(n*10 + last + 1)
		}
	}
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


int main() {
    //cout.precision(10);
    vector<int> v(200010);
    SegmentTree seg(v);
    ll n;
    cin >> n;
    ll a[200010];
    ll inv[200010];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        inv[a[i]] = i;
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ll now = inv[i];
        ll under_ok = now;
        ll under_ng = 0;
        while(under_ok - under_ng > 1){
            ll mid = (under_ok + under_ng) / 2;
            if(seg.getmax(mid, now) > 0){
                under_ng = mid;
            } else {
                under_ok = mid;
            }
        }
        ll upper_ok = now;
        ll upper_ng = n + 1;
        while(upper_ng - upper_ok > 1){
            ll mid = (upper_ok + upper_ng) / 2;
            if(seg.getmax(now + 1, mid + 1) > 0){
                upper_ng = mid;
            } else {
                upper_ok = mid;
            }
        }
        //cout << i << " " << under_ok << " " << upper_ok << endl;
        ans += i * (now - under_ok + 1) * (upper_ok - now + 1);
        seg.update(inv[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6256
n, m = map(int, input().split())
an = []

for i in range(n):
  l = [int(num) for num in input().split()]
  an.append(l[1:])

check = {}
for i in an:
  for j in i:
    if j not in check:
      check[j] = 1
    else :
      check[j] += 1

answer = 0
for v in check.values() :
  if v == n:
    answer +=1
      
print(answer)

Measured memory_bytes: 9108
#include <cstdio>

int main()
{
	int a;
	scanf("%d", &a);
	if(a==25)
	{
		printf("Christmas");
	}
	else if(a==24)
	{
		printf("Christmas Eve");
	}
	else if(a==23)
	{
		printf("Christmas Eve Eve");
	}
	else if(a==22)
	{
		printf("Christmas Eve Eve Eve");
	}
}

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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= 100; i++)
    {
        if ((a * i) % b == c)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

int main(void) {
  ll n, m;
  cin>>n>>m;
  ll sq = sqrt(m);
  ll ans = 1;
  if(m%n == 0) {
    std::cout << m/n << std::endl;
    return 0;
  }
  for(ll i=1; i<=m; i++) {
    if(m/i < n)
      break;
    if(m%i == 0 and i*n <= m) {
      ans = max(ans, i);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main(){
	int N,M;
	cin >> N >> M;
	
	int ans;
	if(M>=2){
		ans+=M*(M-1)/2;
	}
	if(N>=2){
		ans += N*(N-1)/2;
	}
	cout << ans << endl;
}

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

int main() {
  int H, W, count = 0;
  
  cin >> H >> W;
  string str[H];

  for (int i = 0; i < H; i++) {
  	  cin >> str[i];
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
     	if (str[i].at(j) == '.') {
             if (i != 0 && j != 0 && str[i - 1].at(j - 1) == '#'){
              	count++; 
             }
             if (i != 0 && str[i - 1].at(j) == '#'){
              	count++; 
             }
             if (i != 0 && j != W-1 && str[i - 1].at(j + 1) == '#'){
              	count++; 
             }
          	 if (j != 0 && str[i].at(j - 1) == '#'){
              	count++; 
             }
         	 if (j != W-1 && str[i].at(j + 1) == '#'){
              	count++; 
             }
              if (i != H-1 && j != 0 && str[i + 1].at(j - 1) == '#'){
              	count++; 
             }
             if (i != H-1 && str[i + 1].at(j) == '#'){
              	count++; 
             }
             if (i != H-1 && j != W-1 && str[i + 1].at(j + 1) == '#'){
              	count++; 
             }
             string num = to_string(count);
             str[i].at(j) = num.at(0);
             count = 0;
        }
    }
    cout << str[i] << endl;
  }
}


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

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

  int d = b-a;
  int h=d*(d+1)/2;
  /*
  for(int i=1;i<d;i++){
    // 1~Nまでの総和はN(N+1)/2
    h += i*(i+1)/2;
    printf("%d",h);
  }*/

  cout << h-b << endl;
}

/*
d = b-aが隣接した塔のの高さの差
だからdまでの和を求めればそれがbの方の本当の高さhb
hbからbを引けば積もってる雪の深さxが出せる
1 + 1+2 + 1+2+3 + ... + 1+...+d までの和は

…高さの定義間違えてた…
「「隣接した塔の高さの差」の差」が等差数列なんじゃなくて
普通に差が1,2,3,…ってなってるだけだった…
*/

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

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

int main(){
  ll n,k,ans=0,s=0,t=0;
  cin >> n >> k;
  for(ll i=1;i<k;i++){
    s+=i-1;
    t+=n-i+1;
  }
  for(ll i=k;i<=n+1;i++){
    s+=i-1;
    t+=n-i+1;
    ans=(ans+t-s+1)%1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string S;
    while(cin >> S){
        vector<long long> cnt(26, 0);
        long long n = S.size();
        long long res = (n+1) * n / 2 + 1;
        for(auto c : S) cnt[c-'a']++;
        for(auto t : cnt) res -= (t+1) * t / 2;
        cout << res << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int main() {

	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

}

Measured memory_bytes: 3632
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int parent;
  int right;
  int left;
};

struct Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].left != NIL){
    h1 = setHeight(T[u].left)+1;
  }
  if(T[u].right != NIL){
    h2 = setHeight(T[u].right)+1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getsibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else printf("internal node\n");
}

int main(){
  int i,v,l,r,root = 0;
  scanf("%d",&n);
  for(i = 0;i < n;i++) T[i].parent = NIL;

  for(i = 0;i < n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(i = 0;i < n;i++)
    if(T[i].parent == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

  for(i = 0;i < n;i++){
    print(i);
  }
  return 0;
}
    



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd				double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll				vector<long long>
#define vpii			vector<pair<int,int>>
#define vpll			vector<pair<long long,long long>>
#define vvi				vector<vector<int>>
#define vvl				vector<vector<long long>>
#define mii             map<int,int>
#define mll  			map<long long,long long>
#define umii			unordered_map<int,int>
#define umll			unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)		for(int i=0;i<n;i++)
#define rep2(i,a,b)		for(int i=a;i<b;i++)
#define rev(i,n)		for(int i=n;i>=0;i--)
#define rev2(i,a,b)		for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl			'\n'
#define all(x)			x.begin(),x.end()
#define d0(x)			cout <<x<<" "
#define d1(x)			cout <<x<<endl
#define d2(x,y)			cout <<x<<" "<<y<<endl
#define d3(x,y,z)		cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)		cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
const ll mod=1e9+7;
const dd pi=M_PI;
const ll MOD=998244353;
void i_o()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
} 
int main()
{
	fio
   	i_o();
	ll n,k;
	cin>>n>>k;
	n++;
	vll pre(n+1);
	pre[0]=0;
	rep2(i,1,n+1){
		pre[i]=pre[i-1]+i-1;
	}
	ll ans=0;
	rep2(i,k,n+1){
		ll low=pre[i]-pre[0],high=pre[n]-pre[n-i];
		ans+=high-low+1;
		ans=ans%mod;
	}
	//if(k==1) ans++;
	cout <<ans%mod;


    
	return 0;
}



Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    int n;cin >>n;
    vector<double> a(n);REP(i,n) cin >> a.at(i);

    double gyaku;
    gyaku =0;
    REP(i,n){
        gyaku += 1/a.at(i);
    }

    cout << 1/gyaku << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;
int A[200005];
int l,r,xo;
long long rez;

int main(){

    cin >> N;
    for(int i = 1;i <= N;i++){
        cin >> A[i];
    }

    l = 1;
    xo = 0;

    for(int r = 1;r <= N;r++){
        while(xo & A[r]){
            xo ^= A[l];
            l++;
        }
        xo ^= A[r];
        rez += r - l + 1;
    }

    cout << rez;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char s[N];
int sum[N],mx[N],n;
int f(int M){
	for(int i=1,cnt=0;i<=n;++i){
		if(s[i]=='?'){
			if((cnt+1)*2+mx[i]<=M) ++cnt,sum[i]=1;
			else sum[i]=-1;
		}
		else sum[i]=(s[i]=='0'?-1:1);
		sum[i]+=sum[i-1];
	}
	return *min_element(sum,sum+n+1);
}
int main(){
	cin>>(s+1);n=strlen(s+1);
	for(int i=1;i<=n;++i){
		if(s[i]=='?') sum[i]=-1;
		if(s[i]=='1') sum[i]=1;
		if(s[i]=='0') sum[i]=-1;
		sum[i]+=sum[i-1];
	}
	for(int i=n;i>=0;--i)
		if(i+1<=n)mx[i]=max(sum[i],mx[i+1]);
		else mx[i]=sum[i];
	//for(int i=0;i<=n;++i)cout<<mx[i]<<" ";cout<<endl;
	int Z=mx[0];
	cout<<min(Z-f(Z),Z+1-f(Z+1));
	return 0;
}

Measured memory_bytes: 12424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int v = 0;
		int j = 0;
		int N[] = new int[n];
		for (int i = 0; i < n; i++) {
			int x = scanner.nextInt();
			N[i] = x;
		}
		for (int k = 0; k < n - 1; k++) {
			System.out.print (N[k] + " ");
			}
			System.out.println (N[n - 1]);
		for (int i = 1; i < n; i++) {
			v = N[i];
			j = i - 1;
			while (j >= 0 && N[j] > v) {
				N[j + 1] = N[j];
				j--;
				}
			N[j + 1] = v;
			for (int k = 0; k < n - 1; k++) {
				System.out.print (N[k] + " ");
				}
				System.out.println (N[n - 1]);
		}
	}
}


Measured memory_bytes: 31376
n=int(input())
c=[int(input())for i in range(n)]
l=[-1]*(max(c)+1)
d=[0]*(n+1)
d[0]=1
for i in range(1,n+1):
 d[i]=d[i-1];C=l[c[i-1]]
 if i-1!=C!=-1:d[i]+=d[C]
 l[c[i-1]]=i;d[i]%=(10**9+7)
print(d[n])

Measured memory_bytes: 30120
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238463;
int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double angle = abs(H/6.0 + M/360.0- M/30.0);
    double C = sqrt(A * A + B * B - 2.0 * A * B * cos(angle * PI));
    cout << fixed << setprecision(12) << C;
}


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

#define INIT_CAP 10
#define INF 1000000000

inline int nextInt(void) {
	int ch;
	int sign, x;

	do {
		ch = getchar();
	} while (ch < '-');

	if (ch == '-') {
		sign = -1;
		ch = getchar();
	} else
		sign = 1;

	x = 0;
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}

	return sign * x;
}

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[10000];
PNumDis heap[500000];
int hsize;
int d[10000];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

inline void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i;
	int n;

	scanf("%d", &n);

	init(n);
	for (i = 0; i < n; i++) {
		int u = nextInt(), k = nextInt();
		while (k--) {
			int v, c;
			scanf("%d %d", &v, &c);
			add(u, v, c);
		}
	}

	dijkstra(n, 0);

	for (i = 0; i < n; i++)
		printf("%d %d\n", i, d[i]);

	return 0;
}

Measured memory_bytes: 5688
a = int(input())
l = list(map(int, input().split()))

import itertools
itt = list(itertools.combinations(l, 3))
result = 0
for it in itt:
    if len(set(it)) < 3:
        continue
    else:
        tmp = list(it)
        tmp.sort()
        
        if (tmp[0] + tmp[1] > tmp[2]):
            #print(tmp)
            result += 1
print(result)

Measured memory_bytes: 20624
#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 N = 1024, INF = 1e8;

int n, a[N][N];

int b[N][N]; // iがjと試合を行なうのはb[i][j]番目(0-indexed)
int dp[N][N]; // dp[i][j]: iがj人と試合を行なうまでの最短日数
bool seen[N][N];

int rec(int i, int j) {
  if (dp[i][j] != -1) return dp[i][j];
  if (seen[i][j]) return INF;
  seen[i][j] = true;
  if (j == 0) return dp[i][0] = 0;
  int op = a[i][j - 1];
  return dp[i][j] = max(rec(i, j - 1), rec(op, b[op][i])) + 1;
}

int main() {
  cin >> n;
  rep(i, n) rep(j, n-1) cin >> a[i][j];
  rep(i, n) rep(j, n-1) a[i][j]--;
  rep(i, n) rep(j, n-1) b[i][a[i][j]] = j;
  rep(i, n) rep(j, n) dp[i][j] = -1;
  rep(i, n) rep(j, n) seen[i][j] = false;
  int ans = 0;
  rep(i, n) ans = max(ans, rec(i, n-1));
  if (ans >= INF) ans = -1;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 16700
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

res = 0
for i in range(n):
  res += b[i]
  if i > 0 and a[i] == a[i - 1] + 1:
    res += c[a[i - 1] - 1]

print(res)

Measured memory_bytes: 3064
#include <math.h>
#include <stdio.h>
#include <string.h>
int a, b, n, idct = 0;
int main(void) {
    scanf("%d %d %d", &n, &a, &b);
    for (int i = a; i <= b; i++) {
        if (i % n == 0) {
            printf("OK\n");
            idct = 1;
            break;
        }
    }
    if (idct == 0) {
        printf("NG\n");
    }
}

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

// clang-format off
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
#define forn(i, x, y) for(int i = x; i < y; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

using ll = long long;
// clang-format on

int main()
{
  IOS;

  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  forn(i, 0, N) cin >> w[i] >> v[i];

  vector<ll> dp(W + 1, 0);
  for (int i = 0; i < N; i++)
  {
    for (int j = W; j >= 0; j--)
    {
      if (j >= w[i])
        chmax(dp[j], dp[j - w[i]] + v[i]);
    }
  }
  cout << dp[W] << endl;

  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] dp = new int[n + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j *= 6) {
                dp[i] = Math.min(dp[i], dp[i - j] + 1);
            }
            for (int j = 1; j <= i; j *= 9) {
                dp[i] = Math.min(dp[i], dp[i - j] + 1);
            }
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 23764
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int N;
int d=0;
int ans=0;
string S;
cin >> N >> S;
for(int i=0;i<N;i++)
{
if(S.at(i)=='A')d=1;
else if(S.at(i)=='B'&&d==1)d=2;
else if(S.at(i)=='C'&&d==2)d=3;
else d=0;
if(d==3)ans++;
}
cout << ans;
}



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int n,k,c,dp[200001];
string s;
bool ans[200000];
map<int,vector<int>> m;
vector<int> v;

signed main() {
    cin >> n >> k >> c >> s;
    rep(i,n) ans[i] = true;
    rep(i,n) if (s[i] == 'x') ans[i] = false;
    repm(i,n) {
        dp[i] = dp[i+1];
        if (ans[i] && i+c+1 < n) dp[i] = max(dp[i], dp[i+c+1]+1);
    }
    if (dp[0] > k) return 0;
    int now = dp[0];
    bool f=true;
    rep(i,n) {
        if (ans[i]) {
            if (f) now = dp[i], f=false;
            if (now == dp[i]) {
                v.pb(i);
            } else {
                if (v.size() == 1) {
                    cout << v[0]+1 << endl;
                }
                i = max(i-1,v[0]+c);
                v.clear();
                f = true;
            }
        }
    }
    if (v.size() == 1) {
        cout << v[0]+1 << endl;
    }
}





Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
   ll a,b;
   cin>>a>>b;
   if(b==1){cout<<0;return 0;}
   f(i,1,51){
       if((i*a-(i-1))>=b){cout<<i;return 0;}
   }
    return 0;
}   

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;



int main(){
  ll N; cin >> N; N++; ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  ll tmp=0, ans=0;
  ll need[N] = {}; need[0] = 1;
  //コーナーケース
  if(a[0]!=0){
    if(N==1&&a[0]==1){cout << 1 << endl; return 0;}
    else {cout << -1 << endl; return 0;}
  }
  if(N==1){ cout << -1 << endl; return 0;}
  //上から決める、need[i]は深さiの上限
  rep(i, N-1){
    need[i+1] = (need[i]-a[i])*2;
    need[i+1] = min(need[i+1], longinf);
    if(need[i+1]<a[i+1]){
      cout << -1 << endl; return 0;
    }
  }
  ll v[N];
  for(int i=N-1; i>=0; i--){
    tmp+=a[i];
    v[i] = min(need[i], tmp);
    tmp=v[i];
  }
  rep(i, N){
    ans+=v[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		String str=sc.next();

		String[] strArray=str.split("");

		int count=0;
		int max=0;

		for(int i=0;i<strArray.length;i++) {

			if( !(strArray[i].equals("A")||strArray[i].equals("C")||strArray[i].equals("G")||strArray[i].equals("T"))) continue;

			count++;


			if(i!=strArray.length-1) {
				for(int j=i+1;j<strArray.length;j++) {

					if( !(strArray[j].equals("A")||strArray[j].equals("C")||strArray[j].equals("G")||strArray[j].equals("T"))) break;

					count++;
				}

			}

			if(max<count) max=count;

			count=0;

		}

		System.out.println(max);

		sc.close();

	}

}


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

int main(){
  int A, B, ans;
  cin >> A >> B;
  if(A != B){
    ans = max(A, B) * 2 - 1;
  }
  else {
    ans = A * 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
long long a[N],b[N],n,x,y;
int main() {
	n = rd();
	for (int _=1;_<=n;_++) a[_] = rd();
	for (int _=1;_<=n;_++) b[_] = rd();
	for (int _=1;_<=n;_++) {
		if (a[_] == b[_]) continue;
		if (a[_] < b[_]) {
			int c = b[_] - a[_];
			if (c%2 == 0) x += c / 2;else x += c / 2 + 1, y += 1;
		} else {
			y += a[_] - b[_];
		}
	}
	puts(x>=y?"Yes":"No");
	return 0;
}


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

using namespace std;

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

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

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

void solve(long long A, long long B) {
    long long ans = 1;
    int x = 0;
    while (ans < B) {
        ans += A - 1;
        x++;
    }
    cout << x << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>

using namespace std;

int keta(int x){
	int cnt=0;
	while(x){
		cnt++;
		x/=10;
	}
	return cnt;
}

int main(){
	long long n;
	cin >> n;
	long long a,b;
	for(long long i=1;i*i<=n;i++){
		if(n%i==0)a=i;
	}
	b=n/a;
	int ans=max(keta(a),keta(b));
	cout << ans << endl;
	return 0;
}


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

namespace q2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Convert.ToInt32(Console.ReadLine());

            long r = 0;
            for (var i=1; i<=N; i++)
            {
                if (i % 5 != 0 && i % 3 != 0)
                    r += i;
            }
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 27480
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L,R;
string S,T;
const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>S;
    vec abc(N*3,0), rgb(3,0);
    rep(i,N*3){
        char c = S[i];
        ll temp = 0;
        if(c == 'G') temp = 1;
        if(c == 'B') temp = 2;
        ll group = 0;
        rep(j,3){
            if(j == temp)continue;
            group += rgb[j] > rgb[temp];
        }
        ++rgb[temp];
        abc[i] = group;
    }

    /*rep(i,N*3) cout<<abc[i]<<' ';
    cout<<endl;
    rep(i,3) cout<<rgb[i]<<' ';
    cout<<endl;*/
    ll temp = 0;
    mat lr(N*3,vec(2,0));
    rep(i,N*3){
        if(abc[i] == 0){
            ++temp;
        }else if(abc[i] == 1){
            lr[i][0] = temp;
            --temp;
        }
    }
    if(temp != 0) cout<<"error"<<temp<<endl;
    for(int i = N*3 - 1; i >= 0; --i){
        if(abc[i] == 2){
            ++temp;
        }else if(abc[i] == 1){
            lr[i][1] = temp;
            --temp;
        }
    }
    ll ans = 1;
    rep(i,N*3) (ans *= (abc[i] == 1 ? lr[i][0]*lr[i][1] : 1LL))%=MOD;
    reps(i,1,N+1) (ans *= i)%=MOD;
    cout<<ans<<endl;
}


Measured memory_bytes: 19332
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include <unordered_set>
#include <unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;

    ll H,W,D,Q;
    std::vector<ll> S[900010];
    ll A[310][310];
    ll L[100010],R[100010];
    std::unordered_map<int,P> M;
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>H>>W>>D;
    REP(i,H)REP(j,W){
        cin>>A[i][j];
        M.insert({A[i][j],{j+1,i+1}});
    }
    EREP(i,D){
        int j=i;
        while(j<=W*H){
            if(i==j)S[i].push_back(0);
            else{
                ll res=abs(M[j].first-M[j-D].first)+abs(M[j].second-M[j-D].second);
                S[i].push_back(res);
            }
            j+=D;
        }
        REP(l,S[i].size()-1){
            S[i][l+1]+=S[i][l];
        }
    }
    cin>>Q;
    REP(i,Q){
        cin>>L[i]>>R[i];
        if(L[i]%D==0){
            cout<<S[D][R[i]/D-1]-(L[i]/D-1>0?S[D][L[i]/D-1]:0);
        }else{
            cout<<S[R[i]%D][R[i]/D]-(L[i]/D>0?S[L[i]%D][L[i]/D]:0);
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 30500
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN][MAXN];
int main() {
	int n; read(n);
	if (n == 2) {
		puts("-1");
		return 0;
	}
	if (n == 5) {
		puts("aabbc");
		puts("bb.ec");
		puts("..fed");
		puts("c.f.d");
		puts("cbbaa");
		return 0;
	}
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= n; j++)
		s[i][j] = '.';
	if (n % 3 == 0) {
		for (int i = 1, j = 1; i <= n / 3; i++, j += 3) {
			s[j + 0][j + 0] = s[j + 0][j + 1] = 'a';
			s[j + 1][j + 2] = s[j + 2][j + 2] = 'a';
		}
	} else {
		int tn = n;
		if (n & 1) {
			int m = n - 7; tn -= 7;
			s[m + 1][m + 1] = s[m + 1][m + 2] = 'a';
			s[m + 1][m + 3] = s[m + 1][m + 4] = 'b';
			s[m + 1][m + 5] = s[m + 1][m + 6] = 'c';
			s[m + 2][m + 1] = s[m + 2][m + 2] = 'd';
			s[m + 2][m + 3] = s[m + 2][m + 4] = 'e';
			s[m + 3][m + 1] = s[m + 3][m + 2] = 'f';
			s[m + 3][m + 3] = s[m + 3][m + 4] = 'g';
			
			s[m + 2][m + 7] = s[m + 3][m + 7] = 'a';
			s[m + 4][m + 7] = s[m + 5][m + 7] = 'b';
			s[m + 6][m + 7] = s[m + 7][m + 7] = 'c';
			s[m + 4][m + 6] = s[m + 5][m + 6] = 'd';
			s[m + 6][m + 6] = s[m + 7][m + 6] = 'e';
			s[m + 4][m + 5] = s[m + 5][m + 5] = 'f';
			s[m + 6][m + 5] = s[m + 7][m + 5] = 'g';
		}
		for (int i = 1, j = 1; i <= tn / 2; i++, j += 2) {
			s[j + 0][j + 0] = s[j + 0][j + 1] = 'a';
			s[j + 1][j + 0] = s[j + 1][j + 1] = 'b';
			if (i != tn / 2) {
				s[j + 2][j + 0] = s[j + 3][j + 0] = 'c';
				s[j + 2][j + 1] = s[j + 3][j + 1] = 'd';
			} else {
				s[1][j + 0] = s[2][j + 0] = 'c';
				s[1][j + 1] = s[2][j + 1] = 'd';
			}
		}
	}
	for (int i = 1; i <= n; i++)
		printf("%s\n", s[i] + 1);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
#define ALL(X) X.begin(), X.end()
using lint = long long;
template <typename T>
void print_container(std::vector<T> vec)
{
    for (auto iter = vec.begin(); iter != vec.end(); ++iter)
    {
        std::cout << *iter << " ";
    }
    std::cout << std::endl;
}

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

    lint k;
    scanf("%lld", &k);

    lint rem = k;

    for (int i = 0; i < s.size(); ++i)
    {
        if (i == s.size() - 1)
        {
            s[i] = (s[i] - 'a' + rem) % 26 + 'a';
        }
        else if ((26 - (s[i] - 'a')) % 26 > rem)
        {
            continue;
        }
        else
        {
            rem -= (26 - (s[i] - 'a')) % 26;
            s[i] = 'a';
        }
    }

    std::cout << s << "\n";
    return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, b;
	cin >> a >> b;
	if (a >= 13) {
		cout << b << "\n";
	}
	else if (a >= 6) {
		cout << b / 2 << "\n";
	}
	else {
		cout << "0\n";
	}
}


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


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

int main() {
  int64_t N,a,b,c,A,B,C;
  cin >> N;
  
  a = N/3;
  b = N/5;
  c = N/15;
  
  A = (3+3*a)*a/2;
  B = (5+5*b)*b/2;
  C = (15+15*c)*c/2;
  
  cout << (N*N+N)/2 -A -B +C << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ull ans;

int main(){
	ll n,k;
	cin >> n >> k;
	ans = k;
	arep(1,i,n){
		ans*=k-1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;

int n;
int x[100];
int y[100];
ll h[100];

bool fff(int cx,int cy,ll ch)
{
	for(int i=0;i<n;i++)
	{
		ll ih=max(ch-abs(cx-x[i])-abs(cy-y[i]),0LL);
		if(ih!=h[i])
			return false;
	}
	return true;
}

int main()
{
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i]>>h[i];
	
	//最大高さを調べる
	ll mh=0;
	for(int i=0;i<n;i++)
		mh=max(mh,h[i]);

	//それぞれの座標ごとにmh+200まで調べる
	for(int i=0;i<101;i++)
	{
		for(int j=0;j<101;j++)
		{
			for(ll k=0;k<201;k++)
			{
				if(fff(i,j,k+mh))
				{
					cout<<i<<" "<<j<<" "<<k+mh<<endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for (int i = 0; i <= Math.min(s, k); i++) {
            ans += Math.max(0, Math.min(s-i+1, k+1)-Math.max(0,s-i-k));
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 21844