akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int[] c = new int[8];
        c[0] = 1;c[1] = 2;c[2] = 1;c[3] = 2;c[4] = 1;c[5] = 4;c[6] = 1;c[7] = 4;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            int[] b = a.Split(' ').Select(int.Parse).ToArray();
            int[] f = new int[3];
            f[0] = 1000000000;
            for (int i = 0; i < 8; i++)
            {
                int e = 0;
                char[] h = new char[8];
                for (int j = 0; j < 8; j++)
                {
                    int d = j + i;
                    if (d >= 8)
                        d -= 8;
                    int g = b[j] - c[d];
                    if (g < 0)
                        g = 0;
                    e += g;
                    h[j] = (char)(c[d] + '0');
                }
                if (f[0] > e)
                {
                    f[0] = e;
                    f[1] = i;
                    string k = new string(h);
                    f[2] = int.Parse(k);
                }
                if (f[0] == e)
                {
                    string k = new string(h);
                    int l = int.Parse(k);
                    if (f[2] > l)
                    {
                        f[1] = i;
                        f[2] = l;
                    }
                }
            }
            int m = f[1];
            for (int i = 0; i < 8; i++)
            {
                int n = m + i;
                if (n >= 8)
                    n -= 8;
                if (i == 0)
                    Console.Write(c[n]);
                else
                    Console.Write(" " + c[n]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9460
#include<bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define tests(t) int t; cin >> t; while(t--)
#define ll long long
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 200005
using namespace std;

int main()
{
   	int n,k;
    cin>>n>>k;
    int arr[n+1],dp[n+1];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    //dp[2]=min(abs(arr[2]-arr[0]),abs(arr[2]-abs[1]));
    for(int i=2;i<n;i++)
    {int min1=INT_MAX;
    	for(int j=1;j<=k;j++)
    	{if((i-j)<0)
    	break;
    		if(min1>(dp[i-j]+abs(arr[i]-arr[i-j])))
    		min1=(dp[i-j]+abs(arr[i]-arr[i-j]));
		}
		dp[i]=min1;
    
	}
	
    cout<<dp[n-1]<<endl;
    return 0;
}



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

int main() {
   int n, m, a;
   cin >> n >> m;
   vector<long long> vec(n+1);
   for(int i=0; i<m; i++) {
       cin >> a;
       vec.at(a)=-1;
    }
    vec.at(0)=1;
    for(int i=1; i<n+1; i++) {
        if(vec.at(i) != -1) {
            if(i==1) vec.at(i) = vec.at(i-1);
            else {
                vec.at(i) =vec.at(i-1) + vec.at(i-2);
                vec.at(i) %= 1000000007;
            }
        }
        else vec.at(i)=0;
    }
    cout << vec.at(n);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define M 500005
#define bug printf("bug\n")
#define ll long long
int n,arr[M],dp[M];
int c(int a,int b){ return abs(arr[a]-arr[b]); }
int f(int pos)
{
    if(dp[pos]!=-1) return dp[pos];
    if(pos==2) return dp[2] = c(2,1);
    if(pos==3) return dp[3] = min(f(2)+c(3,2),c(3,1));
    return dp[pos] = min(f(pos-1)+c(pos,pos-1),f(pos-2)+c(pos,pos-2));
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)scanf("%d",&arr[i]);
    memset(dp,-1,sizeof dp);
    cout << f(n) << "\n";
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> p(n);
  for(auto& i:p) cin>>i;
  int m=n,res=0;
  for(auto& i:p) if(m>=i) ++res,m=i;
  cout<<res;
  return 0;
}

Measured memory_bytes: 4048
N, D = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(N)]
c = 0
for i in range(N - 1):
    for j in range(i + 1,N):
        c += (sum((a-b)**2 for a,b in zip(x[i], x[j])) ** 0.5).is_integer()

print(c)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int a, b, c, d, e;
	int z, zz, x, xx;
	
	while (scanf("%d", &a)!=EOF){
		z = 0;
		for (b = 0; b <= 9; b++) {
			for (c = 0; c <= 9; c++) {
				for (d = 0; d <= 9; d++) {
					for (e = 0; e <= 9; e++) {
						if ((b + c + d + e) == a) {
							z++;
						}
					}
				}
			}
		}
		printf("%d\n", z);
	}
	
	return (0);
}	

