akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  cout<<"ABC"<<n<<endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <tuple>
using namespace std;
using ll=long long;
ll gcd(ll a,ll b){return (b==0?a:gcd(b,a%b));}
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,n) for(int i=a;i<n;i++)

int main (){
    int a, b, c;
    cin >> a >> b;
    if (a < 10 && b < 10) cout << a*b << endl;
    else cout << "-1" << endl;
}

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

using namespace std;
typedef long long ll;
ll query,p,q,r;

int main()
{
    scanf("%d",&query);
    while (query--)
    {
        scanf("%lld%lld",&p,&q);
        r=sqrt(p*q);
        if (r*r==p*q) r--;
        if (p==q) printf("%lld\n",(p-1)*2);
        else if (r*(r+1)<=p*q-1) printf("%lld\n",r*2-1);
        else printf("%lld\n",r*2-2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n; cin >> n;
  	vector<int> vec;
  	int ans = 0;
  	for (int i = 0; i < n; i++){
    	int a; cin >> a;
      	vec.push_back(a);
    }
  	for (int i = 0; i < n; i++){
    	if (vec[i] % 2 == 0){
        	vec[i] /= 2;
        } else {
        	break;
        }
      	if (i == n - 1){
        	ans++;
          	i = 0;
        }
    }
  	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    int A[N][N];
    int B[N][N];
    rep(i,N){
        rep(j,N){
            if(i == j){
                A[i][j] = 0;
                B[i][j] = 0;
            }
            else{
                A[i][j] = INF;
                B[i][j] = INF;
            }
        }
    }
    rep(i,M){
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        A[a][b] = c;
        A[b][a] = c;
        B[a][b] = c;
        B[b][a] = c;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                chmin(A[i][j], A[i][k] + A[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i,N){
        rep(j,N){
            if(i == j) continue;
            if(A[i][j] == B[i][j] && A[i][j] != INF) ++ans;
        }
    }
    cout << M-ans/2 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#define MAX 100001
#define SENTINEL 2000000000
using namespace std;

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

Node T[MAX];

int n, D[MAX];

void print(int u)
{
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].parent == -1)
        cout << "root, ";
    else if (T[u].left == -1)
        cout << "leaf, ";
    else
        cout << "internal node, ";
    cout << "[";
    for (int i = 0, c = T[u].left; c != -1; i++, c = T[c].right)
    {
        if (i)
        {
            cout << ", ";
        }
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p)
{
    D[u] = p;
    if (T[u].right != -1)
        rec(T[u].right, p);
    if (T[u].left != -1)
        rec(T[u].left, p + 1);
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        T[i].parent = T[i].left = T[i].right = -1;
    int id, k, c, l, r;
    for (int i = 0; i < n; i++)
    {
        cin >> id >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> c;
            if (j == 0)
                T[id].left = c;
            else
                T[l].right = c;
            l = c;
            T[c].parent = id;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (T[i].parent == -1)
            r = i;
    }
    rec(r, 0);
    for (int i = 0; i < n; i++)
        print(i);
    return 0;
}



Measured memory_bytes: 7784
import sys
input = sys.stdin.readline

n = int(input())
seq = [(int(x),i) for i, x in enumerate(input().split())]
seq1 =(i-x for x,i in seq)
seq2 =(i+x for x,i in seq)

d1 = dict()
d2 = dict()
s1 = set()
s2 = set()
for val in seq1:
    try:
        d1[val] += 1
    except:
        d1[val] = 1
for val in seq2:
    try:
        d2[val] += 1
    except:
        d2[val] = 1

ans = 0
for key in d1:
    try:
        ans += d1[key] * d2[key]
    except:
        pass

print(ans)



Measured memory_bytes: 133380
read a b
case $a$b in
  16 ) ;&
  25 ) ;&
  36 ) ;&
  49 ) ;&
  64 ) ;&
  81 ) ;&
  121 ) ;&
  144 ) ;&
  169 ) ;&
  196 ) ;&
  225 ) ;&
  256 ) ;&
  289 ) ;&
  324 ) ;&
  361 ) ;&
  441 ) ;&
  484 ) ;&
  529 ) ;&
  576 ) ;&
  625 ) ;&
  676 ) ;&
  729 ) ;&
  784 ) ;&
  841 ) ;&
  961 ) ;&
  1024 ) ;&
  1089 ) ;&
  1156 ) ;&
  1225 ) ;&
  1296 ) ;&
  1369 ) ;&
  1444 ) ;&
  1521 ) ;&
  1681 ) ;&
  1764 ) ;&
  1849 ) ;&
  1936 ) ;&
  2025 ) ;&
  2116 ) ;&
  2916 ) ;&
  3025 ) ;&
  3136 ) ;&
  3249 ) ;&
  3364 ) ;&
  3481 ) ;&
  3721 ) ;&
  3844 ) ;&
  3969 ) ;&
  4096 ) ;&
  4225 ) ;&
  4356 ) ;&
  4489 ) ;&
  4624 ) ;&
  4761 ) ;&
  5041 ) ;&
  5184 ) ;&
  5329 ) ;&
  5476 ) ;&
  5625 ) ;&
  5776 ) ;&
  5929 ) ;&
  6084 ) ;&
  6241 ) ;&
  6561 ) ;&
  6724 ) ;&
  6889 ) ;&
  7056 ) ;&
  7225 ) ;&
  7396 ) ;&
  7569 ) ;&
  7744 ) ;&
  7921 ) ;&
  8100 ) ;&
  8281 ) ;&
  8464 ) ;&
  8649 ) ;&
  8836 ) ;&
  9025 ) ;&
  9216 ) ;&
  12100 ) ;&
  36100 ) ;&
  44100 ) ;&
  84100 ) ;&
  96100 )
    echo Yes;;
  * )
    echo No
