akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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


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

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += i;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;

ll can_div_count(ll n){
    ll count = 0;
    while(n > 1){
        n = n/2;
        count++;
    }
    return count;
}


int main(void){
    FAST_IO
    
    ll n,k;
    cin >> n >> k;

    vll p(n);
    rep(i,n) cin >> p[i];
    sort(ALL(p));

    ll ans = 0;
    rep(i,k) ans += p[i];
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 3180
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        System.out.print("Christmas");
        while(25-D > 0) {
            System.out.print(" Eve");
            D++;
        }
        System.out.print("\n");
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
ll k, ans, cnt;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s >> k;
    rep(i, 0, s.size()) {
        if (s[i] == '1') cnt++;
        else break;
    }
    if (cnt >= k) ans = 1;
    else ans = s[cnt] - '0';
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int n, m, k;
	cin >> n >> m >> k;

	for (int i = 0; i <= m; i++) {
		for (int j = 0; j <= n; j++) {
			if (n*i+m*j-2*i*j == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    for(double i = B * 10; i < (B + 1) * 10; i++){
        if (i * 0.08 >= A && i * 0.08 < A + 1){
            cout << i << endl;
            return 0;
        }
    }
    cout << - 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, k;
    cin >> n >> k;

    vs32 p(n);
    rep (i, n)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int ans = 0;
    rep (i, k) ans += p[i];

    cout << ans << "\n";
    return 0;
}



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


#define loop(i,n) for(int lc=i;lc<=n;lc++)
#define tloop(tn) for(int tlc=1;tlc<=tn;tlc++)
#define loop2(i2,n2) for(int lc2=i2;lc2<=n2;lc2++)
#define bloop(n,bn) for(int blc=n;blc>=bn;blc--)
#define il() while(true)
#define pi acos(-1)
#define rad_to_deg(angl) ((180*angl)/pi)
#define ll long long
#define caseno printf("Case %d: ",tlc);

#define sfi(def_var) scanf("%d",&def_var)
#define sfii(def_var,def_var2) scanf("%d %d",&def_var,&def_var2)
#define sfll(def_var,def_var2) scanf("%lld %lld",&def_var,&def_var2)

#define sfl(def_var) scanf("%lld",&def_var)
#define sfd(def_var) scanf("%lf",&def_var)
#define sfs(def_var) scanf("%s",&def_var)

#define pfie(def_var) printf("%d\n",def_var)
#define pfi(def_var) printf("%d",def_var)
#define pfl(def_var) printf("%lld",def_var)
#define pfd(def_var) printf("%lf",def_var)
#define nl printf("\n");

int n,m;
int dp[100010];
vector<int>adj_list[100010];
int ans=0;

int bfs(int source)
{
//    cout << "call : " << source << endl;
    queue<int> q;
    q.push(source);

    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        int mx=-1;
        for(int i=0;i<adj_list[u].size();i++)
        {
            int v=adj_list[u][i];
            if(dp[v]==-1)
            {
                dp[v]=bfs(v);
            }
            mx=max(dp[v],mx);
        }
        dp[u]=mx+1;
        ans=max(ans,dp[u]);
//        cout << "returning from call " << u << " : " << dp[u] << endl;
        return dp[u];
    }
}

int main()
{
    sfii(n,m);
    int x,y;
    tloop(m)
    {
        sfii(x,y);
        adj_list[x].push_back(y);
    }
    loop(0,100000) dp[lc]=-1;
    for(int i=1;i<=n;i++)
    {
        if(adj_list[i].size()>0 && dp[i]<0)
        {
            bfs(i);
//            cout << "call for " << i << " done\n";
//            cout << "dp : ";
//            loop(1,n) cout << dp[lc] << ' '; nl;
        }
    }
    pfie(ans);
}


Measured memory_bytes: 42368
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
#include<stack>
#include<queue>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF =100000000;
typedef pair<int,int> P;


int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};

bool compare_by_b(pair<long, long> a, pair<long, long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool dfs(long long sum,long long a[],int K,int N,int i){
    cout<<"sum="<<sum<<", i="<<i<<",a[i]="<<a[i]<<endl;
    if(sum==K){
        return true;
    }
    if(N==i){
        return false;
    }else{

    
    bool ret= dfs(sum+a[i],a,K,N,i+1) || dfs(sum,a,K,N,i+1);
    return ret;
    }
}
int dfs(int N){
    if(N==1){
        return 0;
    }
    if(N==3){
        return 1;
    }
    if(N%2==1){
        dfs(N/2);
        dfs(N/2 +1);
    }else{
        dfs(N/2);
        dfs(N/2);
    }
}

int main(){
    int N;
    cin>>N;
    double v[N];
    FOR(i,N){
        cin>>v[i];
    }
    sort(v,v+N);
    double ans=0.0;
    ans+=v[0];
    for(int i=1;i<N;i++){
        ans=(v[i]+ans)/2.0;
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <numeric>
using namespace std;
#define MAX_N 400

// Input
int r, D, x_2000;

int main() {
    cin >> r >> D >> x_2000;

    for (int i = 0; i < 10; i++) {
        x_2000 = r * x_2000 - D;
        cout << x_2000 << endl;
    }
}

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

char plus_minus(int k){
  if (k){
    return '+';
  }
  else{
    return '-';
  }
}
int main(){
  string S;
  cin >> S;
  int i,k,ret;
  bitset<3> bit;
  rep0(i, (1<<3)){
    ret = S[0] - '0';
    bitset<3> bit(i);
    rep0(k, 3){
      if (bit.test(k)){
        ret += S[k+1] - '0';
      }
      else{
        ret -= S[k+1] - '0';
      }
    }
    if (ret == 7){
      cout << S[0];
      rep0(k, 3){
        cout << plus_minus(bit.test(k)) << S[k+1];
      }
      cout << "=7" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int A[100010] = {}; 
	int I[100010] = {}; 
	vector<int> E[100010] = {}; // 出ていく辺
	vector<int> F[100010] = {}; // 入ってくる辺
	for(int i = 2; i <= N; i++){
		int a; 
		cin >> a; 
		E[i].push_back(a); 
		F[a].push_back(i); 
		I[a] ++; 
	}
	stack<int> st;
	for(int i = 1; i <= N; i++){
		if(!I[i]) st.push(i); 
	}
	vector<int> S = {}; //トポロジカルソート後
	while(st.size()){
		int i = st.top(); st.pop(); 
		S.push_back(i); 
		for(int j = 0; j < E[i].size(); j++){
			I[E[i].at(j)] --; 
			if(I[E[i].at(j)] == 0) st.push(E[i].at(j)); 
		}
	}
	int dp[100010] = {}; 
	for(int i = 0; i < N; i++){
		vector<int> ord = {}; 
		for(int k = 0; k < F[S[i]].size(); k++){
			ord.push_back(dp[F[S[i]].at(k)]);  
		}
		sort(ord.begin(), ord.end()); 
		int tmp = 0; 
		for(int j = 0; j < ord.size(); j++){
			tmp = max(tmp + 1, ord[j] + 1); 
		}
		dp[S[i]] = tmp; 
	}
	cout << dp[1] << endl; 
}

Measured memory_bytes: 12540
#include <stdio.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define N 1000009
typedef struct fac{int n,exp;}F;

int gcd(int p,int q){
  while(q){int t=p%q;p=q;q=t;}
  return p;
}
int fact(int n,F*a){
  int x=n,i,j,c=0;
  for(i=2;i*i<=x;i++){
    for(j=1;!(x%i);j++)x/=i;
    if(j>1){a[c].n=i;a[c++].exp=j-1;}
  }
  if(x-1){a[c].n=x;a[c++].exp=1;}
  return c;
}

int main(){
  int n,a[N],g,ans=0;
  scanf("%d",&n);
  rep(i,n){
    scanf("%d",&a[i]);
    if(!i)g=a[i];
    else g=gcd(a[i],g);
  }
  if(g-1)ans--;
  else{
    int d[N]={};
    rep(i,n){
      F f[N];
      int c=fact(a[i],f);
      rep(j,c)d[f[j].n]++;
	}
    rep(i,N)if(d[i]>1)ans++;
  }
  printf(ans?(ans>0?"setwise coprime":"not coprime"):"pairwise coprime");
  return 0;
}

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int k, q;
	cin >> k >> q;
	vector<int> d;
	d.resize(k + 1);
	for(int i = 0; i < k; ++i) {
		cin >> d[i];
	}
	d[k] = d[0];
	while(q--) {
		int n, x, m;
		cin >> n >> x >> m;
		x %= m;
		vector<ll> a;
		a.resize(k + 1);
		int eq = 0;
		for(int i = 1; i <= k; ++i) {
			a[i] = a[i - 1] + d[i - 1] % m;
			if(d[i - 1] % m == 0) {
				eq += (n - 1) / k;
				if(i <= (n - 1) % k) {
					++eq;
				}
			}
		}
		ll r = a[k] * ((n - 1) / k) + a[(n - 1) % k] + x;
		cout << n - eq - r / m - 1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int n;
  string s;
  cin>>n;
  int k;
  cin>>k;
  int arr[200001];
  sa(arr,n,d);
  int m=0;
  rep(i,n){
      m=max(m,arr[i]);
  }
  int low=1,high=m;
  while(low<high){
      int mid=(low+high)/2;
      int kk=0;
      rep(i,n){
          kk+=arr[i]/mid;
        if((arr[i]/mid)*mid<arr[i]) kk++;
        kk--;
      }
      if(kk<=k) high=mid;
      else low=mid+1; 
  }
  cout<<low<<endl;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  
  int countKaibun=0;

  for (int i=A; i<=B; i++){
    
    int x,x1,x2,x3,x4,x5;
    x=i;
    x5 = x % 10;
    x /= 10;
    x4 = x % 10;
    x /= 10;
    x3 = x % 10;
    x /= 10;
    x2 = x % 10;
    x1 = x/10;
    
//    cout << x5 << x4 << x3 << x2 << x1 << endl;    
  
    if (x5==x1 && x4==x2)
      countKaibun++;
//      cout << i << endl;
    
  }

  cout << countKaibun << endl;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

dp = [0] * N
dp[1] = abs(H[0] - H[1])

for i in range(2,N):
    dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]))
print(dp[-1])

Measured memory_bytes: 13928
#include <stdio.h>
#define maxn 200010
int n,k,a[maxn];
int judge(int x){
	int i,cnt=0;
	for(i=1;i<=n;i++)
		cnt+=(a[i]-1+x)/x-1;//(a[i]-1+x)/x用来统计原木分割的段数((a[i]-1+x)/x此种写法是常见技巧)，切割次数=段数-1
	if(cnt>k)return 0;//切割次数过多
	else return 1;//切割次数小于等于k
}
int main(){
	int i,l,r,mid;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	l=0,r=1000000000;
	while(l+1<r){
		mid=(l+r)/2;
		if(judge(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
	return 0;
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3648
A, B, C, X, Y = map(int, input().split())

answer = 10**18
n = 2*10**6+1
for c in range(n):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a, 0)*A
  cost += max(b, 0)*B
  if answer > cost:
    answer = cost
print(answer)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////
int dp[100010][3];
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1), b(n+1), c(n+1);

    for (int i = 1;i <= n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 0;i <= n;i++){
        for (int j = 0;j < 3;j++){
            dp[i][j] = 0;
        }
    }

    for (int i = 1;i <= n;i++){
        for (int j = 0;j < 3;j++){
            if (j == 0){
                dp[i][j] = max(dp[i-1][1] + b[i], dp[i-1][2] + c[i]);
            }
            else if (j == 1){
                dp[i][j] = max(dp[i-1][0] + a[i], dp[i-1][2] + c[i]);
            }
            else {
                dp[i][j] = max(dp[i-1][0] + a[i], dp[i-1][1] + b[i]);
            }
        }
    }
    int ans = 0;
    for (int i = 0;i < 3;i++){
        ans = max(ans, dp[n][i]);
    }

    cout << ans << endl;
}

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

typedef vector<int> data;

vector<data> ans;

void make(data d, int n){
	if(n == 0){
		ans.push_back(d);
		return;
	}
	for(int i = 1;i <= n;i++){
		if(d.size() > 0 && i > d.back()) continue;
		data t = d;
		t.push_back(i);
		make(t, n - i);
	}
}

bool larger(const data &d1, const data &d2){
	for(int i = 0;i < d1.size() && i < d2.size();i++){
		if(d1[i] > d2[i]) return true;
		if(d1[i] < d2[i]) return false;
	}
	return false;
}

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		make(data(), n);
		sort(ans.begin(), ans.end(), larger);
		for(int i = 0;i < ans.size();i++){
			for(int j = 0;j < ans[i].size();j++){
				cout << ans[i][j];
				if(j != ans[i].size() - 1) cout << ' ';
			}
			cout << endl;
		}
		ans.clear();
	}
	
	return 0;
}

Measured memory_bytes: 1796
N = int(input())

def func(cur, use, counter):
  if cur > N: return
  if use == 0b111: counter.append(1)  # 答えを増やす
    
  # 7を付け加える
  func(cur * 10 + 7, use | 0b001, counter)
  # 5を付け加える
  func(cur * 10 + 5, use | 0b010, counter)
  # 3を付け加える
  func(cur * 10 + 3, use | 0b100, counter)
  
res = []
func(0, 0, res)
print(sum(res))

Measured memory_bytes: 3188
import numpy as np

n, w = map(int, input().split())
l = [list(map(int,input().split())) for i in range(n)]


dp = np.zeros((n + 1, w + 1), dtype=np.int64)

for i in range(n):
    tmp = np.zeros(w + 1, dtype=int)
    tmp[l[i][0]:] = dp[i][:-l[i][0]] + l[i][1]
    dp[i + 1] = np.maximum(dp[i], tmp)
    
print(dp[n][w])

Measured memory_bytes: 92120
#include<bits/stdc++.h>
    #define LIM 1+2+4+8+16+32+64+128
    using namespace std;
    typedef long long int ll;
    int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a>b){
    cout<<b<<endl;
    }else{
    cout<<n*a<<endl;
    }
    return(0);
    }

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

using namespace std;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	if((n-1) % (k-1) == 0){
		cout << (n-1) / (k-1) << endl;
	}else{
		int ans = (n - 1) / (k - 1);
		cout << ans + 1 << endl;
	}
}

