akhauriyash/Code-Regression huggingface dataset:
n = int(input())
rates = [1,1,3,6]
cnt = [0]*10001
def g(x,y,z):
    return x**2 + y**2 + z**2 + x*y + x*z + y*z

for x in range(1,101):
    for y in range(x,101):
        for z in range(y,101):
            rate = rates[len(set([x,y,z]))]
            gv = g(x,y,z)
            if gv < 10001:
                cnt[gv]+=rate
for i in range(1,n+1):
    print(cnt[i])

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    if(n>=1000){
        cout<<"ABD"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    return 0;
}

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

#define mod 1000000007

int main(){

	long long  N, K;
	std::cin >> N >> K;

	long long comb = 0;
	for(int i=N+1; i>=K; i--){
		long long max = 0;
		long long  min = 0;
		min = (i+1)*i/2;
		max = min + i * (N+1-i);
		comb = (comb + max - min + 1)%mod;
	}
	std::cout << comb << std::endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <climits>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

long long int i,j,ans=0;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int INF = 1<<29;
const int mod = 1000000007;

long long int solve(long long int a,long long int k){
	if(a==1){
		return k;
	}else{
		return solve(a-1,k)*5+k/2;
	}
}


int main(){
	char s[12];
	cin>>s;
	int n;
	n=strlen(s);
	long long int k=1;
	for(i=1;i<=n-1;i++){
		k=2*k;
	}
	for(i=n-1;i>=0;i--){
		ans += solve(n-i,k)*(s[i]-'0');
	}
	cout << ans << endl;
}


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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
	int a ,b;
	cin >> a>>b;
	if(a>b){
		cout<<a-1<<endl;
	  }
	  else {
		  cout<<a<<endl;
		}
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  string s, p; 
  cin >> s >> p;
  s += s;  
  
  if(s.find(p) == string::npos){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;  
  }
 
  return 0;
}


Measured memory_bytes: 3200
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}

func solver(a string, b string){
	fmt.Print(b)
  fmt.Println(a)
}
 
func main(){
	a := ""
	b := ""
	fmt.Scan(&a)
	fmt.Scan(&b)
	solver(a,b)
}

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