esac

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

#define all(x) (x).begin(), (x).end()
using lli = long long int;

constexpr int K = 6;

struct Num {
  string prefix, suffix;
  char fill;
  int fill_lenght;

  Num() : Num("") { }
  Num(string p) : Num(p, ' ', 0) { }
  Num(string p, char f, int fl): fill(f), fill_lenght(fl) {
    if (f == ' ') prefix = p;
    else {
      for (int i = 0; i < p.size(); ++i) {
        if (p[i] >= fill) prefix += p[i];
        else suffix += p[i];
      }
    }
  }

  int size() const { return prefix.size() + fill_lenght + suffix.size(); }
  char at(int p) const {
    if (p < prefix.size()) return prefix[p];
    if (p >= prefix.size() + fill_lenght) return suffix[p - fill_lenght - prefix.size()];
    return fill;
  }

  bool operator<(const Num& rhs) const {
    if (size() < rhs.size()) return true;
    if (size() == rhs.size()) {
      for (int i = 0; i < min(K + 2, size()); ++i) {
        if (at(i) == rhs.at(i)) continue;
        return at(i) < rhs.at(i);
      }
      for (int i = max(K + 2, size() - K - 2); i < size(); ++i) {
        if (at(i) == rhs.at(i)) continue;
        return at(i) < rhs.at(i);
      }
    }
    return false;
  }

  void print() {
    cout << prefix;
    for (int i = 0; i < fill_lenght; ++i) cout << fill;
    cout << suffix;
  }
};

vector<int> a;
vector<int> costs = {0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6};

Num solve(int n, string pattern) {
  Num result;
  if (n < 0) return result;
  for (auto it = a.begin(); it < a.end(); ++it) {
    int cost = costs[*it];
    if (n % cost == 0) {
      result = max(result, Num(pattern, '0' + *it, n / cost));
    }
  }
  if (pattern.size() > K) return result;
  for (auto it = a.begin(); it < a.end(); ++it) {
    int cost = costs[*it];
    string tmp = pattern;
    result = max(result, solve(n - cost, tmp + to_string(*it)));
  }
  return result;
}

int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  map<int, int> tmp;
  for (int i = 0; i < m; ++i) {
    int t;
    cin >> t;
    tmp[costs[t]] = max(tmp[costs[t]], t);
  }
  for (auto p : tmp) a.push_back(p.second);
  sort(all(a));
  reverse(all(a));
  solve(n, "").print();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

//int compare_int(const void *a, const void *b){//qsort 整数比較<
//	return *(int*)a - *(int*)b;
//}
//int compare_int2(const void *a, const void *b){//qsort 整数比較>
//	return *(int*)b - *(int*)a;
//}
//

//long long int combination(int n, int r)
//{
//	if (r == 0 || r == n)
//		return (1);
//	else if (r == 1)
//		return (n);
//	return (combination(n - 1, r - 1) + combination(n - 1, r));
//}