Measured memory_bytes: 596
/*
	A - Good Integer
*/
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; cin >> x;
#define lint(x) long long x; cin >> x;
#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<lint> v(n); REP(i,n) cin >> v[i];
#define double(x) double x; cin >> x[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define string(x) string x; cin >> x;

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

	string N1(N.c_str(), N.c_str() + 3);
	string N2(N.c_str() + 1, N.c_str() + 4);

	if ((stoi(N1) % 111 == 0) || (stoi(N2) % 111 == 0))
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int T;

int main() {
    int n;
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += 1ll * (n - i + 1) * i;
    }
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        if (u > v)swap(u, v);
        sum -= 1ll * u * (n - v + 1);
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int v[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

mod0 = 0
modk2 = 0
for i in range(1,n+1):
    if i%k == 0:
        mod0 += 1
    if k%2 == 0:
        if i%k == k//2:
            modk2 += 1
res = 0
if k % 2 != 0:
    res = mod0**3
else:
    res += mod0**3
    res += modk2**3
print(res)

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0;i < n;i++){
    cin >> s[i];
  }
  int a = 0,w = 0,t = 0,r = 0;
  for (int i = 0;i < n;i++){
    if (s[i] == "AC"){
      a++;
    }
    else if (s[i] == "WA"){
      w++;
    }
    else if (s[i] == "TLE"){
      t++;
    }
    else{
      r++;
    }
  }
  
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T>> A >> B >> U;
  if(S == U) {
    A -= 1;
  }
  if(T == U) {
    B -= 1;
  }
  cout << A << " " << B << endl;
}

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

const int N = (int) 2e5 + 5;

int n;
int a[N];