Measured memory_bytes: 640
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const A = parseInt(arg[0]);
    const B = parseInt(arg[1]);
    
    if(A === B) {
        console.log("EQUAL");
        return;
    }
    
    console.log(A > B ? "GREATER" : "LESS");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
let inputs =
    Array.init (stdin.ReadLine() |> int) (fun _ ->
        stdin.ReadLine().Split()
        |> Array.map int
        |> function [|x; y; h|] -> (x, y), h | _ -> failwith "input error")
let manhattan (x1, y1) (x2, y2) = abs (x1 - x2) + abs (y1 - y2)
let heightAt (centerXy, centerHeight) xy = centerHeight - manhattan centerXy xy |> max 0
let (cx, cy), h =
    seq { for cx in 0 .. 100 do for cy in 0 .. 100 -> cx, cy }
    |> Seq.map (fun center ->
        let xy, h = inputs |> Array.find (snd >> (<>) 0)
        center, manhattan center xy + h)
    |> Seq.find (fun (center, height) ->
        let heightAt xy = height - manhattan center xy |> max 0
        inputs |> Array.forall (fun (xy, h) -> heightAt xy = h))
printfn "%d %d %d" cx cy h



Measured memory_bytes: 14416
a, b = map(int, input().split())
def f(i):
    if i == 0:
        return 1^(b-a-(1-a&1))//2%2
    x = a>>i
    y = b>>i
    return (x&1)*(a-x+1)%2^(y&1)*(b-y)%2
