akhauriyash/Code-Regression huggingface dataset:
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,dum;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n){
        cin >> dum;
        a[i] = dum;
    }
    map<int, int> count;
    bool j = true;
    rep(i,n){
        count[a[i]] += 1;
        if(count[a[i]] == 2){
            j = false;
            break;
        }
    }
    if(j == true){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 555
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int K,n;
int ans[sz][sz];

int main()
{
	file();
	read(K);
	if (K<=5) { cout<<K<<'\n'; rep(i,1,K) { rep(j,1,K) printf("%d ",i); puts(""); } return 0; }
	n=(K+1)/2;if (n&1) ++n;
//	rep(i,0,n-1) rep(j,0,n-1) ans[i][(i+j)%n]=j;
	int x=2*n-K;
	rep(i,0,n-x-1) rep(j,0,n-1) ans[j][(i+j)%n]=((i<<1)|(j&1));
	rep(i,n-x,n-1) rep(j,0,n-1) ans[j][(i+j)%n]=K-(i-(n-x))-1;
	printf("%d\n",n);
	rep(i,0,n-1) { rep(j,0,n-1) printf("%d ",ans[i][j]+1); puts(""); }
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll arr[n],sum=0;
    int ar[100001]={0};
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        sum+=arr[i];
        ar[arr[i]]++;
    }
    
    int q;
    cin>>q;
    ll b,c;
    while(q--) {
        cin>>b>>c;
        if(ar[b]==0) {
            cout<<sum<<'\n';
            continue;
        }
        ll val=ar[b];
        ll total=val*b;
        sum-=total;
        ar[b]-=val;
        ar[c]+=val;
        sum+=(c*val);
        cout<<sum<<'\n';
    }
}


Measured memory_bytes: 4832
#include <stdio.h>

int main(void){
  int i, j, n;
  scanf("%d", &n);

  i = (n / 100) * 100 + (n / 100) * 10 + n / 100;

  if( n <= i ){
	printf("%d\n", i);
  }else {
	printf("%d\n", (n / 100 + 1) * 100 + (n / 100 + 1) * 10 + n / 100 + 1);
  }

  return 0;
}


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

struct RollingHash {
    using ull=unsigned long long;
    static constexpr ull MASK30 = (1ULL << 30) - 1;
    static constexpr ull MASK31 = (1ULL << 31) - 1;
    static constexpr ull MOD = (1ULL << 61) - 1;
    static constexpr ull POSITIVIZER = MOD << 2;
    static std::vector<std::pair<ull, ull>> powBase;
    int n;
    std::vector<std::pair<ull, ull>> hash;
    static ull rng() {
        std::random_device rd;
        return std::uniform_int_distribution<ull>(MOD >> 1, MOD - 1)(rd);
    }
    static ull mul(ull a, ull b) {
        ull au = a >> 31;
        ull ad = a & MASK31;
        ull bu = b >> 31;
        ull bd = b & MASK31;
        ull mid = ad * bu + au * bd;
        return (au * bu << 1) + (mid >> 30) + ((mid & MASK30) << 31) + ad * bd;
    }
    static ull calcMod(ull val) {
        val = (val & MOD) + (val >> 61);
        if (val >= MOD) { val -= MOD; }
        return val;
    }
    template<typename Itr> RollingHash(Itr begin, Itr end): n(end - begin) {
        hash.push_back({0, 0});
        for (auto itr = begin; itr != end; itr++) {
            hash.push_back({calcMod((mul(hash.back().first, powBase[1].first) + *itr)),
                            calcMod((mul(hash.back().second, powBase[1].second) + *itr))});
        }
        while (powBase.size() <= n) {
            powBase.push_back({calcMod(mul(powBase.back().first, powBase[1].first)),
                               calcMod(mul(powBase.back().second, powBase[1].second))});
        }
    }
    std::pair<ull, ull> get(int l, int r) const {
        return {calcMod(POSITIVIZER - mul(hash[l].first, powBase[r - l].first) + hash[r].first),
                calcMod(POSITIVIZER - mul(hash[l].second, powBase[r - l].second) + hash[r].second)};
    }
};
std::vector<std::pair<RollingHash::ull, RollingHash::ull>> RollingHash::powBase{{1, 1}, {rng(), rng()}};

int main() {
    string T, P;
    cin >> T >> P;
    RollingHash Th(T.begin(), T.end()), Ph(P.begin(), P.end());
    for (int i = 0; i < (int) T.length() - (int) P.length() + 1; i++) {
        if (Th.get(i, i + P.length()) == Ph.get(0, P.length())) { cout << i << endl; }
    }
}


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