int main() {
	
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= i;
	}
	sort(a + 1, a + 1 + n);
	int med;
	if (n & 1) med = a[(n + 1) / 2];
	else med = a[n / 2];
	long long res = 0;
	for (int i = 1; i <= n; i++) res += abs(a[i] - med);
	cout << res;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int k, s, x, y, z;
	int ans = 0;
	scanf("%d %d", &k, &s);
	for (x = 0; x <= k; x++)
	{
		for (y = 0; y <= k; y++)
		{
			z = s - x - y;
			if (0 <= z&&z <= k)
			{
				ans++;
		}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int a[5];
  a[0] = -1;
  a[1] = -1;
  a[2] = -1;
  int n,m;
  cin >> n >> m;
  int s,c;
  for(int i=0; i<m; i++){
    cin >> s >> c;
    if(a[n-s] == -1){
      a[n-s] = c;
    } else if(a[n-s] != c){
      cout << -1;
      return 0;
    }
  }
  if(n>=2 && a[n-1] == 0){
    cout << -1;
    return 0;
  } else if(n>=2 && a[n-1] == -1){
    a[n-1] = 1;
  }
  cout << max(a[0],0)+max(a[1],0)*10+max(a[2],0)*100;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pp pair<ll,ll>
#define fore(i,n) for(ll i=0;i<n;i++)
#define vi vector<ll>
using namespace std;
const ll mod=998244353;
ll power(ll a,ll b)
{
if(b==0)
return 1;
else if(b==1)
{
return a;
}
else if(b&1)
{
return (a%mod * power((a%mod * a%mod)%mod,b/2)%mod)%mod;
}
else
{
return power((a%mod * a%mod)%mod,b/2)%mod;
}
}
 
void solve()
{
   int n;cin>>n;
   vector<int> arr(n);
   fore(i,n)cin>>arr[i];
   sort(arr.rbegin(),arr.rend());
  
     ll sum=arr[0];
     for(int i=2;i<=n/2;i++)
      {
          sum+=(ll)(2*arr[i-1]);
      }

      if(n&1)
      {
          sum+=arr[n/2];

      }
      cout<<sum<<endl;
   

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

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli d, e, f, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  vector<lli> a(n), b(n + 1, 0);
  map<lli, lli> c;
  cin >> a;
  rep(i, 0, n)
  {
    b[i + 1] = b[i] + a[i];
  }
  rep(i, 0, n + 1)
  {
    c[b[i]]++;
  }
  for (auto it : c)
  {
    lli num = it.second; // it.first が it.second 個ある
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); //cinの高速化
  
  int A,B;
  cin >> A >> B;
  vector<int> sum(B);
  REP(i,A){
    int K;
    IN(K);
    int X;
    REP(j,K){
      IN(X);
      sum[X-1] +=1;
    }
    
  }
  int ans=0;
  REP(i,B) if(sum[i] == A) ans+=1;
  OUT(ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAX_N 200005
#define INF 1000000000000000ll
#define int long long

using namespace std;

int n,ans=INF;
int a[MAX_N];

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),a[i]+=a[i-1];
	for(int i=1;i<n;i++) ans=min(ans,abs((a[i]<<1)-a[n]));
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

    if (S == "ARC") cout << "ABC" << endl;
    if (S == "ABC") cout << "ARC" << endl;
    
    return 0;
}


Measured memory_bytes: 3592
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = (0 until n).map { sc.next() }
    println(problem173b(n, s))
}

fun problem173b(n: Int, s: List<String>): String {
    var ac = 0
    var wa = 0
    var tle = 0
    var re = 0
    for (i in 0 until n) {
        when (s[i]) {
            "AC" -> ac++
            "WA" -> wa++
            "TLE" -> tle++
            "RE" -> re++
        }
    }
    return "AC x $ac\n" +
            "WA x $wa\n" +
            "TLE x $tle\n" +
            "RE x $re"
}

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

public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int arr[]=new int[n];
        for (int i = 0; i <n ; i++) {
            arr[i]=scan.nextInt();
        }
        Arrays.sort(arr);
        for (int i = 1; i <n ; i++) {
            if (arr[i]==arr[i-1]){
                System.out.print("NO");
                return;
            }
        }
        System.out.print("YES");
    }
}


Measured memory_bytes: 66080
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define bp __builtin_popcountll
#define MOD  1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
const int N = 200005;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
	ll h,w;
	cin >> h >> w;
	if(h>w)   swap(h,w);
	if(h==1)
	{
		cout<<1;
		return;
	}
	ll ans = h*w;
	ans = ceil(ans/2.0);
	cout<<ans;
}
 
int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
    	solve();
    }
}

Measured memory_bytes: 256
n = int(input())
A = [0] + list(map(int, input().split())) + [0]

B = [0 for i in range(n+1)]
for i in range(n+1):
    B[i] = abs(A[i+1] - A[i])
su = sum(B)
for i in range(1,n+1):
    print(su-B[i-1]-B[i]+abs(A[i+1]-A[i-1]))


Measured memory_bytes: 14048
#include <stdio.h> 
 int main(){ 
     int h, w; 
     int i, j; 
     while(1){ 
         scanf("%d %d ", &h, &w); 
         if(h==0&&w==0)break; 
         for(i=0;i<h;i++){ 
             for(j=0;j<w;j++){ 
                 if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){ 
                     printf("#"); 
                 }else{ 
                     printf("."); 
                } 
             } 
             printf("\n"); 
         } 
         printf("\n"); 
         } 
     return 0; 
 } 



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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  string s;cin>>s;
  cout<<count(ALL(s),'2')<<endl;

  return 0;
}

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))

k = NI()
a = [1,2,3,4,5,6,7,8,9]
cnt = 0
j = 0
while True:
    x = a[j]
    j += 1
    s = x % 10
    for i in range(s-1,s+2):
        if i >= 0 and i < 10:
            a.append(x * 10 + i)
            cnt += 1
    if cnt > 100000: break