int main(void){
	int n;
	int a,b,c;
	int ans[1000010]={0};
	long long int count=0;

	scanf("%d",&n);
	for(a=1;a<n;a++){
		for(b=1;a*b<n;b++){
			ans[a*b]++;
		}
	}
	for(c=1;c<n;c++){
		count+=ans[n-c];
	}
	printf("%lld",count);
	return 0;
}


Measured memory_bytes: 5644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    cin>>N;
    int L[N];
    rep(i,N)cin>>L[i];
    sort(L,L+N);
    int MAX=L[N-1];
    L[N-1]=0;
    int sum=accumulate(L,L+N,0);
    if(MAX<sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
 
using namespace std;
 
int main(){
    int n;
    int a, b, c;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a >> b >> c;
        int ary[3] = {0};
        ary[0] = a * a;
        ary[1] = b * b;
        ary[2] = c * c;
        sort(ary, ary + 3);
        ary[2] - (ary[0] + ary[1]) || cout << "YES" << endl;
        ary[2] - (ary[0] + ary[1]) && cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N);
    for (int i = 0; i < N; i++)
    {
        vector<int> tmp(D);
        for (int j = 0; j < D; j++)
        {
            cin >> tmp[j];
        }
        X[i] = tmp;
    }
    int ans = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int dist = 0;
            for (int k = 0; k < D; k++)
            {
                dist += pow((X[i][k] - X[j][k]), 2);
            }
            if (sqrt(dist) == (int)sqrt(dist))
            {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
#define ll long long
const int N=1e5+7;
const ll inf=1e17;
ll a,b,q;
ll s[N],t[N],x;
int bin(ll *p,int m)
{
    int l=1,r=m,ans;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(p[mid]<=x)
            l=mid+1;
        else
            r=mid-1;
    }
        return l;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b>>q;
    int j,k;
    for(rg int i=1;i<=a;i++)
        cin>>s[i];
    for(rg int i=1;i<=b;i++)
        cin>>t[i];
        s[0]=-1*inf,s[a+1]=inf;
        t[0]=-1*inf,t[b+1]=inf;
    for(rg int i=1;i<=q;i++)
    {
        ll ans=0;
        cin>>x;
        j=bin(s,a);
        k=bin(t,b);
        ans=min(max(s[j],t[k])-x,x-min(s[j-1],t[k-1]));
        ans=min(ans,min(2*t[k]-s[j-1]-x,t[k]-2*s[j-1]+x));
        ans=min(ans,min(2*s[j]-t[k-1]-x,s[j]-2*t[k-1]+x));
            cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>2
using namespace std;
#define Max 1000000
int prime[Max],status[Max];
void sieve()
{
    int i,j,sqr;
    for(i=2;i<=Max;i++)
        status[i]=1;
    for(i=4;i<=Max;i+=2)
        status[i]=0;
    sqr=(int)sqrt(Max);
    for(i=3;i<=sqr;i+=2){
        if(status[i]==1){
            for(j=i*i;j<=Max;j+=2*i)
               status[j]=0;
        }
    }
    for(i=2,j=0;i<=Max;i++){
        if(status[i]==1)
            prime[j++]=i;
    }
}
int main()
{
    sieve();
    long long int n,i,j,sq;
    while(scanf("%lld",&n)==1)
    {
        cout<<n<<":";
        sq=(int)sqrt(n)+2;
        for(i=0;prime[i]<=sq;i++){
           if(n%prime[i]==0)
          {
            while(n%prime[i]==0){
                n/=prime[i];
                cout<<" "<<prime[i];
            }
        }
    }
    if(n>1)
        cout<<" "<<n;
    cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 7352
def main():
    n = int(input())
    s = input()
    l = [int(i) for i in s.split(' ')]

    d = {}

    for i in l:
        if i not in d:
            d[i] = 0
        d[i] += 1

    l = list(d.keys())

    l.sort()
    ans = 0
    for i in range(len(l)):
        for j in range(i + 1, len(l)):
            a = l[i] + l[j]
            for k in range(j + 1, len(l)):
                if a > l[k]:
                    ans += (d[l[i]] * d[l[j]] * d[l[k]])
                else:
                    break

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
//
//AtCoder Beginner Contest 125
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    cout << t/a*b << endl;
    return 0;
}


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

using namespace std;

int main() {
    long int n,i;
    scanf("%ld",&n);
    long long int dp[n+1];long int arr[n+1];arr[0]=-1;
    dp[0]=dp[1]=0;
    for(i=1;i<=n;i++){
        scanf("%ld",&arr[i]);
    }
    dp[2]=abs(arr[2]-arr[1]);
    for(i=3;i<=n;i++){
        dp[i]=min(dp[i-2] + abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    printf("%lld",dp[n]);
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int D[100000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		D[i] = rei();
	}
	sort(D,D+N);
	int ans = D[N/2] - D[N/2-1];
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    ll a, b[n+1]={};
    forn(i,0,n-1){
        cin>>a;
        b[a]++;
    }
    // for(ll i=n-1;i>0;i--){
    //     b[i]+=b[i+1];
    // }
    forn(i,1,n+1){
        cout<<b[i]<<endl;
    }

}

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

map<ll, ll> prime_factorize(ll);
bool is_prime(ll);

int main() {
  ll N, P;
  cin >> N >> P;

  map<ll, ll> pf = prime_factorize(P);

  ll ans = 1;
  for (pair<ll, ll> p : pf)
  {
    if (N <= p.second)
      ans *= pow(p.first, p.second / N);
  }

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

map<ll, ll> prime_factorize(ll n)
{
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; ++i)
  {
    while (is_prime(i) && n % i == 0)
    {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) mp[n]++;
  return mp;
}

bool is_prime(ll n) {
  if (n <= 1) return false;
  if (n == 2) return true;
  for (int i = 2; i*i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}


Measured memory_bytes: 4060
#include <algorithm>
#include <iostream>
#include <map>
using  namespace  std;
int n;
map<string,int>COUNT;
int main()
{
    int n;
    cin>>n;
    COUNT["AC"]=0;
    COUNT["TLE"]=0;
    COUNT["WA"]=0;
    COUNT["RE"]=0;
    for(int i = 0 ;i<n;i++)
    {
        string s;
        cin>>s;
        COUNT[s]+=1;
     //   cout<<COUNT[s]<<endl;
    }
    cout<<"AC x "<<COUNT["AC"]<<endl;
    cout<<"WA x "<<COUNT["WA"]<<endl;
    cout<<"TLE x "<<COUNT["TLE"]<<endl;
    cout<<"RE x "<<COUNT["RE"]<<endl;
    return 0 ;
}

Measured memory_bytes: 3624
n = int(input())
s = list(input())
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r * g * b
for i in range(n-2):
    for j in range(i+1,n-1):
        if (j - i) + j < n:
            k = (j - i) + j
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1
print(ans)                

Measured memory_bytes: 9188
n = int(input())
a = list(map(int, input().split()))

ans = 1

for i in range(n):
  if a[i] == 0:
    print(0)
    exit()
for i in range(n):
  ans *= a[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
    
print(ans)

Measured memory_bytes: 84620
/**
 *  Curling 2.0 (PKU 3009)
 *  by Kenji Inoue, 2007-01-03
 **/

#include <iostream>

using namespace std;

int w, h;
int f[21][21];
int ans;

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

void rec(int n, int x, int y) {
  if (n >= ans) { return; }

  for (int i=0; i<4; i++) {
    int mx=x, my=y;
    mx += dx[i]; my += dy[i];
    if (mx < 0 || mx >= w) { continue; }
    if (my < 0 || my >= h) { continue; }
    if (f[my][mx] == 1) { continue; }

    while (1) {
      if (f[my][mx] == 3) {
        ans = n;
        return;
      }

      mx += dx[i]; my += dy[i];
      if (mx < 0 || mx >= w) { break; }
      if (my < 0 || my >= h) { break; }

      if (f[my][mx] == 1) {
        f[my][mx] = 0;
        rec(n+1, mx-dx[i], my-dy[i]);
        f[my][mx] = 1;
        break;
      }
    }
  }
}

int main() {
  while (cin >> w >> h, (w || h)) {
    int sx, sy;
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        cin >> f[y][x];
        if (f[y][x] == 2) {
          sx = x; sy = y;
        }
      }
    }

    ans = 11;
    rec(1, sx, sy);
    if (ans > 10) { ans = -1; }
    cout << ans << endl;
  }

  return 0;
}

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

int cmp(const void *a, const void *b){
    return *(const int *)a - *(const int *)b;
}

int main(){
    int N,A[100000];
    int cnt,i;
    cnt = 0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    A[N]=0;

    qsort(A,N,sizeof(int),cmp);

    cnt = 0;
    for(i=0;i<N;i++){
        if(A[i]==A[i+1]){
            i++;
        }else{
            cnt++;
        }
    }

    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const double PI=3.14159265358979323846;
#define sp(n) cout << fixed << setprecision(n)
int main(void){
    sp(10);
    double a,b,h,m;cin>>a>>b>>h>>m;
    double deg1=h*30+m/2,deg2=m*6;
    double x=abs(deg1-deg2);
    if(x>180)x=360-x;
    double buf=a*a+b*b-2*a*b*cos(x/180*PI);
    buf=sqrt(buf);
    cout<<buf<<endl;
}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
 
typedef long long ll;
typedef long double ld;
 
#define X first
#define Y second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define deb(x) cerr << #x << " " << x << '\n';
#define fo(i, n) for(int i = 0; i < n; i++)
#define Fo(i, k, n) for(int i = k; k < n ? i < n : i > n; k < n ? i++ : i--)

#define int ll
 
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
using namespace std;

// vector<vector<int> > g(maxn);
// vector<int> used(maxn);
 
void pudge(){ 
    int n, x;
    cin >> x >> n;
    set<int> a;
    for (int i = -1; i <= 101; i++){
        a.insert(i);
    }
    for (int i = 0; i < n; i++){
        int t;
        cin >> t;
        a.erase(t);
    }
    int ans = -100;
    for (int i : a){
        if ( abs(ans - x) > abs(i - x) ) ans = i;
    }
    cout << ans << '\n';
}
 
// #define PUDGE
// #define TIME

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

#ifdef PUDGE
    freopen("input.txt", "r", stdin);
    // freopen("pudge.out", "w", stdout);
#endif

#ifdef TIME
    auto start = chrono::steady_clock::now();
#endif
    
    // int q; cin >> q; while(q--)
    pudge();

#ifdef TIME
    auto end = chrono::steady_clock::now();
    auto diff = end - start;
    cout << chrono::duration <double, milli> (diff).count() << " ms\n";
#endif

    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdouble;


int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n);

  for(int i =0; i<n; i++){
    cin >> p.at(i);
  }

  ll max=0;
  ll pmax;
  ll rec = 0;
  for(int i =0; i<n-k+1; i++){
    if(i == 0){
      pmax = 0;
      for(int j = 0; j<k; j++){
      pmax += p.at(j);
      }
    }else{
      pmax = pmax - p.at(i-1) + p.at(i+k-1);
    }
    if (pmax >= max){
      max = pmax;
      rec = i;
    }
  }
  double frate =(max+k)/2.0;
  cout << fixed << setprecision(10);
  cout  << frate <<endl;
  return 0;
}

Measured memory_bytes: 1792
from fractions import gcd

def lcm(n,m):
    return (n*m)//gcd(n,m)

def main():
    a,b,c,d=map(int,input().split())
    num=b-a+1
    moda1=(a-1)//c
    moda2=(a-1)//d
    moda3=(a-1)//(lcm(c,d))
    modat=moda1+moda2-moda3
    modb1=b//c
    modb2=b//d
    modb3=b//(lcm(c,d))
    modbt=modb1+modb2-modb3
    mod=modbt-modat
    return num-mod

print(main())

Measured memory_bytes: 5240
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n,m;
vi tr[N*5 + 5];
int tim = 0;
void update(int node,int a,int b,int i,int val)
{
	if(a>b || a>i || b<i)return;
	tr[node].pb(val);
	if(a==b)return;
	int mid = (a + b) >> 1;
	update(node*2,a,mid,i,val);
	update(node*2 +1,mid+1,b,i,val);
}

inline int bs(vi &v,int x)
{
	if(!v.size())return 0;
	int low = 1;
	int high = (int)v.size();
	while(low < high)
	{
		if(low+1 == high)
		{
			if(v[low-1] < x)low=high;
			break;
		}
		int mid = (low + high) >> 1;
		if(v[mid-1] < x)low = mid+1;
		else high = mid;
	}
	if(v[low-1] >= x)return (int)v.size() - low + 1;
	return 0;
}
int query(int node,int a,int b,int i,int j,int x)
{
	if(a>b || a>j || b<i || i>j)return 0;

	if(a>=i && b<=j)
	{
		return bs(tr[node],x);
	}
	int mid = (a + b)>>1;
	int r1 = query(node*2,a,mid,i,j,x);
	r1+= query(node*2 +1,mid+1,b,i,j,x);
	return r1;
}
int main()
{
  finp;
  cin>>n>>m;
  afor(i,1,n)
  {
  	int l,r;
  	cin>>l>>r;
  	update(1,1,m,l,r);
  }
  afor(i,1,4*m + 100)sort(tr[i].begin(),tr[i].end());

  afor(i,1,m)
  {
  	int curr = 0;
  	for(int j=i;j<=m;j+=i)
  	{
  		curr+= query(1,1,m,(j-i+1),j,j);
  	}
  	cout<<curr<<"\n";
  }
  
return 0;
}

Measured memory_bytes: 40224
import java.util.Scanner;

public class Main {
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        char[] right = {'y', 'h', 'n', 'u', 'j', 'm', 'i', 'k', 'o', 'l', 'p'};
        char[] left = {'t', 'g', 'b', 'r', 'f', 'v', 'e', 'd', 'c', 'w', 's', 'x', 'q', 'a', 'z'};
        String s = scan.next();
        while (!s.equals("#")) {
            int count = 0;
            boolean side = false;
            for (int i = 0; i < right.length; i++) {
                if (s.charAt(0) == right[i]) {
                    side = true;
                }
            }

            for (int i = 1; i < s.length(); i++) {
                char c = s.charAt(i);
                if (side == false) {
                    for (int j = 0; j < right.length; j++) {
                        if (c == right[j]) {
                            side = true;
                            count += 1;
                        }
                    }
                } else {
                    for (int j = 0; j < left.length; j++) {
                        if (c == left[j]) {
                            side = false;
                            count += 1;
                        }
                    }
                }
            }
            System.out.println(count);
            s = scan.next();
        }
     }
}

Measured memory_bytes: 20748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int H,A;
    cin >> H >> A; 

    int ans =0;
    if (H%A == 0) ans = H/A;
    else ans = H/A+1;

    // output
    cout << ans << endl;

    return 0;
}

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

int main() {
    int A,B;
    cin >> A >> B;

    int C = A + B;
    if (C == 3){
        cout << "3" << endl;
    } else if (C == 4){
        cout << "2" << endl;
    } else if (C == 5){
        cout << "1" << endl;
    }
    
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>

using namespace std;

char S[100010];

bool check_eraser(int i) {
  if (S[i] != 'e' || S[i+1] != 'r' || S[i+2] != 'a' || S[i+3] != 's' || S[i+4] != 'e' || S[i+5] != 'r') {
    return false;
  }
  return true;
}
bool check_erase(int i) {
  if (S[i] != 'e' || S[i+1] != 'r' || S[i+2] != 'a' || S[i+3] != 's' || S[i+4] != 'e') {
    return false;
  }
  return true;
}
bool check_dreamer(int i) {
  if (S[i] != 'd' || S[i+1] != 'r' || S[i+2] != 'e' || S[i+3] != 'a' || S[i+4] != 'm' || S[i+5] != 'e' || S[i+6] != 'r') {
    return false;
  }
  if (S[i+7] == 'a') {
    return false;
  }
  return true;
}
bool check_dream(int i) {
  if (S[i] != 'd' || S[i+1] != 'r' || S[i+2] != 'e' || S[i+3] != 'a' || S[i+4] != 'm') {
    return false;
  }
  return true;
}

int main() {
  scanf("%s", S);
  int N = strlen(S);
  int i = 0;
  bool ans = true;
  while(i < N && i != N-1) {
    if (check_eraser(i)) {
      i += 6;
    } else if (check_erase(i)) {
      i += 5;
    } else if (check_dreamer(i)) {
      i += 7;
    } else if (check_dream(i)) {
      i += 5;
    } else {
      ans = false;
      break;
    }
  }
  if (ans) {
    printf("YES");
  } else {
    printf("NO");
  }
  return 0;
}


Measured memory_bytes: 256
# AtCoder Regular Contest 065
# D - 連結 / Connectivity
# https://atcoder.jp/contests/arc065/tasks/arc065_b
import sys
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        # self.parent = [i for i in range(n)]
        self.parent = list(range(n))
    def find(self, x):
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, *KL = map(int, input().split())
    uf = [UnionFind(N) for _ in range(2)]
    for i in range(2):
        for j in range(KL[i]):
            p, q = map(int, input().split())
            uf[i].union(p-1, q-1)

    d = defaultdict(int)
    for i in range(N):
        d[(uf[0].find(i), uf[1].find(i))] += 1

    print(*[d[(uf[0].find(i), uf[1].find(i))] for i in range(N)])
    # for i in range(N):
    #     print(d[(uf[0].find(i), uf[1].find(i))], end = " ")
    # print("")
    
    #print(" ".join([str(d[(uf[0].find(i), uf[1].find(i))]) for i in range(N)]))

if __name__ == "__main__":
    sys.setrecursionlimit(10**6)
    main()


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

int main(void) {
	int N; cin >> N;
	long long res = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			res += i;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

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

  ll ans = 0;
  // 1 の倍数の和 g(n) = n(n + 1)/2
  // i の倍数の和 i * g(n / i)
  // g(n / i) が同じ値のとこはまとめて足せる
  auto g = [&](ll x) { return x * (x + 1) / 2; };
  for (ll i = 1; i * i <= n; ++i) {
    auto calc = [&](ll x) {
      ll s = n / x;
      ll s2 = n / (x + 1);
      // ((s2 + 1) + ... + s) * g(x)
      // cerr << x << " " << s2 + 1 << " " << s << endl;
      ans += (g(s) - g(s2)) * g(x);
    };
    calc(i);
    if (i != n / i) calc(n / i);
  }
  cout << ans << endl;
}


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

int main() {
  std::string S;
  std::cin >> S;
  char c = '0';
  int Output = 0;
  int size = S.size();
  for (int i = 0; i < size; ++i) {
    if (c == '0') {
      c = '1';
    } else {
      c = '0';
    }
    if (S[i] == c) {
      ++Output;
    }
  }
  if (size - Output < Output) {
    Output = size - Output;
  }
  std::cout << Output << "\n";
  return 0;
}

Measured memory_bytes: 512
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

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


int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < int(s.size()); i++)
  {
    for (int j = i+1; j < int(s.size()); j++)
    {
      if (s[i] == s[j])
      {
        cout << "no" << endl;
        return 0;
      }
    }
  }

  cout << "yes" << endl;
}


Measured memory_bytes: 256
def eratosutenes(n):
    primes = [1] * (n+1)  # 0からnまでの素数リスト, 最初は全てが素数だと仮定する
    primes[0] = 0
    primes[1] = 0

    for i in range(2, int(n**(1/2))+1):
        if primes[i] == 0:
            continue
        if primes[i] == 1:
            for j in range(i * 2, n+1, i):
                primes[j] = 0
    return primes


# 素数に1がたち、素数でないものに0がたつリストができた
primes = eratosutenes(100001)

Q = int(input())
query = []

for _ in range(Q):
    l, r = map(int, input().split())
    query.append((l, r))

like_numbers_ruisekiwa = [0]  # 0のときは0

for i in range(1, len(primes)):
    if i % 2 == 1:  # 奇数のときだけ処理をする
        if primes[i] == 1 and primes[(i+1)//2] == 1:  # 両方素数ならインクリメントする
            like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1] + 1)
        else:
            like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1])
    if i % 2 == 0:
        like_numbers_ruisekiwa.append(like_numbers_ruisekiwa[-1])


