akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int d[1010];
long a[1010];

map<vector<short>,long> solve_all(int n){
  vector<short> vec(n);
  rep(i,n) vec[i]=i;
  map<vector<short>,long> m;
  do {
    long ans = 0;
    vector<long> t(n,0);
    rep(i,n){
      int idx = vec[i];
      ans += t[idx];
      for(int j=-d[idx]; j<=d[idx]; j++) if(idx+j>=0 && idx+j<n){
        t[idx+j] += a[idx];
      }
    }
    m[vec] = ans;
  } while(next_permutation(all(vec)));
  return m;
}

int main(){
  int n;
  cin>>n;
  rep(i,n) cin>>d[i];
  rep(i,n) cin>>a[i];

  map<vector<short>,long> dp;
  if(n<=7){
    dp = solve_all(n);
    long res = 0;
    for(auto &p : dp) res = max(res, p.se);
    cout << res << endl;
    return 0;
  }

  dp = solve_all(7);
  // ??????7????????¨??????

  repl(i,7,n){
    map<vector<short>,long> nxt;
    for(auto &p : dp){
      auto &vec = p.fi;
      rep(j,8){
        long add = 0;
        vector<short> nvec;
        rep(k,j){
          if(vec[k]>0) nvec.pb(vec[k]-1);
          if(7-vec[k] <= d[i-7+vec[k]]) add += a[i-7+vec[k]];
        }
        nvec.pb(6);
        repl(k,j,7){
          if(vec[k]>0) nvec.pb(vec[k]-1);
          if(7-vec[k] <= d[i]) add += a[i];
        }
        nxt[nvec] = max(nxt[nvec], p.se + add);
      }
    }
    swap(dp,nxt);
  }

  long res = 0;
  for(auto &p : dp) res = max(res, p.se);
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 4252
# -*- coding: utf-8 -*-
import sys
import math
#import collections
#sys.setrecursionlimit(100000)

def check(innum):
	for i in range(3):
		for j in range(3):
			if(a[i][j]==innum):
				a[i][j]=-1
	if(a[0][0]==-1)and(a[1][0]==-1)and(a[2][0]==-1):
		print("Yes")
		sys.exit()
	if(a[0][1]==-1)and(a[1][1]==-1)and(a[2][1]==-1):
		print("Yes")
		sys.exit()
	if(a[0][2]==-1)and(a[1][2]==-1)and(a[2][2]==-1):
		print("Yes")
		sys.exit()
	if(a[0][0]==-1)and(a[0][1]==-1)and(a[0][2]==-1):
		print("Yes")
		sys.exit()
	if(a[1][0]==-1)and(a[1][1]==-1)and(a[1][2]==-1):
		print("Yes")
		sys.exit()
	if(a[2][0]==-1)and(a[2][1]==-1)and(a[2][2]==-1):
		print("Yes")
		sys.exit()
	if(a[0][0]==-1)and(a[1][1]==-1)and(a[2][2]==-1):
		print("Yes")
		sys.exit()
	if(a[0][2]==-1)and(a[1][1]==-1)and(a[2][0]==-1):
		print("Yes")
		sys.exit()


#n=int(input())

a=[[],[],[]]
tmp = input().split()
a[0] = list(map(lambda a: int(a), tmp))
tmp = input().split()
a[1] = list(map(lambda a: int(a), tmp))
tmp = input().split()
a[2] = list(map(lambda a: int(a), tmp))

n=int(input())

for i in range(n):
	b=int(input())
	check(b)
print("No")













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

int main(){
    int N;
    cin >> N;
    vector<int> a(3 * N);
    for (int i = 0; i < 3 * N; i ++){
        cin >> a.at(i);
    }
    sort (a.begin(), a.end());
    reverse (a.begin(), a.end());
    int64_t sum = 0;
    for (int i = 0; i < N; i ++){
        sum += a.at(2 * i + 1);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var mod int64 = 2019

func main() {
	l := readInt64()
	r := readInt64()

	if r-l >= mod {
		fmt.Println(0)
		return
	}

	var i, j int64
	var ans int64 = math.MaxInt64
	for i = l; i <= r; i++ {
		for j = i + 1; j <= r; j++ {
			ans = minInt64(ans, i*j%mod)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int n;

int mod(int a, int b)
{
	if(a < 0 && a%b != 0){
		n = a / b + 1;
		return a - (a / b + 1) * b;//返回非负余数
	}
	n = a / b;
	return a % b;
}

int main()
{
	int r,n2;
	char a[20] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J'};//利用字符
	vector<int> array;
	cin >> n;
	n2 = n;
    r = -2;
	while(n != 0)
		array.push_back(mod(n,r));


	for(int i=array.size()-1;i>=0;i--)
		cout <<  a[array[i]];//倒序输出
    if(n2==0) cout<<"0";
	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = (1..9).to_a
b = (1..9).to_a
i = 0
s = false
while i < 9
  if b.include?(n/a[i].to_f)
    s = true
  end
  i += 1
end

if s
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14240
#include <cstdio>

using namespace std;

const int N = 300'009;

int a[N];
int q[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    --a[i];
  }
  for (int s = 0; s < 2; ++s) {
    for (int i = s; i < n; i += 2) {
      if (a[i] % 2 != s) {
        puts("No");
        return 0;
      }
    }
  }
  for (int s = 0; s < 2; ++s) {
    int ne = s;
    int qh = 0, qt = 0;
    for (int i = s; i < n; i += 2) {
      if (a[i] == ne) {
        ne += 2;
        while (qh < qt && q[qh] == ne) {
          ne += 2;
          ++qh;
        }
      } else
      if (qh == qt || a[i] > q[qt - 1]) {
        q[qt++] = a[i];
      } else {
        puts("No");
        return 0;
      }
      if (qh < qt && i + 1 < n && a[i + 1] != i + 1) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll a[100001];
ll gcd(ll x,ll y){
if(y==0)
    return x;
else return gcd(y,x%y);
}
int solve(int n,int o){
int i;
int x=0;
int y=0;
int in;
ll v=0;
ll g=gcd(a[1],a[2]);
for(i=3;i<=n;i++)
    g=gcd(g,a[i]);

for(i=1;i<=n;i++)
    {a[i]=a[i]/g;


    };
for(i=1;i<=n;i++){
    if(a[i]%2){
        y++;
   v=max(v,a[i]);
      in=i;
    }
    else{
        x++;


    }}


    if((x%2)&&(x<n))
        return o;
    if(((x%2)==0)&&y>=2)
        return (o^1);
    if((x%2)==0&&(y==1)&&(v==1))
        return (o^1);
    a[in]=a[in]-1;
    return solve(n,o^1);

}







int main(){

int n;
cin>>n;
int i;
for(i=1;i<=n;i++)
    cin>>a[i];
    if(n==1){
        if(a[1]%2)
            cout<<"Second"<<endl;
        else
            cout<<"First"<<endl;
            return 0;

    }
  int x=solve(n,0);
  if(x==0)
        cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;














return 0;}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define pb push_back
#define mp make_pair
signed main()
{
    SPEED;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <set>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 200000 + 5;

int n, q;
char s[maxn], t[maxn], d[maxn];

int check(int x) {
    int tot = x;
    for (int i = 1; i <= q; i++) {
        if (t[i] == s[tot]) {
            if (d[i] == 'L') tot--;
            else tot++;
            if (tot == 0) return 1;
            else if (tot == n + 1) return -1;
        }
    }
    return 0;
}

int main() {
    scanf("%d%d%s", &n, &q, s + 1);
    for (int i = 1; i <= q; i++) {
        char tmp1[3], tmp2[3]; scanf("%s%s", tmp1, tmp2);
        t[i] = tmp1[0]; d[i] = tmp2[0];
    }
    int l = 1, r = n, ans1 = 0, ans2 = n + 1;
    while (l <= r) {
        int m = (l + r) >> 1;
        if (check(m) == 1) l = m + 1, ans1 = m;
        else r = m - 1;
    }
    l = 1, r = n;
    while (l <= r) {
        int m = (l + r) >> 1;
        if (check(m) == -1) r = m - 1, ans2 = m;
        else l = m + 1;
    }
    cout << n - ans1 - (n - ans2 + 1) << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> A(N);
    ll cnt=0;
    ll mn = INF;
    ll ans = 0;
    rep(i,N){
        cin>>A[i];
        if(A[i]<0){
            cnt++;
        }
        ans+=abs(A[i]);
        chmin(mn,abs(A[i]));
    } 

    if(cnt%2 == 0){
        cout<<ans<<endl;
    }else{
        cout<<ans-mn*2<<endl;
    }



    return 0;
    

}

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

int cnt=0;

void    insertionSort(vector<int> &A, const int &n, const int &g) {
    for (int i=g; i<=n-1; i++) {
        int v=A.at(i);
        int j=i-g;
        while ((j>=0)&&(A.at(j)>v)) {
            A.at(j+g)=A.at(j);
            j -=g;
            cnt++;
        }
        A.at(j+g)=v;
    }
    return;
}

int main() {
    int n;
    cin >>n;
    vector<int> A(n, 0);
    for (int i=0; i<n; i++)
        cin >>A.at(i);
    vector<int> m;
    m.push_back(n/2);
    cnt=0;
    do {
        insertionSort(A, n, m.back());
        m.push_back(m.back()/2);
    } while(0!=m.back());
    cout <<m.size()-1 <<endl;
    for (int i=0; i<m.size()-2; i++)
        cout <<m.at(i) <<' ';
    cout <<m.at(m.size()-2) <<endl;
    cout <<cnt <<endl;
    for (int i=0; i<n; i++)
        cout <<A.at(i) <<endl;
    return 0;
}


Measured memory_bytes: 6724
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

int c[514],s[514],f[514];
int n;

void solve(int m){
    int cur = 0;
    if(m==n-1){
        puts("0");
        return ;
    }
    FOR(i,m,n-1){
        if(cur > s[i]){
            int diff = cur - s[i];
            int p = (diff+f[i]-1)/f[i];
            cur = s[i] + p*f[i];
        } else cur = s[i];
        cur += c[i];
    }
    printf("%d\n",cur);
}

signed main(){
    scanf("%d",&n);
    REP(i,n-1){
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    }

    REP(i,n) solve(i);
    return 0;
}

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


int main() {
  int n,k;
  cin >> n >> k;
  vector<double> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
    p.at(i)=(1+p.at(i))/2.0;
  }
  vector<double> sum(n-k+1);
  for(int j=0; j<k;j++){
    sum.at(0)= sum.at(0)+p.at(0+j);
  }
  for(int i=1;i<n-k+1;i++){
    sum.at(i)=sum.at(i-1)+p.at(i+k-1)-p.at(i-1);
  }
  sort(sum.begin(), sum.end());
  cout << fixed << setprecision(10) << sum.at(n-k) << endl;
      
  
}




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

int main () {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        printf("bust");
    }
    else {
        printf("win");
    }
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split("")
t = s.length
ans = 753
for num in 0..t-3 do
  a = s[num],s[num+1],s[num+2]
  b = a.join("").to_i
  if (753 - b).abs < ans
    ans =(753 - b).abs

  end
end
p ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    string n;
    cin>>n;
    cout<<"ABC"<<n<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int N, A, B;

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

	cin >> N >> A >> B;

	cout << max(0LL, LL(N-1)*B+A - LL(N-1)*A-B+1)
		<< endl;
	return 0;
}

Measured memory_bytes: 256
def solve(s):
    if s.upper() == s:
        return "A"
    else:
        return "a"


def main():
    s = input()
    res = solve(s)
    print(res)


def test():
    assert solve("B") == "A"
    assert solve("a") == "a"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9092
// ABC096_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    
    // calculation
    cout << (N <= M ? N: N-1) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
while True:

    H,W =[int(i) for i in input().split()]

    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if (h+w) % 2 ==0:
                print('#', end='')
            else :
                print('.' ,end='')
        print()
    print()

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

	


int main(){
    int p,q,r;
    cin >>p >>q >>r;
    if(p<q){
      cout << p+min(q,r) << endl;
    }else{
      cout << q+min(p,r) << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] x = new long[n];
    long[] y = new long[n];
    for(int i=0;i<n;i++){
      x[i]=sc.nextLong();
      y[i]=sc.nextLong();
    }
    long num = (long)Math.pow(10,18)*4;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        for(int m=0;m<n;m++){
          for(int u=0;u<n;u++){
            long minX = Math.min(Math.min(x[i],x[u]),Math.min(x[j],x[m]));
            long minY = Math.min(Math.min(y[i],y[u]),Math.min(y[j],y[m]));
            long maxX = Math.max(Math.max(x[i],x[u]),Math.max(x[j],x[m]));
            long maxY = Math.max(Math.max(y[i],y[u]),Math.max(y[j],y[m]));
            if(minX==maxX||minY==maxY)continue;
            int cnt=0;
            for(int l=0;l<n;l++){
              if(minX<=x[l]&&x[l]<=maxX&&minY<=y[l]&&y[l]<=maxY)cnt++;
            }
            if(cnt>=k)num = Math.min(num,(maxX-minX)*(maxY-minY));
          }
        }
      }
    }
    System.out.println(num);
  }
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> v;
    string str;
    for(int i = 0; i < n; i++){
        cin >> str;
        v.push_back(str);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); i++){
        cout << v[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n;
    cin >> n;

    vector<ll> x(n), l(n);
    rep(i, n)cin >> x[i] >> l[i];

    vector<ll> ord(n);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](ll a, ll b){
        return x[a] < x[b];
    });

    ll arm = x[ord[0]] + l[ord[0]];
    ll ans = n;
    rep(i, n-1){
        if(arm > x[ord[i+1]]-l[ord[i+1]]){
            // cout << "arm " <<  arm << " : " << x[ord[i+1]]-l[ord[i+1]] << endl;
            ans--, arm = min(arm, x[ord[i+1]]+l[ord[i+1]]);
        }
        else arm = x[ord[i+1]]+l[ord[i+1]];
    }

    cout << ans << endl;

}

Measured memory_bytes: 2560
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 057 DigitsInMultiplication c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int f(ll n)
{
  if (n < 10) return 1;
  return f(n/10) + 1;
}

int main()
{
  ll N;
  int ans = (1 << 9), tmp;
  cin >> N;
  for(ll i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      tmp = max(f(i), f(N/i));
      if (tmp < ans) ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
  int n;
  cin >> n;
  for (int x = 1; x <= 50000; x++) {
    double xx = floor(x * 1.08);
    if (xx == (double)n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        Console.WriteLine(NextInt <= NextInt ? "unsafe" : "safe");
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


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

int n;
char str1[105],str2[105];

bool match(int i)
{
  for(int c=0;c<i;c++)
  if (str2[c]!=str1[n-i+c])return false;
  return true;
}

int main()
{
  int ans;

  scanf("%d%s%s",&n,str1,str2);
  ans=n*2;
  for(int c=0;c<=n;c++)
  if (match(c))ans=(n*2)-c;
  printf("%d\n",ans);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;



int main(){
	int N,M,K;cin>>N>>M>>K;
	vector<int>darks;
	for (int i = 0; i < M; ++i) {
		int a;cin>>a;a--;
		darks.push_back(a);
	}
	vector<vector<int>>edges(N,vector<int>(K));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < K; ++j) {
			int t;cin>>t;
			edges[i][j]=t-1;
		}
	}

	vector<int>memo(1<<M,10000000);
	memo[(1<<M)-1]=0;

	queue<int>que;
	que.push((1<<M)-1);
	while (!que.empty()) {
		int nows(que.front());
		que.pop();
		bitset<16>bs(nows);

		for (int ope = 0; ope < K; ++ope) {
			bitset<16>nexts;
			for (int i = 0; i < M; ++i) {
				if (bs[i]) {
					int to=edges[darks[i]][ope];
					auto it=find(darks.begin(),darks.end(),to);
					if (it == darks.end()) {

					}
					else {
						nexts[it-darks.begin()]=true;
					}
				}
			}
			if (memo[nexts.to_ulong()] > memo[bs.to_ulong()] + 1) {
				memo[nexts.to_ulong()]=memo[bs.to_ulong()]+1;
				que.push(nexts.to_ulong());
			}
		}
	}

	cout<<memo[0]<<endl;

	return 0;
}




Measured memory_bytes: 3472
const main = input => {
  const n = parseInt(input)
  let r = 0;
  for (let i = 1; i <= n; i++) if (i % 3 != 0 && i % 5 != 0) r += i
  return r
}

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 35160
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;



int a[105]; 
int n,sum,cnt=999999999,ans;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]%10!=0)
        {
        ans=1;
        cnt=min(cnt,a[i]);
        }
        sum+=a[i];
    }
    if(sum%10!=0)
    {
        cout<<sum;
    }
    if(sum%10==0)
    {
    if(ans==0)
    {
        cout<<'0';
        return 0;
    }
    if(ans==1)
    {
        cout<<sum-cnt;
    }
    }
    //system("pause");
    return 0;
}  

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

ll solve(ll arr[] , int size){
    ll dp[size];
    dp[0] = 0 , dp[1] = abs(arr[1] - arr[0]);
    for(int i = 2;i < size;i++){
        dp[i] = min(abs(arr[i] - arr[i - 2]) + dp[i - 2] , abs(arr[i] - arr[i - 1]) + dp[i - 1]);
    }
    ll ans = dp[size - 1];
    return ans;
}

int main(){
    int n;
    cin >> n;
    ll arr[n];
    for(int i = 0;i < n;i++)
        cin >> arr[i];
    ll ans = solve(arr , n);
    cout << ans << "\n";
  	return 0;
}

Measured memory_bytes: 5080
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 5000000;
int f[N], invf[N];
int binpow(int x, int y){
    int res = 1;
    while(y){
        if (y % 2) res = res * x % mod;
        x = x * x % mod;
        y /= 2;
    }
    return res;
}
int c(int n, int k){
    if (k > n) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    f[0] = 1;
    invf[0] = 1;
    int ans = 0;
    for (int i = 1; i < N; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i < N; i++) invf[i] = binpow(f[i], mod - 2);
    for (int i = r1; i <= r2; i++){
        int k = c(c1 + i - 1, c1 - 1);
        ans = (ans + k *((c(r2 - i + c2 - c1 + 2, c2 - c1 + 1)  - 1 + mod) % mod)) % mod;
   }
    for (int i = c1; i <= c2; i++){
        int k = c(r1 + i - 1, r1 - 1);
        ans = (ans + k *((c(c2 - i + r2 - r1 + 2, r2 - r1 + 1) - 1 + mod) % mod)) % mod;
    }
    cout << ans;
}


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

int main()
{
    int k,x;
    cin >> k >> x;
    for(int i=x-k+1;i<=(k+x-1);i++) 
    {
        if(i>=(-1000000) && i<=1000000)
        {
            cout << i << " ";
        }
        else if(i<=(1000000))
        {
            int d = abs((x-k+1)+1000000);
            i+=d;
        }
        else    break;
    }
    return 0;
}

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

int main () {
    int S;
    cin >> S;
    int hour = S / 60 / 60;
    int min = S % 3600 / 60;
    int second = S % 60;
    
    cout << hour << ":" << min << ":" << second << endl;
    return 0;
}


Measured memory_bytes: 3064
#include<iostream>
#include <cstdio>
#include <vector> 
#include <algorithm>
#include <functional>
#include<string>
using namespace std;


int main()
{
	int a, b, c,sum;
	cin >> a >> b >> c;
	sum = ((a + b) * c) / 2;
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h> 
 
#define N 5
 
int main(){
  char S[N];
  char* abc = "ABC";
  char* arc = "ARC";
  scanf( "%s", S );
 
  if ( strcmp( S, abc ) == 0 ){
    printf( "%s\n", arc );
  }else{
    printf( "%s\n", abc );
  }
  
  return 0;
  
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
const LL INF = 1e16;
const int N = 3 * 1e5 + 5;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	vector<LL> shrine, temple;
	LL x, ans = INF, now;
	int a, b, q;
	cin >> a >> b >> q;
	while(a--) {
		cin >> x;
		shrine.push_back(x);
	}
	while(b--) {
		cin >> x;
		temple.push_back(x);
	}
	shrine.push_back(-INF);
	temple.push_back(-INF);
	shrine.push_back(INF);
	temple.push_back(INF);
	sort(shrine.begin(), shrine.end());
	sort(temple.begin(), temple.end());
	int sza = shrine.size(), szb = temple.size();
	while(q--) {
		cin >> x;

		ans = INF;
		int lo = 0, m, hi = sza-1;
		while(lo < hi-1) {
			m = (lo + hi)/2;
			if (shrine[m] <= x) lo = m;
			else hi = m;
		}
		int l = 0, h = szb-1;
		while(l < h-1) {
			m = (l + h)/2;
			if (temple[m] <= x) l = m;
			else h = m;
		}

		// cout << "shrine " << shrine[lo] << " " << shrine[hi] << '\n';
		// cout << "temple " << temple[l] << " " << temple[h] << '\n';

		ans = min(ans, max(shrine[hi], temple[h]) - x);
		ans = min(ans, x - min(shrine[lo], temple[l]));
		ans = min(ans, shrine[hi] - x + x - temple[l] + min(shrine[hi] - x, x - temple[l]));
		ans = min(ans, temple[h] - x + x - shrine[lo] + min(temple[h] - x, x - shrine[lo]));

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

	return 0;
}


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    print(YES if 'A' in S and 'B' in S else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def myAnswer(N:int,A:int,B:int) -> int:
   ans = 0
   BN = N - B
   A1 = A - 1
   while True:
      if((B - A) % 2== 0):
         ans += (B - A)//2
         break
      elif(A == 1):
         ans += 1
         B -= 1
      elif(B == N):
         ans += 1
         A += 1
      else:
         if(BN > A1):
            ans +=A1
            B -= A1
            A = 1
         else:
            ans += BN
            A += BN
            B = N
   return ans

def modelAnswer():
   tmp=1
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()





template <int MOD>
struct ModInt {
    using lint = long long;
    int val;
 
    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };
 
    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }
 
    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }
 
    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
 
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }
 
    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};
 
constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
 
mint comb(int n, int r) {
    mint ret = 1;
    for (int i = 1; i <= r; ++i) {
        ret *= n - i + 1;
        ret /= i;
    }
    return ret;
}


int main(){
    int n,a,b;
    cin>>n>>a>>b;
    mint ans=mint(2).pow(n)-1;
    ans-=comb(n,a);
    ans-=comb(n,b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,cl,s,t,c,i,j,oa[35][100010]={},cs,cmax=0;
  cin >> n >> cl;
  for (i=0;i<n;i++){
    cin >> s >> t >> c;
    for (j=s-1;j<t;j++) oa[c][j]=1;
  }
  for (i=1;i<=100000;i++){
    cs=0;
    for (j=1;j<=cl;j++) cs+=oa[j][i];
    if (cmax < cs) cmax=cs;
  }
  cout << cmax << endl;
  return 0;
}

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

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

    set<int>st;
    int input;
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        cin>> input;

        st.insert(input);

        if(input == *st.begin())
            ans++;
    }

    cout<< ans;
    
    return 0;
}


Measured memory_bytes: 12944
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    Map<Integer, AtomicInteger> countMap = new HashMap<>();
    for (int x = 1; x <= 10000; x++) {
      int x2 = x * x;
      if (x2 > n) {
        break;
      }
      for (int y = 1; y <= 10000; y++) {
        int y2 = y * y;
        int xy = x * y;
        if ((long) x2 + y2 + xy > n) {
          break;
        }
        for (int z = 1; z <= 10000; z++) {
          long c = x2 + y2 + z * z + xy + y * z + z * x;
          if (c > n) {
            break;
          }
          int castC = (int) c;
          countMap.computeIfAbsent(castC, k -> new AtomicInteger(0))
            .incrementAndGet();
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      pw.println(countMap.getOrDefault(i, new AtomicInteger(0)).get());
    }
  }
}


Measured memory_bytes: 43632
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    edge=[[] for _ in range(N)]
    for _ in range(N-1):
        a,b=map(int1,input().split())
        edge[a].append(b)
        edge[b].append(a)
    cost=[INF]*N
    cost[0]=0
    stack=[0]
    while stack:
        v=stack.pop()
        for nv in edge[v]:
            if cost[nv]==INF:
                cost[nv]=cost[v]+1
                stack.append(nv)
                if nv==N-1:
                    break
    d=cost[N-1]
    v=N-1
    for i in range(d+1):
        if i==(d-1)//2:
            sv=v
        elif i==(d+1)//2:
            fv=v
            break
        for nv in edge[v]:
            if cost[nv]==cost[v]-1:
                v=nv
                break

    stack=[sv]
    used=[False]*N
    used[fv]=True
    c=0
    while stack:
        v=stack.pop()
        used[v]=True
        c+=1
        for nv in edge[v]:
            if not used[nv]:
                stack.append(nv)
    if c>=N-c:
        print('Snuke')
    else:
        print('Fennec')
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 56112
#include <iostream>
using namespace std;
int main (){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        int m; cin >> m;
        int a[m];
        for(int j=0;j<m;j++)
            cin >> a[j];
        int maxup=0;int maxdown=0;
        for(int j=0;j<m-1;j++){
            if((a[j] < a[j+1]) && (maxup<a[j+1]-a[j]))
                maxup = a[j+1]-a[j];
            if((a[j] > a[j+1]) && (maxdown<a[j]-a[j+1]))
                maxdown = a[j]-a[j+1];
        }
        cout << maxup << " " << maxdown << endl;
    }
}

