akhauriyash/Code-Regression huggingface dataset:
/*/ Author: KaySeeKay /*/

#include<bits/stdc++.h>
using namespace std;	

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];

/*/-----------------------------Code begins----------------------------------/*/


signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int d ,t,s;
		cin >> d >>t>>s;
		cout<<(s*t>=d?"Yes":"No");
	
	
	}
	return 0;
}

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

#define pout(n)  printf ("%d\n", n)
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main (){
  int n,a[100001],i,t,s=1;
  int sum = 0;
  scanf("%d",&n);
  
  rep(i,1,n+1){
      scanf("%d",&a[i]);
  }
  rep(i,1,n+1){
      t=a[s];
      s=t;
      sum += 1;
      if(s==2){
          break;
      }
      else if(i == n){
          sum = -1;
      }
  }
  pout(sum);
  return 0;
}

Measured memory_bytes: 640
a=list(raw_input())
b=[]
for i in a:
    b.append(int(i))
for i in range(1):
    if b[0]+b[1]+b[2]+b[3]==7:
        c=[0,0,0]
        break
    elif b[0]+b[1]+b[2]-b[3]==7:
        c=[0,0,1]
        break
    elif b[0]+b[1]-b[2]+b[3]==7:
        c=[0,1,0]
        break
    elif b[0]+b[1]-b[2]-b[3]==7:
        c=[0,1,1]
        break
    elif b[0]-b[1]+b[2]+b[3]==7:
        c=[1,0,0]
        break
    elif b[0]-b[1]+b[2]-b[3]==7:
        c=[1,0,1]
        break
    elif b[0]-b[1]-b[2]+b[3]==7:
        c=[1,1,0]
        break
    elif b[0]-b[1]-b[2]-b[3]==7:
        c=[1,1,1]
        break
ans=""
c.append("=7")
for i in range(4):
    ans+=a[i]
    if c[i]==0:
        ans+="+"
    elif c[i]==1:
        ans+="-"
    else:
        ans+=c[i]
print ans

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

signed main() {
  int n,p,v;
  int a=0;
  int ans=1;
  cin>>n>>p;
  for(int i=0;i<n;i++){
    cin>>v;
    a+=v%2;
  }
  if(a==0){
    if(p==0)ans*=2;
	if(p==1)ans*=0;
  }
    for(int i=0;i<n-1;i++)ans*=2;
    cout<<ans<<endl;
}


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

using namespace std;

int main(void){
    int n;
    int max = 0;
    int sum = 0;
    int tmp;
    cin>>n;
    for(int i=0; i<n; i++){
       cin>>tmp;
       sum += tmp;
       if(max < tmp) max = tmp;
    }
    cout<<sum - max/2<<endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter

if __name__ == '__main__':
    N = int(input())
    xy_list = [list(map(int, input().split())) for _ in range(N)]

    modulo_num = 998244353

    duplicate_list = [0] * (N + 1)
    for i in range(N):
        xi, yi = xy_list[i]
        gradient_list = []
        for j in range(N):
            xj, yj = xy_list[j]
            if xi != xj:
                gradient_list.append((yj - yi) / (xj - xi))
            elif yi != yj:
                gradient_list.append(100000)

        counter = Counter(gradient_list)
        for k in counter.values():
            duplicate_list[k + 1] += 1

    ans = pow(2, N, modulo_num)
    ans -= 1
    ans -= N
    for i in range(2, N + 1):
        cnt = duplicate_list[i] // i
        ans -= cnt * (pow(2, i, modulo_num) - i - 1)
    ans = ans % modulo_num
    print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ld ans=1;
    ll n;
    cin>>n;
    ve <ld> arr(n);
    ll ans1=1;
    rep (i,0,n)
    {
        cin>>arr[i];
        ans*=arr[i];
        ans1*=arr[i];
    }
    if (ans>1e18)
    {
        cout<<"-1\n";
    }
    else
    {
        cout<<ans1<<"\n";
    }
    
}


Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
const double PI = 3.1415926535;

double rad(double d) {
  return d*PI/180;
}
struct P {
  double x,y,z;
  P(double x, double y, double z) :x(x), y(y), z(z) {}
};
// oxÆÜx©çÀWðvZBÌSª´_B
// lon : Ox©çÜíè
// lat : kÉ©çìÉûü
// oxOÜxOûüª²AoXOÜxOª²@kÉª²
double R = 10;
P coord(double lon, double lat) {
  double x = R*cos(lon)*sin(lat);
  double y = R*sin(lon)*sin(lat);
  double z = R*cos(lat);
  return P(x,y,z);
}
// O³Ìñ]sñðp¢½e²ñèÌñ]
P rotatex(P a, double ang) {
  return P(a.x, a.y*cos(ang)-a.z*sin(ang), a.y*sin(ang)+a.z*cos(ang));
}
P rotatey(P a, double ang) {
  return P(a.x*cos(ang)+a.z*sin(ang), a.y, -a.x*sin(ang)+a.z*cos(ang));
}
P rotatez(P a, double ang) {
  return P(a.x*cos(ang)-a.y*sin(ang), a.x*sin(ang)+a.y*cos(ang), a.z);
}
// lon, lat ÍãÆ¯¶
P rotate(P a, double lon, double lat, double ang) {
  P tmp = rotatey(rotatez(a,-lon),-lat);
  tmp = rotatez(tmp, -ang);
  tmp = rotatez(rotatey(tmp, lat), lon);
  return tmp;
}
bool judge(double a, double h, double ang) {
  return (rotate(coord(-a,h), 0, rad(46.8), ang).z >= 0);
}

