akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
vector<int> g[21],d[21];
void solve(int x,int l){
	if(x==1)return;
	if(l&1)g[1].push_back(x),d[1].push_back(l-1);
	if(l/2==0)return;
	g[x-1].push_back(x);
	g[x-1].push_back(x);
	d[x-1].push_back(0);
	d[x-1].push_back(l/2);
	solve(x-1,l/2);
}
int main(){
	int l;
	scanf("%d",&l);
	solve(20,l);
	int num=0;
	for(int i=1;i<21;i++)num+=g[i].size();
	printf("20 %d\n",num);
	for(int i=1;i<=20;i++){
		for(int j=0;j<g[i].size();j++){
			printf("%d %d %d\n",i,g[i][j],d[i][j]);
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();
        double a = Math.abs(x - scanner.nextInt());
        double b = Math.abs(x - scanner.nextInt());

        System.out.println((a > b) ? "B" : "A");

    }
}


Measured memory_bytes: 23636
#include "iostream"

using namespace std;

int main(){
    int N;
	cin >> N;
    
    int ans = N;
    int n;
    int res;
	for(int i = 0; i <= N; i++){
        res = 0;

        n = i;
		while(n > 0){
			res += n%6;
			n /= 6;
		}

		n = N - i;
		while(n > 0){
			res += n%9;
			n /= 9;
		}

		ans = min(ans, res);
	}

	cout << ans << endl;
	
    
    return 0;
}

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

int main(){
  int n,m,i,j,temp;
  cin>>n>>m;
  int a[n][m],b[m],c[n];
  for (j=0;j<n;j++){
    for (i=0;i<m;i++)cin>>a[j][i];
  }
  for (i=0;i<m;i++)cin>>b[i];
  for (j=0;j<n;j++){
    temp=0;
    for (i=0;i<m;i++)temp+=a[j][i]*b[i];
    cout<<temp<<endl;
  }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const int M  = 20;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}
ll a,b,c,d;

int main()
{
    fast
    ll n,k;
    cin>>n>>k;
    
    ll ans=0;
    set<ll>edges[n+1];
    forn(i,1,n+1)
    {
       forn(j,i+1,n+1)
       {
            if(i!=j)
            edges[i].insert(j);
       }
    }
    bool mark[n+1][n+1];
    reset(mark,0);
    bool isok=0;
    forn(i,1,n+1)
    {
        if(ans==k)
        {
            isok=1;
            break;
        }
        ll cnt=0;
        for(auto j:edges[i])
        {
            if(cnt<(n-i-1))
            {
                mark[i][j]=1;
                ans++;
                cnt++;
            }
            if(ans==k)
            {
                isok=1;
                break;
            }
        }
        if(ans==k)
        {
            isok=1;
            break;
        }
    }
    if(!isok)
    {
        cout<<-1;
        return 0;
    }
    ans=(n*(n-1))/2-ans;
    cout<<ans<<endl;
    forn(i,1,n+1)
    {
        for(auto j:edges[i])
        {
            if(!mark[i][j])
            cout<<i<<" "<<j<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 512
def ex_euclid(a, b):
  x0, x1 = 1, 0
  y0, y1 = 0, 1
  z0, z1 = a, b
  
  while z1 != 0:
    q = z0 // z1
    z0, z1 = z1, z0 % z1
    x0, x1 = x1, x0 - q * x1
    y0, y1 = y1, y0 - q * y1
  
  return z0, x0, y0

def mod_inv(a, n):
  g, x, _ = ex_euclid(a, n)
  if g != 1:
    print("modular inverse does not exist")
  else:
    return x % n

def mod_factorial(x, modulo):
  ans = 1
  for i in range(1, x+1):
    ans *= i
    ans %= modulo
  return ans

X, Y = map(int, input().split())
M = 10 ** 9 + 7
a, b = (2*X-Y)/3, (2*Y-X)/3
if a < 0 or b < 0:
  print(0)
elif a == 0 and b == 0:
  print(0)
elif a%1 != 0 or b%1!= 0:
  print(0)
else:
  a, b = int(a), int(b)
  answer = 1
  answer *= mod_factorial(a+b, M)
  answer *= mod_inv(mod_factorial(a, M), M)
  answer %= M
  answer *= mod_inv(mod_factorial(b, M), M)
  answer %= M
  print(answer)

Measured memory_bytes: 9296
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  string a;
  cin >> a;
  deque <char> dq;
  for (int i = 0; i < a.size(); i++) {
    dq.push_back(a[i]);
  }
  bool what = 0;
  int q;
  cin >> q;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      what ^= 1;
    } else {
      int t2;
      char c;
      cin >> t2 >> c;
      if (t2 == 1) {
        if (what == 0) {
          dq.push_front(c);
        } else {
          dq.push_back(c);
        }
      } else {
        if (what == 0) {
          dq.push_back(c);
        } else {
          dq.push_front(c);
        }
      }
    }
  }
  if (what == 0) {

  } else {
    reverse(dq.begin(), dq.end());
  }
  for (auto it : dq) {
    cout << it;
  }
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;

struct SegmentTree
{
  vector< int64 > seg;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, INF);
  }

  int64 rmq(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (INF);
    if(a <= l && r <= b) return (seg[k]);
    return (min(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
                rmq(a, b, 2 * k + 2, (l + r) >> 1, r)));
  }

  int64 rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, sz));
  }

  void update(int k, int64 x)
  {
    k += sz - 1;
    seg[k] = min(seg[k], x);
    while(k > 0) {
      k = (k - 1) >> 1;
      seg[k] = min(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }

};


int main()
{
  int N, Q, A, B, X[200000];
  cin >> N >> Q >> A >> B;
  --A, --B;
  for(int i = 0; i < Q; i++) cin >> X[i], --X[i];

  SegmentTree tree1(N), tree2(N);
  tree1.update(B, abs(A - X[0]) + B);
  tree2.update(B, abs(A - X[0]) - B);
  tree1.update(A, abs(B - X[0]) + A);
  tree2.update(A, abs(B - X[0]) - A);
  int64 sum = 0;
  for(int i = 1; i < Q; i++) {
    int64 latte = tree1.rmq(X[i], N) - X[i] - abs(X[i - 1] - X[i]);
    int64 malta = tree2.rmq(0, X[i]) + X[i] - abs(X[i - 1] - X[i]);
    tree1.update(X[i - 1], min(latte, malta) + X[i - 1]);
    tree2.update(X[i - 1], min(latte, malta) - X[i - 1]);
    sum += abs(X[i - 1] - X[i]);
  }
  int64 ret = INF;
  for(int i = 0; i < N; i++) ret = min(ret, tree1.rmq(i, i + 1) - i);
  cout << ret + sum << endl;
}

Measured memory_bytes: 9216
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val fredgeCount: Int = sc.nextInt()
    val microwaveCount: Int = sc.nextInt()
    val ticketCount: Int = sc.nextInt()

    val fredges: Array[Int] = Array.fill(fredgeCount)(sc.nextInt())
    val microwaves: Array[Int] = Array.fill(microwaveCount)(sc.nextInt())
    val tickets: Array[(Int, Int, Int)] =
      Array.fill(ticketCount)((sc.nextInt(), sc.nextInt(), sc.nextInt()))

    val ticketMin =
      tickets.map { ticket =>
        val (fredge, microwave, discount) = ticket
        val fredgePrice = fredges(fredge - 1)
        val microwavePrice = microwaves(microwave - 1)
        fredgePrice + microwavePrice - discount
      }.min

    val fredgeMin = fredges.min
    val microwaveMin = microwaves.min
    val nonTicketMin = fredgeMin + microwaveMin

    val ans = Math.min(ticketMin, nonTicketMin)

    println(ans)
  }
}


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

