akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int long long

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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 pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int dp[310][310];

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

  int N, K, H[310]; cin >> N >> K;
  REP(i, N) cin >> H[i+1];
  H[0] = 0;

  REP(i, N+1) REP(j, N+1) dp[i][j] = VERYBIG;
  dp[0][0] = 0;
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= i; j++){
      int mn = VERYBIG;
      for(int k = 0; k < i; k++){
        chmin(mn, dp[k][j-1] + max(0ll, H[i]-H[k]));
      }
      dp[i][j] = mn;
    }
  }
  int ans = VERYBIG;
  for(int i = 0; i <= N; i++) chmin(ans, dp[i][N-K]);
  cout << ans << endl;
}

Measured memory_bytes: 1024
MOD = 10**9+7
n, m = map(int, input().split())
broken = [False for _ in range(n+1)]
dp = [0 for _ in range(n+1)]
dp[0] = 1
for _ in range(m):
	broken[int(input())] = True
for i in range(1, n+1):
	if broken[i]:
		continue
	if i == 1:
		dp[i] = dp[i-1]
	else:
		dp[i] = dp[i-1] + dp[i-2]
		dp[i] %= MOD
print(dp[n])

Measured memory_bytes: 7836
#include<bits/stdc++.h>
using namespace std;
#define task "atcoderd"
#define lwb lower_bound
#define upb upper_bound
#define ar array
#define fi first
#define se second
#define ALL(v) (v).begin(), (v).end()
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> pii;

void solve()
{
    ll n,d,cnt=0;
    cin>>n>>d;
    for(ll i=1;i<=n;++i)
    {
        ll x,y;
        cin>>x>>y;
        if((ld)sqrt(x*x+y*y)<=d) ++cnt;
    }
    cout<<cnt;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solve();
}







Measured memory_bytes: 3724
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    int ans = 0;
    rep(i, log10(N) + 1) {
        int a = pow(10, i+1);
        int b = pow(10, i);
        ans += N % a / b;
    }
    cout << (ans == 1 ? 10 : ans) << endl;
}

Measured memory_bytes: 4032
#include<stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d",&a);
    b=a%60;
    c=a-b;
    c/=60;
    c%=60;
    d=(a-c)/3600;
    printf("%d:%d:%d\n",d,c,b);
    return 0;
}


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

int main() {
  int Y = 0;
  int N;
  string S;
  
  cin >> N;
  
  rep(i, N) {
    cin >> S;
    if(S == "Y") {
    	Y++;
    }
  }

  if(Y == 0) {
    cout << "Three" << endl;
  }
  else {
   	cout << "Four" << endl; 
  }
}


Measured memory_bytes: 3596
def main():
  n = int(input())
  ans = 0
  a_lis = list(map(int,input().split()))
  A_dict = [0]*(10**5+1)
  for i in a_lis:
    A_dict[i] += 1
  for j in range(1,10**5):
    tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
    if tmp > ans:
      ans = tmp
  print(ans)

