akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N, K;
vector<vector<int> > num;

int main()
{
    cin >> N >> K;
    num = vector<vector<int> >(K*2, vector<int>(K*3, 0));
    for (int i=0; i<N; i++)
    {
        int a, b;
        char c;
        cin >> a >> b >> c;
        if (c == 'B')
        {
            b += K;
        }
        a %= (2 * K);
        if (a >= K)
        {
            a -= K;
            b += K;
        }
        b %= (2 * K);

        num[a][b] += 1;
        num[a+K][b+K] += 1;
        num[a][b+K] -= 1;
        num[a+K][b] -= 1;
    }
    for (int i=1; i<2*K; i++)
    {
        for (int j=0; j<3*K; j++)
        {
            num[i][j] += num[i-1][j];
        }
    }
    for (int i=0; i<2*K; i++)
    {
        for (int j=1; j<3*K; j++)
        {
            num[i][j] += num[i][j-1];
        }
    }
    int ans = 0;
    for (int i=0; i<2*K; i++) for (int j=0; j<K; j++)
    {
        int tmp = num[i][j] + num[(i+K) % (2 * K)][j+K] + num[i][j + 2 * K];
        ans=max(ans, tmp);
    }

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


Measured memory_bytes: 23936
// Copyright 2017 wu_qing
#include <cstdint>
#include <cstdio>
#include <algorithm>
const int N = 1e5 + 10, mod = 1e9 + 7;
int n, a[N];
int64_t tot;
bool flag = true;
int64_t qp(int64_t a, int exp) {
    int64_t ans = 1;
    while (exp) {
        if (exp & 1)
            ans = ans * a %mod;
        a = a * a % mod;
        exp >>= 1;
    }
    return ans;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    tot = qp(2, n / 2);
    std::sort(a + 1, a + n + 1);
    if (a[1] == 0) {
        for (int i = 2; i <= n; i += 2)
            if (a[i] != i || a[i + 1] != i)
                flag = false;
    } else if (a[1] == 1) {
        for (int i = 1; i <= n; i += 2)
            if (a[i] != i || a[i + 1] != i)
                flag = false;
    } else {
        flag = false;
    }
    if (flag)
        printf("%lld\n", tot);
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;



int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> VP(m);
	rep (i, m) cin >> VP[i].se >> VP[i].fi;

	sort(rng(VP));

	int ans = 1;
	int pos = VP[0].fi;
	for (int i = 1; i < m; i++) {
		if (VP[i].se >= pos) {
			pos = VP[i].fi;
			ans++;
		}
	}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxS =2e5+7;




int main()
{
   ll N;
  cin  >> N;
    string s;
  cin >> s;
  s = "$"+s;
  int Pr[N+1][3];
  memset(Pr,0,sizeof Pr);
  for(int i=1;i<=N;i++)
  {
      if(s[i]=='R')
        Pr[i][0]=1;
    if(s[i]=='G')
        Pr[i][1] = 1;
    if(s[i]=='B')
        Pr[i][2] = 1;
  }
  for(int j=0;j<3;j++)
  {
      for(int i=1;i<=N;i++)
      {
          Pr[i][j]+=Pr[i-1][j];
      }
  }
  ll ans = 0;
  for(int i=1;i<=N-1;i++)
  {
      for(int j=i+1;j<=N;j++)
      {
        if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R'))
        {
          ll diff = j-i;
          ll tmp = Pr[N][2] - Pr[j][2];
          if(j+diff<=N)
            if(s[j+diff]=='B')
              tmp--;
          ans+=tmp;
          //cout << tmp << "\n";
        }
        else
          if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R'))
        {
          ll diff = j-i;
          ll tmp = Pr[N][1] - Pr[j][1];
          if(j+diff<=N)
            if(s[j+diff]=='G')
              tmp--;
          ans+=tmp;
          //cout << tmp << "\n";
        }
        else
         if((s[i]=='B'&&s[j]=='G')||(s[i]=='G'&&s[j]=='B'))
        {
          ll diff = j-i;
          ll tmp = Pr[N][0] - Pr[j][0];
          if(j+diff<=N)
            if(s[j+diff]=='R')
              tmp--;
          ans+=tmp;
          //cout << tmp << "\n";
        }
      }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3664
#include<cstdio>
#include<algorithm>
using namespace std;
const int INF = 1000000000;

int n,m;
int c[20];
int dp[21][50001];

int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++) scanf("%d",c+i);
  fill(dp[0],dp[0]+21*50001,INF);
  dp[0][0] = 0;
  for(int i=1;i<=m;i++){
    for(int j=0;j<=n;j++){
      if(j-c[i-1]>=0){
        dp[i][j] = min(dp[i][j-c[i-1]]+1,dp[i-1][j]);
      }else{
        dp[i][j] = dp[i-1][j];
      }
    }
  }
  printf("%d\n",dp[m][n]);
  return 0;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const int MAX = 5001;
ll dp[4][MAX][MAX];

int main()
{
    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<int>> V(R + 1, vector<int>(C + 1));
    rep(i, K) {
        int r, c, v;
        cin >> r >> c >> v;
        V[r][c] = v;
    }
    // memset(dp, 0x80, sizeof(dp));

    repd(i, 1, R + 1) {
        repd(j, 1, C + 1) {
            ll res = 0;
            rep(k, 4) {
                chmax(dp[k][i][j], dp[k][i][j - 1]);
                chmax(res, dp[k][i - 1][j]);
            }
            chmax(dp[0][i][j], res);
            if (V[i][j] == 0) continue;
            chmax(dp[1][i][j], res + V[i][j]);
            repd(k, 1, 4) {
                chmax(dp[k][i][j], dp[k - 1][i][j - 1] + V[i][j]);
            }
        }
    }
    /*
    rep(i, R) {
        rep(j, C) {
            rep(k, 4) {
                cout << dp[k][i + 1][j + 1] << ", ";
            }
            cout << endl;
        }
    }*/
    ll ans = 0;
    rep(i, 4) chmax(ans, dp[i][R][C]);

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

Measured memory_bytes: 364232
#!/usr/bin/env python3
#ABC87 C

from collections import deque

n = int(input())
a = [list(map(int,input().split())) for _ in range(2)]

dp = [[0]*(n+1) for _ in range(3)]

dp[1][1] = a[0][0]
for i in range(2):
    for j in range(n):
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1] + a[i][j],dp[i+1][j] + a[i][j])
print(dp[2][n])


Measured memory_bytes: 38256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	ll h1,w1,h2,w2;
	cin>>h1>>w1>>h2>>w2;
	ll ans=h1*w1-(h2*w1+w2*h1-w2*h2);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n;
    cin >> n;
    string s;
    int p;
    int num;
    vector<pair<string, int>> vec(n);
    vector<pair<string, int>> vec_copy(n);
    rep(i, n) {
        cin >> s >> p;
        vec[i] = make_pair(s, 100 - p);
        vec_copy[i] = make_pair(s, 100 - p);
    }
    sort(vec.begin(), vec.end());

    rep(i, n) {
        string f = vec[i].first;
        int s = vec[i].second;
        rep(j, n) {
            if (f == vec_copy[j].first && s == vec_copy[j].second) {
                cout << j + 1 << endl;
                break;
            }
        }
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vec<ll> V(N);
    ll ans = 0;
    for(int i=0;i<N;i++){
        cin >> V[i];
        ans += V[i];
    }
    cout << ans-N*(N+1)/2 << endl;
}


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

namespace ABC134C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var conds = new List<int>(N);

            for (var i = 1; i <= N; i++)
                conds.Add(int.Parse(Console.ReadLine()));

            var max = conds.Max();
            var tmp = conds.ToList();
            tmp.Sort((a, b) => b - a);

            for (var i = 0; i < N; i++)
            {
                if (conds[i] == max)
                    Console.WriteLine(tmp[1]);
                else
                    Console.WriteLine(max);
            }

            Console.ReadKey();
        }
    }
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())

priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    llint n;
    vector<llint>a(5,0);
    cin >> n;
    for(int i=0;i<5;i++)cin >> a[i];
    llint t=a[0];
    for(int i=1;i<5;i++)t=min(a[i],t);
    llint ans=(n+t)/t;
    if(n%t==0)ans=n/t;
    cout << ans+4 << endl;
}

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


Measured memory_bytes: 3576
#include <cstdio>

struct station
{
  long long c;
  long long s;
  long long f;
};

int main()
{
  long long n;
  scanf("%lld", &n);
  station st[500];
  for (long long i = 0; i < n - 1; ++i)
  {
    scanf("%lld%lld%lld", &st[i].c, &st[i].s, &st[i].f);
  }
  for (long long i = 0; i < n - 1; ++i)
  {
    long long t = 0;
    for (long long j = i; j < n - 1; ++j)
    {
      if (t <= st[j].s)
      {
        t = st[j].s + st[j].c;
      }
      else
      {
        long long r = t % st[j].f;
        t += (r == 0 ? 0 : st[j].f - r) + st[j].c;
      }
    }
    printf("%lld\n", t);
  }
  puts("0");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
    int n;
    double s, ave, stdev;

    while(cin >> n){
        if(n==0) break;
        stdev = 0;
        ave = 0;
        double S[n];
        for (int i = 0; i < n; i++) {
            cin >> s;
            S[i] = s;
            ave += (1./(double) n) * s;
        }
        for (int i = 0; i < n; i++) {
            s = S[i];
            stdev += (1./n) * pow(s-ave, 2.);
        }
        stdev = sqrt(stdev);
        printf("%lf\n", stdev);
    }
}


