akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
#include <cctype>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5+10;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

typedef string::const_iterator SC;

int factor(SC&);

// ??°????????????
int number(SC& begin){
  int res = 0;

  while(isdigit(*begin)){
    res *= 10;
    res += *begin - '0';
    begin++;
  }

  return res;
}

// ??????
int term(SC& begin){
  int res = factor(begin);

  while(1){
    if(*begin == '*'){
      begin++;
      res *= factor(begin);
    }
    else if(*begin == '/'){
      begin++;
      res /= factor(begin);
    }
    else{
      break;
    }
  }
  return res;
}

// ????????????
int expression(SC& begin){
  int res = term(begin);

  while(1){
    if(*begin == '+'){
      begin++;
      res += term(begin);
    }
    else if(*begin == '-'){
      begin++;
      res -= term(begin);
    }
    else{
      break;
    }
  }
  return res;
}

// ??¬??§?????°????????????
int factor(SC& begin){
  if (*begin == '('){
    begin++;
    int res = expression(begin);
    begin++;
    return res;
  }
  else{
    return number(begin);
  }
}

int main() {
	int n;
	cin >> n;
	string s;
	REP(i,n){
		cin >> s;
		SC begin = s.begin();
		cout << expression(begin) << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<Pii> ans(0);
    int dd = (n+1)%2;
    int kk = n;
    rip(i,m,0){
        ans.push_back({i+1, kk-i});
        if(n/4 == i+1){
            kk -= dd;
        }
    }
    rip(i,m,0) cout << ans[i].first MM ans[i].second << endl;
}

Measured memory_bytes: 4320
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,d;
    cin>>n>>d;
    ll res=d*2+1;
    res=ceil(n/(double)res);
    cout<<res<<endl;
    End;
}


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