int main(){
    int n;
    cin >> n;
    int a[n][n-1];
    rep(i,n){
        rep(j,n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int t = 0;
    int c = 0;
    int ans = 0;
    int m[n] = {};
    int s = 0;
    vector<int> v(n);
    rep(i,n) v[i] = i;
    vector<int> u(n,0);
    while(true){
        ans++;
        c = 0;
        rep(i,n){
            s++;
            int b = a[i][m[i]];
            if(m[i] == n-1 || m[b] == n-1) continue;
            if(u[b] != ans && u[i] != ans && a[b][m[b]] == i){
                m[i]++; m[b]++;
                t++; c++;
                u[b] = u[i] = ans;
            }
        }
        if(s > 1e8){
            cout << n*(n-1)/2 << endl;
            return 0;
        }
        if(!c) break;
    }
    cout << ((t == n*(n-1)/2) ? ans-1 : -1 ) << "\n";
    return 0;
}


Measured memory_bytes: 4096
S = input()
n = len(S)
m = n // 2
if S[0] == '0' or S[-1] == '1':
  print(-1)
  quit()

ans = [[1, 2]]
node = 1
now = 3
for i in range(m):
  if S[i] != S[n-i-2]:
    print(-1)
    quit()
  else:
    if i == 0:
      continue
    ans.append([node, now])
    if S[i] == '0':
      now += 1
    else:
      node = now
      now += 1

for i in range(now, n+1):
  ans.append([node, i])

for a in ans:
  print(*a)

Measured memory_bytes: 17940
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast;
	ll N,K,x,y; cin>>N>>K;
	map<ll,ll>mp;
	for(ll i = 0; i < N; i++)
	{
		cin>>x>>y;
		mp[x] += y;
	}
	ll ans=0,j=0;
	for(auto i = mp.begin(); i != mp.end(); i++)
	{
		j += i->second;
		if(j >= K)
		{
			ans = i->first;
			break;
		}
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 4224
N, A, B = map(int, input().split())
ans = 0
for i in range(N+1):
    youso_wa = 0
    a = i
    while True:
        youso_wa += int(a % 10)
        a = int(a / 10)
        if a == 0:
            break
    if youso_wa >= A and youso_wa <= B:
        ans += i
print(ans)

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const string s = "qwertasdfgzxcvb";
string in;

int check(char c)
{
  vrep(v, s) if(c == *v) return 1;
  return -1;
}

int main()
{
  while(cin >> in, in != "#"){
    int flag = check(in[0]);
    int res = 0;
    vrep(v, in) if(check(*v) != flag){
      flag *= -1;
      res += 1;
    }
    cout << res << endl;
  }

  return 0;
}

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

using namespace std;

int main (){
  int N,count;
  cin >> N;
  count = 0;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(d.at(i) == d.at(j) && i != j){d.at(j) = 0;}
    }
  }
  for(int i = 0; i < N; i++){
    if(d.at(i) > 0){count++;}
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int m, k;
    cin >> m >> k;

    if((1LL << m) <= k){
        cout << -1 << endl;
        return 0;
    }
    if(m == 1 && k == 1){
        cout << -1 << endl;
        return 0;
    }
    if(m == 1 && k == 0){
        cout << "0 0 1 1" << endl;
        return 0;
    }

    int n = 1 << m;
    deque<int> ans;
    ans.push_back(k);
    for(int i = 0; i < n; i++){
        if(i == k){
            continue;
        }
        ans.push_front(i);
        ans.push_back(i);
    }
    ans.push_back(k);

    while(not ans.empty()){
        cout << ans.front() << " ";
        ans.pop_front();
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N;
ll A[Nmax];

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

	int n_neg = 0;
	ll minA = abs(A[0]);
	ll sum = 0;
	for(int i=0; i<N; i++){
		sum += abs(A[i]);
		if(A[i] < 0) n_neg++;
		if(abs(A[i]) < minA){
			minA = abs(A[i]);
		}
	}

	if(n_neg%2){
		cout << sum-2*minA << endl;
	} else {
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
N=int(input())
Hi=list(map(int,input().split()))

# ans=[0]*N

# for i in range (N):
#     a=0
#     # if Hi[i]<Hi[i-1]:
#     #     continue
#     for j in range(N-i-1):
#         if Hi[i+j]>=Hi[i+j+1]:
#             a+=1
#         else:
#             break
#     ans[i]=a

# print(max(ans))

ans=0
temp=0

for i in range(1,N):
    if Hi[i]<=Hi[i-1]:
        temp+=1
    else:
        if temp>ans:
            ans=temp
        else:
            pass
        temp=0
else:
    if temp>ans:
        ans=temp

print(ans)

Measured memory_bytes: 20476
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

a, b, n = input_a

# 問題文を式に直すと
# (a * x / b).floor - a * (x / b).floor
# となっていて、第二項「a * (x / b).floor」がマイナスであるため、この項の値が少なければ少ないほど嬉しい
# 肝となるのは「(x / b).floor」の部分で、例えばx=4のとき、b=2なら答えは2だが、b=3なら1、b=4なら1、b=5なら0となる。つまり、b > x であるとき、第二項は無視できる値となる
# また、第一項「(a * x / b).floor」については、xが大きくなるほど大きくなる(a, bは入力によって固定されている)単調増加であることがわかる(floorに惑わされがちだが無視すればなんてことのない「a * x / b」なので)
# よって、以上の点から第二項を0にして、かつ第一項が最大の値をとるxは x = b - 1 となる。ただし、x <= n という条件があるため、b - 1 が n より大きい場合は x = n である。
x = [n, b - 1].min
# ruby では整数同士の計算であればfloorは要らない
puts (a * x / b)

Measured memory_bytes: 14276
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(3).
01 a              PIC 9(1).
01 b              PIC 9(1).
01 x              PIC 9(1).
01 i              PIC 9(2).
01 ans            PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF b < a
      MOVE a TO x
      MOVE b TO a
      MOVE x TO b
  END-IF.
  PERFORM VARYING i FROM 1 BY 1 UNTIL b < i
      MOVE a TO ans(i:1)
  END-PERFORM
  DISPLAY ans.
  STOP RUN.


Measured memory_bytes: 1144
//============================
// ABC137b One Clue
//
// 2019/08/12
//============================

#include <iostream>

using namespace std;

int main (int argc, char *argv[])
{
  long K, X;
  cin >> K >> X;

  for (int i=X-K+1; i<X+K; i++)
  {
    cout << i << " " << flush;
  }
  cout << endl;
  
  return 0;
}


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

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

	if (n == 100) n++;
	if (d == 0) cout << n << endl;
	else if (d == 1) cout << n * 100 << endl;
	else cout << n * 10000 << endl;

	return 0;
}

Measured memory_bytes: 256
l,r = map(int,input().split())
ans = (l*r)%2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans = min(ans,(i*j)%2019)
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)


Measured memory_bytes: 9072
#include <iostream>

using namespace std;

void counting_sort(int A[],int B[],int k,int n){
  int C[k+1];
  for(int i=0;i<=k;i++){
    C[i] = 0;
  }
  for(int i=0;i<n;i++){
    C[A[i]]++;
  }
  for(int i=1;i<=k;i++){
    C[i] = C[i-1] + C[i];
  }
  for(int i=n-1;i>=0;i--){
    B[C[A[i]]-1] = A[i];
    C[A[i]]--;
  }
}

int main(){
  int n; cin>>n;
  int A[n],B[n];
  int k = -1;
  for(int i=0;i<n;i++){
    cin>>A[i];
    k = max(A[i],k);
  }
  counting_sort(A,B,k,n);
  for(int i=0;i<n;i++){
    if(i) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
}

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

int main()
{
	int H=0 , W=0 ;
	while(true)
	{
		cin >> H >> W ;
		if(H==0&&W==0) break ;

		for(int i=0 ; i<H ; i++)
		{
			for(int ii=0 ; ii<W ; ii++)
			{
				cout << "#" ;
			}
			cout << endl ;
		}
		cout << endl ;
	}
	return 0 ;
}




Measured memory_bytes: 3100
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

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

	int sum;
	if(N%2==1){
		sum=N;
	}else{
		sum=N+1;
	}
	
	vector<pair<int,int>> v;
	for(int i=1; i<N; i++){
		for(int j=i+1; j<=N; j++){
			if(i+j!=sum){
				v.emplace_back(make_pair(i,j));
			}
		}
	}

	cout << v.size() << endl;
	for(int i=0; i<v.size(); i++){
		cout << v[i].first << " " << v[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  int n,x,m[100],sum=0,i,min;
  scanf("%d %d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&m[i]);
    sum+=m[i];
    if(i==0||min>m[i])
      min=m[i];
  }
  printf("%d\n",n+(x-sum)/min);
}

Measured memory_bytes: 128
import math
n,m=[int(i) for i in input().split()]
if(abs(n-m)>1):
    print(0)
    exit()

def is_even(n):
    if(n%2==0):
        return True
    else:
        return False
if(is_even(n) and is_even(m) or not is_even(n) and not is_even(m)):
    print(math.factorial(n)*math.factorial(m)*2%(10**9+7))
    exit()
else:
    print(math.factorial(n)*math.factorial(m)%(10**9+7))
    exit()
# if(is_even(n) and is_even(m)):
#     print(math.factorial(n)*math.factorial(m)*2)
#     exit()
# elif(is_even(n) and not is_even(m)):
#     print(math.factorial(n)*math.factorial(m))
#     exit()
# elif(not is_even(n) and is_even(m)):
#     print(math.factorial(m)*math.factorial(n))
#     exit()
# elif(not is_even(n) and not is_even(m)):
#     print(math.factorial(m)*math.factorial(n)*2)
#     exit()

Measured memory_bytes: 5184
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    double pre[1005];
    for(int i=1;i<=1000;i++)
    {
        double a1=(1.0/(i*1.0));
        //cout<<a1<<endl;
        double a2=0;
        for(int j=1;j<=i;j++)
        {
            a2 += (a1*(j*1.0));
            //cout<<a2<<" to"<<endl;
        }
        pre[i]=a2;
        //cout<<pre[i]<<endl;
    }
    int n,k;
    while(cin>>n>>k)
    {
        double tot=0,x;
        vector<int> arr;
        for(int i=0;i<n;i++)
        {
            int y;
            cin>>y;
            arr.push_back(y);
        }
        double res=0;
        for(int i=0;i<k;i++)
        {

            tot += pre[arr[i]];
        }
        res=max(res,(tot));
        int j=0;
        for(int i=k;i<n;i++)
        {
            tot -= pre[arr[j]];
            tot += pre[arr[i]];
            j++;
            res=max(res,(tot));
        }
        //cout<<fixed<<<<res<<endl;
        printf("%.10lf\n",res);
    }

    return 0;
}


Measured memory_bytes: 1400
using System;

namespace test
{
	class program
	{
		static void Main()
		{
			string[] str = Console.ReadLine().Split(' ');
			int a = int.Parse(str[0]);
			int b = int.Parse(str[1]);
			int c = int.Parse(str[2]);

			int count = 0;
			for (; a <= b; ++a)
			{
				if (c % a == 0) ++count;
			}
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    double d = 0;
    REP(i, N) {
        d += 1.0 / A[i];
    }
    double ans = 1.0 / d;
    
    cout << fixed << setprecision(10) << ans << endl;
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,minj,n,a[100],tmp,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    minj=i;
    for(j=i+1;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      sum++;
    }
    tmp=a[i];
    a[i]=a[minj];
    a[minj]=tmp;
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i==n-1){
      printf("\n");
    }else{
      printf(" ");
    }
  }
  printf("%d\n",sum);
}




Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<ll> A(N+1);
    for (ll i = 0; i < N+1; i++) cin >> A[i];
    vector<ll> B(N);
    for (ll i = 0; i < N; i++) cin >> B[i];
    ll ans = 0;
    for (ll i = 0; i < N+1; i++){
        int c=0,d=0;
        if (i != 0) {
            c = min(A[i],B[i-1]);
            A[i] -= c;
        }
        if (i != N){
            d = min(A[i],B[i]);
            B[i] -= d;
        }
        ans += (c+d);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; 
    int d;
    cin >> n >> d;
    int res = 0;
    for (int i = 0; i < n; ++i) {
        ++res;
        i += d * 2;
    }
    cout << res << "\n";

    return 0;
}

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

int main(){
    ll x;
    cin >> x;
    ll tmp=x/11;
    ll mod=x%11;
    if(mod>6)mod=2;
    else if(mod==0)mod=0;
    else mod=1;
    //cout << tmp << " " << mod << endl;
    ll ans=(ll)tmp*2+mod;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;
  while (true) {
    C -= B;
    if (C <= 0) {
      std::cout << "Yes\n";
      return 0;
    }
    A -= D;
    if (A <= 0) {
      std::cout << "No\n";
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3644
n = int(input())
def f(l):
	return "".join([chr(x+97) for x in l])

ans = [[] for _ in range(n)]
ans[0] = [[0]]
for i in range(1, n):
	for a in ans[i-1]:
		for j in range(max(a)+2):
			ans[i].append(a+[j])

for a in ans[n-1]:
	print(f(a))

Measured memory_bytes: 27460
#include <bits/stdc++.h>
#define FI(n) for(int i = 0; i < n; ++i)
#define FJ(n) for(int j = 0; j < n; ++j)
#define INT_MAX 2147483647
#define l first
#define r second
#define mp make_pair
#define pb push_back
using namespace std;
ofstream coutf;
ifstream cinf;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD=1000000007;
int solve()
{
    int n;
    cin>>n;
    int a,b;
    int maxA=0;
    int sootvmax=0;

    FI(n)
    {
        cin>>a>>b;

        if(a>maxA)
        {
            maxA=a;
            sootvmax=b;
        }
    }
    maxA+=sootvmax;
    cout<<maxA;
    return 0;
}
int main()
{

    coutf.open("output.txt");
    cinf.open("input.txt");
    solve();
    cinf.close();
    coutf.close();
    return 0;
}


Measured memory_bytes: 256
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;             

int arr[100005];

ll ans, sum;

int n;

void solve() {                   
	scanf("%d", &n);  

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);    	
    }

	for (int i = 1; i <= n + 1; ++i) {
		if (arr[i] == 0) {
			ans += sum / 2;
			sum = 0;
		}

		sum += arr[i];
	}	        

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

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
N = int(input())
W = []
answer = 'Yes'
for i in range(N):
    W.append(input())

for i in range(N - 1):
    if W.count(W[i]) > 1:
        answer = 'No'
        break
    if W[i][-1] != W[i+1][0]:
        answer = 'No'
        break
print(answer)

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll A, B, C;

int main()
{
    cin >> A >> B >> C;
    if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
        printf("0\n");
        return 0;
    }
    ll ans = -1;
    REP(i, 3) {
        ll cnt = 0;
        ll diff = 0;
        if(i == 0) { diff = abs(A-B); }
        else if(i == 1) { diff = abs(B-C); }
        else { diff = abs(C-A); }

        if(diff != 0) {
            while(diff % 2 == 0) {
                diff /= 2;
                cnt++;
            }
            if(ans == -1) { ans = cnt; }
            else { ans = min(ans, cnt); }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
while True:
    s = raw_input()
    if(s == "-"):
        break
    m = input()
    for i in range(m):
        h = input()
        temp = ""
        for j in range(h, len(s)):
            temp += s[j]
        for j in range(h):
            temp += s[j]
        s = temp
    print(s)

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

using namespace std;

int N, A, B, C, D;

string S;

void input()
{
    cin >> N >> A >> B >> C >> D;
    --A;
    --B;
    --C;
    --D;
    cin >> S;
}

bool solve()
{
    if (S[C] == '#' || S[D] == '#' || C == D)
        return false;
    for (int i = A + 2; i < C; ++i)
    {
        if (S[i - 1] == '#' && S[i] == '#')
            return false;
    }

    for (int i = B + 2; i <= D; ++i)
    {
        if (S[i - 1] == '#' && S[i] == '#')
        {
            return false;
        }
    }
    bool has_space = false;
    if (S[B - 1] == '.' && S[B + 1] == '.')
        has_space = true;
    for (int i = B; i <= D; ++i)
    {
        if (i + 1 != N && S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.')
        {
            has_space = true;
        }
    }
    if (C < D)
        return true;
    return has_space;
}

int main()
{
    input();
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()

if H == 1:
  print(1)
  exit()

cnt = 1

while H >1:
  cnt += 1
  H //= 2
  
print(2**cnt -1)
  

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  vector< int > A(N);
  cin >> A;
  vector< map< pair< int, int >, int64 > > dp(K + 1);
  dp[0][{(1 << 18) - 1, 0}] = 1;
  for(auto &a : A) {
    for(int i = K - 1; i >= 0; i--) {
      for(auto &p : dp[i]) {
        int x = p.first.first & a;
        int y = p.first.second | a;
        if((x & X) != X || (y | Y) != Y) continue;
        dp[i + 1][{x, y}] += p.second;
      }
    }
  }
  int64 sum = 0;
  for(int i = K; i > 0; i--) sum += dp[i][{X, Y}];
  cout << sum << "\n";
}




Measured memory_bytes: 153932
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
	int a, b;

	cin >> a >> b;

	cout << max({a + b, a - b, a * b}) << endl;
}



Measured memory_bytes: 256
n, m, q = map(int, input().split())

lis = [list(map(int, input().split())) for _ in range(q)]

import itertools
seq = list(range(1,m+1))
lis_p = list(itertools.combinations_with_replacement(seq, n))

ans = 0
ans_max = 0

for li_p in lis_p:
    for li in lis:
        if li_p[li[1]-1] - li_p[li[0]-1] == li[2]:
            ans += li[3]
    #print(li_p, ans)
    if ans > ans_max:
        ans_max = ans
    ans = 0

print(ans_max)

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

#define MAXN (100010)
#define ll long long

int n;
int a[MAXN];
int aa[MAXN], bb[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        aa[i] = a[i];
        bb[i] = a[i];
    }
    std::vector<std::pair<int, int>> vec;
    for (int i = 1; i <= n; ++i) {
        int bi;
        scanf("%d", &bi);
        a[i] -= bi;
        if (a[i] > 0) {
            vec.push_back({a[i], i});
        }
    }
    std::sort(vec.begin(), vec.end());
    std::reverse(vec.begin(), vec.end());
    int ans = 0;
    int sz = (int)vec.size();
    for (int i = 1, j = 0; i <= n; ++i) {
        if (a[i] < 0) {
            while (a[i] < 0 && j < sz) {
                int min = std::min(-a[i], vec[j].first);
                a[i] += min;
                vec[j].first -= min;
                aa[vec[j].second] -= min;
                if (vec[j].first == 0) ++j;
            }
            if (a[i] < 0) {
                puts("-1");
                return 0;
            }
            ++ans;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (aa[i] != bb[i]) ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>

using namespace std;

int main(){
    int K,S,count=0;
    cin>>K>>S;
    for(int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
            if(S-x-y>=0&&S-x-y<=K){
                count++;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int n, m, q;
int a[100];
int b[100];
int c[100];
int d[100];
int ans = 0;
void rec(int i, int num, vector<int> v)
{
    if (i == n)
    {
        int res = 0;
        for (int i = 0; i < q; i++)
        {

            if (v[b[i] - 1] - v[a[i] - 1] == c[i])
            {
                res += d[i];
            }
        }
        ans = max(ans, res);
        return;
    }
    for (int j = num; j < m; j++)
    {
        v[i] = j;
        rec(i + 1, j, v);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> q;
    rep(i, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> tmp(n);
    rec(0, 0, tmp);
    cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	int prime[25] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
	int divisor[25]; // 約数の素因数分解結果
	memset(divisor, 0, sizeof(divisor));
	for (int i = 2, tmp;i <= N;++ i) {
		tmp = i;
		for (int j = 0;tmp > 1;++ j) {
			while (tmp % prime[j] == 0) {
				++ divisor[j];
				tmp /= prime[j];
			}
		}
	}
	
	int ans = 0;
	for (int i = 0;i < 25;++ i) {
		if (divisor[i] >= 74) ++ ans; // a^74の形
		for (int j = 0;j < 25;++ j) {
			if (i == j) continue;
			if (divisor[i] >= 4 && divisor[j] >= 14) ++ ans; // a^4*b^14
			if (divisor[i] >= 2 && divisor[j] >= 24) ++ ans; // a^2*b^24
			for (int k = j + 1;k < 25;++ k) {
				if (i == k || j == k) continue;
				if (divisor[i] >= 2 && divisor[j] >= 4 && divisor[k] >= 4) ++ ans; // a^2*b^4*c^4
			}
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

約数を75=3*5*5個持つ→a^2*b^4*c^4、あるいはa^4*b^14、あるいはa^2*b^24、あるいはa^74の形

それぞれについて成立するか考えていくと良い
*/

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

//#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")

//#define int long long
typedef pair <int, int> pii;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}


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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  vector<int> a;
  int one = 1;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == '0') {
      if (one) {
        a.push_back(cnt);
        one = 0;
        cnt = 0;
      }
    } else {
      if (!one) {
        a.push_back(cnt);
        one = 1;
        cnt = 0;
      }
    }
    cnt++;
  }
  if (cnt)
    a.push_back(cnt);
  if (a.size() % 2 == 0)
    a.push_back(0);
  dump(a);

  ll ans = 0;
  int left = 0;
  int right = 0;
  ll sum = 0;
  for (int i = 0; i < a.size(); i += 2) {
    int nleft = i;
    int nright = min(i + K * 2 + 1, (int)a.size());
    while (nleft > left) {
      sum -= a[left];
      left++;
    }
    while (nright > right) {
      sum += a[right];
      right++;
    }
    dump(left, right, sum);
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
# ABC075-B
H, W = map(int, input().split())
S = []
for i in range(H+2):
    if i == 0 or i == H+1:
        S.append('x' * (W+2))
    else:
        S.append('x' + input() + 'x')
        
for i in range(1, H+1):
    ans_tmp_str = ''
    for k in range(1, W+1):
        ans_tmp = 0   # count of bomb
        # print(S[i][k])
        if S[i][k] == '.':
            if S[i - 1][k - 1] == '#':
                ans_tmp += 1
            if S[i - 1][k] == '#':
                ans_tmp += 1
            if S[i - 1][k + 1] == '#':
                ans_tmp += 1
            if S[i][k - 1] == '#':
                ans_tmp += 1
            if S[i][k + 1] == '#':
                ans_tmp += 1
            if S[i + 1][k - 1] == '#':
                ans_tmp += 1
            if S[i + 1][k] == '#':
                ans_tmp += 1
            if S[i + 1][k + 1] == '#':
                ans_tmp += 1
            ans_tmp_str += str(ans_tmp)
           # print(ans_tmp_str)
        elif S[i][k] == '#':
            ans_tmp_str += '#'
    print(ans_tmp_str)


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

int main(){
    int n, m;   cin >> n >> m;
    vector<int> mb(n, 0), mc(n, 0);
    for(int i=0; i<m; i++){
        int x;  string s;   cin >> x >> s;
        x -= 1;
        if(s=="AC") mb[x] = 1;
        else if(s=="WA" && !mb[x]){
            mc[x] += 1;
        }
    }
    int cnt=0, w=0;
    for(int i=0; i<n; i++){
        if(mb[i]){
            cnt += 1; w += mc[i];
        }

    }
    cout << cnt << ' ' << w << endl;

}

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

int main() {
  int n, k, s;
  cin >> n >> k >> s;
  vector<ll> a(n);

  rep(i, n) {
    if (i < k)
      a[i] = s;
    else if (s < 1e9)
      a[i] = s + 1;
    else
      a[i] = 1;
  }

  rep(i, n) {
    cout << a[i];
    if (i == n - 1)
      cout << endl;
    else
      cout << ' ';
  }
  return 0;
}


Measured memory_bytes: 2048
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> cnt(4,0);
    REP(i,N){
        string s;
        cin>>s;
        if(s=="AC") cnt[0]++;
        if(s=="WA") cnt[1]++;
        if(s=="TLE") cnt[2]++;
        if(s=="RE") cnt[3]++;
    }

    cout<<"AC x "<<cnt[0]<<endl;
    cout<<"WA x "<<cnt[1]<<endl;
    cout<<"TLE x "<<cnt[2]<<endl;
    cout<<"RE x "<<cnt[3]<<endl;
    
}

Measured memory_bytes: 3628
n = int(input())
max_n = 100000
dp = [10000 for i in range(max_n+1)]
dp[0] = 0

for i in range(n+1):
  k = 1
  while i + k <= n:
    dp[i+k] = min(dp[i+k],dp[i]+1)
    k *=6
  k = 1
  while i + k <= n:
    dp[i+k] = min(dp[i+k],dp[i]+1)
    k*=9

print(dp[n])

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
const int MAX_N = 1e5;
const ll MOD = 1e9 + 7;

int main()
{
	scanf("%d",&N);
	vector< pair<int,bool> > A(N * 2);
	FOR(i,0,N){
		scanf("%d",&A [i].first);
		A [i].second = true;
	}
	FOR(i,0,N){
		scanf("%d",&A [i + N].first);
	}
	sort(ALL(A));

	ll ans = 1,cnt = 0;
	FOR(i,0,N * 2){
		if(A [i].second){
			if(cnt < 0){
				(ans *= abs(cnt)) %= MOD;
			}
			cnt++;
		}
		else{
			if(cnt > 0){
				(ans *= abs(cnt)) %= MOD;
			}
			cnt--;
		}
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1792
def count(cakes, sgns):
    a = [sum(x[i]*sgns[i] for i in range(3)) for x in cakes]
    a.sort(reverse=True)
    return sum(a[0:M])
N,M = map(int,input().split())
cakes = [tuple(map(int,input().split())) for _ in range(N)]

ans = []
for a in [-1,+1]:
    for b in [-1,+1]:
        for c in [-1,+1]:
            ans.append(count(cakes, (a,b,c)))
print(max(ans))


Measured memory_bytes: 3252
import math
N = int(input())

def main(N):
    if N % 2 == 1:
        print(0)
        return
    n = 1
    ans = 0
    N //= 2
    while N:
        N //= 5
        ans += N
    print(ans)

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


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
	double m[4], e, f, d, x, y;
	cout.setf (ios::fixed); cout.precision (3);
	while (cin >> m[0] >> m[1] >> e >> m[2] >> m[3] >> f) {
		d = m[0]*m[3] - m[1]*m[2];
		if (0.0 == ((x = (m[3]*e - m[1]*f)/d) + 0.0)) x = 0.0;
		if (0.0 == ((y = (m[0]*f - m[2]*e)/d) + 0.0)) y = 0.0;
		cout << x << " " << y << endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
 
int dead[200000];
 
struct List {
    List *prev;
    List *next;
    int no;
} players[200000];
 
int main()
{
    int n, m, q;
 
    scanf("%d %d %d", &n, &m, &q);
 
    for (int i = 0; i < n; i++){
        players[i].next = &players[(i + 1) % n];
        players[i].prev = &players[(i + n - 1) % n];
        players[i].no = i;
    }
 
    List *pos = &players[0];
 
    for (int r = 0; r < m; r++){
        int succ;
        scanf("%d", &succ);
        if (succ & 1){
            for (int i = 0; i < succ; i++){
                pos = pos->prev;
            }
        }
        else {
            for (int i = 0; i < succ; i++){
                pos = pos->next;
            }
        }
        dead[pos->no] = true;
        pos->next->prev = pos->prev;
        pos->prev->next = pos->next;
        pos = pos->next;
    }
 
    for (int i = 0; i < q; i++){
        int x;
        scanf("%d", &x);
        printf("%d\n", !dead[x]);
    }
 
    return (0);
}

Measured memory_bytes: 6660
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL qread(){
	#define cg (c=getchar())
	LL x,f=1;char c;
	while(cg<'0'||'9'<c)if(c=='-')f=-1;
	for(x=(c^48);'0'<=cg&&c<='9';x=(x<<1)+(x<<3)+(c^48));
	return x*f;
}
#define MAXN 2000
#define MAXA 2000
#define MOD 1000000007
LL niyuan=5e8+4;
LL N,K,ans;
LL a[MAXN+5];//原数组
LL pre[MAXN+5][MAXA+5];//第i位之前有多少个j
LL tot[MAXA+5],maxa;//数列中一共有多少个数
LL dp[MAXN+5];//原序列中大于i的数的个数
int main(){
	// ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	// cin>>N>>K;
	N=qread(),K=qread();
	for(LL i=1;i<=N;++i){
		++tot[a[i]=qread()];
		maxa=max(maxa,a[i]);
	}
	/*
	for(LL i=2;i<=N;++i){
		for(LL j=1;j<=maxa;++j)
			pre[i][j]=pre[i-1][j];
		++pre[i][a[i-1]];
	}
	*/
	for(int i=2;i<=N;++i){
		for(int j=1;j<=a[i-1]-1;++j)pre[i][j]=pre[i-1][j]+1;
			for(int j=a[i-1];j<=maxa;++j)pre[i][j]=pre[i-1][j];
	}
	for(LL i=maxa-1;i>=1;--i)dp[i]=(dp[i+1]+tot[i+1])%MOD;
	for(LL i=1;i<=N;++i){
		LL biger=((K*(K-1)%MOD*niyuan)%MOD)*dp[a[i]]%MOD;
		// for(LL j=a[i]+1;j<=maxa;++j)(biger+=pre[i][j]*K)%=MOD;
		(biger+=pre[i][a[i]]*K)%=MOD;
		(ans+=biger)%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
    public static void main(String[] args)throws IOException {
        BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
        String[] s=bufferedReader.readLine().split(" ");
        int ans=(Integer.parseInt(s[1])%Integer.parseInt(s[0])==0)?Integer.parseInt(s[0])+Integer.parseInt(s[1]):Integer.parseInt(s[1])-Integer.parseInt(s[0]);
        System.out.println(ans);
    }
}

Measured memory_bytes: 22356
#include <iostream>

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    if(s.size()!=t.size()-1){
        cout<<"No";
    }
    else{
            int c1=1;
        for(int i1=0;i1<s.size();i1++){
            if(s[i1]!=t[i1]){
                c1=0;
                break;
            }
        }
            if(c1==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    }

    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long  
const int MX =  2e5+7;
vector<int> v[MX];
int distan[MX] = { 0 };

void bfs(int start, int dis){

    bool vis[MX] = { false };
    queue<int> q;
    q.push(start);
    vis[start] = true;
    while(! q.empty() ){
        int p = q.front();
        q.pop();
        for(int i=0;i<v[p].size();i++){
                
            if(vis[ v[p][i] ] == false){
                
                distan[ v[p][i] ] += distan[p];   
                q.push( v[p][i] );
                vis[ v[p][i] ] = true;
                
            }               
        }
                
    }
}

int32_t main(){

        IOS;
        int n,m,q;
        cin >> n >> q;
        for(int i=1;i<=n-1;i++){
            int a,b;
            cin >> a >> b;
            v[a].push_back(b);
            v[b].push_back(a);
        }
        while(q--){
            int a,b;
            cin >> a >> b;
            distan[a] += b;
        }
        bfs(1,distan[1]);
        for(int i=1;i<=n;i++)
            cout << distan[i] << " ";
        cout << endl;
    
    return 0;
}



Measured memory_bytes: 18160
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

#define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://code//in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)

const double eps = 1e-8;
const int mod = 1000000007;
const int maxn = 1e4 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;

int n, m, x;
int vis[10];
int b[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[maxn];

void update(string& a, string b) {
    if(b.size() > a.size()) {
        a = b;
    } else if(a.size() == b.size()) {
        if(a < b) a = b;
    }
}

int main(){
    cin >>n >>m;
    for(int i = 0; i < m; i++) {
        cin >>x;
        vis[x] = 1;
    }
    for(int i = 2; i <= n; i++) {
        for(int j = 1; j <= 9; j++) {
            if(!vis[j]) continue;
            if(b[j] == i) update(dp[i], to_string(j));
            else if(b[j] < i && dp[i-b[j]] != "")
                update(dp[i], to_string(j) + dp[i-b[j]]);
        }
    }
    cout <<dp[n] <<endl;
    return 0;
}

Measured memory_bytes: 32512
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

vector <int> edges[200000];
long long counter[200000];
long long query_op[200000];
bool used[200000];
void dfs(int cur, long long cum_score){
    counter[cur] = query_op[cur] + cum_score;
    used[cur] = true;
    for(int i = 0; i < edges[cur].size(); i++){
        int next = edges[cur][i];
        if(used[next]){
            continue;
        } 
        dfs(next, cum_score + query_op[cur]);
    }
}

int main(){
    int N;
    int Q;
    cin >> N >> Q;
    for(int i  = 0; i < N - 1; i++){
        int a;
        int b;
        cin >> a >> b;
        edges[a - 1].push_back(b - 1);
        edges[b - 1].push_back(a - 1);
    }

    for(int i = 0; i < Q; i++){
        int p;
        int x;
        cin >> p >> x;
        query_op[p - 1] += x;
    }

    dfs(0, 0);

    for(int i = 0; i < N; i++){
        if(i != N - 1){
            cout << counter[i] << " ";
        } else {
            cout << counter[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25856