int main() {
  int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  int T;
  cin >> T;
  while(T--) {
    int mon,day,hh,mm;
    scanf("%d/%d %d:%d",&mon,&day,&hh,&mm);
    int min = 0;
    REP(i, mon-1)
      min += month[i] * 24 * 60;
    min += (day-1) * 24 * 60 + hh * 60 + mm;
    double ang = rad((1.0+1.0/365.24) * 360 * min / (24 * 60));
//    cout << min << " " << ang << endl;
    //ang = mod(ang, (2*PI));
    int n;
    cin >> n;
    REP(i,n) {
      string name;
      cin >> name;
      int m;
      cin >> m;
      bool f = 1;
      REP(j,m) {
        double a,b;
        cin >> a >> b;
        b = 90.0 - b;
        if (!judge(rad(a), rad(b), ang)) {
          f = 0;
        }
      }
      if (f)
        cout << name <<endl;
    }
  }
}

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

int main() {
  
  int n,c;
  cin >> n >> c;
  vector<vector<int>>d(c,vector<int>(c));
  for(int i=0; i<c; i++){
    for(int j=0; j<c; j++) cin >> d[i][j];
  }
  
  int count0=0,count1=0,count2=0;
  vector<vector<int>>a(n,vector<int>(n));
  for(int l=0; l<n; l++){
    for(int m=0; m<n; m++) cin >> a[l][m];
  }
  
  vector<vector<ll>>ans0(c,vector<ll>(2));
  vector<vector<ll>>ans1(c,vector<ll>(2));
  vector<vector<ll>>ans2(c,vector<ll>(2));
  
  for(int i=0; i<c; i++){
    ans0[i][1]=i,ans1[i][1]=i,ans2[i][1]=i;
    for(int l=0; l<n; l++){
       for(int m=0; m<n; m++){
        int x=a[l][m]-1;
         if((l+m+2)%3==0) ans0[i][0]+=d[x][i];
         if((l+m+2)%3==1) ans1[i][0]+=d[x][i];
         if((l+m+2)%3==2) ans2[i][0]+=d[x][i];
         
     }
    }
  }
  
  sort(ans0.begin(),ans0.end());
  sort(ans1.begin(),ans1.end());
  sort(ans2.begin(),ans2.end());
  
  ll ans=10e9;
  for(int i=0; i<3; i++){
   for(int j=0; j<3; j++){
    for(int k=0; k<3; k++){
      if(ans0[i][1]==ans1[j][1] || ans1[j][1]==ans2[k][1] || ans2[k][1]==ans0[i][1]) continue;
      ll x = ans0[i][0]+ans1[j][0]+ans2[k][0];
      ans=min(ans,x);
    }
   }
  }
  
  cout << ans << endl;
  
}
  
  

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

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mkp make_pair
#define mkt make_tuple
#define pi 3.14159265358979323846264
#define d7 1000000007
#define l7 998244353

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

//some definitions and global variables >>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}

void srihrg(){
    //code starts
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    
    
    //code ends
}

int main(int argc, const char * argv[]) {
#ifdef KR1shna
    cout<<"||ओ३म्||"<<endl;
#endif
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now

    ll t=1;
    //cin>>t;
    ll nt=1;
    while(t--){
        //cout<<"Case #"<<nt<<": ";
        srihrg();
        //nt++;
        cout<<endl;
    }
    
//code ends
    return 0;
}


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

from fractions import gcd
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

long=lcm([n,m])

ln=int(long/n)
lm=int(long/m)

#ans=[]

ok=True