int main() {
  string ABCD; cin >> ABCD;
  for (int bit = 0; bit < (1<<3); bit++) {
    int X = ABCD.at(0) - '0';
    string ans; ans.push_back(ABCD.at(0));
    for (int i = 0; i < 3; i++) {
      if (bit & (1<<i)) {
        X += ABCD.at(i+1) - '0';
        ans.push_back('+');
      }
      else {
        X -= ABCD.at(i+1) - '0';
        ans.push_back('-');
      }
      ans.push_back(ABCD.at(i+1));
    }
    if (X == 7) {
      cout << ans << "=7" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque

p=10**9+7
def primelist(n):
    l=deque([2])
    stack=deque()
    t=1
    for x in range(3,n+1,2):
        flag=0
        for y in tuple(l):
            if x%y==0:
                flag=1
                break
        if flag==0:
            l.append(x)
    return l

def main():
    n=int(input())
    l=primelist(n)
    ans=1
    while l:
        q=l.pop()
        s=0
        c=1
        while n//(q**c):
            s+=n//(q**c)
            c+=1
        ans=ans*(s+1) % p
    print(ans)

main()


Measured memory_bytes: 9304
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    ss=[]
    cs=[]
    temp=[10]*n
    flg=0
    for i in range(m):
        s,c=INTM()
        ss.append(s)
        cs.append(c)
        if s==1 and c==0 and n!=1:
            flg=1
            
    #print(temp)
    #print(ss)
    #print(cs)
    
    for i in range(m):
        if temp[ss[i]-1]==10:
            temp[ss[i]-1]=cs[i]
        else:
            if temp[ss[i]-1]!=cs[i]:
                flg=1
    for i in range(n):
        if temp[i]==10:
            if i==0:
                temp[i]=1
            else:
                temp[i]=0
    if n==1 and m==0:
        temp=[0]
    ans=''
    for i in temp:
        ans+=str(i)
    if flg ==1:
        print(-1)
    else:
        print(ans)
    
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
const int maxn=1e9;
int T,tot1,tot2;
ll n;
char s;
int main()
{
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s=='B')      tot1++;
        else            tot2++;
    }
    if(tot1<tot2)   cout<<"Yes"<<endl;
    else            cout<<"No"<<endl;



	return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B; cin >> A >> B;
    cout << A * B << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

int const N = 55;

int n;

double A;

int a [N];

void small ()
{
	int ans = 0;

	for (int mask = 0; mask < (1 << n); mask++)
	{
		double soma = 0;
		double cnt = 0;

		for (int i = 0; i < n; i++)
			if ((1 << i) & mask)
			{
				cnt++;
				soma += a [i];
			}

		if ((soma/cnt) == A)
			ans++;
	}

	printf ("%d\n", ans);
}

long long dp [N * N][N][N];

long long get (int V, int total, int pos)
{
	if (V < 0)
		return 0LL;

	if (!V)
	{
		if (total == 0)
			return 1LL;
		return 0LL;
	}

	if (pos >= n)
		return 0LL;

	if (!total)
		return 0LL;

	if (dp [V][total][pos] != -1LL)
		return dp [V][total][pos];

	dp [V][total][pos] = get (V - a[pos], total - 1, pos + 1) + get (V, total, pos + 1);

	return dp [V][total][pos];
}

void large ()
{
	int V = (int) (A);

	memset (dp, -1LL, sizeof (dp));

	long long ans = 0;

	for (int i = 1; i <= n; i++)
		ans += get (i * V, i, 0);

	cout << ans << '\n';
}

void solve ()
{
		if (n <= 16)
		{
			small ();
			return;
		}
		
		large ();

}

int main ()
{
		cin >> n >> A;

		for (int i = 0; i < n; i++)
			cin >> a [i];

		solve ();

		return 0;
}

Measured memory_bytes: 71808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int res=0;int sum=0;int max=0;
  rep(i,k){
    sum+=a[i];
  }
  max=sum;
  for(int i=k;i<n;i++){
    sum+=a[i];
    sum-=a[i-k];
    if(sum>max)max=sum;
  }
  printf("%.12lf\n",(double)(max+k)/2);
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    ArrayList<Integer> num = new ArrayList<>();
    for (int i = 0; i < K; i++) {
      if (!num.contains(A + i)) {
        num.add(A + i);
      }
      if (!num.contains(B - i)) {
        num.add(B - i);
      }
    }
    Collections.sort(num);
    for (int i = 0; i < num.size(); i++) {
      int tmp = num.get(i);
      if (tmp >= A && tmp <= B) {
        System.out.println(tmp);
      }
    }
  }
}


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

/*  using namespace  */
using namespace std;

/*  local var  */
int a,b,n;
vector<int> g[100005];
int dist_Fennec[100005];
int dist_Sunuke[100005];

/*  define  */
#define loop(i,j) for(int i = 0; i < j; i++)
#define scan1(d) scanf("%lld",&d);
#define scan2(a,b) scanf("%lld %lld",&a,&b);

