akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
typedef pair<int, int> pii;//cost, vertex
struct edge{
  int to, cost;
};

int main(int argc, char *argv[]){
  int n, m, r;
  cin >> n >> m >> r;
  vector<vector<edge> > g(n);
  int from;
  for (int i = 0; i < m; i++) {
    edge e;
    cin >> from >> e.to >> e.cost;
    g[from].push_back(e);
  }
  int dp[n];
  for (int i = 0; i < n; i++) {
    dp[i] = 1e9;
  }
  dp[r] = 0;
  priority_queue<pii, vector<pii>, greater<pii> > que;
  que.push(mp(0, r));
  //???????????§?????????
  //??????????????????????????????
  while(!que.empty()){
    int v = que.top().second;
    int c = que.top().first;
    que.pop();
    for (int i = 0; i < g[v].size(); i++) {
      edge e = g[v][i];
      if(dp[e.to] > c + e.cost){
        dp[e.to] = c + e.cost;
        que.push(mp(dp[e.to], e.to));
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if(dp[i] == 1e9)std::cout << "INF" << std::endl;
    else std::cout << dp[i] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 11228
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

bool dfs(int x, int y, vector<string> &threads) {
	if(threads[y][x] == '+') return true;
	if(islower(threads[y][x])) return false;

	const bool res = dfs(x, y - 1, threads);
	if(res) threads[y][x] = '|';
	return res;
}

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

	for(int n; cin >> n && n;) {
		vector<string> threads(n);
		for(auto &e : threads) cin >> e;

		vector<int> pos(n, -1);
		REP(y, 1, n) {
			rep(x, threads[y].size() - 1) {
				if(islower(threads[y][x + 1])) {
					threads[y][x] = '+';
					pos[y] = x;
					break;
				}

				threads[y][x] = ' ';
			}
		}

		REP(y, 1, n) {
			dfs(pos[y], y - 1, threads);
		}

		for(const auto &s : threads) {
			cout << s << endl;
		}
	}

	return EXIT_SUCCESS;
}

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


using ll = long long int;
using namespace std;





int main()
{
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	
	ll n, b, r;
	cin >> n >> b >> r;
	ll ans = 0;
	if (b)
	{
		ans = (n / (b+r)) * b + min((n % (b + r)), b);
	}
	
	cout << ans;
	
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    ll sum=0;
   for(int i=0;i<s.length();i++){
       sum+=s[i]-'0';
   }
    if(sum%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3732
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll n,m;
int main() {
	cin>>n;
	int minn  = INF;
	int cnt = 0;
	for(int i=1;i<=n;i++){
		int t ;
		cin>>t;
		minn = min(minn,t);
		if(t<=minn) cnt++;
	} 
	cout<<cnt<<endl;
}



Measured memory_bytes: 256
n,a,b,c = map(int,input().split())
flag = True
ans = []
s = []
for i in range(n):
    s.append(input())
for i in range(n):
    if s[i] == "AB":
        if a == 0 and b == 0:
            flag = False
        if a > b:
            a -= 1
            b += 1
            ans.append("B")
        elif b > a:
            a += 1
            b -= 1
            ans.append("A")
        else:
            if i != n-1:
                if s[i+1] == "AC":
                    a += 1
                    b -= 1
                    ans.append("A")
                else:
                    a -= 1
                    b += 1
                    ans.append("B")
            else:
                ans.append("A")
    if s[i] == "BC":
        if b == 0 and c == 0:
            flag = False
        if b > c:
            b -= 1
            c += 1
            ans.append("C")
        elif b < c:
            b += 1
            c -= 1
            ans.append("B")
        else:
            if i != n-1:
                if s[i+1] == "AB":
                    b += 1
                    c -= 1
                    ans.append("B")
                else:
                    c += 1
                    b -= 1
                    ans.append("C")
            else:
                ans.append("B")
    if s[i] == "AC":
        if a == 0 and c == 0:
            flag = False
        if a > c:
            a -= 1
            c += 1
            ans.append("C")
        elif c > a:
            a += 1
            c -= 1
            ans.append("A")
        else:
            if i != n-1:
                if s[i+1] == "AB":
                    a += 1
                    c -= 1
                    ans.append("A")
                else:
                    c += 1
                    a -= 1
                    ans.append("C")
            else:
                ans.append("A")
if flag:
    print("Yes")
    for i in ans:
        print(i)
else:
    print("No")


Measured memory_bytes: 85828
#include <iostream>
     
    using namespace std;
     
    int main(){
    	int h,w,a,b;
    	cin>>h>>w>>a>>b;
    	for(int i=0;i<h;i++){
    		for(int j=0;j<w;j++){
    			if((i<b)^(j<a))
    				cout<<1;
    			else
    				cout<<0;
    		}
    		cout<<"\n";
    	}
    	return 0;
    }

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>
#include<math.h>
#include<queue>
#include<stack>

using ll = long long;

#define veci            vector<int>
#define vecs            vector<string>

#define vecpii          vector<pair<int,int>>
#define vecpis          vector<pair<int,string>>
#define vecpss          vector<pair<string,string>>
#define mkp             make_pair

#define vecvi(vv,n,m,l) vector<vector<int>> vv(n,veci(m,l))
                                                     // lで初期化
#define vecvs           vector<vector<string>>

using namespace std;

int main()
{
  int n;
  ll ans,e;
  cin >> n;
  vector<ll> a(n);
  e = pow(10,18);
  ans = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0;
      return 0;
    }
  }

  for (int j = 0; j < n; j++) {
    if (e / a[j] < ans) {
      cout << -1;
      return 0;
    }
    ans *= a[j];
  }

    cout << ans;

  return (0);
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    ll a,b; cin >> a >> b;

    ll ans = 0LL;

    for(ll n=1LL; n<=b; n*=2){

        ll num_zero = 0LL;
        ll num_one = 0LL;

        ll k = (b+1)/n;
        ll m = (b+1)%n;

        num_zero += n*((k+1LL)/2LL);
        num_one += n*(k/2LL);

        //cout << num_zero << " " << num_one << endl;

        if(k%2==1) num_one += m;
        else num_zero += m;

        k = a/n;
        m = a%n;

        num_zero -= n*((k+1LL)/2LL);
        num_one -= n*(k/2LL);

        if(k%2==1) num_one -= m;
        else num_zero -= m;

        //cout << num_zero << " " << num_one << endl;
        //cout << n*((num_zero%2)^(num_one%2)) << endl;

        ans += n*(num_one%2);

        //cout << "" << endl;

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=160;
int a[maxn],b[maxn],c[maxn],d[maxn];
bool used[maxn];
int girl[maxn],line[maxn][maxn];
int n;

bool Find(int x)
{
    for(int j=1;j<=n;j++)
    {
        if(line[x][j]&&!used[j]){
            used[j]=1;
            if(girl[j]==0||Find(girl[j])){
                girl[j]=x;
                return true;
            }
        }
    }
    return false;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=1;i<=n;i++) cin>>c[i]>>d[i];
    memset(line,0,sizeof(line));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++){
            if((a[i]<c[j])&&(b[i]<d[j])){
                line[i][j]=1;
            }
        }
    }
    memset(girl,0,sizeof(girl));
    int ans=0;
    for(int i=1;i<=n;i++){
        memset(used,0,sizeof(used));
        if(Find(i)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
l = list(map(int,input().split()))
l.append(0)
l1 = [0]
l = l1+l

count = 0
for i in range(1,n+2):
    count+=+abs(l[i]-l[i-1])
for i in range(1,n+1):
    if l[i-1] <= l[i] <= l[i+1] or l[i-1] >= l[i] >= l[i+1]:
        print(count)
    else:
        print(count-(abs(l[i]-l[i-1])+abs(l[i+1]-l[i]))+abs(l[i+1]-l[i-1]))


Measured memory_bytes: 14048
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int a,b;
    cin>>a>>b;
    if(a > b)
    	swap(a,b);
    for(int i=0;i<b;i++)
    	cout<<a;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> G(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> seen(n,-1);
    int count=0;
    rep(i,n){
        if(seen[i]!=-1) continue;
        queue<int> que;
        que.push(i);
        seen[i]=count;
        while(!que.empty()){
            int v=que.front();
            que.pop();
            for(auto nv:G[v]){
                if(seen[nv]!=-1) continue;
                que.push(nv);
                seen[nv]=count;
               // printf("%d %d %d\n",count,v,nv);
            }
        }
        count++;
    }
    //連結部の個数-1が答え
    cout<<count-1<<endl;
    return 0;
}


Measured memory_bytes: 8804
import java.util.*;

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

    public static void solve1091() {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int a = sc.nextInt();
            int l = sc.nextInt();
            int x = sc.nextInt();
            double nitouhen = menseki(a, calcHeight(l, a));
            double yoyuu = menseki(l, calcHeight(0.5 * (l + x), l));
            System.out.println(nitouhen + 2 * yoyuu);
        }
    }

    public static double menseki(double teihen, double takasa) {
        return 0.5 * teihen * takasa;
    }

    public static double calcHeight(double syahen, double ippen) {
        return Math.sqrt(syahen * syahen - 0.5 * ippen * 0.5 * ippen);
    }
}




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


int main(){
    int a,b;
    cin>>a>>b;
    double ans;
    if(floor(a/0.08*0.1)==b)
        ans=a/0.08;
    else if(floor(b/0.1*0.08)==a)
        ans=b/0.1;
    else
        ans=-1;
    
    cout<<ceil(ans)<<endl;
}

Measured memory_bytes: 256
/**
 * Created by karayuu on 2019/06/17
 */
fun main(args: Array<String>) {
  var (A, B, x) = readLine()!!.split(" ").map { it.toInt() }
  if (x % 500 != 0) {
    //500の倍数に切り上げる
    x += (500 - x % 500)
  }

  /**
   * 1000mLが500mLより安かったら,1000mLを多く使う方が良い
   * 500mL * 2が1000mLより安かったら,500mLを多く使う方が良い
   * それ以外は1000mLを限界まで使って,500mLを残りで払えば良い
   */
  //1000mLを買う個数
  var a = 0
  //500mLを買う個数
  var b = 0

  if (A < B) {
    //1000mLを限界まで買う
    a = x / 1000
    //余ってたらもう一本買う
    if (x % 1000 > 0) {
      a++
    }
  } else if (A > B * 2) {
    b = x / 500
    //xは500の倍数にしているので,これが余ることはない
  } else {
    //1000mLで限界まで買って,500mLを残り買う
    a = x / 1000
    x %= 1000
    b = x / 500
  }

  //出力
  println(A * a + B * b)
}


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

int main(){
    long a,b,c,k;
    cin >> a >> b >> c >> k;
    long ans = 0;
    if(k<a)
        ans = k;
    else if(k<a+b){
        ans = a;
    }
    else {
        ans = a*1 + b*0 + (k-a-b)*(-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define iof freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

using namespace std;
#define f first
#define s second
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define inFile(t) freopen((t),"r",stdin)
#define outFile(t) freopen((t),"w",stdout)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define EPS 1e-7
long long mod = 1e9 + 7;
const int N = 1e4 + 5;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
//typedef complex <ll> point;
typedef tuple<int, int, int> line;
//typedef vector<point> polygon;


int main()
{

	ld sum = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		ld x;
		cin >> x;
		sum += 1.0 / x;
	}
	sum = 1.0 / sum;
	cout << fixed<<setprecision(8)<<sum;
}

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

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];

  int ans = 987654321;
  for (int bit = 0; bit < (1 << (2 * N)); bit++) {
    int a = 0, b = 0, c = 0, tmp = 0;
    for (int i = 0; i < N; i++) {
      int mask = (bit >> (2 * i)) & 3;
      if (mask == 0) {
        if (a != 0) tmp += 10;
        a += L[i];
      } else if (mask == 1) {
        if (b != 0) tmp += 10;
        b += L[i];
      } else if (mask == 2) {
        if (c != 0) tmp += 10;
        c += L[i];
      }
    }
    if (a == 0 || b == 0 || c == 0) continue;
    ans = min(ans, tmp + abs(a - A) + abs(b - B) + abs(c - C));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] A = new int[4][4];
    int count =0;
    for (int i =1; i<=3; i++) {
      for (int j =1; j<=3; j++) { 
      A[i][j] = sc.nextInt();
      }
    }
    int N = sc.nextInt();
    int[] B = new int[N+1];
    for (int i =1; i<=N; i++) {
      B[i] = sc.nextInt();
    }
    boolean[][] check = new boolean[N+1][N+1];
    for (int i =1; i<=N; i++) {
      for (int j =1; j<=3; j++) { 
        for (int k =1; k<=3; k++) { 
          if (B[i] == A[j][k]) {
            check[j][k] = true;
          }
        }
      }
    }
    for (int i =1; i<=3; i++) {
      if (check[i][1] && check[i][2] && check[i][3]) count++;
    }
    for (int i =1; i<=3; i++) {
      if (check[1][i] && check[2][i] && check[3][i] ) count++;
    }
    if(check[1][1] && check[2][2] && check[3][3]) count++;
    if(check[1][3] && check[2][2] && check[3][1]) count++;
    if (count != 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22740
# 入力
s=list(input())
t=list(input())

# sを辞書順最小に
s.sort()
s=''.join(s)

# tを辞書順最大に
t.sort()
t.reverse()
t=''.join(t)

# 出力
if s<t:
  print('Yes')
else:
  print('No')

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

int main(void){

    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;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v) v.begin(),v.end()
#define endl            "\n"


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
  return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
  return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
  lli res = 1;

  x = x % p;
  if (x == 0)
    return 0;

  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;


    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
  if (r == 0)
    return 1;
  if (r == 1)
    return n;


  lli pro = 1, k = n;
  while (k > r)
  {
    pro *= k;
    pro %= p;
    --k;
  }

  k = 2;
  while (k <= (n - r))
  {
    pro *= power(k, (p - 2), p);
    pro %= p;
    ++k;
  }

  return pro;
}


string num_str(lli n, lli k)
{
  string str = "";
  lli x = n;
  while (x != 0)
  {
    string s = to_string(x % k);
    str = s + str;
    x /= k;
  }

  return str;
}

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif*/
}

int main()
{
  c_p_c();

  int n, k;
  cin >> n >> k;
  int arr[n], minH[n];

  for (int j = 0; j < n; ++j)
    cin >> arr[j];

  minH[n - 1] = 0;
  minH[n - 2] = abs(arr[n - 1] - arr[n - 2]);
  int minim, x;

  for (int j = (n - 3); j >= 0; --j)
  {
    minim = INT_MAX;

    for (int p = j + 1; p <= min(n - 1, j + k); ++p)
    {
      x = abs(arr[j] - arr[p]) + minH[p];
      minim = min(minim, x);
    }

    minH[j] = minim;
  }

  cout << minH[0] << endl;
  return 0;
}

Measured memory_bytes: 4372
#include<iostream>

using namespace std;

int N;
int ans=0;
//int a[10000]={0};
int b;

int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>b;
        while(b%2==0){
            b/=2;
            ans++;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
// 2020-09-02 23:37:52
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int V = 100010;
vector<P> G[V];  // to, i
int cs[V], k;
void dfs(int u, int pc) {
  int nc = 1;
  for (auto& [v, i] : G[u])
    if (cs[i] == 0) {
      if (pc == nc) nc++;
      cs[i] = nc++;
      chmax(k, cs[i]);
      dfs(v, cs[i]);
    }
}
void answer() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }
  k = 0;
  dfs(0, 0);
  cout << k << '\n';
  rep(i, n - 1) cout << cs[i] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 11504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long n = Long.parseLong(str[0]);
		long a = Long.parseLong(str[1]);
		long b = Long.parseLong(str[2]);

		int all = (int) modpow(2, n, 1000000007) - 1;
		int muri = (int) c(n, a, 1000000007) + (int) c(n, b, 1000000007);

		int ans = all - muri;
		while (ans < 0) {
			ans += 1000000007;
		}

		System.out.println(ans);
	}

	static long c(long n, long k, long mod) {
		long x = 1;
		for (long i = n - k + 1; i <= n; i++) {
			x = x * i % mod;
		}

		long y = 1;
		for (int i = 1; i <= k; i++) {
			y = y * i % mod;
		}
		y = modpow(y, mod - 2, mod);

		return x * y % mod;
	}

	static long modpow(long a, long n, long mod) {
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1)
				res = res * a % mod;
			a = a * a % mod;
			n >>= 1;
		}
		return res % mod;
	}

}


