akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;

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...));
}

const int MOD = 1000000007;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

int main()
{
    ll a,b ; cin >> a >> b;

    ll fa;
    if(a%4==0) fa=0;
    else if(a%4==1) fa=a-1;
    else if(a%4==2) fa=(a-1)^(a-2);
    else if(a%4==3) fa=(a-1)^(a-2)^(a-3);

    ll fb;
    if((b+1)%4==0) fb=0;
    else if((b+1)%4==1) fb=b;
    else if((b+1)%4==2) fb=b^(b-1);
    else if((b+1)%4==3) fb=b^(b-1)^(b-2);

    pl((fa^fb))
}

Measured memory_bytes: 256
//Battlefield control establishing...
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#define MCV main
#include<iomanip>
#define reset(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
//Get ready? LET'S ROCK!
int MCV()
{
   int t,x;
   cin>>t>>x;
   double ans=(double)t/x;
   cout<<fixed<<setprecision(10)<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
aMax=a[-1]
isAns=[0]*(aMax+1) ## 1=ans 2=multiple or plural
for ai in a:
    isAns[ai]+=1
    if isAns[ai]==1:
      for j in range(2*ai,aMax+1,ai):
        isAns[j]+=2

print(isAns.count(1))

Measured memory_bytes: 32080
Sx, Sy, Tx, Ty = map(int, input().split())

def Main(Sx, Sy, Tx, Ty):
    x = Tx - Sx
    y = Ty - Sy
    dir = ['U','R','D','L','U','R','D','R','D','L','U']
    steps = [y, x, y, x+1, y+1, x+1, 1, 1, y+1, x+1, 1]
    ans = []
    for d, s in zip(dir, steps):
        ans.append(d*s)
    return "".join(ans)
          
                    
print(Main(Sx, Sy, Tx, Ty))

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
    char a[100];
    int i;
    for(i=0;(a[i]=getchar())!='\n';i++);
    for(int j=i-1;j>=0;j--){
        cout<<a[j];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 500;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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

void solve() {
	int a, b, c; cin >> a >> b >> c;
	int x = a ^ b^c;
	if (a == b && a == c) {
		cout << "No" << endl;
	}
	else if (x == a || x == b || x == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init_f(); init();
	//int t; cin >> t; rep(i, t)solve();
	//while(cin>>n,n)solve();
	solve();
	stop
		return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

void counting_sort(const vi& A, vi& B, const int k) {
    int n = A.size();
    vi C(k + 1, 0);

    rep(i, 0, n) {
        ++C[A[i]];
    }

    rep(i, 1, k + 1) {
        C[i] += C[i - 1];
    }

    rrep(i, 0, n) {
        B[C[A[i]] - 1] = A[i];
        --C[A[i]];
    }
}

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

    vi A(n), B(n);
    rep(i, 0, n) { cin >> A[i]; }

    counting_sort(A, B, 10000);

    rep(i, 0, n) {
        cout << B[i];
        if (i != n - 1) { cout << " "; }
        else { cout << endl; }
    }

    return 0;
}


Measured memory_bytes: 18332
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using vi=vector<int>;


void prt(vi&v, int n)
{
	for(int i=0;i+1<n;i++) printf("%d ", v[i]);
	printf("%d\n", v[n-1]);
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi v={1};

		for(int i=2;n-1>v.size();i++)
		{
			vi t=v;
			v.push_back(i);
			copy(t.begin(), t.end(), back_inserter(v));
		}

		for(int i=n-1;i>0;i--)
		{
			prt(v, i);
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>

void trace(int A[], int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i > 0)
        {
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N)
{
    int j, v;
    for (int i = 0; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N;
    scanf("%d", &N);

    int A[N];

    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }
    
    insertionSort(A, N);

    return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        cout <<"Bad";
    } else
        cout <<"Good";


    return 0;
}


Measured memory_bytes: 256
import numpy as np
N,W = map(int,input().split())
V = 1000 * N + 1
dp = np.full(V,W + 1)
dp[0] = 0
for i in range(N):
    w,v = map(int,input().split())
    dp[v:] = np.minimum(dp[v:],dp[:-v] + w)
print(np.max(np.where(dp<=W)))

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

int main() {
  int n; cin >> n;
  vector<int> t(n);
  int sum = 0;
  for (int& e: t) cin >> e, sum += e;

  int m; cin >> m;
  for (int i = 0; i < m; i++) {
    int p, x; cin >> p >> x;
    int ans = sum - t.at(p - 1) + x;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
n = input()
k = int(input())
dp = [[0]*(k+1) for _ in range(2)]
dp[0][0] = 1
for i in range(len(n)):
    newdp = [[0]*(k+1) for _ in range(2)]
    for j in range(k+1):
        if n[i]=='0':
            newdp[0][j] = dp[0][j]
            newdp[1][j] = dp[1][j]
            if j>0:
                newdp[1][j] += dp[1][j-1]*9
        else:
            newdp[1][j] = dp[0][j] + dp[1][j]
            if j>0:
                newdp[0][j] = dp[0][j-1]
                newdp[1][j] += dp[0][j-1]*(int(n[i])-1) + dp[1][j-1]*9
    dp = newdp
print(dp[0][k]+dp[1][k])

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
const double eps=1e-10;

const int N=10005;
int n,m,i,j,x,y,k,t,p;
LL ji,ou,ans;
int main()
{
    scanf("%d%d",&n,&p);
    while(n--)
    {
        scanf("%d",&t);
        if(t%2==1)ji++;
        else ou++;
    }
    if(ji==0)ans=pow(2,ou);
    else
    ans=pow(2,ou)*pow(2,ji-1);
    if(ji==0&&p%2==1)ans=0;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 384
from math import factorial
n, m = map(int, input().split())
if abs(n - m) == 1:
    print((factorial(n) * factorial(m)) % 1000000007)
elif abs(n - m) == 0:
    print(((factorial(n) * factorial(m)) * 2) % 1000000007)
else:
    print(0)

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  int a, b;
  cin >> a >> b;
  if(a >= 13){
    cout << b <<endl;
  }else if(6 <= a){
    cout << b / 2 <<endl;
  }else{
    cout << 0 <<endl;
  }
}


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

int main(){

  int h, w;
  int i, j;

  while(1){
    cin >> h >> w;
    if(w == 0 && h == 0)
      break;

    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	if(i % 2 == 0 && j % 2 == 0)
	  cout <<"#";
	else if(i % 2 == 0 && j % 2 == 1)
	  cout <<".";
	else if(i % 2 == 1 && j % 2 == 0)
	  cout <<".";
	else
	  cout <<"#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
  int N,i,j,n,d,top,left,right,bottom;

  for(;;){
    scanf("%d", &N);
    if(!N) break;

    int squ[400][400]={0};
    int posx[200]={0}; int posy[200]={0};
    squ[200][200]=1;
    posx[0]=200; posy[0]=200;
    for(i=1;i<N;i++){
      scanf("%d %d", &n, &d);
      if(d==0){
	posx[i]=posx[n]-1; posy[i]=posy[n];
      } else if(d==1){
	posx[i]=posx[n]; posy[i]=posy[n]-1;
      } else if(d==2){
	posx[i]=posx[n]+1; posy[i]=posy[n];
      } else if(d==3){
	posx[i]=posx[n]; posy[i]=posy[n]+1;
      }
      squ[posx[i]][posy[i]]=1;
    }
    for(i=0;i<201;i++){
      for(j=0;j<400;j++){
	if(squ[j][i]==1){
	  top=i; i=200; break;
	}
      }
    }
    for(i=0;i<201;i++){
      for(j=0;j<400;j++){
	if(squ[i][j]==1){
	  left=i; i=200;  break;
	}
      }
    }
    for(i=399;i>199;i--){
      for(j=0;j<400;j++){
	if(squ[i][j]==1){
	  right=i; i=200;  break;
	}
      }
    }
    for(i=399;i>199;i--){
      for(j=0;j<400;j++){
	if(squ[j][i]==1){
	  bottom=i; i=200;  break;
	}
      }
    }
    printf("%d %d\n", right-left+1, bottom-top+1);
  }

  return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int L;
  cin >> L;
  double tmp = L / 3.0;
  cout << fixed << setprecision(12) << tmp * tmp * tmp << endl;
  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



i64 n, k, a[101010], b[101010];
P p[101010];
bool used[101010];
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		a[i]--;
		p[i] = {b[i],a[i]};
	}
	sort(p,p+n, greater<P>());
	
	i64 ans = 0, cnt = 0;
	stack<i64> st;
	for(int i = 0; i < k; i++){
		i64 c = p[i].first, pos = p[i].second;
		ans += c;
		if(used[pos]){
			st.push(c);
			continue;
		}
		used[pos] = 1;
		cnt++;	
	}
	i64 aans = ans;
	ans += cnt*cnt;
	for(int i = k; i < n; i++){
		if(st.empty()) break;
		i64 c = p[i].first, pos = p[i].second;
		if(used[pos]) continue;
		used[pos] = 1;
		cnt++;
		aans += c - st.top();
		chmax(ans, aans+cnt*cnt);
		st.pop();
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3840
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n := nextInt()
	k := nextInt()
	var a, b int

	for i := 0; i < n; i++ {
		xi := nextInt()
		if xi <= k/2 {
			a += xi
		} else {
			b += k - xi
		}
	}
	fmt.Println((a + b) * 2)
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

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

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i, b in enumerate(B):
    if b <= A[i]:
        ans += b
    else:
        ans += A[i]
        b -= A[i]
        if b <= A[i+1]:
            ans += b
        else:
            ans += A[i+1]
        
        A[i+1] = max(0, A[i+1]-b)

print(ans)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B, K; cin >> A >> B >> K;
    int count = 0;
    for(int i = min(A, B); i >= 1; i--)
    {
        if(A % i == 0 && B % i == 0) count++;
        if(count == K)
        {
            cout << i << endl;
            return;
        }
    }
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
 
    string S, T;
    cin >> S >> T;

    sort(S.begin(), S.end());
    sort(T.rbegin(), T.rend());
    
    if(S < T) cout << "Yes" << endl;
    else cout << "No" << endl;



}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <set>
#include <map>
#define N 42
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, x, y, z;
int st[1<<16][11];
ll dp[N][1<<16];
bool check(vector<int>ds, int d) {
  reverse(ds.begin(), ds.end());
  ds.push_back(d);
  reverse(ds.begin(), ds.end());
  int sum=0;
  int i =0;
  while(i < ds.size()) {
    sum += ds[i];
    i++;
    if (sum >= z) break;
  }
  if (sum != z) return true;
  sum = 0;
  while(i < ds.size())  {
    sum += ds[i];
    i++;
    if (sum >= y) break;
  }
  if (sum != y) return true;
  sum = 0;
  while(i < ds.size()) {
    sum += ds[i];
    i++;
    if (sum >= x) break;
  }
  return sum != x;
}
int main() {
  cin>>n>>x>>y>>z;
  memset(st, -1, sizeof(st));
  for (int i = 0; i < (1<<16); ++i) {
    vector<int> ds;
    ds.clear();
    int j = i;
    while(j) {
      int cnt=0;
      while(!((1<<cnt)&j)) {
        cnt++;
      }
      ds.push_back(cnt+1);
      j >>= (cnt+1);
    }
    for (int j = 1; j <= 10; ++j) {
      if (check(ds, j)) {
       // if (i==0 && j==1) cout<<"ok!"<<endl;
        int sum=j;
        int k=0;
        int s2 = 1<<(j-1);
        int bits = j;
        for (; k < ds.size(); ++k) {
          if (sum + ds[k] > 16) break;
          sum += ds[k];
          bits += ds[k];
          s2 += 1<<(bits-1);
        }
      //  if (i==0 && j == 1) cout<<"s2="<<s2<<endl;
        st[i][j] = s2;
      }
    }
  }
  memset(dp, 0LL, sizeof(dp));
  dp[0][0] = 1LL;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < (1<<16); ++j) {
      if (!dp[i][j]) continue;
      for (int k = 1; k <= 10; ++k) {
        if (st[j][k] >= 0) {
          dp[i+1][st[j][k]] = (dp[i+1][st[j][k]] + dp[i][j]) % mod;
        }
      }
    }
  }
  ll ans=1LL;
  for (int i = 1; i <= n; ++i) {
    ans = ans * 10LL % mod;
  }
  for (int i = 0; i < (1<<16); ++i) {
    ans = (ans - dp[n][i]+mod) % mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 24576
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();

        int total = 0;
        for (int i=0; i<2; i++) {
            if (a>=b) {
                total += a;
                a--;
            } else {
                total += b;
                b--;
            }
        }
        System.out.println(total);
    }
}

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

//using namespace std;


int main(void) {

	int n, k, x, y;
	std::cin >> n >> k >> x >> y;
	if (n > k) {
		std::cout << k * x + (n - k) * y << std::endl;
	}
	if (n <= k) {
		std::cout << n * x << std::endl;
	}
	return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
ll n;
cin>>n;
vector<ll> c(n);
rep(i,n)cin>>c[i];
sort(c.begin(),c.end());
vector<mint> t(n+1);
t[0]=1;
rep(i,n){
	t[i+1]=t[i]*2;
}
mint ans=0;
rep(i,n){
	int r=n-1-i;
mint temp=0;

		temp+=t[r];
		temp+=(t[r]/2)*r;
	temp*=t[i];
	temp*=c[i];
	temp*=t[n];
//	cout<<temp.x<<endl;
	ans+=temp;

}
cout<<ans.x;

}


Measured memory_bytes: 3328
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin >>n;
    vector<long long> b(n+1), a(n);
    for(long long i = 0; i < n+1; i++)
        cin >>b[i];
    for(long long i = 0; i < n; i++)
        cin >>a[i];
    long long ans = 0;
    for(long long i = 0; i < n; i++){
        // ith hero will first finish monsters in ith position
        // and then move to (i+1)th position
        long long temp = min(a[i], b[i]);
        // kill monsters at ith position
        a[i] -= temp;
        b[i] -= temp;
        ans += temp;
        // kill monsters at (i+1)th position
        temp = min(a[i], b[i+1]);
        a[i] -= temp;
        b[i+1] -= temp;
        ans += temp;
    }
    cout <<ans;
    return 0;
}


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

using namespace std;

void solve()
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}

int main()
{
    solve();
    cerr << "努力不足ですね！" << endl;
    return 0;
}


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

int main(){
	int A,B;
	cin >> A >> B;
	int t(1),ans(0);
	for(int i(0);i<100;++i){
		if(t>=B) break;
		t--;
		t+=A;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    x=input()
    print(chr(ord(x)+1))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, l;
	cin>>n>>l;
	vector<string> v(n);
	for(int i=0; i<n; i++)
		cin>>v[i];
	sort(v.begin(), v.end());
	for(int i=0; i<n; i++)
		cout<<v[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a;
    cin >> a;
    float ans;
    if (a%2 == 0){
        ans = 0.5f;
    }
    else{
        int b = a/2;
        ans = (float)(b+1)/a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= A - B) {
		if (A + B >= A*B) cout << A + B;
		else cout << A*B;
	}
	else {
		if (A - B >= A*B)cout << A - B;
		else cout << A*B;
	}
	
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias t = Tuple!(string, "name", long, "y");

void main()
{
    auto n = lread();
    auto tax = 1.08;
    auto a = (n / tax).ceil();
    if((a * tax).floor() == n)
        writeln(a);
    else
        writeln(":(");
}

auto getdisit(T)(T n)
{
    T i = 0;
    while (abs(n) >= 1)
    {
        n /= 10;
        i++;
    }
    return i;
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int Maxn = 100000;
long long L[100];
int n;
int main()
{
    cin>>n;
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= n; i++)
        L[i] = L[i-1] + L[i-2];
    cout<<L[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
#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 solve(vector<int>& A, int m) {
        for (auto& x : A) {
            x /= 2;
        }
        int g = 0;
        for (auto x : A) {
            g = gcd(g, x);
        }

        for (auto& x : A) {
            x /= g;
        }

        int n = A.size();
        for (int i = 1; i < n; ++i) {
            if ((A[i] ^ A[i - 1]) & 0x1) {
                return 0;
            }
        }

        int res = 0;
        m /= g;
        int X = 0;

        long long L = 1;
        for (int i = 0; i < n; ++i) {
            L = lcm(L, A[i]);
            if (L > m) {
                return res;
            }
        }
        // cout << m << " " << g << " " << X << " " << L << endl;
        X = L;
        if (X <= m) {
            ++res;
        }
        res += (m - X) / (2 * L);

        return res;
    }

private:
    long long gcd(long long a, long long b) {
        while (a != 0) {
            b %= a;
            swap(a, b);
        }
        return b;
    }

    long long lcm(long long a, long long b) {
        return a / gcd(a, b) * b;
    }
};

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

    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Solution sol;
    cout << sol.solve(A, m) << "\n";

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
  int c[3][3];
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
      cin >> c[i][j];
  }
  int a[3], b[3];
  a[0] = 0;
  for (int i = 0; i < 3; i++)
    b[i] = c[0][i];
  for (int i = 1; i < 3; i++)
    a[i] = c[i][0] - c[0][0];
  string ans = "Yes";
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      if (a[i] + b[j] != c[i][j])
        ans = "No";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#define PI pair<int,int>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define R register
using namespace std;
namespace chu_xuan{
    void swap(int &a,int &b){R int tmp=a;a=b,b=tmp;}
    void read(int &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}
    int In() {int a=0,b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*b;}
    int max(int a,int b){return a>b?a:b;}
    int min(int a,int b){return a>b?b:a;}
}using namespace chu_xuan;

const int N=1e5+5;
int n,m,a[N];
ll b[N],ans;

int main()
{
    read(n);read(m);
    for(int i=1;i<=m;i++) read(a[i]);
    sort(a+1,a+1+m);
	for(int i=2;i<=m;i++) b[i-1]=a[i]-a[i-1];
	sort(b+1,b+m);
	// for(int i=1;i<=m;i++) cout<<b[i]<<' ';puts("");
	for(int i=1;i<=m-n;i++) ans+=b[i];
	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a,b,c,temp;
	scanf("%d%d%d",&a,&b,&c);
	temp=a;
	a=b;
	b=temp;
	temp=c;
	c=a;
	a=temp;
	printf("%d %d %d",a,b,c);
}


Measured memory_bytes: 256
t=int(input())
arr1=list(map(int,input().strip().split()))[:t]
y=max(arr1)
arr1.sort(reverse= True)
summ=0
l1=[]
l1.append(y)
w=len(arr1)
for x in range(1,w):
  l1.append(arr1[x])
  l1.append(arr1[x])
j=0
for x in range(1,w):
  summ=summ+l1[j]
  j+=1
print(summ)
  

Measured memory_bytes: 31360
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	double A, B, H, M;
	cin >> A >> B >> H >> M;

	double pi = acos(-1.0);

	double theta = fabs(pi * (60.0 * H - 11.0 * M) / 360.0);

	double l = sqrt(A * A + B * B - 2.0 * A * B * cos(theta));

	cout << fixed;
	cout << setprecision(12) << l << endl;

	return 0;
}



Measured memory_bytes: 4232
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    vector<lint> a;
    vector<lint> s;
    lint ans;
    cin >> n;
    while(true){
        ans = -LINF;
        a.clear();
        a.resize(n);
        s.clear();
        s.resize(n+1);
        s[0] = 0;
        for (int i=0; i<n; ++i){
            cin >> a[i];
        }
        for (int i=0; i<n; ++i){
            s[i+1] = s[i] + a[i];
        }
        for (int i=1; i<=n; ++i){
            for (int j=i; j<=n; ++j){
                ans = max(ans, s[j] - s[i-1]);
            }
        }
        cout << ans << endl;
        cin >> n;
        if(n == 0){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int[] A = new int[N];
			for(int i = 0; i < N; i++) {
				A[i] = in.nextInt();
			}
			String ans = "APPROVED";
			for(int i = 0; i < N; i++) {
				if(A[i] % 2 == 0) {
					if(A[i] % 3 == 0 || A[i] % 5 == 0) {
						
					} else {
						ans = "DENIED";
						break;
					}
				}
			}
			System.out.println(ans);
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256];

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 23380
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<algorithm>
#include<string>
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#include"bits/stdc++.h"
#define LL long long
using namespace std;
#define INF 1000000000





LL N,M,x[100000],xx[100000]/*,A[100000],B[100000],C[100000]*/,W,a,ans,c;

vector<LL> A,B,C;
string s;
int main() {
  
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>M;
		A.push_back(M);
	}
	for(int i=0;i<N;i++){
		cin>>M;
		B.push_back(M);
	}
	for(int i=0;i<N;i++){
		cin>>M;
		C.push_back(M);
	}
	sort(A.begin(),A.end());

	sort(C.begin(),C.end()); 
	a=0;
	c=0;
	for(int i=0;i<N;i++){

		a=lower_bound(A.begin(),A.end(),B[i])-A.begin();
		c=N-(upper_bound(C.begin(),C.end(),B[i])-C.begin());
		
		ans+=a*c;
	}

	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 3316
//abc44

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int n,a;
int x[60];
lint dp[60][60][3000];

int main(){
  cin >> n >> a;
  dp[0][0][0] = 1;
  REP(i,n) cin >> x[i];
  for (int i=1;i<=n;i++){
    for(int j=0;j<=50*n;j++){
      for(int k =0;k<=i;k++){
      dp[i][k][j] += dp[i-1][k][j];
      if(j-x[i-1]>=0&&k>0){
        dp[i][k][j] += dp[i-1][k-1][j-x[i-1]];
      }
    }
    }
  }
  lint ans = 0;
  for(int i=1;i<=n;i++){
    ans += dp[n][i][i*a];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 69888
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()


def flip(c):
    return 'W' if c == 'S' else 'S'


def solve(a1, a2):
    """
    :param a1:
    :param a2:
    :rtype: str
    """
    ans = a1 + a2
    cursor = 1
    while cursor < N:
        if S[cursor] == 'o' and ans[-1] == 'S' or S[cursor] == 'x' and ans[-1] == 'W':
            ans += ans[-2]
        else:
            ans += flip(ans[-2])
        cursor += 1

    if ans[0] == ans[-1]:
        ans = ans[:-1]
        if (ans[0] == 'S' and S[0] == 'o' and ans[1] == ans[-1] or
                ans[0] == 'S' and S[0] == 'x' and ans[1] != ans[-1] or
                ans[0] == 'W' and S[0] == 'o' and ans[1] != ans[-1] or
                ans[0] == 'W' and S[0] == 'x' and ans[1] == ans[-1]):
            return ans
    return ''


# 最初の 2 個が決まれば最後まで決まる
for a1, a2 in itertools.product('SW', repeat=2):
    ret = solve(a1, a2)
    if ret:
        print(ret)
        exit()
print(-1)


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

//int i,n;
#define REP(i,n) for(int i = 0; i < (int n); i++)
typedef long long ll;



int main(void){
	int A,B,C ;
	cin >> A >> B >> C ;

	if (A == B && B == C && A == C) {
		cout << "No" << endl;
	} else if (A != B && B != C && A != C ) {
		cout << "No" << endl;
		}else if (A == B || B == C || A == C ) {
		cout << "Yes" << endl;
		}

}


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

#define int long long

using namespace std;

const int N = 105, M = 1e6 + 123, inf = 1e18 + 7;

int n, s;

int w[N], a[N], can[M], dp[M], ans, sum;

main () {
    cin >> n >> s;
    for (int i = 1;i <= n;i ++) {
        cin >> w[i] >> a[i];
        sum += a[i];
    }can[0] = 1;
    for (int i = 1;i <= 1e6;i ++) {
        dp[i] = inf;
    }
    for (int i = 1;i <= n;i ++) {
        for (int j = sum;j >= 0;j --) {
            if (can[j]) {
                can[j + a[i]] = 1;
                dp[j + a[i]] = min (dp[j + a[i]], dp[j] + w[i]);
                if (dp[j] + w[i] <= s)ans = max (ans, j + a[i]);
            }
        }
    }cout << ans;
}


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

using namespace std;

#define REP(i,a,b) for(int i = a; i <= b; ++i)
#define PER(i,a,b) for(int i = a; i >= b; --i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;

const int maxn = 1e7;
const int maxa = 5000;
const int P = 1e9+7;

int Fac[maxn+5], InvFac[maxn+5];
LL PowMod(LL a, LL b) { LL r=1; while(b) { if(b&1) r=r*a%P; a=a*a%P, b>>=1; } return r; }
LL C(int n, int m) { return LL(Fac[n]) * InvFac[m] % P * InvFac[n-m] % P; }

void Add(int &a, int b) { a+=b; if(a>=P) a-=P; }
void Sub(int &a, int b) { a-=b; if(a<0) a+=P; }

int main() {
    Fac[0] = 1;
    REP(i,1,maxn) Fac[i] = Fac[i-1] * LL(i) % P;
    InvFac[maxn] = PowMod(Fac[maxn], P-2);
    PER(i,maxn-1,0) InvFac[i] = InvFac[i+1] * LL(i+1) % P;

    int n, m, ans = 0;
    scanf("%d%d", &n, &m), n -= m;
    REP(t,1,m+1) {
        int tmp = 0;
        for(int i = 1; i <= t-1; ++i) {
            LL ha = C(t-1, i);
            ha = ha * Fac[i] % P * Fac[i+n-1] % P;
            if(i >= 1)
                ha = ha * InvFac[i-1] % P;
            if(t <= m)
                ha = ha * Fac[i+n+m-t] % P * InvFac[i+n] % P;
            if((t-1-i)&1) Sub(tmp, ha);
            else Add(tmp, ha);
        }
        Add(ans, tmp);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 81964
import collections
import copy
import sys
N = int(input())

cost = 0
diff_list = []
x_y_list = []

if N == 1:
    print(1)
    sys.exit()

for n in range(N):
    x, y = map(int, input().split())
    x_y_list.append((x, y))
    cost += 1

x_y_list_copy = copy.copy(x_y_list)

for n in range(N):
    x_y = x_y_list.pop()
    x = x_y[0]
    y = x_y[1]
    for tmp_x, tmp_y in x_y_list:
        diff_list.append((x - tmp_x, y - tmp_y))

for n in range(N):
    x_y = x_y_list_copy.pop(0)
    x = x_y[0]
    y = x_y[1]
    for tmp_x, tmp_y in x_y_list_copy:
        diff_list.append((x - tmp_x, y - tmp_y))

counter = collections.Counter(diff_list)
print(cost - max(counter.values()))

Measured memory_bytes: 39920
n = $stdin.readline.to_i
r = Array.new(n) { $stdin.readline.chomp.split.map(&:to_i) }.sort_by! {|_, y| - y }
b = Array.new(n) { $stdin.readline.chomp.split.map(&:to_i) }.sort_by! {|x, _| x }

while !b.empty?
  xb, yb = b.shift
  i = r.bsearch_index {|_, y| - y > - yb } || r.size
  while i < r.size && r[i][0] > xb
    i += 1
  end
  if i < r.size
    r.delete_at(i)
  end
end
puts n - r.size

Measured memory_bytes: 14396
#include <stdio.h>

int main(void)
{
	int a=0,b=0,c=0;
	int count=0;
	scanf("%d %d %d",&a,&b,&c);
	
	for(a;a<=b;a++){
		if(c%a==0){
			count++;
		}
	}
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 596
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,m;
  cin >> n >> m;

  cout << (n+m-1)/m << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int c,cont1=0,cont2=0,a=0,b=0;
	for(int i=0;i<4;i++){
		c = getchar();
		if(a==0)a=c;
		else if(c!=a && b==0)b=c;
		else if(c==a)cont1++;
		else if(c==b)cont2++;
	}
	if(cont1==1 && cont2==1)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  string S[H+2];
  S[0]="";
  S[H+1]="";
  for(int i=1;i<H+1;i++){
    cin>>S[i];
  }
  for(int i=0;i<W+2;i++){
    S[0]+="#";
    S[H+1]+="#";
  }
  for(int i=1;i<H+1;i++){
    S[i]="#"+S[i];
    S[i]=S[i]+"#";
  }
  for(int i=0;i<H+2;i++){
    cout<<S[i]<<endl;
  }
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

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

	ll MOD = 1e9 + 7;
	ll ans = 0LL;
	for(ll i = 0LL; i < 62; i++){
		vector<vector<ll>> v(n+1, vector<ll>(2, 0LL));
		for(ll j = n-1; j >= 0; j--){
			ll x = (a[j] >> i) & 1LL;
			v[j][x] = v[j+1][x] + 1LL;
			v[j][1-x] = v[j+1][1-x];
		}

		// rep(i, n+1) rep(j, 2) cout << v[i][j] << (j == 1 ? "\n" : " ");

		ll t = 0LL;
		rep(j, n-1){
			ll x = (a[j] >> i) & 1LL;
			t += v[j+1][1-x];
			t %= MOD;
		}

		// cout << b << " " << t << endl;
		ll b = 1LL << i;
		b %= MOD;
		ll y = t * b;
		y %= MOD;
		ans += y;
		ans %= MOD;
	}

	cout << ans << endl;
}


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

typedef unsigned long long ull;

const ull B=100000007;

using namespace std;

int RabinKarp(string,string);

int main(void){
  string a,b;
  int n,count=0;

  getline(cin,a);
    cin >> n;
    cin.ignore();
    
    for(int i=0;i<n;i++){
    getline(cin,b); 
    b+=b;
    count+=RabinKarp(a,b);
    }
    
    cout << count << endl;

  return 0;
}

int RabinKarp(string a,string b){
  int al=a.size(),bl=b.size();

  ull t=1;
  for(int i=0;i<al;i++)t*=B;

  ull ah=0,bh=0;

  for(int i=0;i<al;i++){
    ah=ah*B+a[i];
    bh=bh*B+b[i];
  }
  
  for(int i=0;i+al<=bl;i++){
    if(ah==bh)return 1;
    if(i+al<bl)bh=bh*B+b[i+al]-b[i]*t;
  }
  return 0;
}

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

const int INF = 1e9;
int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	int res[n] = {};
	for (int i = 1; i < n; i++){
		for (int j = i+1; j < n+1; j++){
			if (i == j) continue;
			int pass1 = j - i;
			int pass2 = abs(x-i) + abs(y-j) + 1;
			res[min(pass1, pass2)]++;
		}
	}

	for (int i = 1; i < n; i++){
		cout << res[i] << endl;
	}



}


Measured memory_bytes: 256