akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
}
int q[N];
char s[N];
map<int,int>mp,vis;
int main(){
	int n;
	n=read();
	int k;
	k=read();
	rep(i,1,n){
		q[i]=read();
	}
	sort(q+1,q+1+n);
	int sum=0;
	rep(i,1,k){
		sum+=q[i];
	}
	cout<<sum;
}
/*

 */

Measured memory_bytes: 3624
N = int(input())
A = [int(_) for _ in input().split()]

a_sum = sum(A)

sums = [0] * (N + 1)
diffs = [0] * (N + 1)

for n in range(1, N + 1):
    sums[n] = sums[n - 1] + A[n - 1]
    diffs[n] = abs(a_sum - 2 * sums[n])

diffs.pop(len(diffs) - 1)
diffs.pop(0)

print(min(diffs))

Measured memory_bytes: 27852
#include<stdio.h>
int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %.5f\n",d,r,f);
    return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
    int a, b, k;
    ci >> a >> b >> k;

    for(int i = 100; i >= 1; i--) {
	if(a % i == 0 && b % i == 0) {
	    if(--k == 0) {
		co << i << en;
		return 0;
	    }
	}
    }
    
    return 0;
}









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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e6+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);


signed main(){
    fast_io();
    int N, A, B;
    cin >> N >> A >> B;
    cout <<  ((A+B) % 2 == 0 ? "Alice" : "Borys") << endl; 
}


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

string s;
const int max_n = 1e5 + 10;
int main()
{
    int n, a[max_n];
    pair<int, int> b[3];
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    bool flag = true;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] != 0)
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
        return 0;
    }

    flag = true;

    if (n % 3 == 0)
    {
        int k = 0;
        b[0].first = a[0];
        b[0].second = 0;
        for (int i = 1; i < n; ++i)
        {
            bool flag_2 = true;
            for (int j = 0; j <= k; ++j)
            {
                if (b[j].first == a[i])
                {
                    flag_2 = false;
                    break;
                }
            }
            if (flag_2)
            {
                ++k;
                b[k].first = a[i];
                b[k].second = 0;
            }
        }
        if (k + 1 > 4)
        {
            flag = false;
        }
        else
        {
            if (k == 0)
            {
                flag = false;
            }
            else if (k == 1)
            {
                sort(b, b + 2);
                if (b[0].first == 0)
                {
                    for (int i = 0; i < n; ++i)
                    {
                        for (int j = 0; j < 2; ++j)
                        {
                            if (b[j].first == a[i])
                            {
                                ++b[j].second;
                            }
                        }
                    }
                    flag = (flag && b[0].second * 2 == b[1].second);
                }
                else
                {
                    flag = false;
                }
            }
            else
            {
                if ((b[0].first ^ b[1].first) != b[2].first)
                {
                    flag = false;
                }
                for (int i = 0; i < n; ++i)
                {
                    for (int j = 0; j < 3; ++j)
                    {
                        if (b[j].first == a[i])
                        {
                            ++b[j].second;
                        }
                    }
                }
                flag = (flag && b[0].second == b[1].second && b[1].second == b[2].second);
            }
        }
    }
    else
    {
        flag = false;
    }

    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
  string a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;

  if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;

void solve()
{
    string s, t;
    cin >> s >> t;
    s += s;
    if (s.find(t) != -1)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}

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



Measured memory_bytes: 3192
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 17:11:47 2020