Measured memory_bytes: 3284
// AOJ ALDS1_6_D Minimum Cost Sort
// 2018.5.4 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }
int min_cost_sort(int n, int *w, int min, int max)
{
	int i, s, t, t1, t2, m, an, cur, ans;
	int *a, *v;
	char *f;

	a = malloc(n<<2), f = malloc(n), v = malloc((max+1)<<2);
	memcpy(a, w, n<<2), memset(f, 0, n);

	qsort(a, n, sizeof(int), cmp);
	for (i = 0; i < n; i++) v[a[i]] = i;

	ans = 0;
	for (i = 0; i < n; i++) {
		if (f[i]) continue;
		cur = i, s = 0, m = max, an = 0;
		while (1) {
			f[cur] = 1, an++, t = w[cur];
			if (t < m) m = t;
			s += t, cur = v[t];
			if (f[cur]) break;
		}
		t1 = s+(an-2)*m, t2 = m+s+(an+1)*min;
		ans += (t1 < t2)? t1: t2;
	}
	free(a), free(f), free(v);
	return ans;
}

int w[1002];

int main()
{
	int n, i, _w, min, max;

	n = in();
	min =  0x10101010;
	max = -0x10101010;
	for (i = 0; i < n; i++) {
		w[i] = _w = in();
		if (_w < min) min = _w;
		if (_w > max) max = _w;
	}
	printf("%d\n", min_cost_sort(n, w, min, max));
	return 0;
}


Measured memory_bytes: 2128
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split("\n");
    tmp1 = tmp.map(Number)
    if(tmp1[0] == 1){
        answer = "Hello World";
    }else{
        answer = tmp1[1] + tmp1[2];
    }

    console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef long long int Int;

int main(void)
{
    int n;
    cin>>n;
    set<Int> a;

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

	set<Int>::iterator it = a.find(temp);
	if(it != a.end())
	{
	    a.erase(it);
	} else {
	    a.insert(temp);
	}
    }

    cout<<a.size()<<endl;

    return 0;
}


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