Measured memory_bytes: 32704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int h,w,n;
  vector<P> p;
  cin>>h>>w>>n;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(y>x)continue;
    p.push_back(P(x,y));
  }
  sort(p.begin(),p.end());
  int x=1,y=1;
  ll ans=h;
  for(int i=0;i<p.size();i++){
    if(p[i].first-x<p[i].second-y)continue;
    if(p[i].first-x==p[i].second-y){
	 x=p[i].first,y=p[i].second-1;
    }else{
	 ans=min(ans,p[i].first-1);
	 break;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

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

    string s, t;
    cin >> s >> t;
    
    for(int i=0; i<s.size(); i++) t+=s[i];
    cout << t << "\n";

    return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val Array(h, w) = in.readLine.split(" ").map(_.toInt)
  val grid = Iterator.continually(in.readLine)
    .take(h)
    .map(_.map(ch => if(ch == '.') true else false).toArray)
    .toArray
  
  val dx = Array(0, 1, 0, -1)
  val dy = Array(1, 0, -1, 0)

  val ans = {
    var isPossible = true
    val check = (i:Int, j:Int, k:Int) =>
      0 <= i + dy(k) && i + dy(k) < h &&
        0 <= j + dx(k) && j + dx(k) < w

    for {
      i <- 0 until h
      j <- 0 until w
      if isPossible && !grid(i)(j)
    } {
      isPossible = 
      (0 until 4)
        .map(k => if(check(i,j,k)) !grid(i+dy(k))(j+dx(k)) else false )
        .exists(_ == true)
    }
    if(isPossible) "Yes" else "No"
  }

  println(ans)
}

Measured memory_bytes: 28820
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	string s;
	int w;

	cin >> s >> w;

	int len = s.size();

	string ss;

	int i = 1;

	while (i <= len) {
		ss += s[i - 1];
		i += w;
	}

	cout << ss;

	return 0;
}

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

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int mod=1000000007;