@author: shinba
"""

n = int(input())
s = list(input())

ans = 0

for i in range(1,n):
    s1 = set(s[:i])
    s2 = set(s[i:])
    ans = max(ans,len(s1 & s2))

print(ans)
    
    




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int INF = (int)(1e9 + 9);

#define maxn 100010
#define mod (ll) (1e9 + 9)

ll inv(ll a, ll b){
    return 1 < a ? b - inv(b % a, a) * b / a : 1;
}

int main() {
#ifdef BZ
    freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(6);

    int n, k;
    cin >> n >> k;

    vector <ii> a (n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    vector <vi> dp (n + 1, vi (100010, INF));

    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 100000; j++) {
            if (dp[i][j] != INF) {
                if (dp[i][j] + (ll) a[i].first <= (ll)k) {
                    //cout << i << " " << j << "\n";
                    dp[i + 1][j + a[i].second] = min (dp[i + 1][j + a[i].second], dp[i][j] + a[i].first);
                    //cout << dp[i + 1][j + a[i].second] << "\n";
                }
                dp[i + 1][j] = min (dp[i + 1][j], dp[i][j]);
            }
        }
    }

    for (int i = 100000; i >= 0; i--) {
        if (dp[n][i] != INF) {
            cout << i << "\n";
            break;
        }
    }

}

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

int main(){
    int n;
    int T;
    cin >> n;
    cin >> T;
    long int t[n];
    long int result = 0;
    for(int i=0;i<n;i++){
        cin >> t[i];
        if((t[i] - t[i-1]) <= T && i != 0){
            result = result + t[i] - t[i-1];
        }else{
          	result += T;
        }
    }
    cout << result << endl;
}

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

#define int long long

const int M = 1e9+7ll;

int n,m;
int ans;
struct matrix{
	int n,m;
	int mat[55][55];
	matrix operator * (const matrix b) const
	{
		matrix res={n,b.m};
		for(int k=1;k<=m;k++)
			for(int i=1;i<=n;i++)
				for(int j=1;j<=b.m;j++)
					res.mat[i][j] = (res.mat[i][j]+mat[i][k]*b.mat[k][j])%M;
		return res;
	}
}f;

matrix ksm(matrix x,int w)
{
	matrix s={n,n};
	for(int i=1;i<=n;s.mat[i][i]=1,i++);
	while(w)
	{
		if(w&1)
			s = s*x;
		x = x*x;
		w >>= 1;
	}
	return s;
}

signed main()
{
	cin>>n>>m;
	f = (matrix){n,n};
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>f.mat[i][j];
	f = ksm(f,m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			ans = (ans+f.mat[i][j])%M;
	cout<<ans<<endl;
	
	return 0;
}

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

mod = 10**9 + 7


def f(k):
    min_r = k * (k-1) // 2
    max_r = (n + n+1-k) * k // 2
    return max_r - min_r + 1

ans = 0
for i in range(k, n+2):
    ans += f(i)
    ans %= mod
print(ans)

Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#define int long long
using namespace std;

signed main(){
    static const double pi = 3.141592653589793;
    double A,B,H,M;
    cin>>A>>B>>H>>M;
    double all=60*H+M;
    
    double theta=abs(all*360.0/720.0-M*360.0/60.0);

    theta=min(theta,360-theta);

    theta=(theta*pi)/180.0;

    double ans=sqrt(A*A+B*B-2*A*B*cos(theta));
    cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
int ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<int> > C(10, vector<int>(10));
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) cin >> C[i][j];
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            if (k == i) continue;
            for (int j = 0; j < 10; j++) {
                if (k == j || i == j) continue;
                if (C[i][j] > C[i][k]+C[k][j]) {
                    C[i][j] = C[i][k]+C[k][j];
                } 
            }
        }
    }
    for (int i = 0; i<H; i++) {
        for (int j = 0; j<W; j++) {
            int a;
            cin >> a;
            if (a == -1 || a == 1) continue;
            ans += C[a][1];
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma") 
 
#include<bits/stdc++.h>
 
#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left
#define lld long long int
#define ulld unsigned long long int
typedef long long ll;
using namespace std;
 
ll binpow(ll a, ll b) { 
ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;
}
 
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
 
bool isPrime(ll n) { 
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}
void solve(){
      lld n,m;
    cin>>n>>m;
    lld sum=0;
    for(int i=0;i<m;i++)
    {
      lld w;
      cin>>w;
      sum+=w;
    }
    if(sum<n)
    cout<<"No";
    else
    {
       cout<<"Yes";
    }
    
}
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll t;
   t=1;
   while(t--)
   { 
   solve();
   }
   return 0;
}

Measured memory_bytes: 3680
n=int(input())
s=input()
c=s[1:n].count('E')
l=[]
l.append(c)
for i in range(1,n):
  if s[i-1:i+1]=='WW':c+=1
  elif s[i-1:i+1]=='EE':c-=1
  l.append(c)
print(min(l))

Measured memory_bytes: 15500
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

vi color;
vvi G;


bool dfs(int v, int c) {
    if(color[v]  != -1) {
        if(c%2 == color[v]) {
            return true;
        } else {
            return false;
        }
    }
    color[v] = c%2;
    for(int next:G[v]){
       if(!dfs(next, c+1)) {
           return false;
       }
    }
    return true;
}

int main() {
    ll N, M;
    scanf("%lld%lld", &N, &M);
    G.resize(N);
    rep(i, M) {
        int a, b;
        scanf("%d%d", &a, &b);
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    color.assign(N, -1);
    if(!dfs(0, 0)) {
        cout << N*(N-1)/2-M << '\n';
        return 0;
    }
    int cc=0;
    rep(i, N) {
        if(color[i]) {
            ++cc;
        }
    }
    cout << (N-cc)*cc-M << '\n';
}

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

int bubbleSort(int A[], int N) {
    auto sw = 0;
    auto flag = true;
    for(int i = 0; flag; i++)
    {
        flag = false;
        for(int j = N -1; j >= i + 1; j--)
        {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = true;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    
    sw = bubbleSort(A, N);

    for(int i = 0; i < N; i++)
    {
        if (i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <queue>
#include <vector>
#include <ios>
#include <iomanip>
using namespace std;

struct city {
  long long year;
  long long num;
  long long pref;
  long long order;
};

bool operator<(const struct city& a, const struct city& b){
  return a.year > b.year;
}

priority_queue<struct city> que[100002]; 
vector<struct city> ps;

int main(void) {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long p, y;
    cin >> p >> y;
    
    struct city t;
    t.pref = p; t.num = i; t.year = y;
    que[p].push(t);
    ps.push_back(t);
  }

  for (long long i = 1; i <= n; i++) {
    long long cur = 1;
    while(!que[i].empty()) {
      struct city t = que[i].top();
      ps[t.num].order = cur;
      que[i].pop();
      cur++;
    }
  }

  for (long long i = 0; i < m; i++) {
    cout << std::setfill('0') << std::right << std::setw(6) << ps[i].pref;
    cout << std::setfill('0') << std::right << std::setw(6) << ps[i].order << endl;
  }

  return 0;
}

Measured memory_bytes: 14316
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int counter[200];

int main() {
    char c;
    while (cin >> c) {
        counter[c]++;
    }
    for (char i = 'a', j = 'A'; i <= 'z'; i++, j++){
        cout << i << " : " << counter[i] + counter[j] << endl;
    }
}


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

int main(){
  string S;
  int N;
  cin >> N >> S;
  int count = 0;
  
  if (N%2==0 && N != 1){
    for(int i=0; i<N/2; i++){
      if(S.at(i) == S.at(i+N/2)){
        count++;
      }
    }
  }
  
  if (count == N/2 && N !=1){
    //cout << count << endl;
    cout<<"Yes"<<endl;
  }
  else{
    //cout << count << endl;
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

std::vector<int> WID;
std::vector<int> HEI;

bool func(intt& h) {
	for (auto r : WID) {
		if (r == h)
			return true;
	}
	return false;
}

bool func2(intt& w) {
	for (auto r : HEI) {
		if (r == w)
			return true;
	}
	return false;
}

int main() {
	intt H, W; std::cin >> H >> W;
	std::vector<std::vector<char>> a(H, std::vector<char>(W));
	bool flag;
	intt I;
	for (I = 0; I < H; ++I) {
		flag = false;
		for (intt j = 0; j < W; ++j) {
			std::cin >> a[I][j];
			if (a[I][j] == '#')
				flag = true;
		}
		if (flag == false)
			WID.push_back(I);
	}
	intt J;
	for (J = 0; J < W; ++J) {
		flag = false;
		for (intt i = 0; i < H; ++i) {
			if (a[i][J] == '#')
				flag = true;
		}
		if (flag == false)
			HEI.push_back(J);
			
	}
	intt w;
	for (intt h = 0; h < H; ++h) {
		for (w = 0; w < W; ++w) {
			if (func(h) == false && func2(w) == false)
				std::cout << a[h][w];
		}
		if (func(h) == false)
			std::cout << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


int main(void) {
long long int N;
scanf("%lld",&N);
long long int monsters[N+1];
long long int heroes[N];

long long int copy[N+1];
for (long long int i=0;i<N+1;i++){
    scanf("%lld",&monsters[i]);
    copy[i]=monsters[i];
}
for (long long int i=0;i<N;i++)
    scanf("%lld",&heroes[i]);
long long int sum=0;
long long int c=0;
for (long long int i=0;i<N;i++){
   c=monsters[i]-heroes[i];
  monsters[i]=c;
if (monsters[i]<=0) {monsters[i]=0;
if (abs(c)>monsters[i+1]) {monsters[i+1]-=monsters[i+1];}
else monsters[i+1]-=abs(c);
}
}
for (long long int i=0;i<N+1;i++)
 {copy[i]-=monsters[i];
sum+=copy[i];
 }
printf("%lld",sum);
return EXIT_SUCCESS;
}


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

using namespace std;

string s, t;
const int N = 100005;
int _next[N][26];
int pos[26];

int main() {

    memset(pos, -1, sizeof(pos));

    cin >> s >> t;
    for (int i = 0; i < 26; i++) {
        _next[s.size()][i] = -1;
    }
    for (int i = s.size() - 1; i >= 0; i--) {
        pos[s[i] - 'a'] = i;
        for (int j = 0; j < 26; j++) {
            _next[i][j] = pos[j];
        }
    }
    for (auto c: t) {
        if (pos[c - 'a'] == -1) {
            cout << -1;
            return 0;
        }
    }
    int num = 0;
    int cur = 0;
    int cnt = 0;
    for (auto ch: t) {
        int c = ch - 'a';
        int nx = _next[cur][c];

        if (nx == -1) {
            num++;
            cur = 0;
            cur = _next[cur][c] + 1;
        } else {
            cur = _next[cur][c] + 1;
            if (cur >= s.size()) {
                cur = 0;
                num++;
            }
        }
        //cout << ch << " " << cur << " "<< num << "\n";
        cnt++;
    }
    cout << 1ll * num * s.size() + cur;
    return 0;
}


Measured memory_bytes: 10752
def func(n):
    if n % 2 == 0:
        return n/2
    else:
        return 3*n + 1
    
s = int(input())
a = [0, s]

for i in range(1, 1000001):
    new = func(a[i])
    if new in a:
        break
    
    a.append(new)
    
print(i+1)

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define f(a,b) for(ll i = a; i < b; i++)
#define fr(a,b) for(ll j = a; j >= b; j--)
#define fi(a,b) for(ll j = a; j < b; j++)
#define fii(a,b) for(ll k = a; k < b; k++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll,ll>
#define vll vector<ll>
#define pll vector< pair<ll,ll> >
#define ld long double


void sieve(int n)
{

    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
              for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
ll modpow(ll a,ll b){
    ll rs=1;
    a%=mod;
    while(b>0){
        if(b&1)rs=(rs*a)%mod;

        b=b>>1;
        a=(a*a)%mod;
    }
    return rs;
}


int main()
{

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

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

while(t--){
   int n,l,smn=0,val=10000000;
   cin>>n>>l;
   int a[n];
   f(0,n){ a[i]=l+i; smn+=a[i]; }
   int ans=10000000,ans1;
   f(0,n){
     int smnm=smn-a[i];
     int ps=abs(smn-smnm);
     if(ps<ans){
        ans=ps;
        ans1=smnm;
     }

   }

  cout<<ans1;

}

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef unsigned long long ull;
typedef set<int>::iterator sit;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second < b.second;}};
int lb(int x){return  x & -x;}
//friend bool operator < (Node a,Node b)   重载
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int maxn = 5e5+10;

int a[maxn];
struct Node
{
	int l,r,id;
}node[maxn];
bool cmp(Node a, Node b)
{
	return a.r < b.r;
}
int vis[maxn];
int tree[maxn];
int n;
void add(int x, int num)
{
	while(x <= n)
	{
		tree[x] += num;
		x += lb(x);
	}
}
int query(int x)
{
	int ans =0 ;
	while(x)
	{
		ans += tree[x];
		x -= lb(x);
	}
	return ans;
}
int ans[maxn];
int main()
{
	int m;
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= n; i ++ )
		scanf("%d",&a[i]);
	for (int  i= 1; i<= m; i ++ )
	{
		scanf("%d%d",&node[i].l,&node[i].r);
		node[i].id = i;
	}
	sort(node + 1,node + 1 + m, cmp);
	int kk = 1;
	for (int i = 1; i <= m; i ++ )
	{
		while(kk <= node[i].r)
		{
			if(vis[a[kk]])
			{
				add(vis[a[kk]], -1);
			}
			add(kk,1);
			vis[a[kk]] = kk;
			kk ++ ;
		}
		int s = query(node[i].r) - query(node[i].l - 1);
		ans[node[i].id] = s;
	}
	for (int  i= 1; i <= m; i ++ )
	{
		printf("%d\n",ans[i]);
	}
}


Measured memory_bytes: 17364
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll a[224514];
ll cnt[224514];
ll memo[224514];
signed main() {
	ll n;
	cin >> n;
	ll ans = 0, inf = -1e9 + 7;
	rep(i, n)cin >> a[i];
	rep(i, n)cnt[a[i] - 1] = i;
	rep(i, n - 1) {
		if (cnt[i] < cnt[i + 1])memo[i] = 1;
		else memo[i] = 0;
	}
	memo[n - 1] = 0;
	rep(i, n) {
		if (memo[i])ans++;
		else {
			inf = max(inf, ans);
			ans = 0;
		}
	}
	cout << n - inf - 1 << endl;
	ggr
}

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




int main(){
	
	string s;
	cin>>s;
	int i;
	for(i=1;i<s.size();i+=2){
		if(s[i-1]!='h' || s[i]!='i'){
			cout<<"No";
			return 0;
		}
	}
	if(s.size()&1)cout<<"No";
	else
	cout<<"Yes";
	return 0;
	
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int A, B;
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else
		cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;

    int dp[N + 1];
    dp[0] = 0;

    FOR(i, 1, N + 1) {
        dp[i]     = INF32;
        int power = 1;
        while (power <= i) {
            dp[i] = min(dp[i], dp[i - power] + 1);
            power *= 6;
        }

        power = 1;
        while (power <= i) {
            dp[i] = min(dp[i], dp[i - power] + 1);
            power *= 9;
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int N, K;
	ll C = 0;
	cin >> N >> K;
	if (K % 2 == 0) {
		printf("%lld\n", (ll)pow(N / (K / 2) - N / K, 3) + (ll)pow(N / K, 3));
	}
	else {
		printf("%lld\n", (ll)pow(N / K, 3));
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<sys/time.h>

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

using namespace std;

typedef long long ll;

ll gettime(){
	struct timeval tv;
	gettimeofday(&tv,NULL);
	return 1000000LL*tv.tv_sec+tv.tv_usec;
}

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int h,w,B[9][9];

int x2,y2,x3,y3; // 2, 3 それぞれの出発点

int bfs(int x,int y,int tar){
	int d[9][9];
	memset(d,-1,sizeof d);
	d[y][x]=0;
	int Q[81],head=0,tail=0; Q[tail++]=y*w+x;
	while(head<tail){
		int i=Q[head]/w,j=Q[head]%w; head++;
		rep(k,4){
			int yy=i+dy[k],xx=j+dx[k];
			if(0<=yy && yy<h && 0<=xx && xx<w && d[yy][xx]==-1){
				if(B[yy][xx]==tar) return d[i][j]+1;
				if(B[yy][xx]== 0 ) Q[tail++]=yy*w+xx, d[yy][xx]=d[i][j]+1;
			}
		}
	}
	return 777;
}

ll t0;

int ans;
void dfs(int x,int y,int now){
	int hstar=bfs(x,y,2)+bfs(x3,y3,3);
	if(ans<now+1+hstar) return;

	if(ans==777){ // 1 秒の間に一つも解が見つからなければ解なし
		ll t1=gettime();
		if(t1-t0>1000000){ ans=0; return; }
	}

	// これまでのパスと接したら最適解でないので探索打ち切り
	int cnt=0;
	rep(k,4){
		int xx=x+dx[k],yy=y+dy[k];
		if(0<=xx && xx<w && 0<=yy && yy<h && B[yy][xx]==7) cnt++;
	}
	if(cnt>=2) return;

	rep(k,4){
		int xx=x+dx[k],yy=y+dy[k];
		if(0<=xx && xx<w && 0<=yy && yy<h){
			if(B[yy][xx]==2){
				ans=now+1+bfs(x3,y3,3);
				return;
			}
			else if(B[yy][xx]==0){
				B[yy][xx]=7;
				dfs(xx,yy,now+1);
				B[yy][xx]=0;
			}
		}
	}
}

int main(){
	while(scanf("%d%d",&h,&w),h){
		rep(i,h) rep(j,w) scanf("%d",B[i]+j);

		rep(i,h) rep(j,w) {
			if(B[i][j]==2) x2=j, y2=i;
			if(B[i][j]==3) x3=j, y3=i;
		}
		B[y2][x2]=7; // 訪問済みのマーク

		t0=gettime();
		ans=777;
		dfs(x2,y2,0);
		printf("%d\n",ans<777?ans:0);
	}

	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<vector>
#include<map>
#include<string>
#include<math.h>
#include<set>
#include<string.h>
#include<unordered_set>
#include<unordered_map>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#define int long long
using namespace std;

int t[300][300];
int mincost[300][300];
signed main() {
	int ans = 0;
	int n; cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int a; cin >> a;
			t[i][j] = a;
			mincost[i][j] = a;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				mincost[j][k] = min(mincost[j][i] + mincost[i][k],mincost[j][k]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (t[i][j] > mincost[i][j]) {
				puts("-1");
				return 0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			bool S = true;
			for (int k = 0; k < n; k++) {
				if (i != k&&j != k) {
					if (mincost[i][k] + mincost[j][k] <= mincost[i][j]) {
						S = false;
					}
				}
			}
			if (S)ans += mincost[i][j];
		}
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 1664
x, y, z, k = map(int, input().split())
aaa = sorted(map(int, input().split()), reverse=True)
bbb = sorted(map(int, input().split()), reverse=True)
ccc = sorted(map(int, input().split()), reverse=True)
ma, mb, mc = aaa[0], bbb[0], ccc[0]
cakes = [(ma - a, 0) for a in aaa[1:]]
cakes += [(mb - b, 1) for b in bbb[1:]]
cakes += [(mc - c, 2) for c in ccc[1:]]
cakes.sort()

buf = [[ma], [mb], [mc]]
ans = [ma + mb + mc]

for d, i in cakes:
    if i == 0:
        a = aaa[len(buf[i])]
        if len(ans) == k and ans[-1] >= a + mb + mc:
            break
        buf[i].append(a)
        ans.extend(a + b + c for b in buf[1] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    elif i == 1:
        b = bbb[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + b + mc:
            break
        buf[i].append(b)
        ans.extend(a + b + c for a in buf[0] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    else:
        c = ccc[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + mb + c:
            break
        buf[i].append(c)
        ans.extend(a + b + c for a in buf[0] for b in buf[1])
        ans.sort(reverse=True)
        ans = ans[:k]

print('\n'.join(map(str, ans)))


Measured memory_bytes: 3956
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregio

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  int sum = 0;
  rep(i, n)
  {
    ll a;
    cin >> a;
    while (a % 2 == 0)
    {
      sum++;
      a /= 2;
    }
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  uint16_t A, B;
  A = (S[0] - '0') * 10 + S[1] - '0';
  B = (S[2] - '0') * 10 + S[3] - '0';

  if (A >= 1 && A <= 12) {
    if (B >= 1 && B <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if (B >= 1 && B <= 12) {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{

string s;getline(cin,s);string cpy=s;
long long k=stoll(s);
string p=to_string(k);
int i=p.length()+1;

string l= cpy.substr(i+2, cpy.length()-1);long long m=stoll(l);

if(s[i]=='+')
{
	cout<<k+m;
}
else
{cout<<k-m;
	
}
//cout<<k;
return 0;
}


Measured memory_bytes: 256
import fractions
a,b,c,d=map(int,input().split())
z=c*d//fractions.gcd(c,d)

x1=(b//z)
x2=(b//c)
x3=(b//d)
x=x2+x3-x1
y1=(a-1)//z
y2=(a-1)//c
y3=(a-1)//d
y=y2+y3-y1

print(b-(a-1)-(x-y))


Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define drep(i,x,y) for(int i=(x);i>=(y);--i)
inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
struct Edge{
	int u,v,Next;
} G[400010];
int head[200010],tot;
int h[200010];
int t,rt;
inline void add(int u,int v){
	G[++tot]=(Edge){u,v,head[u]};
	head[u]=tot;
}
inline void dfs(int x,int fa) {
	h[x]=h[fa]+1;
	if(h[x]>h[t]){
		t=x;
	}
	for(int i=head[x];i!=-1;i=G[i].Next){
		if(G[i].v==fa)continue;
		dfs(G[i].v,x);
	}
}
int main(){
	int n=read();
	memset(head,-1,sizeof(head));
	rep(i,1,n-1){
		int u=read(),v=read();
		add(u,v);add(v,u);
	}
	dfs(1,0);
	rt=t;
	t=0;memset(h,0,sizeof(h));
	dfs(rt,0);
	if(h[t] % 3 == 2) {
		puts("Second");
	}
	else puts("First");
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const ll mod= 1e9+7;
const int inf=1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int calc(int x){
  int ret=0;
  rep(i,10){
    ret+=x%10;
    x/=10;
    }
  return ret;
  }


int main(){
  int n;
  cin>>n;
  int mi=inf;
  rep(i,n-1){
    mi=min(mi,calc(i+1)+calc(n-i-1));
    }
  cout<<mi<<endl;
  return 0;
  }

Measured memory_bytes: 256
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const ll INF = 1e18L + 5;
const ll siz = 1e6 + 5;
#define deb(x) cout << #x << " = " << x << endl;

void solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int count = 1;
	char x = s[0];
	
	for(int i = 1; i<n; i++){
		if(s[i] == x)
			continue;
		else{
			count++;
			x = s[i];
		}
	}
	cout << count << endl;
}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
		//cin >> t;
		while(t--)
		{
			solve();
		}
	return 0;
}
	


Measured memory_bytes: 512
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }

long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


int main() {
	//
	int ans = 0;
	int A = in(); 

	ans = A / 2 * (A - A / 2);
	
		
	print(ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  string str, keyword;
  cin >> str >> keyword;
  str += str;
  //cout << str.find(keyword) << endl;
  if (str.find(keyword) != -1) //見つからなかったら-1を返す
    cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	char a2,b2,c2;
	a2=a[0]+'A'-'a';
	b2=b[0]+'A'-'a';
	c2=c[0]+'A'-'a';
	cout<<a2<<b2<<c2<<endl;
}

Measured memory_bytes: 256
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n,i,j,k,a,b,c,sum=0;
    cin>>n;
    vector<ll>v(n);
    for(i=0;i<n;i++)cin>>v[i];
    set<ll>s;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                s.in(v[i]);
                s.in(v[j]);
                s.in(v[k]);
                if(s.size()==3)
                {
                    auto it=s.begin();
                    a=*it;
                    it++;
                    b=*it;
                    it++;
                    c=*it;
                    if(a+b>c)
                        sum++;
                }
                s.clear();
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3644
//                                 Alisher_2211
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
const long N = 100100;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
long dp[N][2];
void solve(){
    long a;
    cin >> a;
    long ans = 0, q = 1;
    while(a){
        ans += q;
        q *= 2;
        a /= 2;
    }
    cout << ans;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin, (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
using namespace std;


#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	int a,b,tmp;

	cin >> a >> b;
	int gcd;
	if(a<b){
		tmp = a;a = b;b=tmp;
	}
	while(a%b != 0){
		tmp = a%b;
		a = b;
		b = tmp;
	}
	println(b);

	return 0;
}



Measured memory_bytes: 3064
from bisect import bisect,bisect_left
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
tmp=0
for i in b:
    dd=bisect_left(a,i)*(n-bisect(c,i))
    tmp+=dd
print(tmp)

Measured memory_bytes: 105444
#include <iostream>
using namespace std;
 
int main() {
	int flag,i,n,l,j;
	cin>>n>>l;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	flag=0;
	for(i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=l){
			cout<<"Possible"<<endl;
			flag=1;
			break;
		}
	}
	if(flag==0){
		cout<<"Impossible"<<endl;
	}
	if(flag==1){
	for(j=1;j<i+1;j++){
		cout<<j<<endl;
	}
	for(j=n-1;j>i;j--){
		cout<<j<<endl;
	}
	}
}

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

import itertools
INF = 1e10

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = INF
for prod in itertools.product('NABC', repeat=N):
    if not ('A' in prod and 'B' in prod and 'C' in prod):
        continue

    D = {'A': [], 'B': [], 'C': [], 'N': []}
    for i in range(N):
        D[prod[i]].append(L[i])

    tmp = max(len(D['A']) - 1, 0) * 10 + abs(sum(D['A']) - A)
    tmp += max(len(D['B']) - 1, 0) * 10 + abs(sum(D['B']) - B)
    tmp += max(len(D['C']) - 1, 0) * 10 + abs(sum(D['C']) - C)
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 3064