print (a[k-1])

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

int main() {
	int n, a[(int)1e5];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int pos = 1;
	for (int i = 1; i < n; i++) {
		pos = a[pos - 1];
		if (pos == 2) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

bool ispal(string s)
{
    string t = s;
    reverse(t.begin(), t.end());
    return (t == s);
}

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

    int n;
    string s;
    cin >> s, n = s.size();
    s = " " + s;

    bool suc = true;
    if (!ispal(s.substr(1)))
        suc = false;
    if (!ispal(s.substr(1, (n - 1) / 2)))
        suc = false;
    if (!ispal(s.substr((n + 3) / 2, n)))
        suc = false;

    if (suc)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

int sum(std::string s, int sofar) {
  int total = 0;
  if (s == "") {
    return sofar;
  }
  NREP(i, SIZE(s)) {
    total += sum(s.substr(i), std::stol(s.substr(0, i)) + sofar);
  }
  // cout(s << " " << total);
  return total;
}

void solve() {
  std::string s;
  std::cin >> s;
  cout(sum(s, 0));
}

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

int main(){
	int n, k, i, j, l, t;
	int s=0;
	cin >> n;
	cin >> k; 
	
	int a[n];
	
	for(i=0; i<n; i++)
		cin >> a[i];

	for(j=0; j<n; j++)
		for(l=0; l<n; l++){
			if (a[j] <= a[l]){
				t=a[j];
				a[j]=a[l];
				a[l]=t;
			}
		}

	for(i=0; i<k; i++)
		s+= a[i];

	cout << s;

}

	

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)   //test cases
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define error(x) fixed<<setprecision(x) //cout<<error(5)<<someDouble    -> example - 3.14159
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll i = 0; i < n; i++)    cin>>a[i];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

ll r, c, k;
ll grid[3001][3001];
ll dp[3001][3001][4];
ll calc(ll i, ll j, ll t){
	if(i > r || j > c)	return 0;
	if(dp[i][j][t] != -1)	return dp[i][j][t];
	ll ans = max(calc(i+1, j, 0), calc(i, j+1, t));
	if(t == 3)	ans = max(ans, calc(i+1, j, 0));
	else	ans = max({ans, grid[i][j] + calc(i+1, j, 0), grid[i][j] + calc(i, j+1, t+1)});
	return dp[i][j][t] = ans;
}
int main(){
	init();
	fill(dp, -1);
	cin>>r>>c>>k;	ll ri, ci, vi;
	while(k--){
		cin>>ri>>ci>>vi;	grid[ri][ci] = vi;
	}
	cout<<calc(1, 1, 0);
}

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

public static class Bits
{
    public static int PopCount(int bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
    }
}

public class Query
{
    public int QueryType;
    public int i;
    public char c;
    public int l;
    public int r;

    public Query(string s)
    {
        var vals = s.Split(' ');

        QueryType = int.Parse(vals[0]);
        if (QueryType == 1)
        {
            i = int.Parse(vals[1]);
            c = vals[2][0];
        }
        else
        {
            l = int.Parse(vals[1]);
            r = int.Parse(vals[2]);
        }
    }
}

public class SegmentTree
{
    // 元の配列の大きさ
    public int N { get; set; }
    // セグメント木のデータ(2^n-1)
    public int[] Node { get; set; }

    public SegmentTree(int[] a)
    {
        N = 1;
        while (N < a.Length) N *= 2;

        this.Node = new int[2 * N - 1];
        for (int i = 0; i < this.Node.Length; i++) this.Node[i] = 0;

        for (int i = 0; i < a.Length; i++) this.Node[N + i - 1] = a[i];
        for (int i = N - 2; i >= 0; i--)
        {
            this.Node[i] = this.Compare(this.Node[2 * i + 1], this.Node[2 * i + 2]);
        }
    }