for i in range(len(query)):
    l, r = query[i]
    print(like_numbers_ruisekiwa[r] - like_numbers_ruisekiwa[l-1])


Measured memory_bytes: 18904
#include <iostream>

using namespace std;

long long a, b, l1, r1, l2, r2, ans = 0;
int i, j;

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

    if(a==b)
    {
        cout << 1 << '\n';
        return 0;
    }

    for(i=60; i>=0; --i)
        if((a&(1LL<<i)) != (b&(1LL<<i)) ) break;
            else if(a&(1LL<<i)) a -= (1LL<<i), b -= (1LL<<i);

    for(j=i-1; j>=0; --j)
        if(b&(1LL<<j)) break;

    l1 = 1LL<<i;
    r1 = (1LL<<i) + (j>=0 ? (1LL<<(j+1)) - 1 : 0);
    l2 = (1LL<<i) + a;
    r2 = (1LL<<(i+1)) - 1;

    ans = (1LL<<i) - a;
    if(r1<l2) ans += r1-l1+1 + r2-l2+1;
        else ans += r2-l1+1;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;

    static int N;
    static int K;
    static int[] x;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        K = cin.nextInt();
        x = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        int ans = int.MaxValue;
        for (int i = 0; i <= N - K; i++)
        {
            if(x[i] > 0)
                ans = Min(ans, x[i + K - 1]);
            else if(x[i + K - 1] < 0)
                ans = Min(ans, -x[i]);
            else
            {
                if (-x[i] < x[i + K - 1])
                {
                    ans = Min(x[i + K - 1] - 2 * x[i], ans);
                }
                else
                {
                    ans = Min(2 * x[i + K - 1] - x[i], ans);
                }
            }
        }
        WriteLine(ans);
    }

    
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 24160
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right