int main() {
    int ans = 0;
    ll N, D;
    cin >> N >> D;
    rep(i, N) {
        ll X, Y;
        cin >> X >> Y;
        ll d = X * X + Y * Y;
        if(D * D >= d)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3664
S = str(input())
N = len(S)

aim = 1

for _ in range(int(N/2)):
    aim <<= 2
    aim |= 0b10
if N % 2 == 1 and N != 0:
    aim <<= 1
    aim |= 0b1

S = int(S, 2)
mask = "1" * (N)
mask = int(mask, 2)
aim = aim & mask

differences = bin(S ^ aim)
Num1 = differences.count("1")
Num0 = N - Num1

print(min(Num1, Num0))

Measured memory_bytes: 3188
def main():
    N = int(input())
    S = list(input())

    #f len(set(S)) == 1:
    #    print(0)
     #   return

    baseblack = 0
    basewhite = sum([1 for x in S if x == '.'])
    ans = min(basewhite, N-basewhite)
    for i in range(N):
        baseblack += S[i] == '#'
        basewhite -= S[i] == '.'
        ans = min(ans, baseblack+basewhite)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 500005;

char s[N];
int c[26][N];

int sum(int x, int k) {
    int res = 0;
    while (x > 0) {
        res += c[k][x];
        x -= x & -x;
    }
    return res;
}
void add(int x, int n, int d, int k) {
    while (x <= n) {
        c[k][x] += d;
        x += x & -x;
    }
}
int main() {
    int n, q;
    scanf("%d%s%d", &n, s + 1, &q);
    for (int i = 1; i <= n; i++) {
        add(i, n, 1, s[i] - 'a');
    }
    while (q--) {
        int op;
        scanf("%d", &op);
        if (op == 1) {
            int x;
            char c;
            scanf("%d %c", &x, &c);
            add(x, n, -1, s[x] - 'a');
            s[x] = c;
            add(x, n, 1, s[x] - 'a');
        } else {
            int l, r;
            scanf("%d%d", &l, &r);
            int ans = 0;
            for (int i = 0; i < 26; i++) {
                ans += sum(r, i) - sum(l - 1, i) > 0;
            }
            printf("%d\n", ans);
        }
    }
    return 0;
}


Measured memory_bytes: 51584
A = []
for _ in range(3):
	A += list(map(int, input().split()))
for _ in range(int(input())):
  b = int(input())
  if b in A:
    A[A.index(b)] = False

res = "No"

#check line
if not(any([A[0], A[1], A[2]])) or not(any([A[3], A[4], A[5]])) or not(any([A[6], A[7], A[8]])):
  res = "Yes"

#check colmun
if not(any([A[0], A[3], A[6]])) or not(any([A[1], A[4], A[7]])) or not(any([A[2], A[5], A[8]])):
  res = "Yes"

#check diag
if not(any([A[0], A[4], A[8]])) or not(any([A[2], A[4], A[6]])):
  res = "Yes"
print(res)

  

Measured memory_bytes: 9172
n = int(input().strip())

dp=[[0]*3 for _ in range(n)]

# I.C.
a, b, c = map(int, input().strip().split())
dp[0][0]=a
dp[0][1]=b
dp[0][2]=c

for i in range(n-1):
    abc = list(map(int, input().strip().split()))
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[i+1][j]=max(dp[i+1][j], dp[i][k]+abc[j])
print(max(dp[-1]))

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

int main(){
    string a, b;
    cin >> a >> b;
    if (a == "H" && b== "D") cout << "D" << endl;
    else if (a == "H" && b== "H") cout << "H" << endl;
    else if (a == "D" && b== "D") cout << "H" << endl;
    else cout << "D" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll x;
    cin >> x;
    ll sum = 0;
    for(ll i = 1;; i++){
        sum += i;
        if(sum >= x){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <utility>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	char s[35];
	map<string, set<int> > m;
	int x;
	while(1) {
		if(scanf("%s %d", s, &x) == EOF) break;
		if(m.count(s) == 0) {
			set<int> v;
			v.insert(x);
			m.insert(make_pair(s, v));
		} else {
			set<int> v = m[s];
			v.insert(x);
			m[s] = v;
		}
	}
	for(auto it = m.begin(); it != m.end(); ++it) {
		cout << (*it).first << endl;
		for(auto it2 = it->second.begin(); it2 != --(it->second).end(); ++it2) {
			cout << *it2 << " ";
		}
		cout << *--(it->second).end() << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m; cin>>n>>m;
	if(n&1){
		for(int i=1; i<=m; i++){
			cout<<i<<" "<<n-i<<endl;
		}
		return 0;
	}
	int a[100010], b[100010];
	for(int i=0; i<m; i+=2){
		a[i]=i/2;
		b[i]=n-1-i/2;
	}
	for(int i=1; i<m; i+=2){
		a[i]=n/2-2-i/2;
		b[i]=n/2+i/2;
	}
	for(int i=0; i<m; i++){
		if(a[i]==0) a[i]=n;
		if(b[i]==0) b[i]=n;
		cout<<a[i]<<" "<<b[i]<<endl;
	}
	return 0;
}


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

using namespace std;

int INF = 1e9 + 5;

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

    int n;
    cin >> n;
    
    vector<int> h(3);
    for(auto&x : h)
    {
        cin >> x;
    }
    
    --n;

    vector<int> dp(h),dp2(3);
    while(n--)
    {
        for(auto&x : h)
        {
            cin >> x;
        }
        
        for(int i=0; i<3; ++i)
        {
            dp2[i] = h[i] + max(dp[(i+1)%3],dp[(i+2)%3]);
        }
        
        dp = dp2;
    
    }
    
    cout << *max_element(begin(dp),end(dp));
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;

int main(){
    int mae, usiro;
    string s, ans;
    cin >> s;
    mae = (s[0]-'0')*10+(s[1]-'0');
    usiro = (s[2]-'0')*10+(s[3]-'0');
    if(mae==0 || mae>12){
        if(usiro==0 || usiro>12){
            ans = "NA";
        }
        else{
            ans = "YYMM";
        }
    }
    else{
        if(usiro==0 || usiro>12){
            ans = "MMYY";
        }
        else{
            ans = "AMBIGUOUS";
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll x, k;
  cin >> x >> k;
  vector<ll> r(k);
  REP(i, k) cin >> r[i];

  ll idx = 0, p = 0, b = 0, c = x, lb = 0, ub = x;
  ll q;
  cin >> q;
  while(q--) {
    ll t, a;
    cin >> t >> a;
    while(idx < k && r[idx] <= t) {
      ll diff = r[idx] - (idx==0?0:r[idx-1]);
      if(idx%2) {
        p -= diff;
        b = min(b+diff, x);
        c = min(c+diff, x);
      } else {
        p += diff;
        b = max(b-diff, 0LL);
        c = max(c-diff, 0LL); 
      }
      chmax(lb, p);
      chmin(ub, x+p);
      ++idx;
    }
    ll ret = a - p;
    if(a < lb) ret = b;
    if(ub < a) ret = c;
    ll diff = t - (idx==0?0:r[idx-1]);
    if(idx%2) ret = min(ret+diff, x);
    else ret = max(ret-diff, 0LL);
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <ctime>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;

int mod = 1000000007;

vector<int> solve(int n, int a) {
    int B = n / a + 2;
    vector<int> res;
    forn (i, n) {
        if (i % a == 0) {
            res.pb(B - 1);
        } else if (i % a == a - 1) {
            res.pb(-B);
        } else {
            res.pb(0);
        }
    }
    return res;
}

int M[510][510];

int main() {
    ios::sync_with_stdio(false);
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    if (n % a == 0 && m % b == 0) {
        cout << "No\n";
        return 0;
    }
    vector<int> ans;
    if (m % b == 0) {
        ans = solve(n, a);
        forn (i, n) {
            forn (j, m) {
                M[i][j] = ans[i];
            }
        }
    } else {
        ans = solve(m, b);
        forn (i, n) {
            forn (j, m) {
                M[i][j] = ans[j];
            }
        }
    }
    cout << "Yes\n";
    forn (i, n) {
        forn (j, m) {
            cout << M[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<Int> L(N);
        for (int i = 0; i < N; ++i) {
            cin >> L[i];
        }

        sort(all(L));

        map<Int, Int> mp;
        mp[L[0] + L[1]]++;
        Int ans = 0;

        for (int i = 2; i < N; ++i) {
            for (auto e : mp) {
                if (e.first > L[i]) {
                    ans += e.second;
                }
            }
            for (int j = 0; j < i; ++j) {
                mp[L[i] + L[j]]++;
            }
        }

        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


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

int main() {
  long long N, K;
  cin >> N >> K;
  
  long long ans = (N / K) * (N / K) * (N / K);
  if (K % 2 == 0)
    ans += ((N + K / 2) / K) * ((N + K / 2) / K) * ((N + K / 2) / K);
  
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define REP(i, a, n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n;
	
	cin >> n;
	
	cout << n * n * n << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s,t;
    cin >> s >> t;
    ll ans = 0;
    rep(i, len(s)) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s;
  for(;getline(cin,s);){
    bool f=0;
    for (;!f;){
      for(int i=0;i<s.size();i++){
        if(s[i]>='a' && s[i]<='z'){
          s[i]--;
          if(s[i]<'a')s[i]='z';
        }
      }
      // cout << s.substr(0,5)<<endl;
      string t[3]={"the","this","that"};
      for(int i=0;!f&&i<3;i++){
        for(int j=0;!f&&j+t[i].size()<s.size();j++){
          if(s.substr(j,t[i].size())==t[i]){
            cout<<s<<endl;
            f=1;
          }
        }
      }
    }
  }
}



Measured memory_bytes: 3144
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<ll> L(N+1);

    L[0] = 2;
    L[1] = 1;

    for (int i = 2; i <= N; ++i) {
        L[i] = L[i - 1] + L[i - 2];
    }

    cout << L[N] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    
    for (int i = 0;i < N;i++){
        cin >> V.at(i);
    }
      for (int i = 0;i < N;i++){
        cin >> C.at(i);
    }

    int max = 0;
  
  

    for (int i = 0;i < N;i++){    
        if (V.at(i) > C.at(i) ){
            max = V.at(i) - C.at(i) + max;
        }
      	//cout << V.at(i) - C.at(i) << endl;
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<climits>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;
#define is ==
int W,H,N;
const int MAX = 1000;
char f[MAX][MAX];
int d[MAX][MAX];
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
struct P
{
  int x,y;
};
inline bool check(P p){
  return p.x < 0 or p.x >= W or p.y < 0 or p.y >= H;
}
int bfs(P s,int goal){
  if(goal > N+'0')return 0;
  fill(*d,*(d+MAX),-1);
  queue<P> que;
  que.push(s);
  d[s.x][s.y] = 0;
  while(!que.empty()){
    P cur = que.front();que.pop();

    if(f[cur.x][cur.y] is goal)return d[cur.x][cur.y] + bfs(cur,goal+1);

    for (int i = 0; i < 4; ++i){
      P np = {cur.x+dx[i],cur.y+dy[i]};
      if(check(np))continue;
      if(f[np.x][np.y] is 'X')continue;
      if(d[np.x][np.y] > -1)continue;//visited
      d[np.x][np.y] = d[cur.x][cur.y] + 1;
      que.push(np);
    }
  }
  cout << "no goal!" << endl;
  return 0;//error
}

int main(){
  ios::sync_with_stdio(false);
  cin >> H >> W >> N;
  P s;
  for (int j = 0; j < H; ++j){
    for (int i = 0; i < W; ++i){
      cin >> f[i][j];
      if(f[i][j] == 'S')s.x = i,s.y = j;
    }
  }
  cout << bfs(s,'1') << endl;
  
  return 0;
}

Measured memory_bytes: 6108
import math

def Div(a,b,c):
  #a<=x<=bのうちcで割り切れるものの数を返す
  l = ((a-1)//c+1)*c
  r = (b//c)*c
  return (r-l)//c+1

A,B,C,D = map(int,input().split())

print(B-A+1-(Div(A,B,C)+Div(A,B,D)-Div(A,B,C*D//math.gcd(C,D))))

Measured memory_bytes: 9128
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#define pi acos(-1)
using namespace std;
int main()
{
    char s[1207];
    scanf("%[^\n]",s);
    for(int i=0;i<strlen(s);i++)
    {
        if(s[i]>='A'&&s[i]<='Z')s[i]=s[i]-'A'+'a';
        else if(s[i]>='a'&&s[i]<='z')s[i]=s[i]-'a'+'A';
    }
    cout<<s<<endl;
    return 0;
}



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

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

Node T[25];
int n;

void maigoCenter(void);
void printPreorder(int);
void printInorder(int);
void printPostorder(int);


int main(){
  int i, id, root;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d", &id);
    scanf("%d%d", &T[id].left, &T[id].right);
    T[id].parent = -1;
  }

  maigoCenter();

  for(i=0; i<n; i++){
    if(T[i].parent == -1){
      root = i;
      break;
    }
  }

  printf("Preorder\n");

  printPreorder(root);

  printf("\nInorder\n");

  printInorder(root);

  printf("\nPostorder\n");

  printPostorder(root);

  printf("\n");

  return 0;
}

void maigoCenter(void){
  int i;

  for(i=0; i<n; i++){
    if(T[i].left != -1){
      T[T[i].left].parent = i;
    }
    if(T[i].right != -1){
      T[T[i].right].parent = i;
    }
  }

} 

int findSibling(int n){
  if(T[n].parent != -1){
    if(T[T[n].parent].left == n){
      return T[T[n].parent].right;
    }else {
      return T[T[n].parent].left;
    }
  }
    return -1;
}

void printPreorder(int root){
  printf(" %d", root);

  if(T[root].left != -1){
    printPreorder(T[root].left);
  }

  if(T[root].right != -1){
    printPreorder(T[root].right);
  }

}

void printInorder(int root){

  if(T[root].left != -1){
    printInorder(T[root].left);
  }

  printf(" %d", root);

  if(T[root].right != -1){
    printInorder(T[root].right);
  }

}

void printPostorder(int root){

  if(T[root].left != -1){
    printPostorder(T[root].left);
  }

  if(T[root].right != -1){
    printPostorder(T[root].right);
  }

  printf(" %d", root);

}

Measured memory_bytes: 616
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;




int main(){
	for (int i = 0; i < 7; i++) {
		int a, b;
		cin >> a >> b;
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <cstdlib>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
    int n, q, t;
    queue<pair<string, int> > Q;
    string name;

    cin >> n >> q;

    for (int i = 0; i != n; ++i)
    {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;

    while (!Q.empty())
    {
        u = Q.front();
        Q.pop();
        a = min(q, u.second);
        u.second -= a;
        elaps += a;
        if (u.second > 0)
        {
            Q.push(u);
        }
        else
        {
            cout << u.first << " " << elaps << endl;
        }
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll N,K,sum=0;
    cin>>N>>K;
    vector<ll> H(N);
    rep(i,N){
        cin>>H[i];
        sum+=H[i];
    }
    if(K>=N){
        cout<<0<<endl;
    }else{
        sort(ALL(H),greater<ll>());
        rep(i,K){
            sum-=H[i];
        }
        cout<<sum<<endl;
    }

    return 0;
}

//a=97,z=122

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	ll d,s,t;
	cin>>d>>s>>t;
	
	if(s*t>=d){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	
	return 0;
}

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

int main()
{
	int N;
	std::cin >> N;

	std::vector<int> v( N );
	for ( int i = 0; i < N; i++ )
	{
		std::cin >> v[i];
	}

	std::sort( v.begin(), v.end() );

	int total = 0;
	for ( int i = 0; i < N - 1; i++ )
	{
		total += v[i];
	}

	total += v[N - 1] / 2;

	std::cout << total << std::endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <cstdio>
char s[64];
int a[64][64];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int t;
		for (int j = 0; j < 9; j++) {
			s[j] = '0';
		}
		scanf("%d.%s", &t, s);
		long long k = t * 1000000000ll;
		t = 0;
		for (int j = 0; j < 9; j++) {
			if (!s[j]) {
				t = t * 10;
			} else {
				t = t * 10 + s[j] - '0';
			}
		}
		k += t;
		int c2 = 0, c5 = 0;
		while (k % 2 == 0) {
			k /= 2;
			c2++;
		}
		while (k % 5 == 0) {
			k /= 5;
			c5++;
		}
		a[c5][c2]++;
	}
	long long ans = 0;
	for (int i = 0; i < 64; i++) {
		for (int j = 0; j < 64; j++) {
			for (int k = 0; k < 64; k++) {
				for (int l = 0; l < 64; l++) {
					if (i + k >= 18 && j + l >= 18) ans += (long long)a[i][j] * a[k][l];
				}
			}
			if (i + i >= 18 && j + j >= 18) ans -= a[i][j];
		}
	}
	printf("%lld\n", ans / 2);
	return 0;
}


Measured memory_bytes: 1736
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 = sc.nextInt();
		int[] a = new int[n];
		Arrays.setAll(a, i -> sc.nextInt());
		
		int[] l = new int[n];
		int[] r = new int[n];
		
		l[0] = a[0];
		r[n - 1] = a[n - 1];
		for (int i = 1; i < n; i++) {
			l[i] = gcd(l[i - 1], a[i]);
			r[n - 1 - i] = gcd(r[n - i], a[n - 1 - i]);
		}
		
		int max = 0;
		for (int i = 0; i < n; i++) {
			int m;
			if (i == 0) {
				m = r[i + 1];
			} else if (i == n - 1) {
				m = l[i - 1];
			} else {
				m = gcd(l[i - 1], r[i + 1]);
			}
			max = Math.max(max, m);
		}
		System.out.println(max);
	}
	
	static int gcd(int a, int b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
}


Measured memory_bytes: 60520
#include<bits/stdc++.h>
#define Len 100010
using namespace std;
int N,ans=0,stt=1,ipt,bf;
int main(){
	ios_base::sync_with_stdio;
	cin.tie(NULL);
	cin>>N;
	cin>>bf; stt=1;
	for(int i=2;i<=N;i++){
		cin>>ipt;
		if(bf>=ipt) { bf=ipt; continue; }
		else{
			ans=max(ans,i-stt-1);
			stt=i;
		}
		
		bf=ipt;
	}
	ans=max(ans,N-stt);
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

typedef struct {
	int M;
	int S;
	int L;
} POSESSION;

int main()
{
	int i, N;
	char talon[101];
	POSESSION pos[10] = {{0, 0, 0}}, field = {0, 0, 0};
	int pos_sum[100], field_sum;
	
	while (scanf("%d", &N), N != 0){
		scanf("%s", talon);
		
		for (i = 0; i < 10; i++){
			pos[i].M = 0;
			pos[i].S = 0;
			pos[i].L = 0;
			pos_sum[i] = 0;
		}
		field.M = 0;
		field.S = 0;
		field.L = 0;
		for (i = 0; i < 100; i++){
			pos_sum[i] = 0;
		}
		
		for (i = 0; i < 100; i++){
			if (talon[i] == 'M'){
				pos[i % N].M++;
			}
			else if (talon[i] == 'S'){
				field.M += pos[i % N].M;
				field.S += pos[i % N].S + 1;
				field.L += pos[i % N].L;
				
				pos[i % N].M = 0;
				pos[i % N].S = 0;
				pos[i % N].L = 0;
			}
			if (talon[i] == 'L'){	
				pos[i % N].M += field.M;
				pos[i % N].S += field.S;
				pos[i % N].L += field.L + 1;
				
				field.M = 0;
				field.S = 0;
				field.L = 0;
			}
		}
		
		for (i = 0; i < N; i++){
			pos_sum[i] = pos[i].M + pos[i].S + pos[i].L;
		}
		
		field_sum = field.M + field.S + field.L;
		
		sort(pos_sum, pos_sum + N);
		
		for (i = 0; i < N; i++){			
			printf("%d ", pos_sum[i]);
		}
		
		printf("%d\n", field_sum);
	}
	
	return (0);
}

Measured memory_bytes: 1048
n, a, b = map(int, input().split())
c = []
for i in range(n+1):
    str_i = str(i)
    str_i = list(str_i)
    str_i = sum([int(i) for i in str_i])
    if (str_i <= b) & (str_i >= a):
        c.append(i)
print(sum(c))

Measured memory_bytes: 3296
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    double r, S, L, pi = 3.141592653589;

    cin >> r;

    S = r * r * pi;
    L = 2 * r * pi;

    printf("%f %f\n", S, L);

    return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

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

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=1,a[10000000],b[10000000],c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

        cin >> n;
        rep(i,n){cin>>a[i];}
        sort(a,a+n);
        rep(i,n-1){
                sum+=a[i];
                if(sum*2>=a[i+1]){
                        ans++;
                }
                else{
                        ans=1;
                }
                
        }
        Cout(ans);
return 0;
}


Measured memory_bytes: 2304
N=int(input())
AL=list(map(int,input().split()))

app=1

for i in range(N):
	if AL[i]%2 != 0 or AL[i]%3 == 0 or AL[i]%5 == 0:
		continue
	else:
		app=0
		break

if app == 1:
	print('APPROVED')
else:
	print('DENIED')



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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	string s; cin >> s;
	int ans = 0;
	for(int i=0; i<(s.size()/2); i++){
		if(s[i]!=s[int(s.size())-1-i]) ans ++;
	}
	cout <<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int min(int a,int b,int c)
{     int t; 
     if(a>b) {t=a;a=b;b=t;}
     if(c>=a) 
         return a;
      else
       return c;
}
int gcd(int a,int b,int c)
{   int mins=min(a,b,c);
    for(int i=mins;i>=1;i--)
      if(a%i==0&&b%i==0&&c%i==0) return i;
}
int main ()
{   int n;
     scanf("%d",&n);
     int sum=0;
	  for(int i=1;i<=n;i++)
       for(int j=1;j<=n;j++)
        for(int k=1;k<=n;k++)
          sum+=gcd(i,j,k);
         printf("%d\n",sum);
        
}

Measured memory_bytes: 1724
function countFilled(m) {
  let count = 0 
  for(let i = 0; i < m.length; i++) {
    for(let j = 0; j < m[i].length; j++) {
      count += m[i][j] === '#' ? 1 : 0
    }
  }
  return count
}

function main(input) {
  const inputs =input.split('\n')
  const [H, W, N] = inputs[0].split(' ').map(Number)
  const M = inputs.slice(1).map(e => { return e.split('') })
  // console.log(M)

  // paint
  // 行
  let count = 0
  for(let i = 0; i < Math.pow(2, H); i++) {
    // console.log('M:', M)
    let currentM = JSON.parse(JSON.stringify(M))
    // 行塗りつぶし
    for (let ii = 0; ii < H; ii++) {
      // console.log('i:', i, 'ii:', ii, '1 << ii:', 1 << ii, 'i & ( 1 << ii )', i & ( 1 << ii ))
      if (i & ( 1 << ii )) {
        currentM[ii] = currentM[ii].map(e => { return '-' })
      }
    }
    // console.log('i:', i, 'currentM:', currentM)

    if (countFilled(currentM) < N) continue

    // 列

    for (let j = 0; j < Math.pow(2, W); j++) {
      let currentM2 = JSON.parse(JSON.stringify(currentM))
      for(let jj = 0; jj < W; jj++) {
        if (j & (1 << jj)) {
          for (let jji = 0; jji < H; jji++) {
            currentM2[jji][jj] = '-'
          }
        }
      }
      // console.log('i:', i, 'j:', j, 'currentM2:', currentM2)
      if (countFilled(currentM2) === N) count++
    }
  }
  console.log(count)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 34024
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<ll> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
ll N;
vi divisor(ll a){//aの約数が全列挙されたベクトルを返す
  vi res;
  for(ll i=1;i*i<=a;i++){//iはsqrt(n)まで調べれば十分
    if(a%i==0){
      res.push_back(i);
      if(i!=a/i) res.push_back(a/i);
    }
  }
  return res;
}

void solve(){
  ll res=0;
  vi v=divisor(N);
  int vs=v.size();
  rep(i,vs){
    ll m=N/v[i]-1;
    if(v[i]<m) res+=m;
  }
  prin(res);
}
int main(){
  cin>>N;
  solve();
  return 0;
}


Measured memory_bytes: 384