akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct Combination {
	vector<int64_t> fact, rfact;
	Combination(int sz) : fact(sz + 1), rfact(sz + 1) {
		fact[0] = 1;
		for(int i = 1; i < fact.size(); i++){
			fact[i] = fact[i - 1] * i % mod;
		}
		rfact[sz] = inv(fact[sz]);
		for(int i = sz - 1; i >= 0; i--){
			rfact[i] = rfact[i + 1] * (i + 1) % mod;
		}
	}
	int64_t inv(int x) const {
		return pow(x, mod - 2);
	}
	int64_t pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while(n > 0){
			if(n & 1) (ret *= x) %= mod;
			(x *= x) %= mod;
			n >>= 1;
		}
		return (ret);
	}
	int64_t P(int n, int r) const {
		if(r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % mod);
	}

	int64_t C(int p, int q) const {
		if(q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % mod * rfact[p - q] % mod);
	}

	int64_t H(int n, int r) const {
		if(n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	Combination c(n);
	int ans = 0;
	rep(i, 0, n - k + 1){
		ans += c.C(n - i - 1, k - 1) * a[i] % mod;
		ans %= mod;
	}
	reverse(a.begin(), a.end());
	rep(i, 0, n - k + 1){
		ans += (mod - c.C(n - i - 1, k - 1) * a[i] % mod) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include<cmath>

using namespace std;

void Solution()
{
    int n;
    
    cin>>n;
    
    while(n--)
    {
        double xa, ya, ra;
        double xb, yb, rb;
        double d;
        
        cin>>xa>>ya>>ra>>xb>>yb>>rb;
        
        d = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)); // distance of o1 and o2
        
        if (d > ra + rb)
        {
            cout << "0" << endl;
        }
        else if (d >= fabs(ra - rb)) // && ra + rb >= d
        {
            cout << "1" << endl;
        }
        else if (ra > rb) // d < ra - rb
        {
            cout << "2" << endl;
        }
        else
        {
            cout << "-2" << endl;
        }
    }
}

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

Measured memory_bytes: 1232
w = int(raw_input())
n = int(raw_input())

ans = [i for i in range(1, w+1)]

for i in range(n):
  a, b = map(int, raw_input().split(','))

  ans[a-1], ans[b-1] = ans[b-1], ans[a-1]

for i in ans:
  print i

Measured memory_bytes: 6276
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int n, m, a; cin>>n>>m>>a;
        if(n == 0) return 0;
        vector<T> v(m);
        for(int i=0; i<m; i++){
            int h, p, q; cin>>h>>p>>q;
            v[i] = T(h, p, q);
        }

        sort(v.rbegin(), v.rend());

        int height = 1e9;
        for(int i=0; i<m; i++){
            int h, p, q;
            tie(h, p, q) = v[i];

            if(h <= height){
                if(p == a){
                    a = q;
                    height = h - 1;
                }
                else if(q == a){
                    a = p;
                    height = h - 1;
                }
            }
        }

        cout << a << endl;
    }
}


Measured memory_bytes: 3056
n = gets.to_i
a = gets.chomp.split.map(&:to_i).sort!
b = gets.chomp.split.map(&:to_i).sort!
c = gets.chomp.split.map(&:to_i).sort!

res = 0
n.times do |j|
  i = a.bsearch_index {|x| - x <= - b[j] } || n
  k = c.bsearch_index {|x| x > b[j] } || n
  res += i * (n - k)
end
puts res

Measured memory_bytes: 29780
//Catchharsh
    //I Luv Kunj017
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    int main()
    {   
         IOS;
         ll r;
         cin>>r;
         cout<<3*r*r;
         
    }

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

int n;
ll k;
ll vs[100000+10];

ll memo[50][2];
ll solve(int b, int isMax) {
  if(b < 0) {
    return 0;
  }
  ll &res = memo[b][isMax];
  if(res < 0) {
    ll res0 = 0;
    ll res1 = 0;
    REP(i, n) {
      res0 += vs[i] & (1LL << b);
      res1 += ~vs[i] & (1LL << b);
    }
    ll cur = k & (1LL << b);
    if(isMax && cur == 0) {
      res0 += solve(b-1, isMax);
      res = res0;
    } else {
      res0 += solve(b-1, 0);
      res1 += solve(b-1, isMax);
      res = max(res0, res1);
    }
  }
  return res;
}

int main(void) {
  scanf("%d%lld", &n, &k);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }
  memset(memo, -1, sizeof memo);
  ll res = solve(45, 1);
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 1024
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(l[k-1])