int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  if (b - a < 2) {
    cout << 1 + k << endl;
    return 0;
  }
  int x = k - (a - 1);
  ll ans = 0;
  if (x < 2) {
    cout << a + x << endl;
    return 0;
  } else {
    ans += x / 2 * (b - a) + a;
    if (x % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n+1, 0);
    for(int i=0;i<n;++i) {
        a[i+1] = a[i];
        if(s[i] == '#') ++a[i+1];
    }

    int ans = n-a[n];
    for(int i=1;i<=n;++i) {
        int tmp = a[i] + (n-i - (a[n] - a[i]));
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4404
def f(x):
    x+=1
    ans=0
    for i in range(50):
        loop=1<<(i+1)
        cnt=(x//loop)*(loop//2)#i桁目に含まれる1の数
        cnt+=max(0,x%loop-loop//2)#端数分
        if cnt%2==1:
            ans+=1<<i
    return ans 
a,b=map(int,input().split())
print(f(a-1)^f(b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int dfs(vector<int> a,vector<int> b,int n){
    if(n==a.size())return 0;
    int sa=b[n]-a[n]+10;
    sa%=10;
    if(sa==0)return dfs(a,b,n+1);
    vector<int> c=a;
    int ret=1000000000;
    rep(i,n,a.size()){
        (c[i]+=sa)%=10;
        Min(ret,dfs(c,b,n+1)+1);
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int k;cin>>k;
        if(k==0)break;
        string s,t;cin>>s>>t;
        vector<int> a,b;
        rep(i,0,k){
            a.push_back(s[i]-'0');
            b.push_back(t[i]-'0');
        }
        cout<<dfs(a,b,0)<<endl;
    }
}





Measured memory_bytes: 2996
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    long long ans = 1;

    if (K != 1)ans = pow(K - 1, N - 1)*K;

    cout << ans << endl;

    return 0;
}

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

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

    ll ans = 0;
    REP(i, N) {
        ll xi;
        cin >> xi;

        if(xi < (double)K/2) {
            ans += 2*xi;
        } else {
            ans += 2*(K - xi);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int h,w;
  cin >> h >> w;
  
  if(h%3==0 || w%3==0) {
    cout << 0 << endl;
    return 0;
  }
  
  int ans = min(w,h);
  int a,b,c,memo;
  
  a = h * (w/3 +(w%3 - 1) );
  b = (h/2) * (  w - (w/3 +(w%3 - 1) ));
  c = h*w - a - b;
  
  //cout << a << ' ' << b << ' ' << c << endl;
  
  memo = max({a,b,c}) - min({a,b,c});
  ans  = min(ans,memo);
  
  swap(h,w);
  
  a = h * (w/3 +(w%3 - 1) );
  b = (h/2) * (  w - (w/3 +(w%3 - 1) ));
  c = h*w - a - b;
  memo = max({a,b,c}) - min({a,b,c});
  ans  = min(ans,memo);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;


int main(){

    int n;
    cin >> n;
    int a = n;
    int tmp=0;
    while(a>0){
        tmp += a%10;
        a /= 10;
    }
    if(n%tmp) cout << "No" <<endl;
    else cout << "Yes" <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, k;
	cin >> n >> k;
	int answer = 0;
	for (int i = 0;i < n;++i) {
		int t;
		cin >> t;
		if (t >= k) {
			++answer;
		}
	}
	cout << answer << '\n';
	return 0;
}


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

map<pi,int>cnt;
set<pi>s;
map<pi,bool>vis;
 main()

{
    fast
    int n,zo=0,oz=0,z=0,ses=0;
    cin>>n;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        if(a==0 && b==0)
        {
            z++;
        }
        else if(a==0 && b!=0)
        {
            zo++;
        }
        else if(a!=0 && b==0)
        {
            oz++;
        }
        else
        {
            if(a<0)a=-a,b=-b;
            int g=__gcd(abs(a),abs(b));
            a=a/g;
            b=b/g;
            cnt[mp(a,b)]++;
            s.insert(mp(a,b));
        }
    }
    int Magic=1;
    if(oz>=1 && zo>=1)
    {
        int ans=sub(ad(bigmod(2,oz),bigmod(2,zo)),1);
        Magic=gun(Magic,ans);
    }
    else if(oz!=0 && zo==0)
    {
          Magic=gun(Magic,bigmod(2,oz));
    }
    else if(oz==0 && zo!=0)
    {
           Magic=gun(Magic,bigmod(2,zo));
    }
    ses=ad(ses,z);
    set<pi>::iterator it;
    for(it=s.begin();it!=s.end();it++)
    {
        pi yo=*it;
        if(vis[yo]==1)continue;
        pi ulta=mp(-yo.si,yo.fi);
        if(ulta.fi<0)ulta.fi=-ulta.fi,ulta.si=-ulta.si;
        vis[ulta]=1;
        int c1=cnt[yo];
        int c2=cnt[ulta];
        int ans=1;
        if(c1!=0 && c2==0)
        {
             ans=bigmod(2,c1);
        }
        else if(c1==0 && c2!=0)
        {
              ans=bigmod(2,c2);
        }
        else if(c1>=1 && c2>=1)
        {
             ans=sub(ad(bigmod(2,c1),bigmod(2,c2)),1);
        }
         Magic=gun(Magic,ans);
    }
    ses=ad(ses,Magic);
    ses=sub(ses,1);
    cout<<ses<<endl;
    return 0;

}





































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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,x,y,dx,dy,ax,ay,dis;
  cin >> n;
  rep(l,n){
    x = 0,y = 0;
    dis = 0;
    while(cin >> dx >> dy && (dx || dy)){
      x += dx;
      y += dy;
      if(dis < x*x + y*y){
        ax = x;
        ay = y;
        dis = x*x+y*y;
      }
      else if(dis == x*x+y*y){
        if(ax < x){
          ax = x,ay = y;
        }
      }
    }
    cout << ax << ' ' << ay << endl;
  }
  return 0;
}

Measured memory_bytes: 3124
#include <iostream>
using namespace std;
int main(void){
    int b1,b2,b3;
    cin >> b1 >> b2 >> b3;
    if(b3 == 1 || b1 ==1 && b2 == 1){
        cout << "Open" << endl;
    }else{
         cout << "Close" << endl;
    }
}


Measured memory_bytes: 3096
package main

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

func solve() {
	n := getInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		a := getInt()
		m[a]++
	}

	first, second := 0, 0
	for a, num := range m {
		cnt := 0
		for num >= 2 {
			if a > first {
				second = first
				first = a
			} else if a > second {
				second = a
			}

			num -= 2
			cnt++
			if cnt == 2 {
				break
			}
		}
	}

	ans := first * second
	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 7296
#include<iostream>
#include<vector>
using namespace std;
int gcd(int x,int y){
    if(x<y){
        int z=x;
        x=y;
        y=z;
    }
    x=x%y;
    if(x==0){
        return y;
    }else{
        return gcd(y,x);
    }
}

int main(){
    long K,sum=0;
    cin >> K;
    for(int a=1;a<K+1;a++){
        for(int b=1;b<K+1;b++){
            for(int c=1;c<K+1;c++){
                sum += gcd(gcd(a,b),c);
            }
        }
    }
    cout << sum;
}

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

long long gcd(long long a, long long b)
{
	if (a > b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int i, N, x[101], y[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(x[i]), &(y[i]));
	
	int j, k, flag[101][101] = {}, conv[101] = {};	
	long long tmp, a[101][101], b[101][101];
	for (i = 1; i < N; i++) {
		for (j = i + 1; j <= N; j++) {
			a[i][j] = y[i] - y[j];
			b[i][j] = x[j] - x[i];
			if (a[i][j] == 0) b[i][j] = 1;
			else if (b[i][j] == 0) a[i][j] = 1;
			else {
				tmp = gcd(llabs(a[i][j]), llabs(b[i][j]));
				a[i][j] /= tmp;
				b[i][j] /= tmp;
				if (a[i][j] < 0) {
					a[i][j] *= -1;
					b[i][j] *= -1;
				}
			}
			
			for (k = 1; k <= N; k++) {
				tmp = a[i][j] * (x[k] - x[i]) + b[i][j] * (y[k] - y[i]);
				if (tmp * flag[i][j] < 0) break;
				else if (tmp > 0) flag[i][j] = 1;
				else if (tmp < 0) flag[i][j] = -1;
			}
			if (k > N) {
				conv[i] = 1;
				conv[j] = 1;
			} else flag[i][j] = 0;
			
			a[j][i] = a[i][j];
			b[j][i] = b[i][j];
			flag[j][i] = flag[i][j];
		}
	}
	for (i = 1; i < N; i++) {
		if (conv[i] == 0) continue;
		for (j = i + 1; j <= N; j++) {
			if (conv[j] == 0) continue;
			for (k = 1; k <= N; k++) {
				if (k == i || k == j || conv[k] == 0 || a[i][j] != a[i][k] || b[i][j] != b[i][k]) continue;
				tmp = (long long)(x[j] - x[i]) * (x[k] - x[i]) + (long long)(y[j] - y[i]) * (y[k] - y[i]);
				if (tmp < 0) continue;
				tmp = (long long)(x[i] - x[j]) * (x[k] - x[j]) + (long long)(y[i] - y[j]) * (y[k] - y[j]);
				if (tmp < 0) continue;
				conv[k] = 0;
			}
		}
	}
	for (i = 1; i <= N; i++) {
		if (conv[i] != 0) continue;
		for (j = 1; j <= N; j++) {
			flag[i][j] = 0;
			flag[j][i] = 0;
		}
	}
	
	for (i = 1; i < N; i++) {
		for (j = i + 1; j <= N; j++) if (flag[i][j] == 1 || flag[i][j] == -1) break;
		if (j <= N) break;
	}
	if (i == N) {
		for (k = 1; k <= N; k++) {
			if (conv[k] == 1) printf("0.500000\n");
			else printf("0.000000\n");
		}
		fflush(stdout);
		return 0;
	}
	
	const long double pi = atanl(1.0) * 4.0;
	long double theta[101][101] = {}, alpha;
	for (i = 1; i < N; i++) {
		if (conv[i] == 0) continue;
		for (j = i + 1; j <= N; j++) {
			if (flag[i][j] == 0) continue;
			if (a[i][j] == 0) theta[i][j] = pi / 2.0;
			else theta[i][j] = atanl((long double)b[i][j] / a[i][j]);
			if (flag[i][j] == 1) theta[i][j] += pi;
			theta[j][i] = theta[i][j];
		}
	}
	for (i = 1; i <= N; i++) {
		if (conv[i] == 0) printf("0.000000\n");
		else {
			for (j = 1, alpha = pi * 2.0; j <= N; j++) {
				if (conv[j] == 0) continue;
				if (flag[i][j] == 1 || flag[i][j] == -1) {
					if (alpha == pi * 2.0) alpha = theta[i][j];
					else break;
				}
			}
			if (fabsl(alpha - theta[i][j]) < pi) printf("%Lf\n", fabsl(alpha - theta[i][j]) / (pi * 2.0));
			else printf("%Lf\n", 1.0 - fabsl(alpha - theta[i][j]) / (pi * 2.0));
		}
	}
	fflush(stdout);
	return 0;
}

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

int main(){
  int N;  cin >> N;
  long long ans = 0;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(i>0 && A.at(i - 1) > A.at(i)){
      ans += A.at(i - 1) - A.at(i);
      A.at(i) = A.at(i-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
n = int(input())
arr = list(map(int , input().split(" ")))
mx = 100005
freq = [0]*mx
for i in range(n):
    curr = arr[i]
    freq[curr] += 1
    freq[curr]%=2
    if freq[curr] == 0:
        freq[curr] = 2
num_evens = 0
total = 0
for item in freq:
    if item != 0:
        total += 1
    if item == 2:
        num_evens += 1
if num_evens %2 == 1:
    total -= 1
print(total)


Measured memory_bytes: 20816
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n = int(input())
a = list(map(int,input().split()))
cnt = 0
i = 0
flag = 0
while True:
    for i in range(n):
        if a[i]%2 == 0:
            a[i]//=2
        else:
            flag = 1
    if flag == 1:
        break
    cnt += 1
print(cnt)

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

const long Nmax = 10e6 + 1;
vector <int> nod[Nmax];
queue <int> q;
int n,m,first;
bool ok = 1;
vector <bool> viz(Nmax);
vector <int> pas(Nmax),tata(Nmax);
void cit()
{
    int x,y;
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        cin >> x >> y;
        nod[x].push_back(y);
        nod[y].push_back(x);
    }
}
void bfs()
{
    while(!q.empty())
    {
        first = q.front();
        for(auto i : nod[first])
        {
            if(!viz[i])
            {
                q.push(i);
                viz[i] = 1;
                pas[i] = pas[first] + 1;
                tata[i] = first;
            }
        }
        q.pop();
    }
}
int main()
{
    cit();
    viz[1] = 1;
    pas[1] = 0;
    q.push(1);
    bfs();
    for(int i = 1; i <= n; ++i)
        if(!viz[i])
        {
            cout << "No";
            ok = 0;
            break;
        }
    if(ok)
    {
        cout << "Yes\n";
    for(int i = 2; i <= n; ++i)
        cout << tata[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 321232
#include <bits/stdc++.h>
using namespace std;
const int MAXN=159;
int MOD;
inline int add(int a,int b) {return a+=b,a>=MOD?a-MOD:a;}
inline int del(int a,int b) {return a-=b,a<0?a+MOD:a;}
inline int mul(int a,int b) {return 1LL*a*b%MOD;}
inline int quicKpower(int a,int b)
{
	int i,s;
	for(i=a,s=1;b;b>>=1,i=mul(i,i))
		if(b&1) s=mul(s,i);
	return s;
}
int N,K;
int dp_[MAXN][MAXN],dp__[MAXN<<1][MAXN][MAXN];
inline void solve_even()
{
	int ans_=0,ans__=0;
	K>>=1,dp_[0][0]=1;
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<=K;j++) dp_[i][0]=add(dp_[i][0],dp_[i-1][j]);
		for(int j=0;j<K;j++) dp_[i][j+1]=add(dp_[i][j+1],dp_[i-1][j]);
	}
	for(int i=0;i<=K;i++) ans_=add(ans_,dp_[N>>1][i]),ans__=add(ans__,dp_[(N+1)>>1][i]);
	cout<<mul(ans_,ans__)<<endl;
	return;
}
inline void solve_odd()
{
	int p,ans=0;
	dp__[0][0][0]=1;
	for(int i=2;i<=N+K;i+=2)
	{
		for(int j=0;j<=N;j++)
			for(int k=0;k<=K+1;k++) dp__[i][0][0]=add(dp__[i][0][0],dp__[i-2][j][k]);
		if(i<=N)
			for(int j=0;j<=N;j++)
				for(int k=0;k<=K+1;k++) dp__[i][j+1][0]=add(dp__[i][j+1][0],dp__[i-2][j][k]);
		if(i>=K+1)
			for(int j=0;j<=N;j++)
			{
				for(int k=1;k<=K;k++) dp__[i][0][k+1]=add(dp__[i][0][k+1],dp__[i-2][j][k]);
				dp__[i][0][0]=add(dp__[i][0][0],dp__[i-2][j][0]);
			}
		if(i<=N&&i>=K+1)
			for(int j=0;j<=N;j++)
				for(int k=0;max(k,j+1)<=K;k++) dp__[i][j+1][max(k,j+1)+1]=add(dp__[i][j+1][max(k,j+1)+1],dp__[i-2][j][k]);
		p=i;
	}
	for(int i=0;i<=N;i++)
		for(int j=0;j<=K+1;j++) ans=add(ans,dp__[p][i][j]);
	cout<<ans<<endl;
	return;
}
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>N>>K>>MOD;
	if(!(K&1)) solve_even();
	else solve_odd();
	return 0;
}

Measured memory_bytes: 29952
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

#define ll signed long long

int main() {
  int N;
  cin >> N;
  ll A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  ll dp[3][2][N];  // skip, used now, id
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < N; ++k) {
        dp[i][j][k] = -1 * (1ll << 60);
      }
    }
  }

  dp[1][0][0] = 0;
  dp[0][1][0] = A[0];
  for (int skip = 0; skip < 3; ++skip) {
    for (int i = 0; i < N; ++i) {
      for (int used = 0; used < 2; ++used) {
        if (used) {
          ll &m = dp[skip][used][i];
          if (i < 1) continue;
          m = max(m, dp[skip][0][i - 1] + A[i]);
          if (i < 2) continue;
          m = max(m, dp[skip][1][i - 2] + A[i]);

          if (skip < 1) continue;
          m = max(m, dp[skip - 1][0][i - 2] + A[i]);
          if (i < 3) continue;
          m = max(m, dp[skip - 1][1][i - 3] + A[i]);

          if (skip < 2) continue;
          m = max(m, dp[skip - 2][0][i - 3] + A[i]);
          if (i < 4) continue;
          m = max(m, dp[skip - 2][1][i - 4] + A[i]);
        } else {
          ll &m = dp[skip][used][i];
          if (i < 1) continue;
          m = max(m, dp[skip][1][i - 1]);

          if (skip < 1) continue;
          m = max(m, dp[skip - 1][0][i - 1]);
          if (i < 2) continue;
          m = max(m, dp[skip - 1][1][i - 2]);

          if (skip < 2) continue;
          m = max(m, dp[skip - 2][0][i - 2]);
          if (i < 3) continue;
          m = max(m, dp[skip - 2][1][i - 3]);
        }
      }
    }
  }

  ll ans = -(1ll << 60);
  if (N & 1) {
    ans = max(ans, dp[1][0][N - 1]);
    ans = max(ans, dp[2][1][N - 1]);
  } else {
    ans = max(ans, dp[0][0][N - 1]);
    ans = max(ans, dp[1][1][N - 1]);
  }

  // for (int i = 0; i < 3; ++i) {
  //   for (int j = 0; j < 2; ++j) {
  //     cout << i << " " << j << endl;
  //     for (int k = 0; k < N; ++k) {
  //       cout << dp[i][j][k] << " ";
  //     }
  //     cout << endl;
  //   }
  // }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

const int Nmax = 1e6 + 5;

int n;
int a[Nmax];

bool bad(int l, int c) { return a[l] <= c; }

int main()
{
 //   freopen("input", "r", stdin);
    cin.sync_with_stdio(false);
    cin.tie(0);

    int i, j;

    cin >> n;
    for(i=1; i<=n; ++i) cin >> a[i];
    sort(a+1, a+n+1);

    for(i=n; i; --i)
        if(bad(i, n-i)) break;
    ++i;

    /// vreau sa aflu (i, n-i)

    for(j=i-1; j; --j)
        if(bad(j, n-i)) break;

    int ans1 = (j-i) % 2;
    int ans2 = (a[i] - (n-i)) % 2;

    if(ans1 && ans2) cout << "Second\n";
        else cout << "First\n";

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w, n; cin >> h >> w >> n;
    map<P,int> mp;
    rep(i,n) {
        int a, b; cin >> a >> b;
        a--; b--;
        for (int i = a-1; i <= a+1; i++) {
            for (int j = b-1; j <= b+1; j++) {
                if (i-1 >= 0 && i+1 < h && j-1 >= 0 && j+1 < w) {
                    mp[P(i,j)]++;
                }
            }
        }
    }
    vll ans(10,0);
    ans[0] = (ll)(h-2) * (w-2);
    for (auto p : mp) {
        ans[p.second]++;
        ans[0]--;
    }
    rep(i,10) cout << ans[i] << endl;
}

Measured memory_bytes: 59720
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    S = S[::-1]

    dp = [0] * 13
    dp[0] = 1
    p = 1

    for i, c in enumerate(S):
        dp, dp_prev = [0] * 13, dp
        for k in range(13):
            if c == '?':
                for j in range(10):
                    dp[(p * j + k) % 13] = (dp[(p * j + k) % 13] + dp_prev[k]) % MOD
            else:
                dp[(p * int(c) + k) % 13] = (dp[(p * int(c) + k) % 13] + dp_prev[k]) % MOD

        p = p * 10 % 13

    print(dp[5])
    return


if __name__ == '__main__':
    main()


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int A,B,C,ans;

    cin>>A>>B>>C;

    ans=C-(A-B);
    if(ans<0)ans=0;

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
# include<bits/stdc++.h>
 
using namespace std;
 
# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 
# define S second
# define F first
# define kill(x) return(cout << x << endl, 0LL)
# define debug(x) cerr<< #x << " = " << x << endl
# define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
# define tdebug(x, y, z) cerr<< #x << " = " << x  << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define MP make_pair
# define uop(x, y) pii(min(x, y), max(x, y))
 
const int MAXN = 100 * 1000 + 10;
int n, a, b, 
    h[MAXN];

bool check(int x)
{
	int cnt = 0;
	for (int i = 0; i < n; i ++)
		cnt += max(0LL, ((h[i] - x * b) + a - 1) / a);
	return cnt <= x;
}

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

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

	int l = 0, r = (1e18 + 10) / b;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r << endl;
	

	return 0;
}
 



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

#define FOR(i,a,b) for(int i = (a); i< (b); i++)
#define REP(i,n) FOR(i,0,n)
#define endl '\n'
#define ll long long

using namespace std;

const ll MAXN = 1e7+100;
const ll MOD = 1e9+7;
int polje[MAXN];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    REP(i,n){
        int x;
        cin>>x;
        polje[x]++;
    }
    if(n%2==0){
        int poc = 1;
        REP(i,n/2){
            if(polje[poc+2*i]!=2){
                cout<<0;
                return 0;
            }
        }
    }
    else{
        int poc = 2;
        if(polje[0]!=1){
            cout<<0;
            return 0;
        }
        REP(i,n/2){
            if(polje[poc+2*i]!=2){
                cout<<0;
                return 0;
            }
        }
    }
    ll sol = 1;
    FOR(i,1,n/2+1){
        sol=(sol*2LL)%MOD;
    }
    cout<<(sol+MOD)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 640
X,Y,Z,K=map(int, raw_input().split())
A=map(int, raw_input().split())
B=map(int, raw_input().split())
C=map(int, raw_input().split())

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

L=[]
for ia, a in enumerate(A):
	for ib, b in enumerate(B):
		for ic, c in enumerate(C):
			if (ia+1)*(ib+1)*(ic+1)<=K:
				L.append(a+b+c)
			else:
				break

L.sort(reverse=True)

for i in range(K):
	print L[i]

Measured memory_bytes: 39452
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    var max = 0
    val l = sc.nextInt()
    val x = l / 3.0
    println("%f".format(x * x * x))
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31392
fn main(){
    let x: i32 = read();
    let ans = if x >= 30 {"Yes"} else {"No"};
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.trim().parse().unwrap()
}


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

int main()
{
    int n;
    cin >> n;
    int d[n][2];
    for (int i = 0; i < n; i++)
        cin >> d[i][0] >> d[i][1];

    int c = 0;
    int m = c;
    for (int i = 0; i < n; i++)
    {
        if (d[i][0] == d[i][1])
        {
            c++;
            if (c > m)
                m = c;
        }
        else
        {
            c = 0;
        }
    }

    string ans;
    if (m >= 3)
        ans = "Yes";
    else
        ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

long long fin[53];

int main() {

    ios::sync_with_stdio(false);

    long long n;
    cin >> n;

    for(int i = 1; i <= 50; i++) {
        fin[i] = 50-i;
    }

    long long cons = n/50;

    for(int i = 1; i <= 50; i++) {
        fin[i] += cons;
    }

    for(int i = 1; i <= (n%50); i++) {
        fin[i]++;
    }

    cout << 50 << '\n';

    for(int i = 1; i <= 50; i++) {
        cout << fin[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007
#define int unsigned long long

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

int pow_kai(int a, int n)
{ //aのn乗を計算します。
    int x = 1ull;
    while (n > 0ull)
    { //全てのbitが捨てられるまで。
        if (n & 1ull)
        { //1番右のbitが1のとき。
            x = x * a;
        }
        if (x >= 1125899906842624)
        {
            return -1;
        }
        if (x == 0)
        {
            return -1;
        }
        a = a * a;
        n >>= 1ull; //bit全体を右に1つシフトして一番右を捨てる。
    }
    return x;
}

signed main()
{
    int N, P;
    cin >> N >> P;
    if (N == 1)
    {
        cout << P << endl;
        return 0;
    }
    int ans = 1;
    for (int i = 2; i <= P; i++)
    {
        int tmp = pow_kai(i, N);
        if (tmp < 0)
        {
            continue;
        }
        if (tmp > P)
        {
            break;
        }
        if (P % tmp == 0 && tmp != 0)
        {
            P /= tmp;
            ans *= i;
            i--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;

const int MAX_N = 10000000;

int h[MAX_N];

int main()
{
	long long res=0,n;
	bool flag = false;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	sort(h,h+n,greater<int>());
	int i;
	for(i=0;i<n/4;i++){
		for(int j=0;j<4;j++){
			if(h[4*i+j]-i <= 0){
				flag = true;
				break;
			}
			res += h[4*i+j]-i;
		}
		if(flag == true){
			break;
		}
	}
	int j=0;
	while(4*i + j < n && flag == false){
		if(h[4*i+j]-i > 0){
			res += h[4*i+j]-i;
			j++;
		}else{
			flag = true;
		}
	}
	cout << res+1 << "\n";
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
ll N,K;
ll ans = 0;
void solve(){
  ll n = N;
  ll mi = 0, ma = 0;
  for(ll i=0 ; i<N+1 ; i++){
    mi += i;
    ma += n--;
    if(K <= i+1){
      ans += ma - mi + 1 % mod;
      ans %= mod;
    }
  }
}
int main(){
  cin >> N >> K;
  solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
 
        int kazu = int.Parse(ReadLine());
        int[] xza = new int[kazu];
        int[] yza = new int[kazu];
        int[] hig = new int[kazu];
        for(int i=0;i<kazu;i++){
            string[] temp = ReadLine().Split(' ');
            xza[i] = int.Parse(temp[0]);
            yza[i] = int.Parse(temp[1]);
            hig[i] = int.Parse(temp[2]);
        }
        
        //降順ソート
        for(int j=0;j<150;j++){
            for(int i=0;i<kazu-1;i++){
                if(hig[i] < hig[i+1]){
                    int temp = hig[i];
                    hig[i] = hig[i+1];
                    hig[i+1] = temp;
                    
                    temp = xza[i];
                    xza[i] = xza[i+1];
                    xza[i+1] = temp;
                    
                    temp = yza[i];
                    yza[i] = yza[i+1];
                    yza[i+1] = temp; 
                }
            }
        }
        
        int tyoux= -1;
        int tyouy= -1;
        int tyouh= -1;
        for(int x=0;x<=100;x++){
            for(int y=0;y<=100;y++){
                int count = 0;
                int suitei = hig[0] + Abs(x - xza[0]) + Abs(y - yza[0]);
                for(int i=1;i<kazu;i++){
                    int takasa = Max(suitei - Abs(x - xza[i]) - Abs(y - yza[i]),0);
                    if(takasa == hig[i]){
                        count++;
                    }
                }
                if(count == kazu-1){
                    if(suitei > tyouh){
                        tyoux = x;
                        tyouy = y;
                        tyouh = suitei;
                    }
                }
            }
        }
        WriteLine("{0} {1} {2}",tyoux,tyouy,tyouh);
    }
}

Measured memory_bytes: 13268
using System;
using static System.Math;
public class hello
{
	static int jmax = 1 << 16;
	public static void Main()
	{
		while (true)
		{
			string[] line = Console.ReadLine().Trim().Split(' ');
			var n = int.Parse(line[0]);
			var c = int.Parse(line[1]);
			if (n == 0 && c == 0) break;
			var a = getArray(n);
			var b = getArray(c);
			var dp = new int[n + 1, jmax];
			for (int i = 0; i < n + 1; i++)
				for (int j = 0; j < jmax; j++) dp[i, j] = -1;
			var ans = getAns(dp, a, b, n, c);
			Console.WriteLine(ans);
		}
	}
	static int getAns(int[,] dp, int[] a, int[] b, int n, int c)
	{
		dp[0, 0] = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < jmax; j++)
				if (dp[i, j] != -1)
				{
					var nj = j | a[i];
					for (int k = 0; k < c; k++)
					{
						var t2 = nj & (~b[k]);
						var pt = countBit(nj & b[k]);
						dp[i + 1, t2] = Max(dp[i + 1, t2], dp[i, j] + pt);
					}
				}
		var ans = 0;
		for (int i = 0; i < jmax; i++)
			ans = Max(ans, dp[n, i]);
		return ans;
	}
	static int countBit(int bits)
	{
		bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
		bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
		bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
		bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
		return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
	}
	static int[] getArray(int n)
	{
		var a = new int[n];
		for (int i = 0; i < n; i++)
		{
			var s = Console.ReadLine().Trim().Replace(" ", "");
			a[i] = Convert.ToInt32(s, 2);
		}
		return a;
	}
}



Measured memory_bytes: 44656
#include <bits/stdc++.h>
using namespace std;
#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)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

vector<long long> divisor(long long n) {
  vector<long long> d;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      d.push_back(i);
      if(i != n / i) d.push_back(n / i);
    }
  }
  sort(d.begin(), d.end());
  return d;
}

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  vector<int>cnt(1000009);
  rep(i,n){
    cin>>a[i];
    cnt[a[i]]++;
  }

  int ans=0;
  rep(i,n){
    auto mp=divisor(a[i]);
    cnt[a[i]]--;
    bool ok=true;
    for(auto x:mp){
      if(cnt[x]>0)ok=false;
    }
    if(ok)ans++;
    cnt[a[i]]++;
  }

  cout<<ans<<endl;

  return(0);
}


Measured memory_bytes: 8008
using System;
using System.Collections.Generic;
using System.Linq;
//using System.Numerics;
class Program
{     
    const int INF = short.MaxValue;
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int m = int.Parse(inputs[1]);
        int[][] distance =
            Enumerable.Range(0, n)
            .Select(x => new int[n].Select(y => INF).ToArray())
            .ToArray();
        foreach(int i in Enumerable.Range(0, n))
            distance[i][i] = 0;
        var node =
            Enumerable.Range(0, m)
            .Select(x => Console.ReadLine().Split()
                .Select(int.Parse).ToArray())
            .Select(x => new {a = x[0] - 1, b = x[1] - 1, dis = x[2]})
            .ToArray();
        foreach(var item in node)
        {
            distance[item.a][item.b] = item.dis;
            distance[item.b][item.a] = item.dis;
        }
        foreach(int i in Enumerable.Range(0, n))
            foreach(int j in Enumerable.Range(0, n))
                foreach(int k in Enumerable.Range(0, n))
                {
                    distance[j][k] = Math.Min(distance[j][k], distance[j][i] + distance[i][k]);
                }
        //System.Console.WriteLine(string.Join("\n", distance.Select(x => string.Join(",", x))));
        int result = node.Count(x => x.dis != distance[x.a][x.b]);
        System.Console.WriteLine(result);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 13632
import std.stdio,
       std.string,
       std.conv;

void main() {
  int[] buf = readln.chomp.split.to!(int[]);
  int N = buf[0], A = buf[1], B = buf[2];
  int d = B - A;

  writeln(d & 1 ? "Borys" : "Alice");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],cnt=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ind=n/2; 
	cout<<a[ind]-a[ind-1];
	
	
}

Measured memory_bytes: 640
#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
typedef long long ll;
int main(){
	ll t,m,a,b,sum=0;
	double c,d;
	cin>>t>>m;
	d=m*1.0;
	while(t--){
		cin>>a>>b;
		c=sqrt(pow(a,2)+pow(b,2));
		if(c<=d)
		sum++;
	}
	cout<<sum;
}

Measured memory_bytes: 3188