if __name__=='__main__':
  main()

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

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

    if (N < 3) {
        cout << N << endl;
        return 0;
    }

    int index = 1;
    vector<int> num;
    num.push_back(2);

    for (int i = 0; i < N - 2; i++) {
        if (num.size() == index) {
            num.push_back(1);
            index = 0;
        } else {
            num[index]++;
            index++;
        }
    }

    for (int i = 0; i < num.size(); i++)
        cout << num[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;



ll nth(vector<ll>& v, ll t) {
	vector<ll> vv = v;
	for (ll i = 0; i < v.size(); ++i) {
		if (v[i] == t) {
			v[i] = 999;
		}
	}
	sort(vv.begin(), vv.end());
	for (ll i = 0; i < vv.size(); ++i) {
		if (vv[i] == t) {
			return i + 1;
		}
	}
	return -1;
}

int main() {
	ll N;
	cin >> N;
	vector<ll> P(N);
	vector<ll> Q(N);
	for (ll i = 0; i < N; ++i) {
		cin >> P[i];
	}
	for (ll i = 0; i < N; ++i) {
		cin >> Q[i];
	}
	ll m = 1;
	vector<ll> step(N - 1);
	for (ll i = 1; i <= N - 1; ++i) {
		m *= i;
		step[N - 1 - i] = m;
	}
	vector<ll> v(N);
	for (ll i = 0; i < N; ++i) {
		v[i] = i + 1;
	}
	vector<ll> vp = v;
	vector<ll> vq = v;
	ll pp = 1;
	ll qq = 1;
	for (ll i = 0; i < N - 1; ++i) {
		pp += (nth(vp, P[i]) - 1) * step[i];
		qq += (nth(vq, Q[i]) - 1) * step[i];
	}
	ll ans = pp < qq ? qq - pp : pp - qq;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
int s[2][1003];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&s[0][i]);
    }
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&s[1][i]);
    }
    for (int i=1;i<=n;i++)
    {
        s[0][i]+=s[0][i-1];
        s[1][i]+=max(s[0][i],s[1][i-1]);
    }
    printf("%d\n",s[1][n]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, a, b;
    cin >> n >> a >> b;
    vector<lint> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    auto nCk = [](lint n, lint k) {
        lint ret = 1;
        for (lint i = 1; i <= k; ++i) {
            ret *= n - i + 1;
            ret /= i;
        }
        return ret;
    };
    sort(v.begin(), v.end(), greater<lint>());
    double ret = 0;
    lint mini  = inf;
    for (int i = 0; i < a; ++i) {
        ret += v[i];
        chmin(mini, v[i]);
    }
    ret /= a;
    int cntused = 0;
    int cntall  = 0;
    for (int i = 0; i < n; ++i) {
        if (v[i] == mini) {
            cntall++;
            if (i < a)
                cntused++;
        }
    }
    cout << fixed << setprecision(10) << ret << "\n";
    if (v[0] == mini) {
        lint cnt = 0;
        for (int i = a; i <= b; ++i) {
            if (i <= cntall)
                cnt += nCk(cntall, i);
        }
        cout << cnt << "\n";
        return 0;
    } else {
        cout << nCk(cntall, cntused) << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
cards = [int(x) for x in input().split()]
cards = sorted(cards,reverse=True)
a = 0
b = 0
for i in range(n):
    if i%2 == 0:
        a += cards[i]
    else:
        b += cards[i]
if a>b:
    print(a-b)
else:
    print(b-a)


Measured memory_bytes: 3060
//I Guds namn
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int n, T; cin >> n >> T;
	int ans = 1001, c, t;
	for(int i = 0;i < n;i++)
	{
		cin >> c >> t;
		if(t <= T)
		{
			ans = min(ans, c);
		}
	}
	if(ans > 1000)
	{
		cout << "TLE" << endl;
		return 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	my$m=@lms;
	for(0..$m-1){
		$lms_map[$lms[$_]]=$_;
	}
	@sa=$induce->(@lms);
	if($m){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my($l,$r)=@sorted_lms[$_-1,$_];
			my$end_l=$lms[$lms_map[$l]+1]//$n;
			my$end_r=$lms[$lms_map[$r]+1]//$n;
			my$different;
			if($end_l-$l!=$end_r-$r){
				$different=1;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$different=$l==$n||$s[$l]!=$s[$r];
			}
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper+=$different;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 252032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const ll inf=0x3f3f3f3f;
const int maxn=2e5+7;
int main(){
    int n;
    cin>>n;
    printf("%0.12f\n",(double)n*n*n/27);
    return 0;
}


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

int main(){
    int n, m, q, i, j, l, r;
    cin >> n >> m >> q;
    int query[n+1][n+1] = {};
    for(i=0; i<m; i++){
        cin >> l >> r;
        query[l][r]++;
    }
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            query[i+1][j+1] += query[i+1][j] + query[i][j+1] - query[i][j];
        }
    }
    for(i=0; i<q; i++){
        cin >> l >> r;
        cout << query[r][r] - query[r][l-1] - query[l-1][r] + query[l-1][l-1] << '\n';
    }
    return 0;
}

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

int main() {

  int X,Y;

  cin >>X>>Y;
  
 if((Y-2*X)%2==0 && (Y-2*X)>=0 && (4*X-Y)%2==0 &&  (4*X-Y)>=0){
   
   cout<<"Yes"<<endl;
 }
  else{
    cout<<"No"<<endl;
  }
 return 0;
}

Measured memory_bytes: 3636
n,m=map(int,input().split())
l=m//n #gの下限値

def make_divisors(n):
    D=[]
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            D.append(i)
            if i!=n//i:
                D.append(n//i)
    return list(sorted(D))

D=make_divisors(m)
ans=1

for d in D:
    if d>l:
        continue
    if m//d>=n:
        ans=d

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  int cnt = 0;
  cin >> n;
  for(int i=1;i<n+1;i++){
    int p;
    cin >> p;
    if(i!=p) cnt++;
  }
  if(cnt!=2 && cnt!=0) cout<< "NO"<<endl;
  else cout<< "YES" <<endl;
}


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

typedef long long ll;
const int N=20,T=7e4;
int a[N][N];
ll f[T],g[T];

ll calc(int s,int x) {
	ll ret=0;
	for(;s;s&=s-1) ret+=a[x][__builtin_ctz(s)];
	return ret;
}

int main() {
	//freopen("1.in","r",stdin);
	//freopen("1.ans","w",stdout);
	
	int n; scanf("%d",&n);
	for(int i=0;i<n;++i) {
		for(int j=0;j<n;++j) scanf("%d",&a[i][j]);
	}
	int S=1<<n;
	for(int s=1;s<S;++s) g[s]=g[s&(s-1)]+calc(s&(s-1),__builtin_ctz(s));
	for(int s=1;s<S;++s) {
		for(int ss=s;ss;ss=s&(ss-1)) f[s]=max(f[s],f[s^ss]+g[ss]);
	}
	printf("%lld\n",f[S-1]);
	
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cinn(a) for(auto &_k:(a)) cin >> _k
#define coutt(a) for(auto &_k:(a)) cout << _k << ' '
inline int cint() { int temp; cin>>temp; return temp; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,n, b=0; cin >> n;
    a=n;
    n++;
    while(n--)
        b+= (n%2);
    cout << double(b)/a;

}

Measured memory_bytes: 256
import sys

def main():
    inp = [[i for i in map(int, line.rstrip().split())] for line in sys.stdin.readlines()]
    res = [1 for i in range(inp[0][0])
           if sum(
            [inp[1][j]*inp[i + 2][j] for j in range(inp[0][1])]) + inp[0][2] > 0]

    print(sum(res))

if __name__ == '__main__':
    sys.exit(main())



Measured memory_bytes: 3060
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int n;cin>>n;
    vector<string> s(n);
    int ac=0,wa=0,tle=0,re=0;
    rep(i,n){
        cin>>s[i];
        if(s[i]=="AC" ) ac++; 
        if(s[i]== "WA") wa++;
        if(s[i]== "TLE") tle++;
        if(s[i]== "RE") re++;
    }

        cout<<"AC "<<"x "<<ac<<endl;
        cout<<"WA "<<"x "<<wa<<endl;
        cout<<"TLE "<<"x "<<tle<<endl;
        cout<<"RE "<<"x "<<re<<endl;


    
}

Measured memory_bytes: 6360
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	double t,v,y,n;
	while(cin >> v){
		n = 1;
		t = v / 9.8;
		y = 4.9 * t * t;

		while(1){
			if(y < 5 * n - 5){
				break;
			}
			else{
				n++;
			}
		}

		cout << n << endl;
	}

	return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>

int main()
{
  int r, g, b, k;
  scanf("%d %d %d", &r, &g, &b);
  scanf("%d", &k);
  
  for (int i = 0; i < k; i++)
  {
    if (g <= r)
      g <<= 1;
    else
      b <<= 1;
  }
  
  if (r < g && g < b)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &p[i]);
    }

    double MAX = 0;
    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += p[i];
    }
    for (int i = K - 1; i < N; i++) {
        double x = (sum + K) / 2.0;
        MAX = max(MAX, x);
        if (i < N - 1) {
            sum -= p[i - K + 1];
            sum += p[i + 1];
        }
    }

    printf("%.10lf\n", MAX);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define P pair<int,int>