/*  typedef  */
typedef long long ll;

/*  function  */
//none

/*  main program  */
int main()
{
	string s;
	int ans=1;
	int n;
	int num[30005];
	cin>>s;
	cin>>n;
	loop(i,n){
		if(s[i]=='1');
		else{ans=s[i]-'0';break;}
	}
	cout<<ans<<endl;
}
	

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

using namespace std;

double p_norm(int n, double* x, double* y, int p) {
    double ans = 0.;
    for (int i = 0; i < n; ++i) {
        ans += pow(abs(x[i] - y[i]), p);
    }
    ans = pow(ans, 1. / p);
    return ans;
}

double max_norm(int n, double* x, double* y) {
    double ans = abs(x[0] - y[0]);
    for (int i = 1; i < n; ++i) {
        if (ans < abs(x[i] - y[i])) ans = abs(x[i] - y[i]);
    }
    return ans;
}

int main() {
    int n;
    double x[101], y[101];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> y[i];
    }

    printf("%f\n%f\n%f\n%f\n",
           p_norm(n, x, y, 1),
           p_norm(n, x, y, 2),
           p_norm(n, x, y, 3),
           max_norm(n, x, y));
    return 0;
}


Measured memory_bytes: 3416
#include "bits/stdc++.h"    
using namespace std;

#ifdef LOCAL
    #include "debug.h"
    #define input \
        freopen("input.txt", "r", stdin); \
        freopen("output.txt", "w", stdout);
#else
    #define debug(...) 4
    #define input 4
#endif

const int mod = 1e9 + 7;
using ll = long long;
const int N = 2e5 + 5;

struct DSU {
    int par[N];
    int sz[N];
    int find(int x) { 
        return x == par[x] ? x : par[x] = find(par[x]); 
    } //path compression(logn)
    
    void merge(int a, int b) {
        a = find(a);
        b = find(b);
        if(a == b) return;
        if(sz[a] < sz[b])
            swap(a, b);

        sz[a] += sz[b];
        par[b] = a;
    }

    void init(int n) {
        for(int i = 0; i <= n; i++)
            par[i] = i, sz[i] = 1;
    }
};
DSU d;

int32_t main() {
    input;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    d.init(n + 1);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        d.merge(x, y);
    }
    int sz = 0;
    for(int i = 0; i < n; i++) {
        int x = d.sz[d.find(i)];
        sz = max(sz, x);
    }
    cout << sz << "\n";
}