if a == b:
    print(a)
else:
    print(int(''.join(map(str, map(f, range(len(bin(b))-2))))[::-1], 2))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	string S; cin >> S;
	if (S.size() % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < S.size(); i++) {
		if ((i % 2 == 0 && S[i] != 'h') || (i % 2 == 1 && S[i] != 'i')) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int mn = INT_MAX;
    for (int i(0); i <= s.size() - t.size(); ++i) {
        int cnt = 0;
        for (int j(i), k(0); k < t.size(); k++, j++) {
            if (s[j] == t[k]) {
                cnt++;
            }
        }
        //cout << endl;
        mn = min(mn, (int)t.size() - cnt);
    }

    cout << mn << endl;
}

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

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    cout << (T / A) * B << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e15+10;
const ll N=1e6+10;

ll mod_expo(ll a,ll b, ll c)
{
	ll ans=1;
	while(b)
	{
		if(b & (ll)1) ans=(ans*a)%c;
		a=(a*a)%c;
		b=b>>1;
	}
	return ans;
}
ll invese(ll n)
{
	return mod_expo(n,mod-2,mod);
}


int main()
{
	boost;
	string s;
	cin>>s;
	reverse(all(s));
	ll n=s.size();
	std::vector<ll> dp(n,0);
	ll prev=-1;
	if(s[0]=='0') dp[0]=1;
	else dp[0]=3,prev=0;
	
	for(ll i=1;i<n;i++)
	{
		dp[i]=mod_expo(3,i,mod);
		if(s[i]=='0')
		{
			dp[i]=dp[i-1];
		}
		else
		{
			if(prev!=-1) dp[i]+=2*dp[prev],dp[i]%=mod;
			else dp[i]+=2,dp[i]%=mod;
			prev=i;
		}
	}
	cout<<(dp[n-1]);
  	return 0;
}  