    public void Update(int x, int v)
    {
        x += (this.N - 1);
        this.Node[x] = v;

        while (x > 0)
        {
            x = (x - 1) / 2;
            this.Node[x] = this.Compare(this.Node[2 * x + 1], this.Node[2 * x + 2]);
        }
    }

    public int GetKinds(int a, int b)
    {
        return this.GetKinds(a, b, 0, 0, this.N);
    }

    private int GetKinds(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) return 0;

        if (a <= l && r <= b) return this.Node[k];

        var vl = this.GetKinds(a, b, 2 * k + 1, l, (l + r) / 2);
        var vr = this.GetKinds(a, b, 2 * k + 2, (l + r) / 2, r);
        return this.Compare(vl, vr);
    }

    private int Compare(int a, int b)
    {
        return a | b;
    }
}


public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        var Q = int.Parse(Console.ReadLine());

        var queries = new Query[Q];
        for (int i = 0; i < Q; i++)
        {
            queries[i] = new Query(Console.ReadLine());
        }

        var segTree = new SegmentTree(S.Select(c => 1 << (c - 'a')).ToArray());

        var result = new List<int>();
        foreach (var q in queries)
        {
            if (q.QueryType == 1)
            {
                segTree.Update(q.i - 1, 1 << (q.c - 'a'));
            }
            else
            {
                var r = Bits.PopCount(segTree.GetKinds(q.l - 1, q.r));
                result.Add(r);
            }
        }

        Console.WriteLine(string.Join(Environment.NewLine, result));
    }
}

Measured memory_bytes: 32604
#include <iostream>
#include <map>
using namespace std;
#define N 212345
int main() {
  int n;
  long long int a[N];
  long long int h[N];
  map<long long int, int> mp;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long int c, i;
  c = 0;
  h[0] = 0;
  mp[0]=1;
  for (i = 0; i < n; ++i) {
    h[i+1] = h[i] + a[i];
    mp[h[i+1]]++;
  }
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    long long int v = itr->second;
    c += v * (v - 1) / 2;
  }
 
  cout << c;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define str(n) to_string(n)