Measured memory_bytes: 5188
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;



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

    for(int i=A; i<=B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

#define SIZE_MIN ((int) 1)
#define SIZE_MAX ((int) 100)
#define ELEMENT_MIN ((int) 0)
#define ELEMENT_MAX ((int) 1000)

typedef enum
{
	kSuccess = 0,
	kError = -1
}Result;

Result checkNumRange( int num, int min, int max );
void showArray( int *arr, int size );
void execInsertuinSort( int *array, int size );

int main( void )
{
	int i, size, array[SIZE_MAX];

	scanf( "%d", &size );
	if( checkNumRange( size, SIZE_MIN, SIZE_MAX ) == kError )
	{
		return kError;
	}

	for( i = 0; i < size; i++ )
	{
		scanf( "%d", &array[i] );
		if( checkNumRange( array[i], ELEMENT_MIN, ELEMENT_MAX ) == kError )
		{
			return kError;
		}
	}

	showArray( array, size );
	execInsertuinSort( &array[0], size );

	return kSuccess;
}

Result checkNumRange( int num, int min, int max )
{
	return ((num >= min) || (num <= max)) ? kSuccess : kError;
}

void showArray( int *array, int size )
{
	int i;

	for( i = 0; i < size - 1; i++ )
	{
		printf( "%d ", array[i] );
	}
	printf( "%d\n", array[size - 1] );
}

void execInsertuinSort( int *array, int size )
{
	int i, j, work;

	for( i = 1; i < size; i++ )
	{
		work = array[i];
		j = i - 1;

		while( (j >= 0) && (array[j] > work) )
		{
			array[j + 1] = array[j];
			j--;
		}
		array[j + 1] = work;

		showArray(array, size);
	}
}



Measured memory_bytes: 2076
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef unsigned long long int ll;



int main()
{
	int n;
	cin >> n;
	int *w = new int[n];
	rep(i, n) cin >> w[i];
	int s1;
	int s2;
	int ans = 10000;
	for (int i = 1; i < n; i++) {
		s1 = 0;
		s2 = 0;
		for (int left = 0; left < i; left++) {
			s1 += w[left];
		}
		for (int right = i; right < n; right++) {
			s2 += w[right];
		}
		ans = min(ans, abs(s1 - s2));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//ABC160-E
//#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
#include <set>
//#include <string.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int x,y,a,b,c;
    cin >>x>>y>>a>>b>>c;
    multiset<int>p,q,r;
    long long ans  = 0;
    //input
    int z;
    //eat
    multiset<int>st;
    
    rep(i,a) {
        cin >>z;
        p.insert(z);
    }
    rep(i,b) {
        cin >>z;
        q.insert(z);
    }
    rep(i,c) {
        cin >>z;
        st.insert(z);
    }
    
    rep(i,x){
        auto itr = p.end();
        itr--;
        int maxp = *itr;
        st.insert(maxp);
        p.erase(itr);
    }
    rep(i,y){
        auto itr = q.end();
        itr--;
        int maxq = *itr;
        st.insert(maxq);
        q.erase(itr);
    }

    rep(i,x+y){
        auto itr = st.end();
        itr--;
        ans += *itr;
        st.erase(itr);
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int N;
    cin>>N;
    cout<<N/3<<endl;
	
    return 0;
}


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

using namespace std;

int main() {
  int K;
  string S;
  
  cin >> K >> S;
  
  if (S.length() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K) + "..." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3612
/* Coached by rainboy */
#include <stdio.h>

long long solve(int n, long long x) {
	long long k;

	k = (1LL << n - 1) + 3 * ((1LL << n - 1) - 1);
	if (n == 0)
		return 1;
	else if (x == 1)
		return 0;
	else if (x <= 1 + k)
		return solve(n - 1, x - 1);
	else if (x == 1 + k + 1)
		return (1LL << n) - 1 + 1;
	else if (x <= 1 + k + 1 + k)
		return (1LL << n) - 1 + 1 + solve(n - 1, x - (1 + k + 1));
	else
		return (1LL << n + 1) - 1;
}

int main() {
	int n;
	long long x;

	scanf("%d%lld", &n, &x);
	printf("%lld\n", solve(n, x));
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=INT64_MAX;
const int32_t LOG=21;
const int MOD=MOD1;
int pre[200005];
int suf[200005];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int n,k;
          cin>>n>>k;
          rep(i,1,n+2)
          {
             pre[i]=i-1;
             suf[i]=i-1;
          }
          rep(i,1,n+2)pre[i]+=pre[i-1];
          rev(i,n+1,1)suf[i]+=suf[i+1]; 
          int ans=0;
          rep(i,k,n+2)
          {
              int min1=pre[i];
              int max1=suf[n+2-i];
              ans+=(max1-min1+1);
              ans%=MOD;
          }
          cout<<ans<<endl;
      }


      return 0;                         
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  long long ans = 0;
  for (int i = 0; i < N - K; ++i) {
    ans += H[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4044
N = int(input())
A = []
Ans = 0
count = 0
A = list(map(int, input().split()))


while True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = int(A[i]/2)
            count += 1
    else:
        if count == N:
            Ans += 1
            count = 0
        elif count != N:
            break

print(Ans)

Measured memory_bytes: 3064
b1,b2,b3=map(int,input().split())
if (b1,b2,b3) == (1,0,0):
    print("Close")
elif (b1,b2,b3) == (0,1,0):
    print("Close")
elif (b1,b2,b3) == (1,1,0):
    print("Open")
elif (b1,b2,b3) == (0,0,1):
    print("Open")
else:
    print("Close")


Measured memory_bytes: 5596
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,r[2010][2010],c[2010][2010],ans=0;
string s[2010];

int main()
{
	cin>>n>>m;
	rep(i,n) cin>>s[i];
	rep(i,n)
	{
		rep(j,m)
		{
			if(s[i][j]=='#') continue;
			int p=j;
			while(p<m&&s[i][p]=='.') p++;
			for(int k=j;k<p;k++) r[i][k]=p-j;
			j=p-1;
		}
	}
	rep(j,m)
	{
		rep(i,n)
		{
			if(s[i][j]=='#') continue;
			int p=i;
			while(p<n&&s[p][j]=='.') p++;
			for(int k=i;k<p;k++) c[k][j]=p-i;
			i=p-1;
		}
	}
	rep(i,n) rep(j,m) ans=max(ans,r[i][j]+c[i][j]-1);
	cout<<ans<<endl;
	rt0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

ll N;
set<ll> s;
int main(){
  cin >> N;
  ll temp = 0;
  REP(i, N){
    ll a; cin >> a;
    if(a < 3200) s.insert(a / 400);
    else temp++;
  }
  printf("%lld %lld\n", (s.empty() ? 1 : s.size()) , s.size() + temp);
}


Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
As = list(map(int, input().split()))

Bs = sorted(As)
M = N*(N+1)//2

def isOK(mid):
    Am = Bs[mid]
    Ss = [1 if A >= Am else -1 for A in As]
    Ss = list(accumulate([0]+Ss))

    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [0] * (numPow2+1)
        return data, numPow2
    def addValue(iA, A):
        iB = iA + 1
        while iB <= numPow2:
            data[iB] += A
            iB += iB & -iB
    def getSum(iA):
        iB = iA + 1
        ans = 0
        while iB > 0:
            ans += data[iB]
            iB -= iB & -iB
        return ans

    data, numPow2 = makeBIT(N+1)
    iSs = list(range(N+1))
    iSs.sort(key=lambda iS: Ss[iS])
    odrSs = [0]*(N+1)
    for odrS, iS in enumerate(iSs):
        odrSs[iS] = odrS

    num = 0
    for odrS in odrSs:
        num += getSum(odrS)
        addValue(odrS, 1)
    return num >= (M+1)//2


ng, ok = N, -1
while abs(ok-ng) > 1:
    mid = (ng+ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

print(Bs[ok])


Measured memory_bytes: 128444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count_mount = sc.nextInt();
		int[] mounts = new int[count_mount];
		for (int i = 0; i < count_mount; i++) {
			mounts[i] = sc.nextInt();
		}
		sc.close();
		int count = 1;
		int max = mounts[0];
		for (int i = 1; i < count_mount; i++) {
			if (mounts[i] >= max) {
				max = mounts[i];
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22608
#include<iostream>
#include<algorithm>
using namespace std;
int dp[256][20001];
main()
{
	int n,m;
	while(cin>>n>>m,n)
	{
		int c[16];
		for(int i=0;i<m;i++)cin>>c[i];
		for(int i=0;i<256;i++)for(int j=0;j<=n;j++)dp[i][j]=1<<28;
		dp[128][0]=0;
		for(int i=1;i<=n;i++)
		{
			int a;cin>>a;
			for(int j=0;j<256;j++)
			{
				for(int k=0;k<m;k++)
				{
					int u=j+c[k];
					if(u<0)u=0;
					if(u>=256)u=255;
					dp[u][i]=min(dp[u][i],(a-u)*(a-u)+dp[j][i-1]);
				}
			}
		}
		int mindp=1<<28;
		for(int i=0;i<256;i++)mindp=min(mindp,dp[i][n]);
		cout<<mindp<<endl;
	}
}

Measured memory_bytes: 23084
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
INF = 10**18

N = 26
L = [0] * N
now = 0
for d in range(D):
    nx = 0
    mx = -INF

    for i in range(N):
        res = now
        prevL = L[i]
        L[i] = d

        res += S[d][i]
        for l, c in zip(L, C):
            res -= c * (d - l)

        L[i] = prevL
        if mx < res:
            mx = res
            nx = i
    now = res
    print(nx + 1)


Measured memory_bytes: 9400
#include <iostream>
#define M 100

using namespace std;

int main()
{
	int n, m, sum, bigsum=0;
	int A[M][M];

	cin >> n >> m;
	for (int i=0;i<n;i++)
	{
	
		for (int j = 0; j < m; j++)
		{
			cin >> A[i][j];
		}
	}	
	for (int i = 0; i < n; i++)
	{
		sum = 0;
		for (int j = 0; j < m; j++)
		{
			cout << A[i][j] << " ";
			sum += A[i][j];
		}
		bigsum += sum;
		cout << sum << endl;
	}
	for (int i = 0; i < m; i++)
	{
		sum = 0;
		for (int j = 0; j < n; j++)
		{
			sum += A[j][i];
		}
		cout << sum << " ";
	}
	cout << bigsum << endl;
	return 0;
}


Measured memory_bytes: 3112
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var K = nextInt();
  var sum = 0;
  for(var i = 1; i <= K; i++){
    for(var j = 1; j <= K; j++){
      for(var l = 1; l <= K; l++){
        var mae = gcd(i,j);
        sum += gcd(mae,l);
      }
    }
  }
  myout(sum);
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}

Measured memory_bytes: 31648
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

namespace Solver {

    int w, h;
    vector<vector<int>> vw, hw, field;
    inline bool Read() {
        cin >> w >> h;
        if (h == 0) return false;

        vw.resize(h);
        hw.resize(h - 1);
        for (int i = 0; i < h * 2 - 1; i++) {
            int idx = i / 2;
            if (i % 2 == 0) {
                vw[idx].resize(w - 1);
                for (int j = 0; j < w - 1; j++) {
                    cin >> vw[idx][j];
                }
            } else {
                hw[idx].resize(w);
                for (int j = 0; j < w; j++) {
                    cin >> hw[idx][j];
                }
            }
        }

        return true;
    }

    const int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
    inline void Work() {
        vector<vector<int>> field(h);
        for (int y = 0; y < h; y++) {
            field[y].resize(w);
            for (int x = 0; x < w; x++) {
                field[y][x] = -1;
            }
        }

        queue<pair<int, int>> que;
        que.push(pair<int, int>(0, 0));
        field[0][0] = 0;
        while (!que.empty()) {
            pair<int, int> pos = que.front();
            que.pop();
            int x = pos.first, y = pos.second;
            for (int k = 0; k < 4; k++) {
                int nx = x + dx[k], ny = y + dy[k];

                if (nx < 0 || nx >= w || ny < 0 || ny >= h || field[ny][nx] != -1) continue;

                if (dx[k] == 1 && vw[ny][nx - 1] == 1) continue;
                if (dx[k] == -1 && vw[ny][nx] == 1) continue;
                if (dy[k] == 1 && hw[ny - 1][nx] == 1) continue;
                if (dy[k] == -1 && hw[ny][nx] == 1) continue;

                field[ny][nx] = field[y][x] + 1;
                que.push(pair<int, int>(nx, ny));
            }
        }

        if (field[h - 1][w - 1] == -1) {
            cout << 0 << endl;
        } else {
            cout << field[h - 1][w - 1] + 1 << endl;
        }
    }

    inline void Solve() {
        while (Read()) Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1240
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

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

const int max_N = 1e5 + 10;
char cache[max_N];

char ask(int idx);
void solve(vector<int> indices);

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

	vector<int> indices;
	for (int i = 0; i < N; ++i) {
		indices.push_back(i);
	}

	solve(indices);
}

char ask(int idx)
{
	if (cache[idx] != 0) {
		return cache[idx];
	}

	cout << idx << endl;
	string response;
	cin >> response;

	if (response[0] == 'V') {
		exit(0);
	}
	cache[idx] = response[0];
	return response[0];
}

void solve(vector<int> indices)
{
	trace(indices.size(), indices.front(), indices.back());
	int N = indices.size();
	int m = N / 2;

	assert(N % 2);
	assert(N >= 3);

	if (N == 3) {
		ask(indices[0]);
		ask(indices[1]);
		ask(indices[2]);
	}

	if (m % 2 == 0) {
		int L = 0, R = m;
		if (ask(indices[L]) == ask(indices[R])) {
			vector<int> up;
			int nsz = N - m;
			if ((nsz / 2) % 2) {
				for (int i = R + 1; i <= N; ++i) {
					up.push_back(indices[i % N]);
				}
			} else {
				for (int i = R; i < N; ++i) {
					up.push_back(indices[i]);
				}
			}
			solve(up);
		} else {
			vector<int> down;
			for (int i = L; i <= R; ++i) {
				down.push_back(indices[i]);
			}
			solve(down);
		}
	} else {
		int L = m + 1, R = N - 1;
		if (ask(indices[L]) == ask(indices[R])) {
			vector<int> down;
			int nsz = m + 2;
			if ((nsz / 2) % 2) {
				for (int i = 0; i <= L; ++i) {
					down.push_back(indices[i]);
				}
			} else {
				down.push_back(indices[R]);
				for (int i = 0; i < L; ++i) {
					down.push_back(indices[i]);
				}
			}
			solve(down);
		} else {
			vector<int> up;
			for (int i = L; i <= R; ++i) {
				up.push_back(indices[i]);
			}
			solve(up);
		}
	}
}


Measured memory_bytes: 2508
#include<stdio.h>
int X[17][17]={0};
int i,j;
int f(int x,int y){
    if(x<=0||x>i||y<=0||y>j||X[x][y]==-1)return 0;
    if(x==1 && y==1)return 1;
    return f(x-1,y)+f(x,y-1);
}
int main(void){
    int n,d,e,k,l,m;
    while(1){
    scanf("%d%d",&i,&j);
    if(i==0 && j==0)break;
    scanf("%d",&n);
    for(l=0;l<17;l++){
        for(m=0;m<17;m++){
            X[l][m]=0;
        }
    }
    for(k=0;k<n;k++){
        scanf("%d%d",&d,&e);
        X[d][e]=-1;
    }
    printf("%d\n",f(i,j));
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        if (2 * k > b - a + 1) {
            for (int i = a; i <= b; i++) {
                System.out.println(i);
            }
        } else {
            for (int i = a; i < a + k; i++) {
                System.out.println(i);
            }
            for (int i = b - k + 1; i <= b; i++) {
                System.out.println(i);
            }
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
	int i, j, temp;
	int a[3];

	for (i = 0; i < 3; i++)
		scanf("%d", &a[i]);

	j = 0;

	while (j < 2)
	{
		for (i = 1; i >= 0; i--)
		{
			if (a[i] > a[i + 1])
			{
				temp = a[i + 1];
				a[i + 1] = a[i];
				a[i] = temp;
			}
		}
		j++;
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);
	return 0;
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
#define fre(i,t,n)  for(int i =(t);i<=(n);++i)
#define fer(i,n,t)  for(int i =(n);i>=(t);--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
void smain();
int main(){
    ios::sync_with_stdio(false);
    smain();
    return 0;
}
const int maxn = 100+100+100;
int A[maxn];
void smain(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;++i)    cin>>A[i];
    for(int i=1;i<n;++i)
    {
        if(A[i]==A[i-1])    A[i]=1000+i,ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
struct edge {
	int to, cost;
	edge(int to_, int cost_) : to(to_), cost(cost_) {};
};
bool operator<(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
template<class Type>
std::vector<Type> shortest_path_dijkstra(std::vector<std::vector<edge> > &G, int s) {
	std::priority_queue<edge> que; que.push(edge(s, 0));
	std::vector<Type> ret(G.size(), std::numeric_limits<Type>::max()); ret[s] = 0;
	while (!que.empty()) {
		edge u = que.top(); que.pop();
		for (edge e : G[u.to]) {
			if (ret[e.to] > ret[u.to] + e.cost) {
				ret[e.to] = ret[u.to] + e.cost;
				que.push(edge(e.to, -ret[e.to]));
			}
		}
	}
	return ret;
}
int n, m, a, b, c;
int main() {
	cin >> n >> m;
	vector<vector<edge> > G(n);
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c; a--, b--;
		G[a].push_back(edge{ b, c });
		G[b].push_back(edge{ a, c });
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		vector<int> res = shortest_path_dijkstra<int>(G, i);
		for (edge e : G[i]) {
			int p = res[e.to];
			if (p < e.cost) ret++;
		}
	}
	cout << ret / 2 << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
int a,b,x,A,B;
scanf("%d %d %d",&x,&a,&b);

A = a - x;
B = b - x;
if(A < 0) A = -A;
if(B < 0) B = -B;

if(A < B){
printf("A");
}else{
printf("B");
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
struct node{
	int pre, to, val;
}edge[200010];
int head[100010], tot;
int k;
void add(int u, int v, int l) {
	edge[++tot] = node{head[u], v, l};
	head[u] = tot;
}
int dis[100010], vis[100010];
queue<int> q;
void spfa() {
	memset(dis, 0x3f, sizeof(dis));
	dis[1] = 1;
	vis[1] = 1;
	q.push(1);
	while (!q.empty()) {
		int x = q.front(); q.pop();
		for (int i = head[x]; i; i = edge[i].pre) {
			int y = edge[i].to;
			if (dis[y] > dis[x] + edge[i].val) {
				dis[y] = dis[x] + edge[i].val;
				if (!vis[y]) {
					vis[y] = 1;
					q.push(y);
				}
			}
		}
		vis[x] = 0;
	}
}
int main() {
	cin >> k;
	for (int i = 0; i < k; i++) {
		add(i, (i + 1) % k, 1);
		add(i, i * 10 % k, 0);
	}
	spfa();
	cout << dis[0];
	return 0;
}

Measured memory_bytes: 3840
N,Y = map(int,input().split())
Y = Y/1000
torf = False
for numoft in range(N+1):
    for numof5t in range(N-numoft+1):
        numof10t = (N)-(numoft+numof5t)
        if Y == numoft + 5*numof5t + 10*numof10t:
            print(numof10t,numof5t,numoft)
            exit()
print("-1 -1 -1")

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

using namespace std;

int main()
{
	int N;
	vector<int> a;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int rabbit;
		cin >> rabbit;
		a.push_back(rabbit);
	}
	int nPair = 0;
	for (int i = 0; i < N; i++)
	{
		if (a[a[i] - 1] == i + 1 && a[i] != i + 1)
		{
			nPair++;
		}
	}
	cout << nPair / 2 << endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define equals(a,b) fabs((a) - (b)) < EPS

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<string> split(const string &str, char delim) {
    vector<string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != string::npos) {
        res.push_back(string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(string(str, current, str.size() - current));
    return res;
}

int stoi(string s) {
    int ret;
    stringstream ss;
    ss << s;
    ss >> ret;
    return ret;
}

double dp[1<<12][12];

int main() {
    string s;
    while(getline(cin,s)) {
        vector<string> t = split(s,' ');
        int len = stoi(t[0]);
        vector<int> v;
        REP(i,1,t.size()) {
            v.push_back(stoi(t[i]));
        }
        int n = v.size();

        rep(i,1<<n) {
            rep(j,n) dp[i][j] = INF;
        }

        rep(i,n) {
            dp[1<<i][i] = v[i];
        }

        rep(k,(1<<n)) {
            rep(i,n) {
                rep(j,n) {
                    if(k & (1<<j)) continue;
                    double r = (v[i]+v[j]) * (v[i]+v[j]) - (v[i]-v[j])*(v[i]-v[j]);
                    dp[k|(1<<j)][j] = min(dp[k|(1<<j)][j],dp[k][i] + sqrt(r));
                }
            }
        }

        double res = INF;
        rep(i,n) {
            res = min(res,dp[(1<<n)-1][i] + v[i]);
        }

        if(res <= len) cout << "OK" << endl;
        else cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1632
<?php
  $n = fgets(STDIN);
  $debt = 100000.0;
  for($i=0; $i<(int)$n; $i++) {
    $debt *= 1.05;
    if($debt % 1000 != 0) {
      $debt = ((int)($debt/1000)+1)*1000;
    }
    else { 
      $debt = ((int)($debt/1000))*1000;
    }
  }
  echo $debt."\n";

Measured memory_bytes: 15304
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int m = scanner.nextInt();
            int f = scanner.nextInt();
            int r = scanner.nextInt();
    
            if (m == -1 && f == -1 && r == -1) {
                scanner.close();
                return;
            }

            if (m == -1 || f == -1) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (m + f >= 65 && m + f < 80) {
                System.out.println("B");
            } else if (m + f >= 50 && m + f < 65) {
                System.out.println("C");
            } else if (m + f >= 30 && m + f < 50) {
                if (r >= 50) {
                    System.out.println("C");
                } else {
                    System.out.println("D");
                }
            } else {
                System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26320
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100;

ll N, K;

void input() {
	scanf("%lld%lld", &N, &K);
}

void solve() {
	if(K > (N-1)*(N-2)/2){
		p(-1);return;
	}

	vector<ll> a((N)*(N-1)/2,0),b((N)*(N-1)/2,0);
	ll index=0;
	for(ll i=2;i<=N;i++){
		a[index]=1;
		b[index]=i;
		index++;
	}

	ll count=(N-1)*(N-2)/2;
	ll anum=2;
	ll bnum=3;
	while(count>K){
		a[index]=anum;
		b[index]=bnum;
		index++;
		count--;
		bnum++;
		if(bnum>N){
			anum++;
			bnum=anum+1;
		}
	}

	p(index);
	rep(i,index){
		cout<<a[i]<<" "<<b[i]<<endl;
	}


}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using vec_i64 = vector<i64>;
using vvec_i64 = vector<vec_i64>;

// typedef pair<i32, bool> cache;

// returns whether the first player can win or not when i stones are left
i32 rec(i32 i, vec_i64& a_list, i32 first_turn, vvec_i64& memo) {
    if (memo.at(i).at(first_turn) != 0) return memo.at(i).at(first_turn);
    if (first_turn == 1) {
        for (i32 j = 0; j < a_list.size(); j++) {
            if (i < a_list.at(j)) break;
            if (rec(i - a_list.at(j), a_list, 0, memo) == 1) {
                memo.at(i).at(1) = 1;
                break;
            }
        }
        if (memo.at(i).at(1) == 0) memo.at(i).at(1) = 2;
    }
    else {
        for (i32 j = 0; j < a_list.size(); j++) {
            if (i < a_list.at(j)) break;
            if (rec(i - a_list.at(j), a_list, 1, memo) == 2) {
                memo.at(i).at(0) = 2;
                break;
            }
        }
        if (memo.at(i).at(0) == 0) memo.at(i).at(0) = 1;
    }
    return memo.at(i).at(first_turn);
}

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

    i32 N, K;
    cin >> N >> K;

    vec_i64 a_list(N);
    for (i32 i = 0; i < N; i++) {
        cin >> a_list.at(i);
    }

    vvec_i64 memo(K + 1, vec_i64(2, 0));
    i32 first_winning = rec(K, a_list, 1, memo);
    if (first_winning == 1) cout << "First" << "\n";
    else cout << "Second" << "\n";

    return 0;
}




Measured memory_bytes: 13568
#include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> P;
#define MAX 10000
 
int is_prime[MAX+5];// 1:prime 0:not prime
int ans[MAX+5];
void eratos()
{
	int i,j;
	for(i=2;i<=MAX;i++)is_prime[i]=1;
	for(i=2;i*i<=MAX;i++)if(is_prime[i]==1)
	{
		for(j=i*2;j<=MAX;j+=i)is_prime[j]=0;
	}
	return;
}
 
int main(void)
{
	eratos();
	for(int i=0;i<=MAX;i++)if(is_prime[i]&&is_prime[i+2])ans[i+2]=i+2;
	for(int i=5;i<=MAX;i++)if(ans[i]==0)ans[i]=ans[i-1];
	while(1)
	{
		int n;
		cin >> n;
		if(n==0)break;
		cout << ans[n]-2 << ' ' << ans[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1236