Measured memory_bytes: 1160
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>
 
using namespace std;
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int K;
int in[10], to[10];
void rot(int& x, int r){
  x = (x + r + 10) % 10;
}

int dfs(int idx){
  if(idx >= K)
	return 0;
  
  int diff = to[idx] - in[idx];
  if(diff == 0) return dfs(idx+1);

  int res = K;
  int prv[10];
  REP(i,K) prv[i] = in[i];
  for(int r=idx;r<K;++r){
	rot(in[r], diff);
	res = min(res, 1+dfs(idx+1));
  }
  REP(i,K) in[i] = prv[i];

  return res;
}

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

  while(cin>>K,K){
	string s1, s2; cin >> s1>> s2;
	REP(i,K)
	  in[i] = s1[i] - '0', to[i] = s2[i] - '0';
	cout << dfs(0) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <algorithm>

using namespace std;
int main(void)
{
	int i, j, k, h, n;
	int sum = 0;
	while (scanf("%d", &n) != EOF){
		
		sum = 0;
		
		for (i = 0; i < 10; i++){
			for (j = 0; j < 10; j++){
				for (k = 0; k < 10; k++){
					for (h = 0; h < 10; h++){
						if (i + j + k + h == n){
							sum++;
						}
					}
				}
			}
		}
	
	
		printf("%d\n", sum);
	}
	return (0);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        ll ev = 0;
        ll od = 0;
        rep(i, 0, N) {
                ll a;
                cin >> a;
                if (even(a)) ++ev;
                else ++od;
        }

        if (ev == 0) {
                if (even(od)) {
                        cout << "YES" << endl;
                        return 0;
                }
        }

        if (even(ev) and even(od)) {
                cout << "YES" << endl;
        } else if (odd(ev) and even(od)) {
                cout << "YES" << endl;
        } else {
                cout << "NO" << endl;
        }
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
const int MAXN = 200000;
char s[MAXN + 5];
int main() {
	scanf("%s", s+1);
	int n = strlen(s+1), nw = n;
	long long ans = 0;
	for(int i=n;i>=1;i--)
		if( s[i] == 'B' )
			ans += (nw-i), nw--;
	printf("%lld\n", ans);
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn=200020,maxa=4040,mod=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,a[maxn],b[maxn],f[maxa][maxa],ans,fac[maxa<<1],inv[maxa<<1],invfac[maxa<<1];
int C(int n,int m){
	return 1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod;
}
int main(){
	n=read();
	fac[0]=fac[1]=inv[1]=invfac[0]=invfac[1]=1;
	FOR(i,2,8000){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=mod-1ll*(mod/i)*inv[mod%i]%mod;
		invfac[i]=1ll*invfac[i-1]*inv[i]%mod;
	}
	FOR(i,1,n){
		a[i]=read(),b[i]=read();
		f[2001-a[i]][2001-b[i]]++;
	}
	FOR(i,1,4001) FOR(j,1,4001) f[i][j]=((f[i][j]+f[i-1][j])%mod+f[i][j-1])%mod;
	FOR(i,1,n) ans=(ans+f[2001+a[i]][2001+b[i]])%mod;
	FOR(i,1,n) ans=(ans-C(2*(a[i]+b[i]),2*a[i])+mod)%mod;
	printf("%lld\n",ans*500000004ll%mod);
}

Measured memory_bytes: 65280
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	int m=sc.nextInt();
    	
    	System.out.println(48-m);
    }

}







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

int main()
{
    int n;
    int f[101][6][3];
    int p[101][11];
    cin >> n;
    for(int i = 1; i < n + 1; i++){
        for(int j = 1; j < 6; j++){
            for(int k = 1; k < 3; k++){
                cin >> f[i][j][k];
            }
        }
    }
    for(int i = 1; i < n + 1;  i++){
        for(int j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }
    long long answer;
    for(int i = 1; i < 1024; i++){
        int mon1 = i % 2;
        int mon2 = (i / 2) % 2;
        int tue1 = (i / 4) % 2;
        int tue2 = (i / 8) % 2;
        int wed1 = (i / 16) % 2;
        int wed2 = (i / 32) % 2;
        int thu1 = (i / 64) % 2;
        int thu2 = (i / 128) % 2;
        int fri1 = (i / 256) % 2;
        int fri2 = (i / 512) % 2;
        int open[101];
        for(int j = 1; j < n + 1; j++){
            open[j] = f[j][1][1] * mon1 + f[j][1][2] * mon2 + f[j][2][1] * tue1 + f[j][2][2] * tue2 + f[j][3][1] * wed1 + f[j][3][2] * wed2 + f[j][4][1] * thu1 + f[j][4][2] * thu2 + f[j][5][1] * fri1 + f[j][5][2] * fri2;
        }
        long long compare = 0;
        for(int j = 1; j < n + 1; j++){
            compare = compare + p[j][open[j]];
        }
        if(i > 1){
            answer = max(answer, compare);
        }
        else{
            answer = compare;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

static const int P = 50;

int main() {
	ll N; cin >> N;
	ll t = (N / 11) * 2;

	if (N % 11 == 0) cout << t;
	else if (N % 11 <= 6) cout << ++t;
	else if (N % 11 > 6) cout << t + 2;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;   
int main(){
    int n,a[100005],ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int c=0,d=0;
    for(int i=0;i<n-1;i++){
        if(d==0){
            if(a[i]==a[i+1]){
                continue;
            }
            if(a[i]<a[i+1]){
                d=1;
            }
            else{
                d=2;
            }
        }
        if(d==1 && a[i]>a[i+1]){
            ans++;
            d=0;
        }
        if(d==2 && a[i]<a[i+1]){
            ans++;
            d=0;
        }
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 3984
from itertools import accumulate
import heapq as hq
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort()
ls = []
hq.heapify(ls)
k = max([a[0] for a in ab]+[m])
daylist = [0]*(k+1)
for i in range(n):
  daylist[ab[i][0]] += 1
daylistsum = list(accumulate(daylist))
ans = 0
for i in range(1,m+1):
  for j in range(daylistsum[i-1],daylistsum[i]):
    hq.heappush(ls,-ab[j][1])
  if ls:
    ans -= hq.heappop(ls)
print(ans)

Measured memory_bytes: 35516
n = gets.to_i
numbers = gets.split.map(&:to_i)

sorted_numbers = numbers.sort
left_median = sorted_numbers[(n - 1) / 2]
right_median = sorted_numbers[((n - 1) / 2) + 1]


answers = numbers.map { |number|
  number <= left_median ? right_median : left_median
}

puts answers


Measured memory_bytes: 36708
not_dict = {"0": "1", "1": "0"}
n = int(input())
a_list_0d = list(map(int, input().split()))
bit_sum = [0]
a_list_0b = list(map(lambda x: bin(x)[2:], a_list_0d))
max_bit = max(map(len, a_list_0b))
a_list_str = list(map(lambda x: x.zfill(max_bit), a_list_0b))
all_sum = 0
for i in range(n):
    all_sum ^= a_list_0d[i]
all_sum_str = bin(all_sum)[2:].zfill(max_bit)

new_list = ["0b" for _ in range(n)]
for b in range(max_bit):
    if all_sum_str[b] == '1':
        for i in range(n):
            new_list[i] += not_dict[a_list_str[i][b]]
    else:
        for i in range(n):
            new_list[i] += a_list_str[i][b]
    # print(new_list)


for i in range(n):
    print(int(new_list[i], 0), end=" ")

Measured memory_bytes: 64828