using namespace std;

P b[500000];
signed main(){
	int ans=LLONG_MAX;
	int a;cin>>a;
	for(int c=0;c<a;c++){
		scanf("%lld%lld",&b[c].first,&b[c].second);
		}
	sort(b,b+a);
	for(int d=1;d<a;d++){
		for(int e=d-1;e>=0;e--){
			if((b[e].first-b[d].first)*(b[e].first-b[d].first)>ans)break;
			ans=min(ans,(b[e].first-b[d].first)*(b[e].first-b[d].first)+(b[e].second-b[d].second)*(b[e].second-b[d].second));
			}
		}	
	cout<<ans<<endl;	
	}

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


#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define pair < int , int > pii



int main(){

	double a, b;
	cin >> a >> b;
	cout << ceil((a+b)/2) << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
using namespace std;
int N;
double pw;
double vw[1<<17],pf[1<<17],wf[1<<17],th[1<<17];
double calc(double W)
{
	double cost=W*pw;
	for(int i=0;i<N;i++)
	{
		double now=th[i]-W*vw[i];
		if(now>0)cost+=now/wf[i]*pf[i];
	}
	return cost;
}
main()
{
	while(cin>>N,N)
	{
		cin>>pw;
		for(int i=0;i<N;i++)cin>>vw[i]>>pf[i]>>wf[i]>>th[i];
		double L=0,R=1e9;
		for(int ccc=0;ccc<200;ccc++)
		{
			double M1=(L*2+R)/3;
			double M2=(L+R*2)/3;
			double c1=calc(M1);
			double c2=calc(M2);
			if(c1<c2)R=M2;
			else L=M1;
		}
		cout<<fixed<<setprecision(16)<<calc(L)<<endl;
	}
}



Measured memory_bytes: 6380
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char a;
    cin >> a;
    if(a == 'a' || a == 'e' || a == 'i' || a== 'o' || a == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
        /* code */cout << "consonant" <<endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<math.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const ll N= 1e8;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    int ans=0;
    for (int i = 0; i < n;i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = 0;i<k;i++)
        ans += a[i];
    cout << ans;
    system("pause");
    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
//cout,cinが使える//
#include<cstdio>
//scanf,printfが使える//
#include<cctype>
//文字の種類の判定や文字の変換を行う関数を使える//
using namespace std;

int main(){
    char ch;
    int cnt[26]={};
    
    while (cin >> ch){
        ch = tolower(ch);
        //chの小文字を返す//
        if (isalpha(ch)){
            //chがアルファベットならtrueを返す//
            cnt[ch-'a']=cnt[ch-'a']+1;
            //aからzまで連続したアスキーコードが割り当てられているので、文字からaを引くと対応した番号がgetできる//
        }
    }
    for(int i=0; i<26;i++){
        printf("%c : %d\n", i+'a', cnt[i]);
    }
    
    return 0;
    
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n,cnt = 0;
    cin >> n;
    vector<int> a(3*n+2);
    for (int i = 0;i < 3*n;++i) cin >> a[i],a[i]--;
    a[3*n] = a[3*n+1] = n;
    vector<vector<int>> dp0(n+1,vector<int>(n+1,-1e9)),dp1(n+1,vector<int>(n+1,-1e9));
    vector<int> b(n+1,-1e9);
    dp0[a[0]][a[1]] = dp0[a[1]][a[0]] = dp1[a[0]][a[1]] = dp1[a[1]][a[0]] = 0;
    b[a[0]] = b[a[1]] = 0;
    for (int i = 2;i < 3*n;i += 3) {
        int mx = *max_element(b.begin(),b.end());
        if (a[i] == a[i+2]) swap(a[i+1],a[i+2]);
        if (a[i+1] == a[i+2]) swap(a[i],a[i+2]);
        if (a[i] == a[i+2]) {
            cnt++;
            continue;
        }
        if (a[i] == a[i+1]) {
            for (int j = 0;j < n;++j) dp1[j][a[i+2]] = max(dp1[j][a[i+2]],dp0[j][a[i]]+1);
            for (int j = 0;j < n;++j) dp1[a[i+2]][j] = dp1[j][a[i+2]];
        }
        dp1[a[i]][a[i+1]] = max(dp1[a[i]][a[i+1]],dp0[a[i+2]][a[i+2]]+1);
        dp1[a[i+1]][a[i]] = dp1[a[i]][a[i+1]];
        dp1[a[i+1]][a[i+2]] = max(dp1[a[i+1]][a[i+2]],dp0[a[i]][a[i]]+1);
        dp1[a[i+2]][a[i+1]] = dp1[a[i+1]][a[i+2]];
        dp1[a[i+2]][a[i]] = max(dp1[a[i+2]][a[i]],dp0[a[i+1]][a[i+1]]+1);
        dp1[a[i]][a[i+2]] = dp1[a[i+2]][a[i]];
        for (int j = 0;j < 3;++j) for (int k = 0;k < 3;++k) if (j-k) dp1[a[i+j]][a[i+k]] = max(dp1[a[i+j]][a[i+k]],mx);
        for (int j = 0;j < 3;++j) for (int k = 0;k < n;++k) {
            dp1[a[i+j]][k] = max(dp1[a[i+j]][k],b[k]);
            dp1[k][a[i+j]] = dp1[a[i+j]][k];
        }

        if (a[i] == a[i+1]) {
            for (int j = 0;j < n+1;++j) {
                dp0[j][a[i+2]] = dp0[a[i+2]][j] = dp1[j][a[i+2]];
                b[j] = max(b[j],dp0[j][a[i+2]]);
                b[a[i+2]] = max(b[a[i+2]],dp0[j][a[i+2]]);
            }
        }
        for (int j = 0;j < 3;++j) for (int k = 0;k < 3;++k) if (j-k) {
            dp0[a[i+j]][a[i+k]] = dp1[a[i+j]][a[i+k]];
            b[a[i+j]] = max(b[a[i+j]],dp0[a[i+j]][a[i+k]]);
            b[a[i+k]] = max(b[a[i+k]],dp0[a[i+j]][a[i+k]]);
        }
        for (int j = 0;j < 3;++j) for (int k = 0;k < n+1;++k) {
            dp0[a[i+j]][k] = dp0[k][a[i+j]] = dp1[a[i+j]][k];
            b[k] = max(b[k],dp0[k][a[i+j]]);
            b[a[i+j]] = max(b[a[i+j]],dp0[k][a[i+j]]);
        }
    }
    int ans = 0;
    for (int i = 0;i < n+1;++i) ans = max(ans,*max_element(dp0[i].begin(),dp0[i].end()));
    cout << ans+cnt << endl;
}

Measured memory_bytes: 35084
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

string s;
string code("CODEFESTIVAL2016");

int main() {
  cin >> s;

  solve();

  return 0;
}

void solve() {
  ll cnt = 0;

  rep(i, 16) {
    if(s[i]!=code[i]) ++cnt;
  }

  cout << cnt << endl;
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;

#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
  cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
  return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
  cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
  return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
  for (auto& i : arr)cin >> i; return in;
}

/////////////////////////////////////////////////////////////////////////

int h,w;
string g[1010];
int dist[1010][1010];
int main(int argc, char const* argv[])
{
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> g[i];
  }
  queue< pair<int,int> > Q;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(g[i][j] == '#'){
        Q.emplace(i,j);
      }else{
        dist[i][j] = 100000000;
      }
    }
  }
  while(Q.size()){
    auto[x,y] = Q.front();
    Q.pop();
    for (int dx = -1; dx < 2; dx++) {
      for (int dy = -1; dy < 2; dy++) {
        if(abs(dx)+abs(dy)==1){
          int nx = x + dx;
          int ny = y + dy;
          auto inside = [=](int x,int y){
            return x >= 0 && x < h && y >= 0 && y < w;
          };
          if(inside(nx,ny) && dist[nx][ny] > dist[x][y] + 1){
            dist[nx][ny] = dist[x][y] + 1;
            Q.emplace(nx,ny);
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      chmax(ans,dist[i][j]);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector <int> cost(M);
  for(int i = 0; i < M; i++) cin >> cost.at(i);
  
  int cost1 = 0;
  for (int i = 0; i < X; i++){
    for (int j = 0; j < M; j++){
      if (i == cost.at(j)) cost1 ++;
    }
  }
  int cost2 = 0;
  for (int i = X+1; i < N; i++){
    for (int j = 0; j < M; j++){
      if (i == cost.at(j)) cost2 ++;
    }
  }
  if (cost1 < cost2) cout << cost1 << endl;
  else cout << cost2 << endl;
} 

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
ll dp[310][310][310];
vector<P> v[310];
int main(){
    int n,m;cin>>n>>m;
    for(int i=0;i<m;i++){
        int l,r,x;cin>>l>>r>>x;
        v[r].push_back(P(l,x));
    }
    dp[0][0][0]=1;
    ll ans=0;
    for(int r=0;r<=n;r++){
        for(int g=0;g<=n;g++){
            for(int b=0;b<=n;b++){
                if((r&&g&&b)&&(r==g||g==b||b==r))continue;
                int id=max(max(r,g),b);
                bool ok=true;
                for(auto a:v[id]){
                    int s=0;
                    if(a.first<=r)s++;
                    if(a.first<=g)s++;
                    if(a.first<=b)s++;
                    if(s!=a.second)ok=false;
                }
                if(!ok){
                    dp[r][g][b]=0;
                }
                if(id==n){
                    (ans+=dp[r][g][b])%=MOD;
                    continue;
                }
                (dp[id+1][g][b]+=dp[r][g][b])%=MOD;
                (dp[r][id+1][b]+=dp[r][g][b])%=MOD;
                (dp[r][g][id+1]+=dp[r][g][b])%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 227584
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int h, w, a, b;

#include <cassert>
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);


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

  cin >> h >> w >> a >> b;

  mint memo[h];

  REP(i, h) {
    memo[i] = c((w - b - 1) + (h - i - 1), (h - i - 1));
  }

  mint ans = 0;
  for(int i = 0; i <= (h - a - 1); i++) {
    ans += c((b - 1 + i), i) * memo[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 4224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200010
long long a[N];
long long n, k, q;

long long bs(long long x, long long r){
	long long nl, nr, nm;
	nl = 0;
	nr = n;
	while (nl + 1 < nr){
		nm = (nl + nr) / 2;
		if (a[nm] >= x - r)nl = nm;
		else nr = nm;
	}
	return nl;
}


int main(){
	long long b[N];
	long long c[N];
	f(i, N)a[i] = 0;
	long long x, y, z;
	long long s, ans;
	long long l, r, m;
	bool v = true;
	ans = 0;
	scanf("%lld %lld", &n,&q);
	f(i, n){
		scanf("%lld", &a[n-i-1]);
	}
	b[0] = 0;
	f(i, n){
		b[i + 1] = b[i] + a[i];
	}
	b[n + 1] = b[n];
	c[n] = 0;
	c[n + 1] = 0;
	c[n + 2] = 0;
	for (int i = n - 1; i >= 0; i--){
		if (i % 2 == 0){
			c[i] = c[i + 1] + a[i];
		}
		else c[i] = c[i + 1];
	}
	f(qq, q){
		scanf("%lld", &k);
		l = 0;
		r = n;
		while (l + 1 < r){
			m = (l + r) / 2;
			z = bs(k, a[m] - k);
			x = z - m;
			if (m <= x)l = m;
			else r = m;
		}
		ans = 0;
		ans = b[l + 1];
		ans += c[(2 * l) + 2];
		printf("%lld\n", ans);
	}


	return 0;
}

Measured memory_bytes: 6016
# import sys
# input = sys.stdin.readline
import bisect

# template input
def IT():  # 整数1個
    return int(input())

def IL():  # 整数複数
    return [int(_) for _ in input().split()]

def IS():  # 文字列複数
    return [_ for _ in input().split()]

def ILS(n):  # 整数1つ　縦にズラーってなってるやつ
    return [int(input()) for _ in range(n)]

def SLS(n):  # 文字列　縦にズラーってなってるやつ
    return [input() for _ in range(n)]

def ILSS(n):  # 整数複数　縦にズラーってなってるやつ
    return [[int(_) for _ in input().split()] for j in range(n)]

# template technique
def bit_full_search(ss):
    n = len(ss)
    for i in range(1 << n):
        s = ""
        for j in range(n + 1):
            if ((1 & i >> j) == 1):
                s += ss[j]
        print(s)

def bit_full_search2(A):
    # https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                # output.append(A[j])
                output.append(A[j])
        value.append([format(i, 'b').zfill(16), sum(output)])

    value.sort(key=lambda x: x[1])
    bin = [value[k][0] for k in range(len(value))]
    val = [value[k][1] for k in range(len(value))]
    return bin, val

def matching_bisect(list1_val, list2_val, n):
    # 2分探索
    j = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                # ans = list2_bin[j] + list1_bin[i]
                break
    return j

"""ここからメインコード"""

def main():
    n = IT()
    a = input()
    b = input()
    c = input()

    count = 0
    for i in range(n):
        if a[i] == b[i] and b[i] == c[i]:
            pass
        elif b[i] == c[i] or a[i] == b[i] or a[i] == c[i]:
            count += 1
        else:
            count += 2
    print(count)

main()


Measured memory_bytes: 3192
#include <stdio.h>
int main()
{
  int A, B;
  int i;
  int plug;
  scanf("%d %d", &A, &B);
  if(B == 1){
    printf("%d\n", 0);
    return 0;
  }
  for(i = 0; /* inf */; ++i){
    plug = i * (A-1);
    if((plug + A) >= B){
      printf("%d\n", i + 1);
      return 0;
    }
  }
}


Measured memory_bytes: 128
N = int(input())
x = input().split()
X = list(map(int,x))
Xi = list(X)
Xi.sort()
Xi.reverse()


for i in range(N):
	if(X[i]<Xi[int(N/2)-1]):
		print(Xi[int(N/2)-1])
	elif(X[i]>=Xi[int(N/2)-1]):
		print(Xi[int(N/2)])

Measured memory_bytes: 30228
def is_pal(s):
    if len(s) < 2:
        return True
    elif s[0] == s[-1]:
        return is_pal(s[1:-1])
    return False

s = input().strip()
ja = len(s)
#print(s,(ja-1)/2,(ja+3)/2)
s1 = s[:int((ja-1)/2)]
s2 = s[int((ja+3)/2)-1:]
#print(is_pal(s), is_pal(s1), is_pal(s2))
print("Yes" if (is_pal(s) and is_pal(s1) and is_pal(s2)) else "No")


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const long long N = 50;
long long ans[N];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long k;
  cin >> k;
  iota(ans, ans + N, 0);
  for (int i = 0; i < N; i++) {
    ans[i] += k / N;
  }
  k -= k / N * N;
  for (int i = 0; i < k; i++) {
    ans[i] += N;
    for (int j = 0; j < N; j++) {
      if (j == i) continue;
      ans[j]--;
    }
  }
  cout << N << '\n';
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 100002
bool pr[MAX];
void era(){
    for(int i=0;i<MAX;i++) pr[i]=true;
    pr[0]=false;
    pr[1]=false;
      
    for(int i=0;i*i<MAX;i++){
        if(pr[i]){
            for(int j=i*i;j<=MAX;j=j+i){
                pr[j]=false;
            }
        }
    }
}
int main(void){
    era();
    vector<int> v;
    int count=0;
    for(int i=0;i<MAX;i++){
        if(i%2&&pr[i]&&pr[(i+1)/2])count++;
        v.push_back(count);
    }
    int n,a,b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        int ans=0;
        ans=v[b+1]-v[a-1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,j,k,m,a,b;
	cin>>k>>a>>b;
	int fl=0;
	for(i=a;i<=b;i++){
		if(i%k==0){
			fl=1;break;
		}
	}
	if(fl)cout<<"OK";
	else cout<<"NG";
	getchar();getchar();
}

Measured memory_bytes: 3636
# https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c

s = input()
k = int(input())
n = len(s)
ans = []
for i in range(n):
    t = (ord('z') - ord(s[i]) + 1) % 26
    if k - t >= 0:
        ans.append('a')
        k -= t
    else:
        ans.append(s[i])
if k > 0:
    k %= 26
    ans[-1] = chr(ord(ans[-1]) + k)
print(''.join(ans))

Measured memory_bytes: 46192
N, K = map(int, input().strip().split())
ab = []
for _ in range(N):
  ab.append(tuple(map(int, input().strip().split())))

kc = 0
for a, b in sorted(ab, key=lambda x: x[0]):
  if kc + b >= K:
    break
  kc += b

print(a)


Measured memory_bytes: 18996
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func readf(sc *bufio.Scanner) float64 {
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	v := make([]float64, n)
	for i := range v {
		sc.Scan()
		v[i] = readf(sc)
	}

	max := 0.0
	sort.Float64s(v)
	for i := n - 1; i >= 0; i-- {
		tmp := Alchemy(v)
		if max < tmp {
			max = tmp
		}
	}
	fmt.Println(max)
}

func alchemy(x, y float64) float64 {
	return (x + y) / 2
}

func Alchemy(list []float64) float64 {
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		list[i+1] = alchemy(list[i], list[i+1])
	}
	return list[len(list)-1]
}


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

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  x-=a;
  while(x>=b)x-=b;
  cout<<x<<endl;
  return 0;
}

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

using namespace std;

const int N = 1e5+1;
const int Z = 1e9+7;

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

    int pow3[N+1];
    pow3[0] = 1;
    for (int i = 1; i <= N; i++) {
        pow3[i] = 1ll * pow3[i-1] * 3 % Z;
    }
    int pow2 = 1;

    int ans = 0;
    for (int i = 0; i < l.length(); i++) {
        if (l[i] == '1') {
            ans = (ans + 1ll * pow2 * pow3[l.length()-1-i]) % Z;
            pow2 = pow2 * 2 % Z;
        }
    }
    ans = (ans + pow2) % Z;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

#define  N 10000

int  search(int A[], int n, int key){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( A[i] == key ) return 1;
  }
  return 0;
}

int main(){
  int n, i, q, key, cnt=0;
  int A[N];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  scanf("%d", &q);

  for ( i = 0; i < q; i++ ) {
    scanf("%d", &key);
    cnt +=search(A,n,key);
  }
  printf("%d\n",cnt);
  
  return 0;
}


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

int main()
{
  int n, m, c, a;
  cin >> n >> m >> c;
  vector<int> B(m);
  for(int i = 0; i < m; ++i)
  {
  	cin >> B[i];
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i)
  {
    long long sum  = 0;
  	for(int j = 0; j < m; ++j)
    {
    	cin >> a;
      	sum += (a*B[j]);
    }
    if(sum + c > 0)
      cnt++;
  }
  cout << cnt << "\n";
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P[i];
  sort(P.begin(), P.end());
  P[N - 1] /= 2;
  printf("%d\n", accumulate(P.begin(), P.end(), 0));
  return 0;
}


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

void f(int *x,int *y){
    int temp = *x;
    *x = *y;
    *y = temp;
}

int g(int *a,int n){
    int cnt = 0;
    bool flag =true;
    for(int i=0;i<n;i++){
        flag = false;
        int mini=i;
        for(int j=i;j<n;j++){
            if(*(a+j)<*(a+mini)){
                mini = j;
            }
        }
        if(mini != i){
            flag = true;
            f(a+i,a+mini);
        }
        if(flag)cnt++;
    }
    return cnt;
}

int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0; i<n;i++){
        cin >> a[i];
    }
    int res;
    res = g(a,n);
    for(int i=0; i<n; i++){
        if(i){
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
bool check(string s)
{
	int n=s.size();
	for(int i=0;i<n/2;i++)
	if(s[i]!=s[n-1-i])
	return false;
	return true;
}

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

string s;
cin>>s;
int n=s.size();
bool b=true;
b=b&check(s);

string ss="";
for(int i=0;i<=(n-1)/2-1;i++)
ss+=s[i];

b=b&check(ss);
ss="";
for(int i=(n+3)/2-1;i<n;i++)
ss+=s[i];

b=b&check(ss);
if(b)
cout<<"Yes";
else
cout<<"No";

}


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

int main() {
    int n, p;
    cin >> n >> p;
    int a[n];
    int64_t count_odd = 0;
    int64_t count_even = 0;
    rep(i,n) {
        cin >> a[i];
        if (a[i] % 2 == 1) count_odd++;
        else count_even++;
    }
    int64_t ans;
    if (p == 0) {
        ans = pow(2, count_even) * pow(2, max(count_odd-1, 0l)); //偶数を0~count_even個　* 奇数を偶数個
    }
    if (p == 1) {
        if (count_odd == 0) ans = 0;
        else ans = pow(2, count_odd-1) * pow(2, count_even); //奇数を奇数個　*　偶数を0~count_even個
    }
    if (n == 1) ans = (a[0] % 2 == p) + (p == 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
x = int(input())
ans = 0
if x <= 6:
    ans = 1
    
elif 6 < x <= 11:
    ans = 2
    
else:
    ans = (x//11) * 2
    x = x% 11
    if 0< x <= 6:
        ans += 1
    elif 6 < x <= 11:
        ans += 2
print(ans)

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

#define MOD 10000

int n, m;
int t[102];
int dp[102][4][4];

void solve(){
  memset(dp, 0, sizeof(dp));
  dp[0][3][3] = 1;

  for(int i = 0; i < n; i++){
    for(int pre1 = 0; pre1 < 4; pre1++){
      for(int pre2 = 0; pre2 < 4; pre2++){
        if(dp[i][pre1][pre2] == 0) continue;

        if(t[i] != -1){
          if(pre1 == pre2 && pre2 == t[i]) continue;
          dp[i + 1][pre2][t[i]] += dp[i][pre1][pre2];
          dp[i + 1][pre2][t[i]] %= MOD;
        }
        else{
          for(int today = 0; today < 3; today++){
            if(pre1 == pre2 && pre2 == today) continue;
            dp[i + 1][pre2][today] += dp[i][pre1][pre2];
            dp[i + 1][pre2][today] %= MOD;
          }
        }
      }
    }
  }

  int ans = 0;

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      ans += dp[n][i][j];
      ans %= MOD;
    }
  }

  cout << ans << endl;
}

int main(){
  while(cin >> n >> m){
    memset(t, -1, sizeof(t));

    for(int i = 0; i < m; i++){
      int a, b;
      cin >> a >> b;
      t[a - 1] = b - 1;
    }

    solve();
  }
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    int * a = new int[n + 2];
    int * todo = new int[n];
    a[0] = 10000;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i + 1];
    }
    a[n + 1] = 0;

    unsigned long long money = 1000, kabu = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] <= a[i - 1] && a[i] < a[i + 1])
        {
            // buy all
            kabu = money / a[i];
            money = money % a[i];
        }
        else if (a[i] > a[i - 1] && a[i] >= a[i + 1])
        {
            // sell all
            money += kabu * a[i];
            kabu = 0;
        }
    }
    if (kabu > 0)
    {
        money += kabu * a[n];
        kabu = 0;
    }
    cout << money << endl;

    delete[] a;
    delete[] todo;
    return 0;
}


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

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

    
  }
  
  cout<<ALL;
    

  return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int,input().split()))
q = int(input())
ans = sum(a)
a_list = [0]*(10**5)
for i in a:
    a_list[i-1] += 1

for j in range(q):
    b,c = map(int,input().split())
    a_list[c-1] += a_list[b - 1]
    ans += (c - b) * a_list[b -1]
    a_list[b-1]=0
    print(ans)

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

void sieve(int n,vector<char>& v){
    v.resize(n+1);
    fill(v.begin(),v.end(),true);
    v[0]=v[1]=false;

    for(int i=2;i*i<=n;i++){
        if(v[i]){
            for(int j=i+i;j<=n;j+=i){
                v[j]=false;
            }
        }
    }
}

int main(){
    vector<char> is_prime;
    vector<int> prime_list;

    sieve(50000,is_prime);

    for(int i=0;i<is_prime.size();i++){
        if(is_prime[i]){
            prime_list.push_back(i);
        }
    }

    int n;

    while(cin>>n,n){
        int pr=0;

        for(int i=0;i<prime_list.size();i++){
            if(prime_list[i]+prime_list[i] > n) break;

            if(binary_search(prime_list.begin(),prime_list.end(),n-prime_list[i])){
                pr++;
            }
        }

        cout<<pr<<endl;
    }

    return 0;
}

Measured memory_bytes: 1328