int main(){
    int n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll sum[n+1];
    memset(sum,0,sizeof(sum));
    map<ll,int> x;
    x[0]++;
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
        x[sum[i+1]]++;
    }
    ll ans=0;
    for(auto it=x.begin();it!=x.end();++it){
        ll tmp=it->second;

        ans+=tmp*(tmp-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15872
import java.io.*;
import java.util.*;
import java.math.BigDecimal; 
 
public class Main {
 
	void submit() {
	    int X = nextInt();
	    int A = nextInt();

	    if(X<A){
	        out.println(0);	        
	    }else{
	        out.println(10);	        
	    }
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 24916
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;

#define ll long long
#define ull unsigned long long

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<bool> ac(n, false);
	vector<long> wa(n, 0);
	ll a = 0, w = 0;

	for (ll i = 0; i < m; i++)
	{
		ll p;
		string s;
		cin >> p >> s;
		p--;
		if (ac[p])
			continue;
		if (s == "WA")
			wa[p]++;
		else
		{
			a++;
			w += wa[p];
			ac[p] = true;
		}
	}

	printf("%lld %lld", a, w);

	return 0;
}


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

int main(){
    string S;
    cin >> S;

    bool flag = false;
    for(int i = 0; i+1 < S.size(); i++){
        if(S[i] != S[i+1]){
            flag = true;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <complex>

using namespace std;
int main() {

    long i,j;
    long max_num = 0;
    long min_num;
  	long N;
    double sqrtN;
    int counter = 0;

    cin >> N;
   // cout << N << endl;
    sqrtN = sqrt((double)N);
    
    min_num = N;

    for(i = 2; i <= (int)sqrtN; i++){
       // cout << N % i << endl;
        if(N % i == 0) {
            j = N / i;
         //  cout << "i" << i << "j" << j << endl;
            max_num = max(i,j);
            if(min_num >= max_num){
                min_num = max_num;
            }

        }
    }
    //cout << min_num << ":" << max_num << endl;

    while(min_num > 0){
        min_num /= 10;
       // cout << min_num << endl;
        counter++;
    }

    cout << counter << endl;

    return 0;
}

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

int main() {
	string A,B,C;
	cin >> A >> B >>C;
	if (
		A[A.size()-1] == B[0] && B[B.size()-1] == C[00]
		)
		cout << "YES" << endl;
	else(
		cout << "NO" << endl);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var js = new int[h[0]].Select(_ => read()).Where(j => j[0] <= h[1]).ToLookup(j => j[0], j => j[1]);

		var r = 0L;
		var l = new List<int>();
		for (var i = 1; i <= h[1]; i++)
		{
			if (js.Contains(i))
				foreach (var b in js[i])
				{
					var k = l.BinarySearch(b);
					if (k < 0) k = ~k;
					l.Insert(k, b);
				}

			if (!l.Any()) continue;
			r += l.Last();
			l.RemoveAt(l.Count - 1);
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 25264
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int a,b,c,d,e,k;
	cin >> a>>b >>c>>d>>e>>k;
	if (e - a > k)cout << ":(" << endl;
	else cout << "Yay!" << endl;

	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BCraneAndTurtle {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b;
        in >> a >> b;
        int aux = b - 2 * a;
        bool valid = true;
        if (aux < 0 or aux % 2) {
            valid = false;
        }
        int y = aux / 2, x = a - y;
        if (x < 0) {
            valid = false;
        }
        out << (valid ? "Yes" : "No") << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BCraneAndTurtle solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3640
n,m = map(int,input().split())
S = []
for _ in range(m):
  s = list(map(int,input().split()))
  del s[0]
  k = 0
  for i in s:
    k +=  1<<(i-1)
  S.append(k)

p = list(map(int,input().split()))

dp = [[] for _ in range(m+1)]
dp[0] = [i for i in range(2**n)]
for i in range(m):
  for j in dp[i]:
    if str(bin(j & S[i])).count('1')%2==p[i]:
      dp[i+1].append(j)
      
print(len(dp[m]))
  



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

class Q
{
	static void Main()
	{
		Func<int[]> read = () => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		var n = int.Parse(Console.ReadLine());
		var h = read();
		var a = read();

		var l = new List<int> { 0 };
		var dp = new long[n + 1];
		for (int i = 0; i < n; i++)
		{
			var j = ~l.BinarySearch(h[i]);
			var v = dp[l[j - 1]] + a[i];
			while (j < l.Count && dp[l[j]] <= v) l.RemoveAt(j);
			l.Insert(j, h[i]);
			dp[h[i]] = v;
		}
		Console.WriteLine(dp[l[l.Count - 1]]);
	}
}


Measured memory_bytes: 45520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	string a,b,c;
	std::cin >> a>>b>>c;
	a[0]-=32;b[0]-=32;c[0]-=32;
	std::cout << a[0]<<b[0]<<c[0] << std::endl;
}





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

int32_t main()
{
	int n,k;
	cin>>n>>k;
	
	int arr[n];
	for (int i=0;i<n;i++)cin>>arr[i];
	
	sort(arr,arr+n);
	
	int left = n-1;
	left-=k;
	
	int sum=0;
	while (left>=0){
		sum+=arr[left];
		left--;
	}
	cout<<sum<<'\n';
}


Measured memory_bytes: 1792
from collections import Counter
N = int(input())
D = list(map(int, input().split()))

C = Counter(D)

P = [0] #takahashi
if C[0] > 0:
  print(0)
  exit(0)
  
hidarif = True
for i in range(1,13):
  if C[i] == 0:
    continue
  if C[i] > 2:
    print(0)
    exit(0)
  if C[i] == 2:
    P.append(i)
    P.append(24-i)
    continue
  
  P.append(i if hidarif else 24-i)
  hidarif = not hidarif
  
P.sort()

ans = 24
for i in range(0,len(P)):
  compare = 0 if i == len(P) - 1 else i+1
  ans = min(ans, abs(P[compare] - P[i]))
  
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
	int A,B,C,D,P;
	int a,b1,b2,b;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);
	scanf("%d",&P);
	a=A*P;
	if(C<P){
		b1=P-C;
		b2=b1*D;
	}
	b=B+b2;
	if(a<=b){
		printf("%d\n",a);
	}
	else if(b<a){
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 1024
N,M= map(int,input().split())
AB = [list(map(lambda x:x-1,[int(i) for i in input().split()])) for _ in range(M)]
c = [0]*N

for i in range(M) :
    c[AB[i][0]] += 1
    c[AB[i][1]] += 1

for i in range(N) :
    print(c[i])

Measured memory_bytes: 9144
#!/usr/bin/ruby

class Monster
  def initialize(owner, hp, power)
    @owner = owner
    @hp = hp
    @power = power
  end

  attr_accessor :owner, :hp, :power

  def attack(attackee)
    attackee.damage(power)
  end

  def damage(damaged_point)
    @hp -= damaged_point
  end

  def die?
    @hp <= 0
  end
end

a, b, c, d = *ARGF.read.chomp.split(/\s+/).collect(&:to_i)

takahashi = Monster.new('Takahashi', a, b)
aoki = Monster.new('Aoki', c, d)

[[takahashi, aoki], [aoki, takahashi]].cycle do |offence, defence|
   offence.attack(defence)
   if defence.die?
     result = defence.owner == 'Aoki' ? 'Yes' : 'No'
     puts result
     break
   end
end

Measured memory_bytes: 14228
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define SIZE 2010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int h, w, k, a[11][SIZE], pre[11][SIZE], ans = 1e9;

int query(int xa, int ya, int xb, int yb) {
	return pre[xb][yb] - pre[xa][yb] - pre[xb][ya] + pre[xa][ya];
}

void gao(int top) {
	vector<int> vec(1, 0);
	int cnt = 1, tmp = 0, pre = 0;
	while (top) {
		if (top & 1) ++tmp, vec.emplace_back(cnt);
		top >>= 1;
		++cnt;
	}
	vec.emplace_back(h);
	//for (auto i : vec) cout << i << ' ';
	//cout << '\n' << tmp << '\n' << '\n';
	
	rep(i, 1, w) {
		rep(j, 1, (vec.size() - 1)) {
			if (query(vec[j - 1], pre, vec[j], i) > k) {
				if (query(vec[j - 1], i - 1, vec[j], i) > k) return;
				++tmp; pre = i - 1;
			}
		}
	}
	//cout << tmp << '\n';
	ans = min(ans, tmp);
}

int main() {
	//freopen("max_06.in", "r", stdin);
	io(); cin >> h >> w >> k;
	int top = (1 << (h - 1)) - 1;
	rep(i, 1, h) {
		string s; cin >> s;
		rep(j, 1, w) a[i][j] = (s[j - 1] - '0');
	}
	rep(i, 1, h) {
		rep(j, 1, w) {
			pre[i][j] = a[i][j] + pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1];
			//cout << pre[i][j] << ' ';
		}
		//cout << '\n';
	}
	for (int i = top; i >= 0; --i) gao(i);
	cout << ans;
}
/*
5 6 1
111011
111101
111011
111101
111011

5 2 1
01
10
01
10
01
*/

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

int main(){
  int n,m,k[40],a[40][40],food[40],ans;
  cin>>n>>m;
  for(int i=0;i<40;i++)food[i]=0;
  
  for(int i=0;i<n;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      cin>>a[i][j];
      food[a[i][j]]++;
  }
}
  ans=0;
  for(int i=0;i<40;i++){
    if(food[i]==n)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Ai = Sarray();
            var dct = new Dictionary<long, long>();
            foreach(var a in Ai)
            {
                if (!dct.ContainsKey(a)) dct[a] = 0;
                ++dct[a];
            }
            var ans = 0L;
            foreach(var d in dct)
            {
                var k = d.Key;
                var v = d.Value;
                if (k == v)
                    continue;
                if (k < v)
                    ans += v - k;
                else
                    ans += v;
            }
            WriteLine(ans);
            //Out.Flush();
        }
        static long gcd(long x, long y) => y == 0 ? x : gcd(y, x % y);
    }
}

Measured memory_bytes: 31708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int d = 0,r = 0;
		double f =0.0;
	     Scanner sc = new Scanner(System.in);
	     int a = sc.nextInt();
		 int b = sc.nextInt();
		 d = a / b;
		 r = a % b;
		 f = 1.0 * a / b;
		 System.out.println(String.format("%d %d %f",d,r,f));
	}
}


Measured memory_bytes: 26420
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
    
    
    
     public static void main(String[] args) {
        
         Scanner sc = new Scanner(System.in);
         int A = sc.nextInt();
         int L = sc.nextInt();
          int b[ ] = new int[A];
         int a[ ] = new int[A];
         for(int i = 0 ; i<A ; i++){
                   a[i]  =  i+1;
             
         }
         
       for(int i = 0 ; i<A ; i++){
               b[i]=  L+a[i]-1;
           
       }  
         Arrays.sort(b);
         int sum = 0 ;
         int min=Integer.MAX_VALUE;
         int index=-1;
         for(int i=0;i<A;i++)
         {
             sum+=b[i];
             if(min>Math.abs(b[i])){
                 min=Math.abs(b[i]);
                 index=i;
             }
         }
         
         
      //   System.out.println(b[1]+b[2]+b[3]+b[4]+b[5]);
         System.out.println(sum-b[index]);
         
    }
}


Measured memory_bytes: 22868
import Control.Applicative

main = do
	[w,h,x,y,r] <- map read . words <$> getLine
	putStrLn $	if 0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h
					then "Yes"
					else "No"

{- 
main = do
    [w,h,x,y,r] :: [Int] <- map read . words <$> getLine
    putStrLn $ if 0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h
                   then "Yes"
                   else "No"
-}

Measured memory_bytes: 3640
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.IntSet as IS

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    n <- readLn
    print $ quot n 2 + if odd n then 1 else 0



Measured memory_bytes: 508
def solve(aaa):
    l = 1
    r = 200000
    while l < r:
        m = (l + r) // 2
        if check(m, aaa):
            r = m
        else:
            l = m + 1
    return r


def check(d, aaa):
    if d == 1:
        return all(a1 < a2 for a1, a2 in zip(aaa, aaa[1:]))
    l = 0
    word = {}
    for a in aaa:
        if l >= a:
            if not carry(d, word, a):
                return False
            for i in list(word.keys()):
                if a < i:
                    del word[i]
        l = a
    return True


def carry(d, word, i):
    while i > 0:
        if i in word:
            if word[i] < d:
                word[i] += 1
                return True
            del word[i]
        else:
            word[i] = 2
            return True
        i -= 1
    return False


n = int(input())
aaa = list(map(int, input().split()))
print(solve(aaa))


Measured memory_bytes: 88788
import bisect
n = int(input())
an = [int(i) for i in input().split()]
an.sort()
ans = 0

for i in range(n):
  for j in range(i+1,n):
    k = an[i]+an[j]-1
    ans += bisect.bisect_right(an,k)-j-1
print(ans)

Measured memory_bytes: 3188
n = int(input())
a = 0
b = 0
x = 0
ans = 0
for i in range(n):
  s = input()
  ans += s.count("AB")
  a += s[-1] == "A"
  b += s[0] == "B"
  x += (s[-1] == "A") and (s[0] == "B")
if a == x == b != 0:
  ans += x-1
else:
  ans += min(n-1,a,b)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=2000010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  if(stoi(s.substr(5,2))<=4){ cout<<"Heisei"<<endl; return 0;}
  cout<<"TBD"<<endl;
  return 0;
}


Measured memory_bytes: 256
import static java.lang.System.in;
import static java.lang.System.out;

import java.io.*;
import java.util.*;

public class Main {
	static final double EPS = 1e-10;
	static final double INF = 1L << 31;
	static final double PI = Math.PI;

	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public void run() throws IOException {
		String input;
		input = br.readLine();
		String s = "CODEFESTIVAL2016";
		int c = 0;
		for (int i=0; i<input.length(); i++)
			if (input.charAt(i)!=s.charAt(i)) c++;
		sb.append(c);
		ln(sb);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
}


Measured memory_bytes: 9172
// Problem: D - Knapsack 1
// Contest: AtCoder - Educational DP Contest
// URL: https://atcoder.jp/contests/dp/tasks/dp_d
// Parsed on: 2020-09-06 13:23:06
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);

using namespace std;

void mini(long& a, long b) { a = a > b ? b : a; }
void maxi(long& a, long b) { a = a > b ? a : b; }

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> weights(n), values(n);
    for (int a = 0; a < n; a++) cin >> weights[a] >> values[a];
    // dp[i] : Minimum total weight of items with value exactly i
    long limit = accumulate(values.begin(), values.end(), 0l);
    vector<long> dp(limit+1, 1e9);
    dp[0] = 0;

    for (int item = 0; item < n; item++) {
        for (int va = limit - values[item]; va >= 0; va--)
            mini(dp[va + values[item]], (dp[va] + weights[item]));
    }

    long answer = 0;
    for (int a = 0; a <= limit; a++) {
        if (dp[a] <= w) maxi(answer, a);
    }
    cout << answer;
    // for(auto e : dp) cerr <<e << " ";
    return 0;
}


Measured memory_bytes: 3616
import numpy as np
import sys

if __name__=="__main__":
    N = int(input())
    s = []
    for i in range(N):
        s.append(int(input()))
    s = np.array(s)

    tensu = np.sum(s)
    s = np.sort(s)
    if np.sum(s % 10)==0:
        print(0)
        sys.exit()

    if tensu % 10 != 0:
        print(int(tensu))
        sys.exit()

    for i in range(N):
        if (tensu - s[i]) % 10 != 0:
            print(int(tensu - s[i]))
            sys.exit()

Measured memory_bytes: 12888
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let s: Vec<char> = s.chars().collect();
    let mut pre = ' ';
    for c in s {
        if c == pre {
            println!("Bad");
            return;
        }
        pre = c;
    }
    println!("Good");
    return;
}


Measured memory_bytes: 4352