Measured memory_bytes: 61776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll H;
    cin >> H;
    ll ans = 0;
    ll num = 1;
    while(H){
        ans += num;
        H /= 2;
        num *= 2;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
def diff(tmp):
    if tmp > cnt:
        return tmp
    else:
        return  cnt

list = list(input())

cnt = 0
tmp = 0
for row in list:
    if row in ('ACGT'):
        tmp += 1
        cnt = diff(tmp)
    else:
        cnt = diff(tmp)
        tmp = 0

print(cnt)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;
int main()
{
    int N;
    int n;
    while(true)
    {
        cin>>N;
        if(N==0)
        {
            break;
        }
        int i=0;
        for(int a=1;a<N;a++)
        {   
            n=0;
            for(int b=a;n<N;b++)
            {
                n=n+b;
                if(n==N)
                {
                    i=i+1;
                }
            }
        }
        cout<<i<<endl;
            
    }
}

Measured memory_bytes: 2956
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

int main()
{
  lint x;
  cin >> x;


  std::vector<lint> primes(100003,0);
  primes[0] = 2;
  for(int i=1;i<primes.size();i++){
    primes[i] = primes[i-1] + 1;
  }

  lint cnt=0;
  while(1){
    if(primes[cnt]!=0){
      for(int i=cnt+1;i<primes.size();i++){
        if(primes[i]%primes[cnt]==0){
          primes.erase(primes.begin()+i);
        }
      }
    }
    cnt++;
    if(cnt==primes.size()) break;
  }

  REP(i,primes.size()){
    if(primes[i]>=x){
      cout << primes[i] << "\n";
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;

int main(){
  int a,b;
  while(cin>>a>>b,a+b){
    int MAP[a+1][b+1]={};
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      MAP[x][y]=1;
    }
    queue<pair<int,int> >que;
    que.push(mp(1,1));
    int ans=0;
    while(!que.empty()){
      pair<int,int>now=que.front();
      que.pop();
      if(now.F==b&&now.S==a){
	ans++;
	continue;
      }
      if(now.F+1>0&&now.F+1<=b&&!MAP[now.S][now.F+1]){
	que.push(mp(now.F+1,now.S));
      }
      if(now.S+1>0&&now.S+1<=a&&!MAP[now.S+1][now.F]){
	que.push(mp(now.F,now.S+1));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
    // int a = atoi(argv[1]);
    // string s = argv[2];
    int a;
    string s;
    cin>>a;
    cin>>s;
    if (a<3200){
        cout<<"red"<<endl;
    } else {
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    while(cin>>n,n){
        vector<string> s(n);
        rep(i,n)cin>>s[i];
        int mi=-inf;
        int ma=inf;
        rep(i,n){
            if(s[i]=="x"){
                if(i>0&&s[i-1]=="x"||i<n-1&&s[i+1]=="x"){
                    cout<<"none"<<endl;
                    goto LOOP;
                }
                if(i%2==0){
                    if(i>0)ma=min(ma,stoll(s[i-1])-1);
                    if(i<n-1)ma=min(ma,stoll(s[i+1])-1);
                }
                else{
                    mi=max(mi,stoll(s[i-1])+1);
                    if(i<n-1)mi=max(mi,stoll(s[i+1])+1);
                }
            }
            else if(i%2&&(s[i-1]!="x"&&stoi(s[i-1])>stoi(s[i])||i<n-1&&s[i+1]!="x"&&stoi(s[i+1])>stoi(s[i]))){
                cout<<"none"<<endl;
                goto LOOP;
            }
            else if(i%2==0&&(i>0&&s[i-1]!="x"&&stoi(s[i-1])<stoi(s[i])||i<n-1&&s[i+1]!="x"&&stoi(s[i+1])<stoi(s[i]))){
                cout<<"none"<<endl;
                goto LOOP;
            }
            // cout<<mi<<" "<<ma<<endl;
        }
        if(ma==mi)cout<<ma<<endl;
        else if(ma<mi)cout<<"none"<<endl;
        else cout<<"ambiguous"<<endl;
        LOOP:;
    }
}


Measured memory_bytes: 3292
from bisect import *
n = int(input())
l = sorted(list(map(int, input().split())))
res = 0
for i in range(n-1):
    for j in range(i + 1, n):
        a, b = l[i], l[j]
        c_cnt = bisect_left(l, a + b) - j - 1
        res += c_cnt
print(res)


Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> snk(n, 0);
    for(int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for(int i = 0; i < d; i++) {
            int inp;
            cin >> inp;
            snk[inp - 1] += 1;
        }
    }
    cout << count(all(snk), 0) << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
// constexpr int MOD = 1e9+7;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    ll x = 1, y = 1;
    Rep(n){
        Cin(int, a, b);
        ll k = max((x+a-1)/a, (y+b-1)/b);
        x = k*a, y = k*b;
    }
    Cout(x+y);
}


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

int main(){

    string S, T;
    cin >> S;
    cin >> T;

    int index = -1;
    for(int i = 0; i < S.length() - T.length() + 1; i++){
        bool match = true;
        for(int j = 0; j < T.length(); j++){
            if(S[i + j] != T[j] && S[i + j] != '?') match = false;
        }
        if(match) index = i;
    }

    if(index == -1){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for(int i = 0; i < S.length(); i++){
        if(i == index){
            cout << T;
            i += T.length() - 1;
        }else if(S[i] == '?'){
            cout << "a";
        }else{
            cout << S[i];
        }
    }
    cout << endl;

    return 0;
}

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

int main()
{
    int A, B;

    cin >> A >> B;

    bool flg[3] = {false};

    flg[A - 1] = true;
    flg[B - 1] = true;

    for (int i = 0; i < 3; i++)
    {
        if (flg[i] == false)
        {
            cout << i + 1 << endl;
        }
    }

    return 0;
}

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

int main()
{

    while (1)
    {
        int h, w;
        cin >> h >> w;

        if (h == 0 && w == 0)
            break;

        string oddWid = "", evenWid = "";
        for (int i = 0; i < w; i++)
        {
            if (i % 2 == 0)
            {
                oddWid += ".";
                evenWid += "#";
            }
            else
            {
                oddWid += "#";
                evenWid += ".";
            }
        }

        for (int i = 0; i < h; i++)
        {
            if (i % 2 == 0)
                cout << evenWid << endl;
            else
                cout << oddWid << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
import sys
n,y=map(int,input().split())

for i in range(n+1):
    for j in range(n+1-i):
        tmp=1000*(n-i-j)+5000*i+10000*j
        if tmp==y:
            print(j,i,n-i-j)
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=18,S=65540,mo=1e9+7;
ll qmi(ll x,ll n)
{
	ll t=1;
	for(x%=mo;n;n>>=1,x=x*x%mo) if(n&1) t=t*x%mo;
	return t;
}
void inc(ll &x,ll y){x=(x+y)%mo;}
int n,m,a[N],_2[N],use[S];
bool cmp(int x,int y){return x>y;}
ll f[N][S],fac[S],ifac[S];
ll C(ll m,ll n) {return (m < n || n < 0) ? 0 : fac[m] * ifac[n] % mo * ifac[m-n] % mo;}
int main()
{
	n=read(),m=read();
	_2[0]=1;fo(i,1,n) _2[i]=_2[i-1]<<1;
	fac[0]=1;
	fo(i,1,_2[n]) fac[i]=fac[i-1]*i%mo;
	ifac[_2[n]]=qmi(fac[_2[n]],mo-2);
	fd(i,_2[n]-1,0) ifac[i]=ifac[i+1]*(i+1)%mo;
	fo(i,1,m) a[i]=read();
	sort(a+1,a+m+1,cmp);
	fo(s,0,_2[n]-1)
		fo(j,1,n) if(s & _2[j-1]) use[s] += _2[j-1];
	f[0][0]=1;
	fo(i,1,m)
		fo(s,0,_2[n]-1) if(f[i-1][s])
		{
			inc(f[i][s], f[i-1][s]);
			fo(j,1,n) if(!(s & _2[j-1]))
				inc(f[i][s ^ _2[j-1]], f[i-1][s] * C(_2[n] - a[i] - use[s], _2[j-1] - 1) % mo * fac[_2[j-1]] % mo);
		}
	ll ans = 0;
	fo(s,0,_2[n]-1)
	{
		int p = 1, rem = _2[n] - 1 - use[s];
		fo(j,1,n) if(s & _2[j-1]) p = -p;
		ans = (ans + p * f[m][s] % mo * fac[rem] % mo) % mo;
	}
	ans = (ans + mo) % mo;
	printf("%lld\n",ans * _2[n] % mo);
	return 0;
}

Measured memory_bytes: 9728
from collections import deque
h, w = map(int, input().split())
maze = []
white = 0
que = deque([])
visited = []
dirs = [[-1, 0], [1, 0], [0, -1], [0, 1]]
ans = -1

for i in range(h):
  temp = list(input())
  white += temp.count('.')
  maze.append(temp)

for i in range(h):
  visited.append([0]*w)

visited[0][0] = 1
que.append([0, 0, 1])

while len(que):
  y, x, count = que.popleft()
  # print(y, x)
  if x == w-1 and y == h-1:
    ans = white - count
    break
  
  for dir in dirs:
    if y+dir[0] < 0 or y+dir[0] >= h or x+dir[1] < 0 or x+dir[1] >= w:
      continue

    if maze[y+dir[0]][x+dir[1]] == '.' and visited[y+dir[0]][x+dir[1]] == 0:
      visited[y+dir[0]][x+dir[1]] = 1
      que.append([y+dir[0], x+dir[1], count+1])

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 29;
const double EPS = 1e-10;

int x[200000];
int dis[200000];

int main(){
  int T, n, k;
  cin >> T;
  while(T--){
    cin >> n >> k;
    rep(i, n) cin >> x[i];
    rep(i, n - 1){
      dis[i] = x[i+1] - x[i];
    }
    sort(dis, dis + n - 1);
    int res = x[n - 1] - x[0];
    rep(i, k - 1){
      if(n - 2 - i < 0) break;
      res -= dis[n-2-i];
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1648
#include <iostream>

int main(int argc, char const* argv[]) {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N, D, X;
    std::cin >> N >> D >> X;
    int sum = X;
    for (int i=0; i<N; i++) {
        int Ai;
        std::cin >> Ai;
        sum += (D-1) / Ai + 1;
    }
    std::cout << sum << '\n';
    return 0;
}


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

const int maxn = 2010, inf = 1000000;

int res[maxn][maxn], n, m;
vector<int> g[maxn], c[maxn];

void dfs(int x, int pa) {
	for (auto t : g[x]) if (t != pa) {
		dfs(t, x);
		c[x].push_back(t);
	}
	
	res[x][0] = 1;
	for (int t : c[x]) {
		res[x][0] += res[t][0];
	}
	
	for (int h = 1; h <= m; h ++) {
		int fi = h - 1, sc = min(fi, m - h);
		int s = 0, d = 0;
		for (int t : c[x]) {
			s += res[t][sc];
			d = max(d, res[t][sc] - res[t][fi]);
		}
		res[x][h] = min(res[x][h - 1], s - d);
	}
}


int main() {
	//freopen("in.txt", "r", stdin);
	cin >> n >> m; m ++;
	for (int i = 0; i < n - 1; i ++) {
		int u, v; cin >> u >> v; 
		u --;
		v --;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int i = 0; i < maxn; i ++)
		for (int j = 0; j < maxn; j ++)
			res[i][j] = inf;
	dfs(0, -1);
	if (m == 1) cout << n - 1 << endl;
	else {
		int ans = inf;
		for (int i = 0; i < n; i ++) {
			ans = min(ans, n - res[i][0] + res[i][m]);
		}
		cout << ans << endl;
	}
//	cout << res[0][0] << endl;
	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main(int argc, char const* argv[])
{
  string s;
  cin>>s;

  REP(i,s.size()) cout << "x";
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  int l, x, y, t;
  while (cin >> s, s != "#") {
    l = s.size();
    y = 1;
    t = l-1;
    if (s[t] == 'h') {
      t -= 5;
      x = 0;
    } else {
      t -= 4;
      x = 90;
    }
    for (int i = t; i >= 0; --i) {
      y *= 2;
      if (s[i] == 'h') {
	i -= 4;
	x = 2*x - 90;
      } else {
	i -= 3;
	x = 2*x + 90;
      }
    }
    if (y > 1) {
      x /= 2;
      y /= 2;
    }
    if (y == 1) cout << x << endl;
    else cout << x << "/" << y << endl;
  }
  return 0;
}

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

int main(){
	int n;
	char mark;
	int num;
	int S[13], H[13], C[13], D[13];

	for(int i = 0; i < 13; i++){
		S[i] = H [i] = C[i] = D[i] = 0;
	}

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> mark >> num;
		if(mark == 'S'){
			S[num - 1] = 1;
		}
		else if(mark == 'H'){
			H[num - 1] = 1;
		}
		else if(mark == 'C'){
			C[num - 1] = 1;
		}
		else if(mark == 'D'){
			D[num - 1] = 1;
		}
	}


	for(int i = 0; i < 13; i++){
		if(S[i] == 0){
			cout << "S " << i + 1 << endl;
		}
	}
	for(int i = 0; i < 13; i++){
		if(H[i] == 0){
			cout << "H " << i + 1 << endl;
		}
	}
	for(int i = 0; i < 13; i++){
		if(C[i] == 0){
			cout << "C " << i + 1 << endl;
		}
	}
	for(int i = 0; i < 13; i++){
		if(D[i] == 0){
			cout << "D " << i + 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod = 1000000007;

const int MAX = 300005;
using namespace std;

	

//Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1
///    *check mod
///    *check input file  
///    *NO IDIOT SUBMISSION
int main(){
	IOS ;
	int n ; cin >> n ;
	vi p(n) ;
	for(int i = 0 ; i < n ; i++) cin  >> p[i] ;
	vi s = p ;
	sort(s.begin() , s.end()) ;
	if(p == s) return cout << "YES" <<endl , 0 ; 
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			swap(p[i] , p[j]) ;
			if(s == p) return cout << "YES" <<endl , 0;
			swap(p[i] , p[j]) ;
		}
	}
	cout << "NO" << endl ;
	return 0;
}





Measured memory_bytes: 256
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  string str;

  cin>>str;
  
  int a[26]={ };

  for(int i=0;i<str.length();i++){

    a[str[i]-'a']++;

  }

  int cnt=0;

  for(int i=0;i<26;i++){

    if(!(a[i]%2==0)){
      cnt++;
    }
  }

  if(!cnt){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a,b,c;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c;
	cout<<b+min(a+b+1,c)<<endl;
	return 0;
}

Measured memory_bytes: 256
def fac(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr


N=int(input())
ans=0
A=fac(N)
for i in range(len(A)):
  p=2*A[i][1]
  q=p**0.5
  if A[i][0]==1:
    ans+=0
  elif type(q)=="int":
    ans+=q-1
  else:
    q=q//1
    if q*(q+1)<=p:
      ans+=q
    else:
      ans+=q-1
print(int(ans))

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };


int a, b, n;
VI pm;

int main() {
	pm.push_back( 2 );
	for ( int i = 3; i < 9000000; i += 2 ) {
		bool can_add = true;
		for ( int j = 0; j < pm.size() && pm[ j ] * pm[ j ] <= i; j++ ) {
			if ( !( i % pm[ j ] ) ) {
				can_add = false;
				break;
			}
		}
		if ( can_add ) {
			pm.push_back( i );
		}
	}
	while ( ~scanf( "%d %d %d", &a, &b, &n ) && a && b && n ) {
		while ( n ) {
			n -= binary_search( pm.begin(), pm.end(), a );
			if ( !n ) {
				printf( "%d\n", a );
				break;
			}
			a += b;
		}
	}
	return 0;
}

Measured memory_bytes: 5848
//
//  main.cpp
//  atcoder166
//
//  Created by zer0 on 2020/05/03.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
    int n,m;
    int ans=0;
    cin >> n >> m;
    
    vector<long long> H(n,0), h(n,0), A(m,0), B(m,0);
    
    for(int i=0;i<n;i++){
        cin >> H[i];
    }
    for(int i=0;i<m;i++){
        cin >> A[i] >> B[i];
    }
    
    for(int i=0;i<m;i++){
        long long a=A[i]-1;
        long long b=B[i]-1;
        
        if(H[a]<=H[b]){
            h[a]++;
        }
        if(H[a]>=H[b]){
            h[b]++;
        }
    }
    for(int i=0;i<n;i++){
        if(h[i]<=0){
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6428
#include <iostream>
#include <string>
#include <vector>


using namespace std;
using ll = long long;
int main() {
	ll x;
	cin >> x;
	if (x <= 2) {
		cout << 2 << endl;
		return 0;
	}
	ll xx = 100004;
	vector<bool> prime(xx, true);
	prime[0] = false;
	prime[1] = false;
	for (ll i = 0; i < xx; ++i) {
		if (prime[i]) {
			for (ll j = i * 2; j < xx; j += i) {
				prime[j] = false;
			}
		}
	}
	for (ll i = 0; i < xx; ++i) {
		if(i >= x && prime[i]) {
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
open_list = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    open_list[a].append(b)
    open_list[b].append(a)

# 探索済みリスト
closed_list = [False] * N
closed_list[0] = True
cnt = 0
level = 1

# 深さ優先探索
def dfs(target):
    global cnt, level
    if all(closed_list):
        cnt += 1
        return
    # open_listリストのnode
    for node in open_list[target]:
        # 探索済みでない場合
        if closed_list[node] is False:
            # 探索開始
            closed_list[node] = True
            # 再帰
            level += 1
            dfs(node)
            level = 1
            # levalを戻す
            closed_list[node] = False
    return


dfs(0)
print(cnt)


Measured memory_bytes: 3064
package main

import "fmt"

func chmax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func main() {
	var n, W int
	fmt.Scan(&n, &W)
	w := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	sw := n * 3
	dp := make([][]int, n+1)
	for k := 0; k <= n; k++ {
		dp[k] = make([]int, sw+1)
	}
	for i := 0; i < n; i++ {
		for c := n - 1; c >= 0; c-- {
			for s := 0; s+(w[i]-w[0]) <= sw; s++ {
				chmax(&dp[c+1][s+(w[i]-w[0])], dp[c][s]+v[i])
			}
		}
	}
	ans := 0
	for c := 1; c <= n; c++ {
		wmax := W - w[0]*c
		for s := 0; s <= wmax && s <= sw; s++ {
			chmax(&ans, dp[c][s])
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
s=input()
s_list=list(s)

string=[]

for i, x in enumerate(s_list):
    if x=='0':
        string.append('0')
    if x=='1':
        string.append('1')
    if x=='B':
        if len(string) != 0 :
            string.pop()
        else: pass
        
string_out=''.join(string)

print(string_out)

Measured memory_bytes: 3060
K = int(input())

import collections as clt
import math
import itertools as itt

sum = 0

#print(v)

from functools import reduce

#def gvc(*numbers):
	#return reduce(math.gcd, numbers)
def gcd_list(numbers):
	return reduce(math.gcd, numbers)

for j in itt.product(range(1,K+1),repeat=3):
	sum += gcd_list(j)
print(sum)

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

using namespace std;

int INF = 1e9 + 5;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int total = min(k, a);
    k -= total;
    if (k > 0) {
        k -= min(k, b);
    }
    if (k > 0) {
        total -= min(k, c);
    }
    cout << total << endl;
}

Measured memory_bytes: 3648
import math

n, k = map(int, input().split(" "))
hs = sorted([int(input()) for _ in range(n)], reverse=True)

ans = 10000000000000
for i in range(n - k + 1):
    j = i + k - 1
    ans = min(hs[i] - hs[j], ans)

print(ans)

Measured memory_bytes: 14044
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	map<long long int, long long int> mp;
	long long int a;
	for (long long int i = 0; i < n; i++) {
		cin >> a;
		mp[a - 1]++;
		mp[a]++;
		mp[a + 1]++;
	}
	long long int MAX = -2;
	for (long long int i = -1; i < 100010; i++) {
		MAX = max(MAX, mp[i]);
	}
	cout << MAX << endl;
	return 0;
}

Measured memory_bytes: 6528
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  cin >> n;
  vector<ii> a(n * 2);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = 0;
  }
  for (int i = n; i < n * 2; ++i) {
    cin >> a[i].first;
    a[i].second = 1;
  }
  sort(a.begin(), a.end());
  vector<int> fact(n + 1);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = 1LL * fact[i - 1] * i % MOD;
  int ret = 1;
  vector<int> A;
  for (auto&  [_, k] : a) {
    if (SZ(A) && A.back() != k) {
      ret = 1LL * ret * SZ(A) % MOD;
      A.pop_back();
    } else {
      A.push_back(k);
    }
  }
  cout << ret << '\n';
  return 0;
}


Measured memory_bytes: 5372
#include <stdio.h>
#include <stdlib.h>
struct node_t {
	int key;
	struct node_t *next;
	struct node_t *prev;
};
typedef struct node_t Node;
static Node g_first, g_last;

void insert(int key) {
	Node *p;

	p = malloc(sizeof(Node));
	p->key = key;
	p->next = g_first.next;
	p->prev = &g_first;
	g_first.next->prev = p;
	g_first.next = p;
}

void delete_first(void) {
	Node *p;

	p = g_first.next;
	if (p != &g_last) {
		g_first.next = p->next;
		p->next->prev = &g_first;
		free(p);
	}
}

void delete_last(void) {
	Node *p;

	p = g_last.prev;
	if (p != &g_first) {
		g_last.prev = p->prev;
		p->prev->next = &g_last;
		free(p);
	}
}

void delete_key(int key) {
	Node *p;

	for (p = g_first.next; p != &g_last; p = p->next) {
		if (p->key == key) {
			p->prev->next = p->next;
			p->next->prev = p->prev;
			free(p);
			break;
		}
	}
}

void print_node(void) {
	Node *p;
	const char *fmt = "%d";

	for (p = g_first.next; p->key >= 0; p = p->next) {
		printf(fmt, p->key);
		fmt = " %d";
	}
	putchar('\n');
}

int main(void) {
	int n, key;
	char in[20];

	g_first.next = &g_last;
	g_last.prev = &g_first;
	g_first.key = g_last.key = -1;
	scanf("%d ", &n);
	while (n--) {
		scanf("%s%d", in, &key);
		if (in[0] == 'i') {
			insert(key);
		} else {
			if (in[6] == '\0') {
				delete_key(key);
			} else if (in[6] == 'F') {
				delete_first();
			} else {
				delete_last();
			}
		}
	}
	print_node();
	return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N;
int A[220000];
multiset<int> ms;

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++)cin >> A[i];
    sort(A, A + N);
    reverse(A, A + N);
    for (int i = 0; i < N; i++)ms.insert(A[i]);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        auto it = ms.find(A[i]);
        if (it == ms.end())continue;
        ms.erase(it);
        int n = 1;
        while (n <= A[i])n <<= 1;
        it = ms.find(n - A[i]);
        if (it == ms.end())continue;
        ms.erase(it);
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11264
S = input()

def word_check(S):
    for s in S:
        if s.isupper():
            if s not in ["A", "C"]:
                return "WA"
    if S[0] == "A":
        if S[1] not in ["A", "C"] and S[-1] not in ["A", "C"]:
            count_C = 0
            for s in S[2: -1]:
                if s == "C":
                    count_C += 1
            if count_C == 1:
                return "AC"
    return "WA"

print(word_check(S))

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

vd fact_log10;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll x,y;
	cin>>x>>y;
	if(x>y)swap(x,y);
	if(y-x<2){
	    cout<<"Brown"<<endl;
	}else{
	    cout<<"Alice"<<endl;
	}
	
}


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

int main(){
    int n;
    long long count=0;

    cin >> n;

    for(int i=1;i<n+1;i++){
        if((i%3==0)&&(i%5==0)){
            // FizzBuzz
        }else if(i%3==0){
            // Fizz
        }else if(i%5==0){
            // Buzz
        }else{
            count += i;
        }
    }
    
    cout << count << endl;
}

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

struct UnionFind{
    vector<int> par;
    
    UnionFind(int n) : par(n){
        rep(i, n) par[i] = i;
    }
    
    int root(int x){
        if(par[x] == x) return x;
        return root(par[x]);
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    
    UnionFind uf(n);
    
    int t, x, y;
    rep(i, q){
        cin >> t >> x >> y;
        if(t == 0){
            uf.unite(x, y);
        }else{
            if(uf.same(x, y)){
                cout << 1 << endl;
            }else{
                cout << 0 << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 3140
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		sc.close();

		for (int i = 0; i <= X; i++) {
			if (2 * i + 4 * (X - i) == Y) {
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}
}


Measured memory_bytes: 35768
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a,b,c,op[N],ans[N],cnt;
char s[5];
int g(){
    if(strcmp(s,"AB")==0)return 1;
    if(strcmp(s,"AC")==0)return 2;
    if(strcmp(s,"BC")==0)return 3;
}
bool solve(){
    if(a+b+c==0)return 0;
    if(a+b+c==1){
        for(int i=1;i<=n;++i){
            if(op[i]==1){
                if(a==0 && b==0)return 0;
                if(a==0)ans[++cnt]=0,a++,b--;
                else ans[++cnt]=1,b++,a--;
            }
            else if(op[i]==2){
                if(a==0 && c==0)return 0;
                if(a==0)ans[++cnt]=0,a++,c--;
                else ans[++cnt]=2,c++,a--;
            }
            else if(op[i]==3){
                if(b==0 && c==0)return 0;
                if(b==0)ans[++cnt]=1,b++,c--;
                else ans[++cnt]=2,c++,b--;
            }
        }
        return 1;
    }
    if(a+b+c>=2){
        for(int i=1;i<=n;++i){
            if(op[i]==1){
                if(a==0 && b==0)return 0;
                if(a==1 && b==1 && i+1<=n && op[i+1]!=op[i]){
                    if(op[i+1]==2){
                        ans[++cnt]=0,a++,b--;
                    }
                    else if(op[i+1]==3){
                        ans[++cnt]=1,b++,a--;
                    }
                }
                else{
                    if(a<b)ans[++cnt]=0,a++,b--;
                    else ans[++cnt]=1,b++,a--;
                }
            }
            else if(op[i]==2){
                if(a==0 && c==0)return 0;
                if(a==1 && c==1 && i+1<=n && op[i+1]!=op[i]){
                    if(op[i+1]==1){
                        ans[++cnt]=0,a++,c--;
                    }
                    else if(op[i+1]==3){
                        ans[++cnt]=2,c++,a--;
                    }
                }
                else{
                    if(a<c)ans[++cnt]=0,a++,c--;
                    else ans[++cnt]=2,c++,a--;
                }
            }
            else if(op[i]==3){
                if(b==0 && c==0)return 0;
                if(b==1 && c==1 && i+1<=n && op[i+1]!=op[i]){
                    if(op[i+1]==1){
                        ans[++cnt]=1,b++,c--;
                    }
                    else if(op[i+1]==2){
                        ans[++cnt]=2,c++,b--;
                    }
                }
                else{
                    if(b<c)ans[++cnt]=1,b++,c--;
                    else ans[++cnt]=2,c++,b--;
                }
            }
        }
        return 1;
    }
}
int main(){
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(int i=1;i<=n;++i){
        scanf("%s",s);
        op[i]=g();
    }
    if(!solve())puts("No");
    else{
        puts("Yes");
        for(int i=1;i<=n;++i){
            printf("%c\n",ans[i]+'A');
        }
    }
    return 0;
}


Measured memory_bytes: 4624
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n], b[n];
        for(int &i : a){
            cin >> i;
        }
        for(int &i : b){
            cin >> i;
        }
        int cnt1 = 0, cnt2 = 0;
        for(int i = 0; i < n; i++){
            if(a[i] > b[i]){
                cnt1 += a[i] - b[i];
            }else{
                cnt2 += (b[i] - a[i]) / 2;
            }
        }
        if(cnt1 > cnt2){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    }
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll k ; 
    cin >> k ;
    ll yr = 0 , sum = 100;
    while( sum <  k){
        yr+=1;
        sum =  sum + (( sum/100));
    }
    cout << yr <<"\n";
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#define INF 10000000
using namespace std;
struct data{
    int x,y;
};
int H,W,N;
int ans[1001][1001];
char field[1001][1001];
int cou,sx,sy;
void bfs(data start,int num){
    int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
    data g;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans[i][j]=INF;
            if(field[i][j]==num+'0'){
                g.x=i,g.y=j;
            }
        }
    }
    ans[start.x][start.y]=0;
    queue<data> q;
    q.push(start);
    while(!q.empty()){
        data now=q.front();
        q.pop();
        if(now.x==g.x&&now.y==g.y)break;
        int nex,ney;
        for(int i=0;i<4;i++){
            nex=now.x+dx[i];
            ney=now.y+dy[i];
            if(nex>=0&&nex<H&&ney>=0&&ney<W&&field[nex][ney]!='X'&&ans[nex][ney]==INF){
                data nowne;
                nowne.x=nex,nowne.y=ney;
                q.push(nowne);
                ans[nex][ney]=ans[now.x][now.y]+1;
            }
        }
    }
    cou+=ans[g.x][g.y];
    if(num!=N)bfs(g,num+1);
}
int main(){
    data s;
    cin>>H>>W>>N;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>field[i][j];
            if(field[i][j]=='S'){
                s.x=i,s.y=j;
            }
        }
    }
    bfs(s,1);
    cout<<cou<<endl;
return 0;
}

Measured memory_bytes: 6112
#include <stdio.h>
int main(void)
{
    long long int a,b,c,k;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
    if(k%2==1)printf("%lld\n",b-a);
    else printf("%lld\n",a-b);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int ans = 0;
		int maxSub = 0;
		for (int i = 0; i < 5; i++) {
			int time = sc.nextInt();
			int sub;
			if (time % 10 == 0) {
				sub = 0;
			} else {
				sub = 10 - (time % 10);
			}
			ans += time + sub;
			if (sub > maxSub) {
				maxSub = sub;
			}
		}

		System.out.println(ans - maxSub);

	}

}


Measured memory_bytes: 25300