for i in range(n-1):
    if (i*ln)%lm==0:
        if s[i]!=t[(i*ln)//lm]:
            ok=False

if n==1:
    if s!=t[0]:ok=False
if m==1:
    if t!=s[0]:ok=False

if not ok:long=-1

print(long)

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

int main() {
  string s;
  cin >> s;
  int gx, gy;
  cin >> gx >> gy;

  vector<int> idox, idoy;
  set<int> cangox, cangoy;
  int xx, mode = 0, count = 0;
  bool tokubetu = true;
  for (int i = 0; i <= s.size(); i++) {
    if (s[i] == 'T' || i == s.size()) {
      if (tokubetu) {
        cangox.insert(count);
        tokubetu = false;
      } else if (mode == 0)
        idox.push_back(count);
      else
        idoy.push_back(count);
      mode ^= 1;
      count = 0;
    }
    if (s[i] == 'F') count++;
  }

  if (cangox.size() == 0)
    cangox.insert(0);
  cangoy.insert(0);

  // ヨコ移動について
  for (int i = 0; i < idox.size(); i++) {
    set<int> res(cangox);
    cangox.clear();
    for (auto x : res) {
      cangox.insert(x + idox[i]);
      cangox.insert(x - idox[i]);
    }
  }

  // タテ移動について
  for (int i = 0; i < idoy.size(); i++) {
    set<int> next(cangoy);
    cangoy.clear();
    for (auto y : next) {
      cangoy.insert(y + idoy[i]);
      cangoy.insert(y - idoy[i]);
    }
  }

  if (cangox.count(gx - xx) && cangoy.count(gy))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 768
// MPC-C2.cpp
//#include "pch.h"
#include <iostream>
#include <vector>
using namespace std;

static vector<int>dp(100001, 0);
int cake(int x) {
	if ((dp.at(x - 100) + dp.at(x - 101) + dp.at(x - 102) + dp.at(x - 103) + dp.at(x - 104) + dp.at(x - 105)) > 0)
	{
		dp.at(x) = 1;
		return 1;
	}
	else {
		dp.at(x) = 0;
		return 0;
	}
}
int main()
{
	long long X;
	cin >> X;
	if (X>=2000)
	{
		cout << "1" << endl;
		return 0;
	}
	if (X<100)
	{
		cout << "0" << endl;
		return 0;
	}
	if (X>=100&&X<=105)
	{
		cout << "1" << endl;
		return 0;
	}
	for (int i = 1; i <= 199; i++)
	{
		dp.at(i) = 0;
	}
	for (int i = 100; i <= 105; i++)
	{
		dp.at(i) = 1;
	}

	for (long long j = 200; j < X; j++)
	{
		cake(j);
	}
	cout << cake(X) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=200010,M=2019;
char s[N];
int a[N],n,ans;
int sa[N],ex[N],m[M];
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(int i=1;i<=n;++i) a[i]=s[i-1]-'0';
	ex[0]=1;m[0]=1;
	for(int i=1;i<=n;++i) ex[i]=ex[i-1]*10%M;
	for(int i=n;i>=1;--i) sa[i]=(sa[i+1]+ex[n-i]*a[i])%M;
	//for(int i=1;i<=n;++i) printf("%d\n",sa[i]);
	for(int i=1;i<=n;++i) ++m[sa[i]];
	for(int i=0;i<M;++i){
		if(m[i]){
			ans+=(m[i]*(m[i]-1))>>1;
		}
	}
	printf("%d",ans);
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    int n, m; cin >> n >> m;
    V<bool> b(n + 1, false);
    for(int i = 0; i < m; i++){
        int a; cin >> a;
        b[a] = true;
    }

    V<int> dp(n + 5);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        if(b[i]) continue;
        if(!b[i + 1]) dp[i + 1] += dp[i], dp[i + 1] %= MOD;
        if(!b[i + 2]) dp[i + 2] += dp[i], dp[i + 2] %= MOD;
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3788
#include<cstdio>
int d(int a,int b){
    if(a<b)return b-a;
    else return a-b;
}
int main(){
    int n,a,b,c,l[8],mp=1e9;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(int i=0;i<n;i++)scanf("%d",&l[i]);
    for(int i=0;i<(1<<(2*n));i++){
        int k[8],cnt[4]={};
        for(int j=0;j<n;j++){
            k[j]=(i>>(2*j))%4;
            if(k[j]==3)cnt[3]++;
            else cnt[k[j]]+=l[j];
        }
        if(cnt[0]>0&&cnt[1]>0&&cnt[2]>0){
            int nowmp=d(a,cnt[0])+d(b,cnt[1])+d(c,cnt[2])+10*(n-3-cnt[3]);
            if(mp>nowmp)mp=nowmp;
        }
    }
    printf("%d\n",mp);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;
 
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}
 
int main() {
    string s;
    while(cin >> s) {
        int j = 0;
        rep(i,0,3) {
            if(s[3*i] == s[3*i+1] && s[3*i+1] == s[3*i+2]) {
                if(s[3*i] == 'o') j = 1;
                else if(s[3*i] == 'x') j = 2;
            }
            if(s[i] == s[i+3] && s[i+3] == s[i+6]) {
                if(s[i] == 'o') j = 1;
                else if(s[i] == 'x') j = 2;
            }
        }
        if(j == 0) {
            if(s[0] == s[4] && s[4] == s[8]) {
                if(s[0] == 'o') j = 1;
                else if(s[0] == 'x') j = 2;
            }
            if(s[2] == s[4] && s[4] == s[6]) {
                if(s[2] == 'o') j = 1;
                else if(s[2] == 'x') j = 2;
            }
        }
        switch(j) {
            case 1:
            cout << "o" << endl;
            break;

            case 2:
            cout << "x" << endl;
            break;

            case 0:
            cout << "d" << endl;
            break;
        }
    }
    return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

inline int read() {
  int n = 0, f = 1;
  char c;
  for (c = getchar(); c != '-' && (c < '0' || c > '9'); c = getchar())
    ;
  if (c == '-')
    f = -1, c = getchar();
  for (; c >= '0' && c <= '9'; c = getchar())
    n = (n << 3) + (n << 1) + (c & 15);
  return n * f;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  int n = read();

  multiset<int> a;
  rep(i, n) {
    int tmp = read();
    a.insert(tmp);
  }

  int ans = 0;

  while (a.size() >= 2) {
    int mx = *a.rbegin();
    int p2 = 2;
    while (p2 <= mx)
      p2 *= 2;
    if (p2 == mx - p2) {
      a.erase(a.lower_bound(mx));
      auto itr = a.lower_bound(mx);
      if (itr != a.end()) {
        a.erase(itr);
        ans++;
      }
    } else {
      a.erase(a.lower_bound(mx));
      auto itr = a.lower_bound(p2 - mx);
      if (*itr == p2 - mx) {
        ans++;
        a.erase(itr);
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 13092
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
keta=len(n)
ans=0

# dp=[[0,1]]
# for i in range(keta):
#     dp.append([float('inf')]*2)
dp0=[float('inf')]*(keta+1)
dp1=[float('inf')]*(keta+1)
dp0[0]=0
# dp[0]=[0,1]
# print(dp)
for i in range(keta):
    s=int(n[-1-i])
    dp0[i+1]=min(dp0[i]+s,dp1[i]+s+1)
    dp1[i+1]=min(dp0[i]+(10-s),dp1[i]+(10-s-1))
# print(dp)
print(min(dp0[-1],dp1[-1]+1))

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

int main(){
  int n, k; cin >> n >> k;
  vector<int> v(n); int index;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 1) index = i;
  }
  int ans = 0;
  if (n == k) cout << 1 << endl;
  else {
    int u = index % (k-1); int v = (n-index-1) % (k-1);
    if ((u+v) < k && u != 0 && v != 0) ans--;
    cout << (index+k-2)/(k-1) + (n-index-1+k-2)/(k-1) + ans << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>  
#include<deque> 
#include<stack>
#include<string> 
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n) 
{ 
  vector<ll> result;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    int count=1;
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                {
                  prime[i] = false; 
                }
            count++;
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          {
            result.push_back(p);
          }
    return result;
}



vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

 
int main()
{
  _FI 

  ll n;
  cin>>n;

  V<ll> arr(n);
  map<ll,ll> mp;
  forn(i,n)
    {
      cin>>arr[i];
      mp[arr[i]]++;
    }
    if(mp.size()==n)
    {
      cout<<"YES";
    }
    else
    {
      cout<<"NO";
    }
  

  return 0;
}















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


void solve(){
    int d;
    cin >> d;
    int tmp = 25-d;
    string s = "Christmas";
    rep(i,tmp){
        s += " Eve";
    }
    cout << s << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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

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

    int N;
    cin >> N;
    auto x = make_vec<int>(N);
    auto y = make_vec<int>(N);
    auto h = make_vec<int>(N);
    REP(i, N) { cin >> x.at(i) >> y.at(i) >> h.at(i); }

    REP(cx, 101) {
        REP(cy, 101) {
            int H = -1;
            int flug = false;
            REP(i, N) {
                if (h[i] != 0) {
                    H = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                    break;
                }
            }
            REP(i, N) {
                if (h[i] != 0) {
                    if (H - abs(cx - x[i]) - abs(cy - y[i]) != h[i]) {
                        // cout << cx << " " << cy << " " << H << " x:" << x[i] << " y:" << y[i]
                        //<< " dif:" << H - abs(cx - x[i]) + abs(cy - y[i]) << endl;
                        flug = true;
                        break;
                    }
                } else {
                    if (H - abs(cx - x[i]) - abs(cy - y[i]) > 0) {
                        flug = true;
                        break;
                    }
                }
            }

            if (flug) {
                continue;
            } else {
                REP(i, N) {
                    if (h[i] != 0) {
                        cout << cx << " " << cy << " " << H << endl;
                        return 0;
                    }
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            if (s1 != "1" && s2 != "1")
            {
                Console.WriteLine("1");
            }
            if (s1 != "2" && s2 != "2")
            {
                Console.WriteLine("2");
            }
            if (s1 != "3" && s2 != "3")
            {
                Console.WriteLine("3");
            }
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    rep(y,ty-sy) cout << "U";
    rep(x,tx-sx) cout << "R";
    rep(y,ty-sy) cout << "D";
    rep(x,tx-sx) cout << "L";
    cout << "L";
    rep(y,ty-sy+1) cout << "U";
    rep(x,tx-sx+1) cout << "R";
    cout << "DR";
    rep(y,ty-sy+1) cout << "D";
    rep(x,tx-sx+1) cout << "L";
    cout << "U" << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		String[] in = null;
		int numToken = 0;
		ArrayList<Integer> tokens = new ArrayList<>();

		try { // read numToken
			line = input.readLine();
			numToken = Integer.parseInt(line);
		} catch (IOException e) {
			System.out.println("IOException");
		} catch (NumberFormatException e) {
			System.out.println("The first line isn't int");
		}

		try {
			line = input.readLine(); //read tokens
			in = line.split(" ");
			for (String str : in) {
				tokens.add(Integer.parseInt(str));
			}
			int firstToken = tokens.remove(0);

			/* solve */
			//make List
			long countInterimSol[] = new long[21];
			long countInterimSolTemp[] = new long[21];
			int interimSol;
			countInterimSol[firstToken] = 1; //prevent bag from (firstToken == 0)
			for (int token : tokens) {
				for(int i = 0; i <= 20; i++) {
					if(countInterimSol[i] == 0){ //should have no this if statement?
						continue;
					}
					interimSol = i + token;
					if(interimSol <= 20) {
						countInterimSolTemp[interimSol] += countInterimSol[i];
					}
					interimSol = i - token;
					if(interimSol >= 0) {
						countInterimSolTemp[interimSol] += countInterimSol[i];
					}
				}
				for(int i = 0; i <= 20; i++) {
					countInterimSol[i] = countInterimSolTemp[i];
				}
				Arrays.fill(countInterimSolTemp, 0);
			}

			System.out.println(countInterimSol[0]);

		} catch (IOException e) {
			System.out.println("IOException");
		} catch (NumberFormatException e) {
			System.out.println("The first line isn't int");
		}
	}
}


Measured memory_bytes: 24432
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int ans = 1;
    rep(i, N - 1) {
        if (S[i] != S[i + 1]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline
from heapq import heappop,heappush
t=int(input())
for _ in range(t):
	happy=0
	n=int(input())
	camel=[]
	p=[]
	m=[]
	for i in range(n):
		k,l,r=map(int,input().split())
		happy+=min(l,r)
		if l-r>=0:
			p.append((k,l-r))
		else:
			m.append((k,r-l))
	p.sort();m.sort(reverse=True)
	now=0
	P=[];M=[]
	for i in range(n):
		if now<len(p):
			while p[now][0]==i+1:
				heappush(P,(p[now][1],p[now][0]))
				now+=1
				if now==len(p):
					break
		while len(P)>i+1:
			r=heappop(P)
	now=0
	for i in range(n,0,-1):
		if now<len(m):
			while m[now][0]==i:
				heappush(M,(m[now][1],m[now][0]))
				now+=1
				if now==len(m):
					break
		while len(M)>n-i:
			r=heappop(M)
	for x in P:
		happy+=x[0]
	for x in M:
		happy+=x[0]
	print(happy)

Measured memory_bytes: 48728
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=200500;
int n;
int w[N],s[N];
ll v[N];
struct O{
	int w,s,i;
	ll v;
	O(){}
	O(int i, int w, int s, ll v):i(i),w(w),s(s),v(v){}
	bool operator<(const O o){
		return s+w>o.w+o.s;
	}
};
O x[N];
ll dp[1024][20011];
ll f(int i, int j){
	if(i==n)return 0;
	ll &r=dp[i][j];
	if(r!=-1)return r;
	r=f(i+1,j);
	if(j>=x[i].w)r=max(r,f(i+1,min(x[i].s,j-x[i].w))+x[i].v);
	return r;
} 
int main(){FIN;
	cin>>n;
	fore(i,0,n){
		cin>>w[i]>>s[i]>>v[i];
		x[i]=O(i,w[i],s[i],v[i]);
	}
	sort(x,x+n);
	memset(dp,-1,sizeof dp);
	cout<<f(0,20000)<<"\n";
}

Measured memory_bytes: 164096
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

int main() {
	int N, M;
	map<int, int> mods;

	cin >> N >> M;
	ll sum = 0;
	mods[0] = 1;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		sum += tmp;

		mods[sum%M]++;
	}
	
	ll ans = 0;
	for (auto i = mods.begin(); mods.end() != i;i++) {
		ans += (ll)i->second * (i->second - 1) / 2;
	}

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

Measured memory_bytes: 3200
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static int minCost(int[] h, int i, int[] dp, int k) {
        if (i == 0) {
            return 0;
        }

        int cost = Integer.MAX_VALUE;
        if (dp[i] == -1) {
            for (int j = 1; j <= k; j++) {
                if (i - j >= 0) {
                    cost = Integer.min(cost, minCost(h, i - j, dp, k) + Math.abs(h[i] - h[i - j]));
                }
            }
            dp[i] = cost;
        }
        return dp[i];
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
            int size = scanner.nextInt();
            int k = scanner.nextInt();
            int[] h = new int[size];
            for (int i = 0; i < h.length; i++) {
                h[i] = scanner.nextInt();
            }
            int[] dp = new int[size];
            Arrays.fill(dp, -1);
            System.out.println(minCost(h, h.length - 1, dp, k));

        } finally {
            scanner.close();
        }
    }
}

Measured memory_bytes: 62356
import Data.List
import Text.Printf

solve :: [Double] -> [Double] -> [Double]
solve xs ys = p1 : p2 : p3 : p : []
    where
        ts = zip xs ys
        p1 = foldl (\a t -> a + abs (fst t - snd t)) 0 ts
        p2 = sqrt $ foldl (\a t -> a + abs (fst t - snd t) ** 2) 0 ts
        p3 = (foldl (\a t -> a + abs (fst t - snd t) ** 3) 0 ts) ** (1 / 3)
        p  = maximum $ map (\t -> abs (fst t - snd t)) ts

main :: IO ()
main = do
    _  <- getLine
    xs <- getLine
    ys <- getLine
    putStr $ unlines $ map (printf "%.6f") $ solve (map read $ words xs) (map read $ words ys)

Measured memory_bytes: 4540
n = int(input())
s = input()
d = 0
a = []
for i in s:
    if i == "I":
        d += 1
        a.append(d)
    else:
        d -= 1
        a.append(d)
if max(a) <= 0:
    print(0)
else:
    print(max(a))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f q.front()
#define SIZE (ll)(1e3)
#define mod (ll)(1e9+7)
using namespace std;
typedef long long int ll;
int main(){
	IOS
 ll a,b;
 cin>>a>>b;
 ll h=a%b;ll y =b-h;
 cout<<min(h,y);
return 0;}

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

int main(void)
{
  int n, m, a;
  scanf("%d %d",&n,&m);
  for (int i = 0; i < m; ++i)
  {
    scanf("%d",&a);
    n = n - a;
    if (n < 0) {
      printf("-1\n");
      exit(0);
    }
  }
  printf("%d\n",n);
  return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin >> n;
  vector<long int>a(n);
  long long int sum=0;
  long long int h=0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    if(i>0){
      if(a.at(i)<a.at(i-1)){
        h=(a.at(i-1)-a.at(i));
        a.at(i)+=h;
        sum+=h;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4736
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long gcd = gcd(A,B);

    Set<Long> set = new HashSet<>();
    for (long i = 2; i*i <= gcd ; i++) {
      if(gcd%i ==0){
        set.add(i);
        while(gcd%i == 0)
          gcd =gcd/i;
      }
    }
    if(gcd!=1) set.add(gcd);

    System.out.println(set.size()+1);

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



}

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

using namespace std;

int main(){
 	
  int n;
  cin >> n;
  vector<int> arr(n);
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  bool pos = true;
  if( arr[0] != 1 )
    arr[0]--;
  for(int i = 1; i < n; i++)
    if( arr[i]-arr[i-1] < 0 )
      pos = false;
  	else if( arr[i] - arr[i-1] > 0 )
      arr[i]--;
  
  if( pos )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
      
  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for(ll i = k + 1; i <= n; i++){
		ll n1 = n;
		ans += (n1 / i) * (i - k);
		n1 %= i;
		ans += max(0LL, n1 - k + 1);
	}
	if(!k) ans -= n;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
isInteger :: RealFrac a => a -> Bool
isInteger x = x == fromInteger (round x)

main = do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    let k = abs (fromIntegral b + fromIntegral a) / 2
    putStrLn $
      if isInteger k then show $ round k else "IMPOSSIBLE"


Measured memory_bytes: 508
n,k = map(int,input().split())
p = [input() for _ in range(n)]
p_ini = [0]*26
for _p in p:
    p_ini[ord(_p[0])-ord('A')] += 1
res = 0
while p_ini.count(0)<=26-k:
    p_ini = sorted(p_ini)[::-1]
    for i in range(k):
        if p_ini[i]!=0:
            p_ini[i] -= 1
    res += 1
print(res)


Measured memory_bytes: 3700
import java.io.*;
import java.util.*;



class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    
    static int minimum;
    static int gap;
    
    public static void main(String[] args) throws IOException{
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int minimum = scanner.nextInt();
        int time = scanner.nextInt();
        
        //minimumはその時点での最小値のことである
        
        gap = time - minimum;
        if(minimum >= time)minimum = time;
        
        for(int i = 0;i<number - 2;i++){
            time = scanner.nextInt();
            
            if(time - minimum >= gap)gap = time - minimum;
            if(minimum >= time)minimum = time;
        }
        
        System.out.println(gap);
    
    
    }
}

Measured memory_bytes: 94456
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>

using namespace std;
typedef long long int ll;

long long int powmod(long long int a, long long int k, long long int m){ //0<=a<=1e9, 0<k<=1e18, 0<m<=1e9
	if(a==0){
		return 0;
	}
	long long int apow[30], c[30];
	for(int i=0; i<30; i++){
		if(i==0){
			apow[i]=a;
			c[i]=1;
		}else{
			apow[i]=apow[i-1]*apow[i-1]%m;
			c[i]=c[i-1]*2;
		}
	}
	long long int ans=1;
	for(int i=29; i>=0; i--){
		if(k>=c[i]){
			ans=ans*apow[i]%m;
		}
		k=k%c[i];
	}
	return ans;
}
 
ll inv(ll x, ll p){
  return powmod(x, p-2, p);
}

int main()
{
	ll n, m;
	scanf("%lld %lld", &n, &m);
	ll p[3001], p2[3001];
	p[0]=1, p2[0]=2;
	for(ll i=1; i<=n; i++){
		p[i]=p[i-1]*2%m;
		p2[i]=p2[i-1]*p2[i-1]%m;
	}
	ll pk[3002][3002];
	for(ll i=1; i<=n+1; i++){
		pk[i][0]=1;
		for(ll j=1; j<=n; j++){
			pk[i][j]=pk[i][j-1]*i%m;
		}
	}
	ll f[3001], invf[3001];
	f[0]=1;
	for(ll i=1; i<=n; i++){
		f[i]=f[i-1]*i%m;
	}
	invf[n]=inv(f[n], m);
	for(ll i=n-1; i>=0; i--){
		invf[i]=invf[i+1]*(i+1)%m;
	}
	ll c[3001];
	c[0]=1;
	ll ans=p2[n];
	for(ll k=1; k<=n; k++){
		ll x=p[n-k];
		ll px[3001];
		px[0]=1;
		for(ll i=1; i<=k; i++){
			px[i]=px[i-1]*x%m;
		}
		ll s[3001];
		s[0]=1;
		for(ll i=1; i<=k; i++){
			if(i%2==0){
				s[i]=(s[i-1]+px[i]*invf[i]%m)%m;
			}else{
				s[i]=(s[i-1]-px[i]*invf[i]%m+m)%m;
			}
		}
		c[k]=0;
		for(ll i=0; i<=k; i++){
			c[k]=(c[k]+px[k-i]*invf[k-i]%m*s[i]%m*pk[k+1-i][k]%m)%m;
		}
		if(k%2==0){
			ans=(ans+f[n]*invf[n-k]%m*invf[k]%m*p2[n-k]%m*c[k]%m)%m;
		}else{
			ans=(ans+m-f[n]*invf[n-k]%m*invf[k]%m*p2[n-k]%m*c[k]%m)%m;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 70784
import java.util.Scanner;

public class Main {
	static int[] l;
	static int min = 1000000000;
	static int N, A, B, C;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		l = new int[N];
		for(int i = 0; i < N; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();
		dfs(0, 0, 0, 0, 0);
		System.out.println(min);
	}
	static void dfs(int n, int a, int b, int c, int d) {
		if(n == N) {
			if(a == 0 || b == 0 || c == 0) {
				return;
			}
			int cost = Math.abs(A - a) + Math.abs(B - b) + Math.abs(C - c);
			cost += d - 30;
			min = Math.min(min, cost);
			return;
		}
		dfs(n + 1, a, b, c, d);
		dfs(n + 1, a + l[n], b, c, d + 10);
		dfs(n + 1, a, b + l[n], c, d + 10);
		dfs(n + 1, a, b, c + l[n], d + 10);
	}

}


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

int main()
{
	string s;

	cin >> s;
	int ans = 700;
	if (s[0] == 'o') ans += 100;
	if (s[1] == 'o') ans += 100;
	if (s[2] == 'o') ans += 100;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 7;
int n, ok[maxn][maxn], ans;

int main() {
	scanf("%d", &n);
	int m = n;
	if(n & 1) {
		--m;
		ans += m;
		for (int i = 1; i <= m; ++i) ok[i][n] = 1;
	}
	ans += m / 2 * (m - 2);
	for (int i = 1; i <= m; ++i) {
		for (int j = i + 1; j <= m; ++j) ok[i][j] = 1;
		ok[i][m - i + 1] = 0;
	}
	printf("%d\n", ans);
	for (int i = 1; i <= n; ++i) for(int j = i + 1; j <= n; ++j) 
		if(ok[i][j]) printf("%d %d\n", i, j);
	return 0;
}

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

using namespace std;

int main()
{
    int n, ans=9999999999, a, d;
    string b, c;
    cin>>n;
    for (int i=1; i<n; i++)
    {
        d=0;
        a=n-i;
        b=to_string(i);
        c=to_string(a);
        for (int j=0; j<b.size(); j++) d+=b[j]-'0';
        for (int j=0; j<c.size(); j++) d+=c[j]-'0';
        ans=min(ans, d);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N;
    int ans=0;
    cin>>N;
    VI l(2*N);
    REP(i,2*N)cin>>l[i];
    sort(All(l));
    REP(i,N){
        ans+=l[i*2];
    }
    cout<<ans<<endl;

}




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

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& e : A) cin >> e;
  auto p = minmax_element(cbegin(A), cend(A));
  int s = *p.first, l = *p.second;
  int x = count(cbegin(A), cend(A), s), y = N - x;
  bool ans = l - s < 2 &&
             (s == l ? s == N - 1 || 2 * s <= N : x < l && 2 * (l - x) <= y);
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007

int dp[305][305][305];
vector<pair<int,int>> v[305];

int main(){
  int N, M;
  cin >> N >> M;
  rep(i,M){
    int l, r, x;
    cin >> l >> r >> x;
    v[r].push_back(make_pair(l,x));
  }

  ll ret = 0;
  dp[0][0][0] = 1;

  rep(i,N+1){
    rep(j,N+1){
      rep(k,N+1){
        int m = max(i,max(j,k));

        rep(ii,v[m].size()){
          int r = m;
          int l = v[r][ii].first;
          int x = v[r][ii].second;

          int cnt = 0;
          if(l<=i && i<=r) cnt++;
          if(l<=j && j<=r) cnt++;
          if(l<=k && k<=r) cnt++;
          //cout << cnt << " " << x << " " << dp[i][j][k] << endl;
          if(cnt != x){
            dp[i][j][k] = 0;
          }
        }

        if(m == N){
          ret += dp[i][j][k];
          ret %= MOD;
          continue;
        }

        //cout << i << " " << j << " " << k << " -> " << m+1 << " " << dp[i][j][k] << endl;
        dp[m+1][j][k] += dp[i][j][k];
        dp[m+1][j][k] %= MOD;
        dp[i][m+1][k] += dp[i][j][k];
        dp[i][m+1][k] %= MOD;
        dp[i][j][m+1] += dp[i][j][k];
        dp[i][j][m+1] %= MOD;

      }
    }
  }
  
  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 110848
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<stack>
#include<vector>
#define maxn 10000
#define INF 10000000000
typedef long long ll;
typedef unsigned long long ul;
using namespace std;
int main()
{
	int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	n--;
	cout<<arr[n];
	return 0;
	
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll k,t,cnt=INF,before; cin>>k>>t;
    vector<ll> a(t);
    rep(i,t) cin>>a[i];
    ll maxi=*max_element(all(a));
    cout<<max(maxi-1-(k-maxi), 0LL)<<endl;
    return 0;
}

Measured memory_bytes: 3552
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

const int MAX_N = 15;
int x[MAX_N][MAX_N];
int y[MAX_N][MAX_N];
int N;
int A[MAX_N];
int bits[MAX_N];
bool honest[MAX_N];
int ans;

int check_honest()
{
    bool flag = true;
    for(int i = 0; i < N; ++i){
        if(!bits[i]) continue;
        for(int j = 0; j < A[i]; ++j){
            if((bits[x[i][j]-1] & 1) ^ y[i][j]){
                flag = false;
            }
        }
    }

    if(!flag) return -1;

    int cnt = 0;    
    for(int i=0; i < N; ++i){
        if(bits[i]) ++cnt;
    }
    return cnt;
}

void solve(){
    for (int i = 0; i < pow(2, N); ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            int bit = (i >> j) & 1;
            bits[j] = bit;
        }
        int res = check_honest();
        ans = max(ans, res);

    }
}

int main(void){
    cin >> N;
    for(int i=0;i<N;++i){
        cin >> A[i];
        for(int j=0;j<A[i]; ++j){
            cin >> x[i][j];
            cin >> y[i][j];
        }
    }
    solve();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(){
    val S = readLine()!!.split("").filter { it != "" }

    var count = 0

    if(S[0] == "R"){
        count++
        if(S[1] == "R"){
            count++
            if(S[2] == "R"){
                count++
            }
        }
    }else if(S[1] == "R"){
        count++
        if(S[2] == "R"){
            count++
        }
    }else if(S[2] == "R"){
        count++
    }
    println(count)
}

Measured memory_bytes: 39776
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] visited = new int[n+1];
		ArrayList<Edge>[] list = new ArrayList[n+1];
		for(int i = 1; i <= n; i++){
		    list[i] = new ArrayList<Edge>();
		}
		for(int i = 0; i < m; i++){
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    int z = sc.nextInt();
		    
		    list[x].add(new Edge(x, y));
		    list[y].add(new Edge(y, x));
		}
		
		// 計算
		int result = 0;
		ArrayDeque<Integer> ad = new ArrayDeque<Integer>();
		for(int i = 1; i <= n; i++){
		    if(visited[i] == 1) continue;
		    visited[i] = 1;
		    result++;
		    ad.add(i);
		    while(!ad.isEmpty()){
		        int now = ad.poll();
		        for(Edge e : list[now]){
		            int j = e.to;
		            if(visited[j] == 1) continue;
		            visited[j] = 1;
		            ad.add(j);
		        }    
		    }
		}
		
		// 出力
        System.out.println(result);
	}
}

class Edge {
    int from;
    int to;
    
    Edge(int from, int to){
        this.from = from;
        this.to = to;
    }

    public String toString(){
        return "from:" + from + " to:" + to ;
    }
    
}

Measured memory_bytes: 110272