k,x=n1()
print("Yes" if k*500>=x else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    ll ans = 0;
    for (ll i = 1; i * i < n; ++i) {
        if (n % i == 0 && n / i - 1 > i) ans += n / i - 1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
const int N = 1e5 + 5 ;
vii g[N] ;
int n,m, dp[2][N], ans[N] ;

// 0 - white , 1 - black 

void dfs(int node, int par =-1 ) {
	dp[0][node] = dp[1][node] = 1 ; 

	for(auto i : g[node]) {
		if( i!= par) {
			dfs(i,node) ;
			dp[0][node] = (dp[0][node] * dp[0][i]) % m ;
			dp[1][node] = (dp[1][node] * (dp[0][i] + dp[1][i])) % m ;
		}
	}
}

void calc(int node, int par =-1 ) {
	int a = dp[0][node] ; 
	int b = dp[1][node] ; 
	dp[0][node] = dp[1][node] = 1 ; 

	vii pf[2], sf[2] ; 

	for(auto i : g[node]) {
		pf[0].eb(dp[0][i]) ;
		pf[1].eb((dp[0][i] + dp[1][i])%m) ; 
		sf[0].eb(dp[0][i]) ;
		sf[1].eb((dp[0][i] + dp[1][i])%m) ;
	}

	int s = sz(g[node]) ;

	for(int i = 1 ; i < s ; ++i ) {
		pf[0][i] = (pf[0][i-1] * pf[0][i]) % m ; 
		pf[1][i] = (pf[1][i-1] * pf[1][i]) % m ;
	}

	for(int i = s-2 ; i >=0 ; --i) {
		sf[0][i] = (sf[0][i] * sf[0][i+1]) % m ;
		sf[1][i] = (sf[1][i] * sf[1][i+1]) % m ; 
	}

	ans[node] = sf[1][0] ; 

	int c = 0 ;

	for(auto i : g[node]) {
		if(i != par) {
			dp[0][node] = (c>0 ? pf[0][c-1] : 1) * (c < s-1 ? sf[0][c+1] : 1) % m;
			dp[1][node] = (c>0 ? pf[1][c-1] : 1) * (c < s-1 ? sf[1][c+1] : 1) % m;
			calc(i,node) ; 
		}
		++c ; 
	}

	dp[0][node] = a ;
	dp[1][node] = b ; 
} 

void solve() {
	cin >> n >> m ;
	rep(i,0,n-1) {
		int u,v; cin >> u >> v ;
		g[u].eb(v) ;
		g[v].eb(u) ;
	}

	dfs(1) ; 

	if(n ==1 ) {
		cout << 1 ; return ;
	}

	calc(1) ; 

	rep(i,1,n+1) cout << ans[i] << nl ;
}

int32_t main() {
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif   
    fast;
	// int t; cin >> t; while(t--) 
		solve() ;
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 39088
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = Integer.parseInt(sc.next());
    int t = Integer.parseInt(sc.next());
    int s = Integer.parseInt(sc.next());
    
    if(t*s >= d){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
   
    sc.close();
    return;
  }
  
}


Measured memory_bytes: 35632
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        k = (n - i - j)
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, a;

int main() {
    scanf("%lld %lld", &n, &a);

    if (n == 1) {
        puts("1");
        return 0;
    }

    ll ans = n;
    for (int k = 0; k < 44; k++) {
        for (int s = 2; s <= 1000001; s++) {
            ll cki = 1, sec = 0;
            for (int i = 0; i < k && cki < n; i++) {
                cki *= s;
                sec += s+a;
            }
            while (cki < n && s != 2) {
                cki *= (s-1);
                sec += s-1+a;
            }
            if (cki >= n) {
                ans = min(ans, sec - a);
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d%d", &a, &b)
	if a+b == 15 {
		fmt.Printf("+\n")
		return
	}
	if a*b == 15 {
		fmt.Printf("*\n")
		return
	}
	fmt.Printf("x\n")
	return
}


Measured memory_bytes: 512