ll ans = 0;

const int N = pow(10,5) + 20;
bool x[N] = {};

int main(){
    ll n,k,r,s,p,ans = 0;
    string t;

    bool f[N] = {};

    cin >> n >> k >> r >> s >> p >> t;

    for(int i = 0; i < n; ++i){
        if(i >= k){
            if(t[i] == t[i - k]){
                if(f[i - k] == false){
                    f[i] = true;
                }else{
                    if(t[i] == 'p')ans += s;
                    if(t[i] == 's')ans += r;
                    if(t[i] == 'r')ans += p;
                }
            }else{
                if(t[i] == 'p')ans += s;
                if(t[i] == 's')ans += r;
                if(t[i] == 'r')ans += p;
            }
        }else{
            if(t[i] == 'p')ans += s;
                if(t[i] == 's')ans += r;
                if(t[i] == 'r')ans += p;
        }
    }



    

    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n;
    cin >> n;
    vll x(n);
    vll xs(n);
    rep(i, n) {
        cin >> x[i];
        xs[i] = x[i];
    }
    Sort (xs);
    
    ll l = xs[n/2 - 1];
    ll r = xs[n/2];
    
    rep(i, n) {
        if (x[i] <= l) mes(r);
        if (x[i] > l) mes(l);
    }
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 6428
#include <iostream>

using namespace std;

struct Item
{
  long long w;
  int v;
};

const long long PINF = 1000LL*1000LL*1000LL*1000LL;

int main()
{
  int n;
  long long W;
  cin >> n >> W;
  Item items[n];
  for (int i = 0; i < n; ++i)
    cin >> items[i].w >> items[i].v;
  int nbV = n*1000;
  long long dp[n+1][nbV+1];
  for (int i = 0; i < nbV + 1; ++i)
    dp[0][i] = PINF;
  dp[0][0] = 0;
  long long best = 0LL;
  for (int i = 1; i < n + 1; ++i)
    for (int j = 0; j < nbV + 1; ++j)
    {
      dp[i][j] = min(dp[i-1][j], (j >= items[i-1].v) ? dp[i-1][j-items[i-1].v] + items[i-1].w : dp[i-1][j]);
      best = max(best, (dp[i][j] <= W) ? j : 0LL);
    }
  cout << best << '\n';
}


Measured memory_bytes: 79104
package main

import "fmt"

func main() {
	var a int
	var b int
	var c int
	fmt.Scan(&a, &b, &c)
	if a > c {
		tmp := a
		a = c
		c = tmp
	}
	if a > b {
		tmp := a
		a = b
		b = tmp
	}
	if b > c {
		tmp := b
		b = c
		c = tmp
	}
	fmt.Println(a, b, c)
}


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

using namespace std;

typedef long long ll;

int main(){

    ll n, m, a;
    cin >> n >> m;
    priority_queue<ll> pq;
    for(int i = 0; i < n; i++){
        cin >> a;
        pq.push(a);
    }
    while(m && (!pq.empty())){
        auto p = pq.top();
        pq.pop();
        if(p){
            p = p>>1;
            m--;
            if(p)
                pq.push(p);
        }else{
            break;
        }
    }
    ll sm = 0;
    while(!pq.empty()){
        sm += pq.top();
        pq.pop();
    }

    cout << sm << endl;
    return 0;
}

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

#define o(output) cout << output << endl

using namespace std;

string s;
int a,b,c,d;
char A,B;
priority_queue<int> pr;

int main(){
  cin>>a>>b;
  for(int i=0;i<a;i++){
    int dispo;
    cin>>dispo;
    pr.push(dispo);
    }
  for(int i=0;i<b;i++){
    c+=pr.top();
  pr.pop();
    }
  o(c);
}

Measured memory_bytes: 256
#include <stdio.h>
    #include <map>
    #include <utility>
    using namespace std;
    const int N=1e5+10;
    int max(int a,int b){return a>b?a:b;}
    map<pair<int,int>,int> m;
    int a[N][3];
    int dp(int n,int last){
    if(n==0)return 0;
    if(m.find({n,last})!=m.end())return m[{n,last}];
    return m[{n,last}]=max(dp(n-1,(last+1)%3)+a[n][(last+1)%3],dp(n-1,(last+2)%3)+a[n][(last+2)%3]);
    }
    int main(){
    int n;
      scanf("%d",&n);
      for(int i=1;i<=n;i++)scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
      printf("%d\n",max(dp(n,0),max(dp(n,1),dp(n,2))));
    }

Measured memory_bytes: 32640
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, N;
  cin >> H >> W >> N;
  int sr, sc;
  cin >> sr >> sc;
  sr--; sc--;
  string S, T;
  cin >> S >> T;

  int left = 0, right = W-1;
  if(S.at(N-1) == 'L') left++;
  if(S.at(N-1) == 'R') right--;
  for(int i = N-2; i >= 0; i--){
    if(T.at(i) == 'L') right = min(right+1, W-1);
    else if(T.at(i) == 'R') left = max(left-1, 0);
    if(S.at(i) == 'L') left++;
    if(S.at(i) == 'R') right--;
    if(left > right){
      cout << "NO" << endl;
      return 0;
    }
  }
  

  int up = 0, down = H-1;
  if(S.at(N-1) == 'U') up = 1;
  if(S.at(N-1) == 'D') down = H-2;
  for(int i = N-2; i >= 0; i--){
    if(T.at(i) == 'U') down = min(down+1, H-1);
    else if(T.at(i) == 'D') up = max(up-1, 0);
    if(S.at(i) == 'U') up++;
    if(S.at(i) == 'D') down--;
    if(up > down){
      cout << "NO" << endl;
      return 0;
    }
  }
  

  if(left <= sc && sc <= right && up <= sr && sr <= down) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 920
PROGRAM piyo
      IMPLICIT NONE
      character(6) :: s
      
      read*,s
      
      if( s(3:3)==s(4:4) .and. s(5:5)==s(6:6) )then
        print*,'Yes'
      else
        print*,'No'
      end if
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
vector<int> a;

bool checkArray(){
  for(int i = 0; i < a.size(); i++){
    if(a[i]%2 == 0) a[i] /= 2;
    else return false;
  }
  return true;
}

int main(){
  int n,cnt = 0;
  cin >> n;
  a = vector<int>(n);
  for(int i = 0; i < a.size(); i++) cin >> a[i];
  while(true){
    if(checkArray()) cnt++;
    else break;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a[101][101] = {0};
	int b[101] = {0};
	int d[101] = {0};
	int i,j,r,c;
	int x;
	int e = 0;
	
	scanf("%d %d" , &r,&c);
	
	for(j=0; j<r; j++) {
		for(i=0; i<c; i++) {
			scanf("%d",&x);
			a[j][i] = x;
		}
	}
	
	for(j=0; j<r; j++){
		for(i=0; i<c; i++) {
			b[i] += a[j][i];
		}
	}
	
	for(j=0; j<r; j++){
		for(i=0; i<c; i++){
			d[j] += a[j][i];
		}
	}
	
	for(j=0; j<r; j++) {
		for(i=0; i<c; i++) {
			printf("%d ",a[j][i]);
		}
		printf("%d\n", d[j]);
	}
	for(i =0; i<c; i++) {
		printf("%d " ,b[i]);
		e += b[i];
	}
	printf("%d\n", e);
	
	return 0;
}


Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
    class Program
    {
      static void Main(string[] args){
        int s = Int32.Parse(Console.ReadLine());
        var ret = new List<int>();
        ret.Add(s);
        int x=s;
        int result = 2;
        for(int i=result; i<100000 ;i++){
          x=f(x);
          if(ret.Contains(x)) {
            result = i;
            break;
          }
          ret.Add(x);
        }
        Console.Write(result);
      }
      static int f(int n){
        if(n%2==0) return n /2;
        return 3 * n +1;
      }
    }





Measured memory_bytes: 13148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll a[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort (a + 1, a + n + 1);
	ll ans = 1e18;
	for (int x = a[1]; x <= a[n]; x++) {
		ll res = 0;
		for (int i = 1; i <= n; i++) {
			res += (a[i] - x) * (a[i] - x);
		}
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			long a = sc.nextLong();
			long b = sc.nextLong();
			long k = sc.nextLong();
			
			if ( a >= k ) {
				System.out.println( (a-k) + " " + b);
			}
			else {
				k = k - a;
				if ( b >= k ) {
					System.out.println( 0 + " " + (b-k));
				}
				else {
					System.out.println("0 0");
				}
			}
		}
	}
}

Measured memory_bytes: 38888
N, a, b = map(int, input().split())

MOD = 10**9+7

def modcmb(n, r, m):
    x = 1
    y = n
    for i in range(2,r+1):
        x *= i
        x %= MOD
        y *= n-i+1
        y %= MOD
    return y * pow(x, m-2, m) % m

ans = pow(2, N, MOD) - modcmb(N, a, MOD) - modcmb(N, b, MOD) - 1
print(ans % MOD)

Measured memory_bytes: 3064
#include	<stdio.h>

int		main(void)
{
	int a, b, c, k;
	int i;

	scanf("%d %d %d", &a, &b, &c);
	scanf("%d", &k);

	for (i = 0; i < k; i++) {
		if (c <= a) {
			c *= 2;
		}
		else if (c <= b) {
			c *= 2;
		}
		else if (b <= a) {
			b *= 2;
		}
	}

	if ((a < b) && (b < c)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE;
    SetConsoleTextAttribute(hConsole, 7);
    cerr << '\n';
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1> {}(p.first);
        auto h2 = hash<T2> {}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "-1\n";
    exit(0);
}
const int NMAX = 3 * 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;
const int seed = 1e3 + 7;


string s;
int main()
{
    FASTIO;
    cin >> s;
    for0(i, s.size() - 1) if(s[i] == 'A' && s[i + 1] == 'C') return cout << "Yes",0;
    cout << "No";
    return 0;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[][] a = new char[n][n];
        char[][] b = new char[m][m];
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            for (int j = 0; j < n; j++) {
                a[i][j] = str.charAt(j);
            }
        }
        for (int i = 0; i < m; i++) {
            String str = sc.next();
            for (int j = 0; j < m; j++) {
                b[i][j] = str.charAt(j);
            }
        }
        boolean flag = false;
        outer:
        for (int i = 0; i <= n - m; i++) {
            for (int j = 0; j <= n - m; j++) {
                boolean flagTemp = false;
                inner:
                for (int k = 0; k < m; k++) {
                    for (int l = 0; l < m; l++) {
                        if (a[i + k][j + l] != b[k][l]) {
                            break inner;
                        } else if (k == m - 1 && l == m - 1) {
                            flagTemp = true;
                        }
                    }
                }
                if (flagTemp) {
                    flag = true;
                    break outer;
                }
            }
        }
        if (flag) System.out.println("Yes");
        else System.out.println("No");
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define MAXN 105
using namespace std;
int n;
double tan2[MAXN],x[MAXN],y[MAXN];
const double pie=acos(-1);

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%lf%lf",&x[i],&y[i]);
	for(int i=1; i<=n; i++)
	{
		memset(tan2, 0, sizeof(tan2)); double ans=0;
//		for(int i=1;i<=n;i++)
//			cout<<x[i]<<','<<y[i]<<' ';
		cout<<endl;	
		swap(x[1], x[i]); swap(y[1], y[i]);
		for(int j=2; j<=n; j++)
			tan2[j]=atan2(y[1]-y[j], x[1]-x[j]);
			
		sort(tan2+2, tan2+1+n);
//		for(int j=2; j<=n; j++)
//			printf("%.3lf !\n",tan2[j]);
		for(int j=3; j<=n; j++)
			ans=max(ans, tan2[j]-tan2[j-1]-pie);
		ans=max(ans, tan2[2]-tan2[n]+pie);
		printf("%.18lf\n",ans/(2*pie));
		swap(x[1], x[i]); swap(y[1], y[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int a;
while(cin>>a,a){
	map<string,string>s;
	for(int b=0;b<a;b++){
	string c,k;
	cin>>c>>k;
	s.insert(pair<string,string>(c,k));
	}
	int d;
	cin>>d;
	string r="";
	for(int e=0;e<d;e++){
	string t;
	cin>>t;
	if(s[t].empty()==true)s[t]=t;;
	r+=s[t];
	}
	cout<<r<<endl;
	}
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6 && a <=12){
        cout << b/2 <<endl;
    }else{
        cout << 0 << endl;
    }
}

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

int main() {
  int A,B,K,sum=0;
  cin >> A >> B >> K;
  while(K!=sum){
      sum +=1;
      if(sum%2==1){
        if(A%2==1){
          A=A-1;
        }
        B=B+A/2;
        A=A/2;
      }if(sum%2==0){
        if(B%2==1){
          B=B-1;
        }
        A=A+B/2;
        B=B/2;
      }
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
"use strict";

function main(input) {
  var lines = input.split('\n');
  var str = lines[0];
  var length = str.length;

  for (var start = 0; start < length; start++) {
    for (var end = start; end <= length; end++) {
      var s = str.slice(0, start) + str.slice(end);

      if (s === 'keyence') {
        console.log('YES');
        return;
      }
    }
  }

  console.log('NO');
}

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

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 22188
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int R0, W0, C, R;
	while (cin >> R0 >> W0 >> C >> R, R0 || W0 || C || R) {
		REP(i, 0, 10001) {
			if (R0 + i*R >= W0*C) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x,y,z;
    cin>>x>>y>>z;
    if (x+y+z>=22)
    cout<<"bust";
    else
    cout<<"win";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }


int find(char str[]) {
  long long key;
  int i ,position;
  key = getKey(str);
  for(i = 0; ; i++) {
    position = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[position], str) == 0) {
      return 1;
    }
    else if(H[position][0] == '\0'){
      return 0;
    }
  }
  return 0;
}
 

int insert(char str[]){
  long long key;
  int position,i;
  key=getKey(str);
  for(i=0; ;i++){
    position = (h1(key) + i * h2(key)) % M;
    if(H[position][0]=='\0'){
      strcpy(H[position],str);
      return 0;
    }
    else if(strcmp(H[position], str) == 0)return 1;
  }

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i;
ll a[maxN], sum, last;

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
    sort(a + 1, a + n + 1);

    last = sum = 0;
    for (i = 1; i < n; i++) {
        sum += a[i];
        if (2 * sum < a[i + 1])
            last = a[i + 1];
    }

    ll ans = 0;
    for (i = 1; i <= n; i++)
        if (a[i] >= last)
            ans++;

    printf("%lld", ans);


    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <bitset>
#include <stack>
#include <queue>
#include <map>
#include <functional>
using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpii;

int N;
long long A[100000];

int main(void){

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

    for(;;){
        sort(A, A+N);
        long long  n = -1;
        for(int i = 0; i < N; i++){
            if(A[i] == 0) 
                continue;
            if(n == -1) {
                n = A[i]; 
                if(i == N - 1) {
                    cout << A[N-1] << endl; 
                    return 0;
                }
                continue;
            }
            A[i] %= n;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
const ll M=1000000007;
//------------------------------------------//

int main(){
  int N,K;cin>>N>>K;
  vector<int> h(N);
  rep(i,N) cin>>h[i];
  sort(h.begin(),h.end());
  
  int ans=M;
  rep(i,N-K+1){
    ans=min(ans,h[i+K-1]-h[i]);
  }
  cout<<ans<<endl;
}

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


int main(){
    int n ;
    cin >> n ;
    ll X[n] , Y[n] , H[n] ;
    rep(i,n) cin >> X[i] >> Y[i] >> H[i] ;
    int ans_H = 0 ;
    int ans_Y = 0 ;
    ll ans_X = 0 ;
    ll ch ;  
    rep(x,101){
        rep(y,101){
            rep(i,n) if( H[i] != 0 ) ch =(ll) H[i] + abs(x - X[i]) + abs(y - Y[i]) ;
            int count = 0 ;
            rep(i,n) if( H[i] == max(ch - abs(x - X[i]) - abs(y - Y[i]),(ll)0) )count++ ;
            if( count == n ){
                    ans_H = ch ;
                    ans_X = x  ;
                    ans_Y = y  ;
            }
        }
    }
    cout << ans_X << endl;
    cout << ans_Y << endl ;
    cout << ans_H << endl;
}


Measured memory_bytes: 256
import copy
N = int(input())
numList = list(map(int, input().split()))
numListCopy = copy.deepcopy(numList)
numList = sorted(numList)
medIndex = int((N)/2)
med1 = numList[medIndex-1]
med2 = numList[medIndex]


for i in range(0,N):
	if numListCopy[i] <= med1:
		print(med2)
	elif med2 <= numListCopy[i]:
		print(med1)

Measured memory_bytes: 26528
def solve(X, P):
    if X not in P:
        return X
    l = X
    while l in P:
        l -= 1
    r = X
    while r in P:
        r += 1
    return min(l, r, key=lambda x: (abs(x - X), x))


def main():
    X, N = map(int, input().split())
    P = [int(p) for p in input().split()]
    print(solve(X, P))


if __name__ == "__main__":
    main()


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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int n;
    cin >> n;
    vi a(n);
    int res;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i==0)
            res = a[i];
        else
            res = __gcd(res, a[i]);
    }
    cout << res;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    string s;
    cin >> s;
    ll n = s.size();
    vector<ll> count(26);
    loop(i, n)
    {
        count[(ll)(s[i] - 'a')]++;
    }
    //例えばaが6個有れば6C2=6*5/2通りだけ場合の数が減る
    ll ans = 1 + n * (n - 1) / 2;
    loop(i, 26) ans -= count[i] * (count[i] - 1) / 2;
    putout(ans);
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);
vector<vector<int>> G;
void dfs(int now,vector<int> &dist){
  for(auto nv:G[now]){
    if(dist[nv]>=0)continue;
    dist[nv]=dist[now]+1;
    dfs(nv,dist);
  }
}
int main(){
  int n,u,v;
  cin >> n >> u >> v;
  u--;
  v--;
  G.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int>d1(n,-1),d2(n,-1);
  d1[u]=0;d2[v]=0;
  dfs(u,d1);
  dfs(v,d2);
  int ans=0;
  rep(i,n){
    if(d1[i]<d2[i]){
      ans = max(ans,d2[i]-1);
    }
  }
  cout << ans << endl;
  
}


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

int main()
{
    int N,K;
    scanf("%d%d",&N,&K);
    int A[N],i;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    int ans=0,sum=0;
    while( sum < N ){
        sum += K;
        if( sum < N ){
            sum--;
        }
        ans++;
    }

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

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
const int mod = 1000000007;

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

vl fac(1000000, 1);
vl invfac(fac.size(), 1);

ll bin (int k, int n) {
  if (k < 0 || k > n) return 0;
  return fac[n] * invfac[k] % mod * invfac[n-k] % mod;
}

int main() {
  for (int i = 2; i < fac.size(); ++i) fac[i] = fac[i-1] * i % mod;
  invfac.back() = mpow(fac.back(), mod - 2);
  for (int i = fac.size() - 2; i > 0; --i) invfac[i] = invfac[i + 1] * (i+1) % mod;
  int n,m,k;
  while (cin >> n >> m >> k) {
    ll sum = 1, res = 0;
    for (int s = 0; s <= m + k; ++s) {
      ll mul = mpow(3, m + k - s) * bin(s, s + n - 1) % mod;
//      sum = 0;
//      for (int i = max(0, s - k); i <= min(s, m); ++i) {
//        sum = (sum + bin(i, s)) % mod;
//      }
      res = (res + mul * sum) % mod;
      sum = sum * 2 - bin(min(s, m), s) + bin(max(0, s - k) - 1, s);
      if (s < m) sum += 1;
      if (s >= k) sum -= bin(s - k, s + 1);
      sum %= mod;
    }
    cout << (res % mod + mod) % mod << endl;
  }
  return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  int x = 0;
   cin >> N;
vector<int> vecA(N);
for (int i = 0; i < N; i++) {
  cin >> vecA.at(i);
}
  vector<int> vecB(N);
for (int i = 0; i < N; i++) {
  cin >> vecB.at(i);
}
  vector<int> vecC(N);
for (int i = 0; i < N-1; i++) {
  cin >> vecC.at(i);
}
  
  for (int i = 0; i < N; i++) {
    x = x + vecB.at(vecA.at(i)-1);
      if (i < N-1 && vecA.at(i) + 1 == vecA.at(i+1)) {
        x = x + vecC.at(vecA.at(i)-1);
      }
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
<?php

$N = trim(fgets(STDIN));
$A = explode(" ",trim(fgets(STDIN)));

$dp[0][0] = 0; // * +1
$dp[0][1] = -10 ** 9; // * -1

for ($i=1; $i < $N+1; $i++) { 
    $dp[$i][0] = max($dp[$i-1][0]+$A[$i-1],$dp[$i-1][1]-$A[$i-1]);
    $dp[$i][1] = max($dp[$i-1][0]-$A[$i-1],$dp[$i-1][1]+$A[$i-1]);
}

echo $dp[$N][0];

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t H;
  cin >> H;
  int64_t res = 0, cnt = 1;
  while (H > 0) {
    H /= 2;
    res += cnt;
    cnt *= 2;
  }
  cout << res << '\n';
  return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
        for (auto &u : v) os << u << endl;
        return (os);
}

template<typename T>
istream& operator >>(istream &is, pair<vector<T>&, int> v) {
        while (v.second--) {
                T a;
                v.first.push_back(is >> a, a);
        }
        return (is);
}

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

int main() {
    ll A, B;
    cin >> A >> B;
    ll val = 1ll << 61;
    
    ll ans = 0ll;
    ll stopper = 1ll << 61;
    while (A <= B && val) {
        if (B >= val) {
            if (A < val) {
                ans += (val - A);
                ans += max(0ll, min(stopper - val, val) - A);
                B = min(B - val, A - 1);
                stopper = min(A, stopper - val);
                A = 0;
            } else {
                A -= val, B -= val;
                stopper -= val;
            }
        }
        val >>= 1;
    }
    if (val == 0 && A == B && stopper != A) ans++;
    cout << ans << el;
    return (0);
}


Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        if (total % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 50756
#include <iostream>
using namespace std;
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    if(A-B >=C){
        cout << "0" << endl;
    }
    else if(A-B <C){
        cout << C-(A-B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 200005
#define FH 400005
#define inf INT32_MAX
#define MOD 1000000007LL

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pr;


inline void solve()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	fore(i, 0, n)
	{
		if (i == k - 1)
			s[i] = tolower(s[i]);
	}
	cout << s;
}



int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
n = int(input())

if n < 10:
  print(n)
elif n < 100:
  print(9)
elif n < 1000:
  print(n - 90)
elif n < 10000:
  print(909)
elif n < 100000:
  print(9 + 900 + (n - 9999))
else:
  print(90909)

Measured memory_bytes: 2940
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#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;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[21][21];
ll cost[(1 << 16)];
ll dp[(1 << 16)];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 0; i < n; i ++)
      for (int j = 0; j < n; j ++)
         cin >> a[i][j];
   for (int mask = 0; mask < (1 << n); mask ++) {
      for (int i = 0; i < n; i ++) {
         if (!(mask & (1 << i))) continue;
         for (int j = 0; j < n; j ++) {
            if (!(mask & (1 << j))) continue;
            cost[mask] += a[i][j];
         }
      }
      dp[mask] = cost[mask];
   }
   for (int mask = 0; mask < (1 << n); mask ++) {
      for (int t = mask;t; t = ((t - 1) & mask)) {
         dp[mask] = max (dp[mask], dp[t] + dp[(mask ^ t)]);
      }
   }
   cout << dp[(1 << n) - 1] / 2;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 1280
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    T = [
        ['d','r','e','a','m'],
        ['d','r','e','a','m','e','r'],
        ['e','r','a','s','e'],
        ['e','r','a','s','e','r']
    ]
    S = list(_ for _ in input())
    S.reverse()

    for i in range(4):
        T[i].reverse()
    while len(S)>0:
        if(''.join(S[0:len(T[0])]) == ''.join(T[0])):
            for i in range(len(T[0])):
                S.pop(0)
        elif(''.join(S[0:len(T[1])]) == ''.join(T[1])):
            for i in range(len(T[1])):
                S.pop(0)
        elif(''.join(S[0:len(T[2])]) == ''.join(T[2])):
            for i in range(len(T[2])):
                S.pop(0)
        elif(''.join(S[0:len(T[3])]) == ''.join(T[3])):
            for i in range(len(T[3])):
                S.pop(0)
        else:
            print('NO')
            break
        
    if(len(S) ==0):
        print('YES')

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 4580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String n = sc.next();
		int N = Integer.parseInt(n);
		int sn[] = new int[n.length()];
		int S = 0;
		sc.close();

		for (int i = 0; i < n.length(); i++) {
			sn[i] = Integer.parseInt(n.substring(i, i + 1));
			S += sn[i];
		}

		if (N % S == 0) {
			System.out.print("Yes");
		} else {
			System.out.print("No");

		}

	}
}

Measured memory_bytes: 22996