Measured memory_bytes: 1232
def resolve():
    '''
    code here
    '''
    import collections
    s = input()

    N = len(s)

    unique_num_dict = collections.Counter(s)
    most_common = unique_num_dict.most_common()[0]

    if len(unique_num_dict) == 1:
        print(0)
    elif most_common[1] == 1:
        print(N//2)
    else:
        s_set = set(s)
        temp_min_num = 101
        for item in s_set:
            temp_max_num = max([len(item) for item in s.split(item)])
            temp_min_num = min(temp_min_num, temp_max_num)
        print(temp_min_num)
            

if __name__ == "__main__":
    resolve()


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

vector<int> v;
int d[5] = {5 ,7, 5, 7, 7};

int main(){
while(1){//start	
	
	int n;
	cin >> n;
	if(n == 0) break;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		v.push_back((int)s.size());
	}
	
	//debug
	//for(int i = 0; i < n; i++) cout << v[i] << endl;
	
	int ans = 0;
	for(int i = 0; i < n - 1; i++){
		int len = 0;
		int tmp = 0;
		int next = 0;
		for(int j = i; j < n; j++){
			len += v[j];
			tmp += v[j];
			if(next == 4 and len == 31){
				ans = i + 1;
				goto end;
			}
			else if(d[next] == tmp){
				//cout << tmp << endl;
				tmp = 0;
				next++;
			}
		}
		//cout << endl;
	}
	
	end:
	cout << ans << endl;
	
	v.clear();
}//end
	return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = Math.abs(a - x);
		int d = Math.abs(b - x);

		if (c < d) {

			System.out.println("A");

		} else {

			System.out.println("B");

		}
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(void){
    int a=0,k;
    while(scanf("%d",&a)!=EOF){
        int g[20],i=512,j=0;
        do{
            if(a%i!=a){
                g[j++]=i;
                a-=i;
            }
            i/=2;
        }while(a!=0);
        for(k=j-1;k>0;k--)printf("%d ",g[k]);
        printf("%d\n",g[0]);
    }
    return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

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

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

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



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

ll power(int n, int a){
  ll ans = 1;
  rep(i,a){
    ans *= n;
  }
  return ans;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

int main(){
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  combination c(n+k);
  mint ans = 0;
  for(int i=0; i <= k; ++i){
    mint now = mint(26).pow(k-i);
    now *= mint(25).pow(i);
    now *= c(i+n-1,n-1);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35516
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val sa = br.readLine()!!
    val sb = br.readLine()!!
    val sc = br.readLine()!!

    var ia = 0
    var ib = 0
    var ic = 0

    var current = 'a'
    while (true) {
        when (current) {
            'a' -> {
                if (ia == sa.length) {
                    out.println('A')
                    return
                }
                current = sa[ia]
                ia++
            }
            'b' -> {
                if (ib == sb.length) {
                    out.println('B')
                    return
                }
                current = sb[ib]
                ib++
            }
            'c' -> {
                if (ic == sc.length) {
                    out.println('C')
                    return
                }
                current = sc[ic]
                ic++
            }
        }
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

vector<ll> dx = {1, 0, -1, 0};
vector<ll> dy = {0, 1, 0, -1};

bool check[105][105];

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

 	ll H, W;
 	cin >> H >> W;   

 	vector<string> S(H);
 	REP(i, H) cin >> S[i];

 	REP(i, 105)REP(j, 105) check[i][j] = false;

 	queue<pll> qu;
 	qu.push({0, 0});
 	check[0][0] = true;
 	while(!qu.empty()){
 		pll tmp = qu.front();
 		qu.pop();
 		REP(i, 4){
 			ll nx = tmp.first + dx[i];
 			ll ny = tmp.second + dy[i];
 			if(nx<0) continue;
 			if(nx>H-1) continue;
 			if(ny<0) continue;
 			if(ny>W-1) continue;
 			if(!check[nx][ny]){

 				bool ok = false;
 				if(nx%2==0){
 					if(ny%2==0){
 						if((nx+ny)%4==0){
 							if(S[nx][ny] == '6') ok = true;
 						}else{
 							if(S[nx][ny] == '1') ok = true;
 						}
 					}else{
 						if((ny)%4==1){
 							if(S[nx][ny] == '3') ok = true;
 						}else{
 							if(S[nx][ny] == '4') ok = true;
 						}
 					}
 				}else{
 					if((nx)%4==1){
						if(S[nx][ny] == '2') ok = true;
					}else{
						if(S[nx][ny] == '5') ok = true;
					}
 				}

 				if(ok){
 					qu.push({nx, ny});
 					check[nx][ny] = true;
 				}
 			}
 		}
 	}
 	cout << (check[H-1][W-1] ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3268
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
A=0
B=0
for i in range(n):
    if i%2==0:
        A+=max(a)
        a.remove(max(a))
    else:
        B+=max(a)
        a.remove(max(a))
print(A-B)
        

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[20][20];
int d[(1 << 16)];
vector<int> vec;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)cin >> a[i][j];
	for (int i = 1; i < (1 << n); i++) {
		vec.clear();
		for (int j = 0; j < n; j++)if (i&(1 << j))vec.push_back(j);
		int m = (int)vec.size();
		int ma = 0;
		for (int j = 0; j < (int)vec.size(); j++)for (int k = j + 1; k < (int)vec.size(); k++)ma += a[vec[j]][vec[k]];
		for (int j = 0; j < (1 << m); j++) {
			int cnt = 0;
			for (int k = 0; k < m; k++)if (j&(1 << k))cnt += (1 << vec[k]);
			ma = max(ma, d[cnt] + d[i - cnt]);
		}
		d[i] = ma;
	}
	cout << d[(1 << n) - 1] << endl;
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

S = input()

print(S.replace('?', 'D'))

Measured memory_bytes: 9248
import sys

input = sys.stdin.readline


def dot(a, b):
    c = [[0] * n for _ in range(n)]
    for i, ai in enumerate(a):
        for j, bj in enumerate(zip(*b)):
            c[i][j] = sum(ak * bk for ak, bk in zip(ai, bj)) % md
    return c


def pwr(a, k):
    c = None
    while c == None:
        if k & 1:
            c = a
        a = dot(a, a)
        k >>= 1

    while k > 0:
        if k & 1:
            c = dot(a, c)
        a = dot(a, a)
        k >>= 1
    return c


md = 10 ** 9 + 7
n, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
print(sum([sum(pk) % md for pk in pwr(a, k)]) % md)


Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  vector<bitset<10>> A(N);
  rep(i,0,N){
    rep(j,0,10){
      bool F;
      cin>>F;
      if(F)
        A[i].set(j);
      }
    }
  vii B(N,vi(11));
  rep(i,0,N){
    rep(j,0,11)
      cin>>B[i][j];
    }
  int ans=-MOD;
  rep(i,1,(1<<10)){
    int sum=0;
    bitset<10> C(i);
    rep(j,0,N){
      bitset<10> D=A[j]&C;
      sum+=B[j][D.count()];
      }
    ans=max(ans,sum);
    }
  cout<<ans;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3001;
string s, t;
int dp[N][N];
int calc(int i, int j) {
	if (i >= s.size() || j >= t.size())
		return 0;
	int &ret = dp[i][j];
	if (ret != -1)
		return ret;
	if (s[i] == t[j])
		ret = calc(i + 1, j + 1) + 1;
	else
		ret = max(calc(i + 1, j), calc(i, j + 1));
	return ret;
}
void print(int i, int j) {
	if (i >= s.size() || j >= t.size())
		return;
	if (s[i] == t[j]) {
		cout << s[i];
		print(i + 1, j + 1);
	}
	else if (calc(i + 1, j) > calc(i, j + 1))
		print(i + 1, j);
	else
		print(i, j + 1);
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	memset(dp, -1, sizeof(dp));
	print(0, 0);
	return 0;
}

Measured memory_bytes: 35712
# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush
from random import randint
from collections import defaultdict
from itertools import accumulate
from fractions import gcd
from collections import defaultdict
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
size = 10**6 + 1
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    g1[i] =  ( g1[i-1] * i ) % MOD 
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 
    g2[i] =  (g2[i-1] * inverse[i]) % MOD

X, Y = inpl()
if (X > Y):
    X, Y = Y, X

if (min(X, Y) < abs(Y - X) or (X+Y)%3 != 0):
    print(0)
else:
    a, b = 0, 0
    Z = Y-X
    a = (X-Z)//3
    b = (X-Z)//3 + Z
    print(cmb(a+b, a, MOD)%MOD)

Measured memory_bytes: 124080
$routes=[]
$distance=[]
$condition=[]
def counter
  count = 0
  ->{
    count += 1
    return count
  }
end

def get_fatigue (now,m,n,now_place)
  inner=[]
  now.upto(m-n+now) do |i|
    inner.push($distance[now_place]*$condition[i-1])#疲労度
  end
  $routes.push(inner)
end

a=gets.split("\s")
n=a[0].to_i
m=a[1].to_i
n.times do $distance.push(gets.chomp.to_i) end
  m.times do $condition.push(gets.chomp.to_i) end

    c=counter
    n.times do |i|
      get_fatigue(c.call,m,n,i)
    end
    0.upto(m-n) do |y|
      0.upto(n-1) do |x|
        if x>0 && y>0  then
          if $routes[x-1][y]+$routes[x][y]>$routes[x][y-1] then
            $routes[x][y]=$routes[x][y-1]
          else
            $routes[x][y]+= $routes[x-1][y]
          end
        elsif x>0
          $routes[x][y]+=$routes[x-1][y]
        elsif y>0
          if $routes[x][y]>$routes[x][y-1] then
            $routes[x][y]=$routes[x][y-1]
          end
        else
        end
      end
    end
    p $routes[n-1].min



Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, x;
    cin >> n >> x;

    vector<int> l(n);
    for(int i = 0; i < n; i++) {
        cin >> l[i];
    }

    int count = 1;
    int pre = 0;
    for(int i = 0;i < n;i++) {
        if (pre + l[i] <= x) {
            count++;
        }

        pre = pre + l[i];
    }

    cout << count;
}

Measured memory_bytes: 256
#pragma region Imports
#include<bits/stdc++.h>
using namespace std;
#pragma endregion
#pragma region Macros
#pragma GCC optimize (2)
#define uns unsigned
#define out cout
#define in cin
#define au auto
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define elif else if
#define sz(x) x.size()
#define fl(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define fli(i, a, b, c) for(int (i)=a;(i)<(b);(i)+=(c))
#define fr(i, x) for(int (i)=(x)-1;(i)>=0;(i)--)
#define fb(i, x) for(int (i)=0;(i)<(x);(i)++)
#define fa(i, x) for(auto& (i):(x))
#define ia(a, n) for(int qw=0;qw<(n);qw++)cin>>(a)[qw];
#define oa(a, n) for(int qw=0;qw<(n);qw++)cout<<(a)[qw]<<" ";
#define im(a, n, m) fb(i,(n))fb(j,(m))cin>>(a)[i][j];
#define om(a, n, m) fb(i,(n))fb(j,(m))cout<<(a)[i][j]<<" \n"[j==(m)-1];
#define eb(v, x) (v).emplace_back(x);
#define seb(s, x) (s).emplace(x);
#define pr(x, y) pair<x,y>
#define vr(x) vector<x>
#define mp(x, y) make_pair(x,y)
#define hm(x, y) map<x,y>
#define um(x, y) unordered_map<x,y>
#define stk(x) stack<x>
#define qu(x) queue<x>
#define dq(x) deque<x>
#define pq(x) priority_queue<x>
#define pqm(x) priority_queue<x,vector<x>,greater<(x)>>
#define mem(a, x) memset(a,(x),sizeof(a));
#define fi(x) (x).first
#define se(x) (x).second
#define ql(x) int tc;tc=(x);if(tc==-1)cin>>tc;while(tc--)
#define srt(x) sort((x).begin(),(x).end());
#define pops(y, x) auto (y)=(x).front();(x).pop();
#define ppc(x) __builtin_popcount((x))
#define all(x) (x).begin(),(x).end()
#define sieve(b, n) bool (b)[(n)];mem((b),true);int sq=int(sqrt(n))+1;(b)[0]=(b)[1]=false;fl(i,2,sq)if((b)[i])fli(j,i*i,n,i)(b)[j]=false;
#define dbg(x) cout<<#x<<" "<<(x)<<"\n";
#pragma endregion
#pragma region Typedefs and Consts
typedef long long int ll;
typedef unsigned long long int ull;
typedef string stg;
typedef float flo;
typedef char chr;
typedef vector<int> vi;
const ull mod = 1000000007;
const int imx = INT_MAX;
const int imn = INT_MIN;
const ll lmx = LLONG_MAX;
const ll lmn = LLONG_MIN;
#pragma endregion
#pragma region Functions
inline ull powm(ull x,ull y,bool b=false,ull m=mod){ if(b){ ull t=1;x%=m;while(y>0){ if(y%2)t=(t*x)%m;y=y>>1;x=(x*x)%m; }return t; }else
    { ull t=1;while(y>0){ if(y&2)t*=x;y=y>>1;x*=x; }return t;}}
inline ll gcd(ll a,ll b){a=abs(a);b=abs(b); while(b!=0){ ll c=a%b;a=b;b=c;}return a;}
#pragma endregion
int main() {
  fio
  int n;
  in>>n;
  string s;
  in>>s;
  ll z[n][n];
  mem(z,0)
    z[0][0]=1;
    fb(i,n-1){
      fb(j,n-1)
        z[i][j+1]=(z[i][j+1]+z[i][j])%mod;
      fb(j,i+2){
        if(s[i]=='>')
        z[i+1][j]=(z[i][i]-(j?z[i][j-1]:0)+mod)%mod;
      else
        z[i+1][j]=(j?z[i][j-1]:0);
      }
    }
  ll q=0;
  fb(i,n)
    q=(q+z[n-1][i])%mod;
  out<<q;
  return 0;
}

Measured memory_bytes: 70528
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(int, readline().split()))
a = sorted(x - i for i, x in enumerate(a))
low = (len(a) + 1) // 2 - 1
high = len(a) // 2
print(sum(a[high:]) - sum(a[:low + 1]))


Measured memory_bytes: 22004
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int n = Integer.parseInt(scan.nextLine());
        String inp = scan.nextLine();

        int red = 0;
        int blue = 0;


        for(int i = 0; i < n; i++){
            if(inp.charAt(i) == 'R'){
                red = red + 1;
            } else {
                blue = blue + 1;
            }
        }
        
        if( red > blue){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        

  
    }
}

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

int main() {
    int t[100010]={};
    int a[100010]={};
    t[0]=0;
    int N,Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    a[0]=0;
    for(int i=1; i<N; i++){
        if(S[i]=='C' && S[i-1]=='A') a[i]=1;
    }
for(int i=0; i<N-1; i++){
    t[i+1]=t[i]+a[i+1];
}
int l[100010];
int r[100010];
for(int i=0; i<Q; i++){
    cin>>l[i]>>r[i];
    l[i]--;
    r[i]--;
}

for(int i=0; i<Q; i++){
    cout<<t[r[i]]-t[l[i]]<<endl;
    
}
}


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

int main(){
    int N;
    cin >> N;
    for(int i =0; i < 3; i++){
        int r = N%10;
        if(r == 7){
            cout << "Yes" << endl;
            return 0;
        }
        N /= 10;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>

typedef long long int ll;

ll h;

ll getans(ll x) {
    if (x == 0) {
        return 0;
    }
    else if (x == 1) {
        return 1;
    }
    else {
        return (getans(x >> 1) << 1) + 1;
    }
}

int main() {
    scanf("%lld", &h);
    printf("%lld", getans(h));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
int m=a/4;
	for(int i=0;i<=m;i++)
	{
		if((a-i*4)%7==0)
		{
			cout<<"Yes";
			return 0;
		}
	}
cout<<"No";
return 0;	
} 

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

vector<int> v;

void pushBack(int x) {
  v.push_back(x);
}

void randomAccess(int x) {
  cout << v[x] << endl;
}

void popBack() {
  v.pop_back();
}

int main() {
  int n, q, x;

  cin >> n;
  for (int i = 0; i < n; i++ ) {
    cin >> q;
    switch (q) {
      case 0:
        cin >> x;
        pushBack(x);
        break;
      case 1:
        cin >> x;
        randomAccess(x);
        break;
      case 2:
        popBack();
        break;
    }
  }
}



Measured memory_bytes: 3848
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  long long K;
  cin >> K;
  K--;
  for (int i = 0; i < (int)S.size(); ++i) {
    if (S[i] == '1' && (ll)i == K) {
      cout << '1' << endl;
      break;
    }
    if (S[i] != '1') {
      cout << S[i] << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<string> a(5);
    for(int i=0;i<5;i++){
    cin>>a[i];
    }
    
    for(int i=0;i<5;i++){
    int aa=0;
    int ss=0;
    if(a[i].size()==0) break;
        for(int j=0;j<a[i].size()-2;j++){
            if(a[i][j]=='J' && a[i][j+1]=='O' && a[i][j+2]=='I'){
                aa++;
            }
            if(a[i][j]=='I' && a[i][j+1]=='O' && a[i][j+2]=='I'){
                ss++;
            }
        }
        cout<<aa<<endl;
        cout<<ss<<endl;
    }
}


Measured memory_bytes: 3184