#define int(w) stoi(w)
#define len(l) l.size()
#define append(l,i) l.push_back(i)
int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans="";
    rep(i,tx-sx){
        ans+="R";
    }
    rep(i,ty-sy){
        ans+="U";
    }
    rep(i,tx-sx){
        ans+="L";
    }
    rep(i,ty-sy){
        ans+="D";
    }
    ans+="L";
    rep(i,ty-sy+1){
        ans+="U";
    }
    rep(i,tx-sx+1){
        ans+="R";
    }
    ans+="DR";
    rep(i,ty-sy+1){
        ans+="D";
    }
    rep(i,tx-sx+1){
        ans+="L";
    }
    ans+="U";
    cout<<ans<<endl;
    return 0;
}


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

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

    static class TaskL {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
            }
            long[][] dp = new long[n + 1][n + 1];
            helper(a, dp, 1, n);
            out.println(dp[1][n]);
        }

        private void helper(int[] a, long[][] dp, int l, int r) {
            if (dp[l][r] != 0) {
                return;
            } else {
                if (l == r) {
                    dp[l][r] = a[l];
                } else {
                    helper(a, dp, l + 1, r);
                    helper(a, dp, l, r - 1);
                    dp[l][r] = Math.max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}

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

using namespace std;

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

        if (a == 1 && b == 2){
                cout << "3" << endl;
        }
        else if (a == 1 && b == 3){
                cout << "2" << endl;
        }
        else if (a == 2 && b == 1){
                cout << "3" << endl;
        }
        else if (a == 2 && b == 3){
                cout << "1" << endl;
        }
        else if (a == 3 && b == 1){
                cout << "2" << endl;
        }
        else if (a == 3 && b == 2){
                cout << "1" << endl;
        }
        return 0;
}

Measured memory_bytes: 3624
#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 = 5000000000000000;
constexpr auto MOD = 1000000007;

int n, m;
vvi e, rev;
V<bool> root;
vi tpr;

void dfs(int v) {
	rep(i, e[v].size()) {
		if (root[e[v][i]])continue;
		root[e[v][i]] = true;
		dfs(e[v][i]);
	}
	tpr.push_back(v);
	return;
}

int main() {

	cin >> n >> m;
	e.resize(n);
	rev.resize(n);
	root.assign(n, true);

	rep(i, n - 1 + m) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		e[a].push_back(b);
		rev[b].push_back(a);
		root[b] = false;
	}

	rep(i, n)if (root[i]) { dfs(i);break; }
	
	vi ans(n, 0);
	reverse(all(tpr));
	rep(i, tpr.size())rep(j, e[tpr[i]].size()) {
		ans[e[tpr[i]][j]] = tpr[i] + 1;
	}
	
	for (auto x : ans)cout << x << endl;

}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  
  int d = a.size() - 1;
  int e = b.size() - 1;
  int f = c.size() - 1;
  
  if(a.at(d) == b.at(0)) {
    if(b.at(e) == c.at(0)) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  else {
    cout << "NO" << endl;
  }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s; cin >> s;

  cout << ((!(SZ(s)%2) ^ (s[0] == s[SZ(s)-1])) ? "Second" : "First") << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;


int main()
{
  static int INF = 1000000000;
  int N;
  cin >> N;
  vector <int> a(N);
  vector <int> b(N);
  vector <int> c(N);

  for( int i=0;i<N;i++ )
    cin >> a[i] >> b[i] >> c[i];

  vector < vector<int> > dp(N, vector<int>(3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  
  for( int i=1;i<N;i++ )
    {
      dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i];
      dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b[i];
      dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c[i];
    }

  cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
}


Measured memory_bytes: 6912
N = int(input())
def judge(N):
  if N <= 2:
    print('No')
    return
  for k in range(2, 18):
    if 2 ** k > N + 1:
       break
  K = 2 ** (k - 1) - 1
  if N - K == 1:
    print('No')
    return
  print('Yes')
  if N % 2:
    for i in range(1, K):
      print('{} {}'.format(i, i + 1))
      print('{} {}'.format(i + N, i + 1 + N))
    print('{} {}'.format(K, N + 1))
    if K < N:
      for i in range(K + 1, N + 1):
        print('{} {}'.format(i, 1 if i % 2 else i + 1))
        print('{} {}'.format(i + N, 1 if i % 2 == 0 else i - 1 + N))
  else:
    for i in range(K + 1, N):
      print('{} {}'.format(i, 1 if i % 2 else i + 1))
      print('{} {}'.format(i + N, 1 if i % 2 == 0 else i - 1 + N))
    m = N ^ (K + 1)
    print('{} {}'.format(N, m + N))
    print('{} {}'.format(m + N, K + 1))
    print('{} {}'.format(K + 1, 2 * N))
    P = [i for i in range(2, K + 1)]
    P.pop(P.index(m))
    print('{} {}'.format(2 * N - 1, P[0]))
    for i, p in enumerate(P[:-1]):
      print('{} {}'.format(p, P[i + 1]))
      print('{} {}'.format(p + N, P[i + 1] + N))
    print('{} {}'.format(P[-1], m))
    print('{} {}'.format(P[-1] + N, m + N))
    print('{} {}'.format(K + 1, N + 1))
judge(N)

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

int main(){
	int s[101] = { };
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = a; i < b; i++){
		s[i]++;
	}
	for(int i = c; i < d; i++){
		s[i]++;
	}
	int ans = 0;
	for(int i = 0; i < 101; i++){
		if(s[i] == 2) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

long long int num[100000100];

void erat(int n) {
    for (int i = 0; i <= n; i++) num[i] = true;

    num[0] = num[1] = false;

    for (int i = 2; i * i <= n; i++) {
        if (!num[i]) continue;
        else {
            for (int j = 2*i; j <= n; j += i) {
                num[j] = false;
            }
        }
    }
}

int main()
{
    int n, cnt = 0;

    while (cin >> n) {
        erat(n);
        for (int i = 0; i <= n; i++) {
            if (num[i]) cnt++;
        }
        cout << cnt << endl;
        cnt = 0;
    }
}



Measured memory_bytes: 10800
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  string s; cin >> s;
  int n = (int) s.size();
  vector<int> a(n + 1);
  rep(i,n) {
    if (s[i] == '<') {
      a[i + 1] = max(a[i + 1], a[i] + 1);
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '>') {
      a[i] = max(a[i], a[i + 1] + 1);
    }
  }
  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;


const int N = 1100;

char mat[N][N];

int vis[N][N];


int h, w;
int inside(int x, int y) {
	return (0 <= x && x < h) && (0 <= y && y < w);
}

int main() {
	cin >> h >> w;
	queue <pair<int, int> > q;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> mat[i][j];
			if(mat[i][j] == '#') {
				q.push(make_pair(i, j));
				vis[i][j] = 1;
			}
		}
	}

	while(!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();

		for (int dx = -1; dx <= 1; ++dx) {
			for (int dy = -1; dy <= 1; ++dy) {
				if(abs(dx) + abs(dy) != 1) continue;
				int nx = x+dx;
				int ny = y+dy;
				if(inside(nx, ny) && vis[nx][ny] == 0) {
					vis[nx][ny] = vis[x][y]+1;
					q.push(make_pair(nx, ny));
				}
			}
		}	
	}
	int mx = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			mx = max(mx, vis[i][j]);
		}
	}

	printf("%d\n", mx-1);
}

Measured memory_bytes: 13840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

bool is_all_zero(vector<int> h){
	rep (i, (int)h.size()){
		if (h[i] != 0){
			return false;
		} // end if
	} // end rep
	return true;
}

int is_first_zero(vector<int> h){
	rep(i, (int)h.size()){
		if (h[i] == 0){
			return i;
		} // end if
	} // end rep
	return -1;
} 

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> h(N, 0);
	rep (i, N){
		cin >> h[i];
	} // end rep

	int res = 0;
	while(!is_all_zero(h)){
		int left = 0;
		if (is_first_zero(h) != -1){
			for (; h[left] == 0 && left < N; ++left);
		} // end if

		int right = left;
		for (; h[right] != 0 && right < N; ++right);
//		cerr << "left: " << left << " right: " << right << endl;
		for (int i = left; i < right; ++i){
			--h[i];
		} // end for
		++res;
	} // end while

	cout << res << endl;

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;

int n,a[maxn];

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

  cin>>n;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);

  int alice = 0; int bob = 0;
  
  for (int i=0; i<n; i++) {
    if (i%2 == 0) {
      alice+=a[i];
    } else {
      bob+=a[i];
    }
  }

  int ans = alice-bob;
  out(ans);
  

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

bool
isPrime(vector<ll> & p, ll i) {
  for (auto k : p) {
    if (k * k > i) break;
    if (i % k == 0) return false;
  }

  return true;
}

void
solve() {
  ll n;
  cin>>n;

  vector<ll> p;
  
  ll temp = n;
  map<ll, ll> cnt;
  for (ll i=2; i<1000000; i++) {
    if (i * i > n) break;
    if (i > 2 && i % 2 == 0) continue;

    if (isPrime(p, i)) {
      p.push_back(i);

      while (temp % i == 0) {
        cnt[i]++;
        temp /= i;
      }
    }
  }
  if (temp > 1)
    cnt[temp]++;

  ll ans = 0;
  for (auto t : cnt) {
    //cout<<t.first<<":"<<t.second<<endl;
    ll now = 1;
    ll left = t.second;
    while (left >= now) {
      ans++;
      left -= now;
      now++;
    }
  }
  cout<<ans<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}


Measured memory_bytes: 4256
n = int(input())
a = [0]
a.extend(list(map(int, input().split())))
a.append(0)

cost = [abs(a[i] - a[i + 1]) for i in range(len(a) - 1)]
total = sum(cost)

for i in range(n):
    ans = total - cost[i] - cost[i + 1] + abs(a[i] - a[i + 2])
    print(ans)




Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string small="abcdefghijklmnopqrstuvwxyz";
  char a;
  cin>>a;
  bool tf;
  for(int i=0;i<small.size();i++){
    if(small[i]==a){
      tf=true;
      break;
    }else{
      tf=false;
    }
  }
  if(tf==true){
    cout<<"a"<<endl;
  }else{
    cout<<"A"<<endl;
  }
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s[0] == 'S') {
        cout << "Cloudy" << "\n";
    }
    if (s[0] == 'C') {
        cout << "Rainy" << "\n";
    }
    if (s[0] == 'R') {
        cout << "Sunny" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int ans=-inf;
int n;
int d[101],f[101][101],a[101][101];
void dfs(int x){
	if(x==11){
		int k=0,q=0;
		FOR(i,1,n){
			int c=0;
			FOR(j,1,10){
				q|=d[j];
				c+=d[j]&f[i][j];
			}
			k+=a[i][c];
		}
		if(!q)return ;
		ans=max(ans,k);
		return ;
	}
	d[x]=1;
	dfs(x+1);
	d[x]=0;
	dfs(x+1);
}
int main(){
	in(n);
	FOR(i,1,n)
		FOR(j,1,10)
			in(f[i][j]);
	FOR(i,1,n)
		FOR(j,0,10)
			in(a[i][j]);
	dfs(1);
	out(ans);
}

Measured memory_bytes: 384
a,b=map(int, input().split())
arr=[]
de=9999999999999999999
denum=0
for i in range(a):
    arr.append(i+b)
    if abs(i+b)<de:
        de=abs(i+b)
        denum=i
#print(arr)
#print(denum)
del arr[denum]
print(sum(arr))



Measured memory_bytes: 2940
import java.util.*;
import java.io.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        System.out.println((x / 3600) + ":" + (x % 3600 / 60) + ":" + (x % 60));
    }
}


Measured memory_bytes: 26352
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

int K;
void input() {
  cin >> N >> K;
  // int ans = (N - K) * (N - K + 1) / 2;
  // // cout << ans << endl;

  // int ans2 = 0;

  // rep(a, 1, N) {
  //   rep(b, K, a) {
  //     if (a % b >= K) {
  //       ans2++;
  //     }
  //   }
  // }
  // cout << ans + ans2 << endl;

  // ;
  // ;
}
int ans;
void solve() {
  ;
  if (K == 0) {
    cout << (N * N) << endl;
    return;
  }
  rep(b, K + 1, N) {
    int k = N % b;
    int p = N / b;
    ans += p * (max(0LL, b - K));
    ans += max(0LL, k - (K - 1));
  }
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, K) = Read2Longs();
            var A = new List<List<long>>();
            var sunukes = new bool[N];
            for (int i = 0; i < K; i++)
            {
                ReadLong();
                //A.Add(ReadLongs());
                foreach (var item in ReadLongs())
                {
                    sunukes[item - 1] = true;
                }
            }

            return sunukes.Count(x => !x);
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28432
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, T;
    cin >> n >> T;
    vector<Int> t(n);
    for (Int i = 0; i < n; i++) {
        cin >> t[i];
    }

    Int ans = 0;
    for (Int i = 0; i < n - 1; i++) {
        if (t[i + 1] - t[i] < T) {
            ans += t[i + 1] - t[i];
        } else {
            ans += T;
        }
    }
    ans += T;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

char s[100];
int main(void){
	scanf("%s", s);
	int result = 1000;
	for (int i = 0; s[i + 2]; i++) {
		int item = ((s[i] - '0') * 10 + s[i + 1] - '0') * 10 + s[i + 2] - '0';
		int maybe = (item >= 753 ? item - 753 : 753 - item);
		if (maybe < result) result = maybe;
	}
	printf("%d\n", result);
}


Measured memory_bytes: 128