akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  	inputArr = input.split("\n");
	var n = parseInt(inputArr[0], 10);
	var d = inputArr[1].split(" ");

    dd = d.sort(function(a,b){
        var an = parseInt(a, 10);
        var bn = parseInt(b, 10);
        if( an < bn ) return -1;
        if( an > bn ) return 1;
        return 0;
	});
    var center = dd.length / 2;
    console.log(dd[center] - dd[center - 1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 18224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define Mod 1000000007
using namespace std;
long long f[2010][2010];
int n,k;
long long fac[4000010],inv[4000010];
long long fpow(long long a,long long b)
{
	long long ans=1,t=a;
	while(b)
	{
		if(b&1)ans=ans*t%Mod;
		t=t*t%Mod;
		b>>=1;
	}
	return ans;
}
void getfac()
{
	fac[0]=1;
	for(int i=1;i<=n*k;i++)
		fac[i]=fac[i-1]*i%Mod;
	inv[n*k]=fpow(fac[n*k],Mod-2);
	for(int i=n*k;i;i--)
		inv[i-1]=inv[i]*i%Mod;
	return ;
}
long long C(int a,int b)
{
	return fac[a]*inv[b]%Mod*inv[a-b]%Mod;
}
int main()
{
	cin>>n>>k;
	if(k==1){
		cout<<1<<"\n";
		return 0;
	}
	getfac();
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			f[i][j]+=f[i-1][j];
			if(j)
				f[i][j]=(f[i][j]+f[i][j-1]*(n-j+1)%Mod*C(n-i+(k-1)*(n-j+1)-1,k-2)%Mod)%Mod;
		}
	printf("%lld\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 94208
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int T;
int A;
int H[1000];
int main(){
  int i, k;
  rd(N);
  rd(T);
  rd(A);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
    }
  }
  k = 1000 * (T - A);
  for(i=0;i<N;i++){
    H[i] = abs(6* H[i] - k);
  }
  {
    int FmcKpFmN, Q5VJL1cS, RZTsC2BF, cTE1_r3A, e98WHCEY=0;
    for(Q5VJL1cS=0;Q5VJL1cS<((N)-1)+1;Q5VJL1cS++){
      RZTsC2BF = H[Q5VJL1cS];
      if(e98WHCEY==0 || cTE1_r3A>RZTsC2BF){
        cTE1_r3A = RZTsC2BF;
        e98WHCEY = 1;
        FmcKpFmN = Q5VJL1cS;
      }
    }
    k =FmcKpFmN;
  }
  wt_L(k+1);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, T, A, H[1000];
// {
//   int i, k;
// 
//   rd(N,T,A,H(N));
// 
//   k = 1000 * (T - A);
//   rep(i,N) H[i] = abs(6 H[i] - k);
// 
//   k = argmin(H(N));
//   wt(k+1);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
signed main(){
  int a,b=0,c;
  cin>>a;
  c=a;
  while(c!=0){
    b*=10;
    b+=c%10;
    c/=10;
  }

  if(b==a)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return(0);
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
 
using namespace std;
typedef long long ll;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
 
const ll mod = 1e9 + 7;
const ll inf = 1e18;
 
int timeline[200010];
int useline[200010]; // 使っていれば1
int neednum[200010] = {}; // その時間に求められる録画機の数（ラインの数）
 
void resetTimeline(){
    FOR(i, 0, 200010){
        timeline[i] = 0;
        useline[i] = 0;   
    }
}
 
void printArray(int *a, int num){
    FOR(i, 0, num){
        cout << a[i] << " ";
    }
    cout << endl;
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    // input
    int N, channelNum;
    cin >> N >> channelNum;
 
    vector<int> S(N);
    vector<int> T(N);
    vector<int> C(N);
 
    // タイムスケールを2倍にして整数で考える
    FOR(i, 0, N){
        int s, t, c;
        cin >> s >> t >> c;
        s *= 2;
        t *= 2;
        S[i] = s;
        T[i] = t;
        C[i] = c;
    }
 
    // 各チャンネル毎に占有したい時間帯を求める
    FOR(c, 1, channelNum+1){
        resetTimeline();
        FOR(i, 0, N){
            if(C[i]==c){
                timeline[S[i]-1] = 1;
                timeline[T[i]] = -1;
            }
        }
        // いもす
        useline[0] = timeline[0];
        FOR(i, 1, 200010){
            useline[i] = useline[i-1] + timeline[i];
        }
        //
        FOR(i, 0, 200010){
            if(useline[i]>0){
                neednum[i]++;
            }
        }
    }
 
    int answer = neednum[0];
    FOR(i, 0, 200010){
        answer = max(answer, neednum[i]);
    }
 
    p(answer);
    
    return 0;
}

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

int main(){
    string S;
    ll K;
    cin >> S >> K;
    int pos = 0;
    while(S[pos] == '1' && K > 0){
        K--;
        pos++;
    }

    if(K == 0) cout << S.substr(pos - 1, 1) << endl;
    else cout << S.substr(pos, 1) << endl;
}


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

using namespace std;

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

	int n,k;
	cin>>n>>k;
	vector<int>nums(n);
	for(int i=0;i<n;++i)
		cin>>nums[i];

	sort(begin(nums),end(nums));
	long long sum=0;
	for(int i=0;i<k;++i)
		sum+=nums[i];

	cout<<sum;
}


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

int main(){
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  cout << 10*a[0]+a[1]+a[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    
    int answer;
    if(A == B) answer = C;
    if(B == C) answer = A;
    if(C == A) answer = B;
    
    printf("%d\n", answer);
    return 0;
}

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

int main(){
	int x, y;
	ll ans;
	cin >> x >> y;
	if(x % y == 0){
		cout << -1 << endl;
		return 0;
	}
	for(ll i = 1;;i++){
		ans = (ll)x * i;
		if(y % ans != 0){
			cout << ans << endl;
			return 0;
		}
	}
}

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

#define ll long long
#define fi first
#define se second

const ll maxn = 1e5+1;

ll par[maxn],sz[maxn];

ll fnd(ll a){
    while(a!=par[a]){
        par[a]=par[par[a]];
        a=par[a];
    }
    return a;
}

void un(ll a,ll b){
    if(sz[a]<sz[b]){
        swap(a,b);
    }
    par[b]=a;
    sz[a]+=sz[b];
    sz[b]=0;
}

int main(){

    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<=n;i++){
        par[i]=i;
        sz[i]=1;
    }

    pair<ll,ll> p[m];
    for(ll i=0;i<m;i++){
        cin>>p[i].first>>p[i].second;
    }
    reverse(p,p+m);
    vector<ll> ans;
    ll cur=(n*(n-1))/2;
    ans.push_back(cur);
    for(ll i=0;i<m;i++){
        ll a=fnd(p[i].fi);
        ll b=fnd(p[i].se);
        if(a!=b){
            cur-=sz[a]*sz[b];
            un(a,b);
        }
        ans.push_back(cur);
    }
    ans.pop_back();
    reverse(ans.begin(),ans.end());
    for(auto it:ans){
        cout<<it<<endl;
    }
    return 0;

}

Measured memory_bytes: 5364
import sys
d = {i:0 for i in range(1, 101)}
for n in sys.stdin:
    if n == "\n":
        break
    else:
        d[int(n)] += 1
sort = sorted(d.items(), key=lambda x: x[1], reverse=True)
mode = sort[0]
for n in sort:
    if mode[1] == n[1]:
        print(n[0])

Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
	ll n;cin>>n;
	double x[n];string u[n];rep(i,0,n)cin>>x[i]>>u[i];
	double a=0;
	rep(i,0,n){
		if(u[i]=="JPY") a+=x[i];
		else a+=x[i]*380000;
	}
	cout << a << ednl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll s,sum=0; cin>>s;
    if(s<3){
        cout<<0<<endl;
        return 0;
    }
    vector<ll> dp(s+1,0);
    dp[3]=0;
    for(int i=3;i<=s;i++){
        dp[i]=(dp[i]+sum+1)%MOD;
        sum=(sum+dp[i-2])%MOD;
    }
    cout<<dp[s]<<endl;
}

Measured memory_bytes: 3628
import itertools

N = int(input())
S = list(input())

for i in range(N):
    if S[i] == '.':
        S[i] = 0
    else:
        S[i] = 1

B = list(itertools.accumulate(S))

MIN = 10000000
cnt = []
for i in range(N):
    cnt.append(B[i] + N - B[N-1] + B[i] - i - 1)
    # MIN = min(MIN, cnt)
MIN = min(cnt)



S_s = list(set(S))
if len(S_s) == 1:
    MIN = 0
else:
    MIN = min(MIN, S.count(0))
print(MIN)


Measured memory_bytes: 20748
#include <iostream>

int main()
{
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;
    if(0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int a,b,c[7],d,g;
	for(d=0;d<=6;d++){
	scanf("%d %d",&a,&b);
	c[d]=a-b;
	}
	for(g=0;g<=6;g++){
	printf("%d\n",c[g]);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  
  string str;
  cin>>str;
  bool check = false;
  for (int i = 0; i < str.size()-1; i++)
  {
    if(str[i] =='A' && str[i+1] == 'C')check = true;
  }
  cout<<(check?"Yes":"No")<<endl;
  
  return;
}




int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    map<pair<char,char>,ll> mp;

    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        string now = to_string(i);

        mp[make_pair(now.front(),now.back())]++;
    }

    ll ans = 0;
    for(int i = 0;i <= n;i++){
        string now = to_string(i);

        ans += mp[make_pair(now.back(),now.front())];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    int n,q;
    string s;
    pair<int,int> p[111111];
    int ke[111111];
    cin>>n>>q;
    cin>>s;
    rep(i,q){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(a,b);
    }
    int co=0;
    ke[0]=0;
    for(int i=1;i<n;i++){
        if(s[i-1]=='A' && s[i]=='C'){
            co++;
        }
        ke[i]=co;
    }
    rep(i,q){
        cout<<ke[p[i].second-1]-ke[p[i].first-1]<<endl;
    }
    
    
    
	

}

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

const int MOD = 1e9 + 7;
void add(int &a, int b)
{
	a += b;
	if (a >= MOD)
		a -= MOD;
}

void sub(int &a, int b)
{
	a -= b;
	if (a < 0)
		a += MOD;
}

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

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

	vector<int> candies;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		candies.push_back(x);
	}

	vector<int> dp(k + 1);
	dp[0] = 1;

	for (int i = 0; i < n; i++)
	{
		vector<int> new_dp(k + 1);
		vector<int> pref(k+1);
		pref[0] = dp[0];
		for (int j = 1; j <= k; j++)
		{
			add(pref[j], pref[j-1]);
			add(pref[j], dp[j]);
		}

		for (int j = 0; j <= k; j++)
		{
			if (j - candies[i] <= 0)
				add(new_dp[j], pref[j]);
			else
			{
				int x = pref[j];
				sub(x, pref[j - candies[i] - 1]);
				add(new_dp[j], x);
			}
		}
		dp = new_dp;
	}
	cout << dp[k] << "\n";
}

Measured memory_bytes: 1496
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for _ in range(N)]

ans=inf=float('inf')
for p in range(1,1<<N):
    tt,lvls=0,[0]*M
    for i in range(N):
        if p&(1<<i)==0:
            continue
        tt+=C[i][0]
        for j in range(M):
            lvls[j]+=C[i][j+1]
        for j in range(M):
            if lvls[j]<X:
                break
        else:
            ans=min(ans,tt)
            break


print(ans if ans<inf else -1)


Measured memory_bytes: 68420
#include<bits/stdc++.h>
using namespace std;
class dsu{
	private:
	public:
	vector<int> arr;
	vector<int> rank;
	dsu(int n){
		arr.resize(n+1);
		rank.resize(n+1);
		init();
	}
	void init(){
		for(int i=0;i<arr.size();i++)
		arr[i]=i,rank[i]=1;
	}
	int root(int a){
		while(a!=arr[a]){
			arr[a]=arr[arr[a]];
			a=arr[a];
		}
		return a;
	}
	void unin(int a,int b){
		int x=root(a);
		int y=root(b);
		if(x==y)
		return ;
		if(rank[x]<rank[y]){
			arr[x]=y;
			rank[y]+=rank[x];
		}
		else {
			arr[y]=x;
			rank[x]+=rank[y];
		}
	}
	bool find(int a,int b){
		if(root(a)==root(b))
		return true;
		else return false;
	}
};
int main(){
	int n,m,a,b;
	cin>>n>>m;
	dsu d(n);
	while(m--){
		cin>>a>>b;
		d.unin(a-1,b-1);
	}
//	for(int i=0;i<d.rank.size();i++)
//	cout<<d.rank[i]<<" ";
//	cout<<endl;
	cout<<*max_element(d.rank.begin(),d.rank.end())<<endl;
}


Measured memory_bytes: 4836
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque
from heapq import heappush, heappop
sys.setrecursionlimit(10 ** 7)
ans = 0
tmp = 0
inf = 10 ** 20
INF = float("INF")
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hip(n): return [i() - 1 for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
p = hip(n)

stillset = set()
flagli = [0] * n
for i in range(n):
    if p[i] - 1 in stillset:
        if p[i] != 0:
            flagli[p[i] - 1] = 1
    stillset.add(p[i])

sign = 1 if flagli[0] == 1 else 0
tmp = 1 if flagli[0] == 1 else 0
for i in range(1, n):
    if sign == 1:
        if flagli[i] == 1:
            tmp += 1
        else:
            sign = 0
            ans = max(ans, tmp)
            tmp = 0
    else:
        if flagli[i] == 1:
            tmp += 1
            sign = 1
        else:
            pass
ans = max(ans, tmp) + 1

print(n - ans)

Measured memory_bytes: 28212
while True:
  x, a, y = map(str, input().split())
  x=int(x)
  y =int(y)
  if a is "+":
    print(x+y)
  elif a is "-":
    print(x-y)
  elif a is "*":
    print(x*y)
  elif a is "/":
    print(x // y)
  elif a is "?":
    break


Measured memory_bytes: 5596
#include <iostream>
using namespace std;
int main(void) {
  int W, a, b;
  cin >> W >> a >> b;
  if (a + W < b) {
    cout << b - (a + W) << endl;
  } else if (b + W < a) {
    cout << a - (b + W) << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/* ALDS1_4_A: Linear Search */

#include <iostream>
#include <cstdio>

int main() {
    int n;
    std::cin >> n;
    int S[n + 1];
    for (int i = 0; i < n; i++)
        scanf("%d", &S[i]);

    int q;
    std::cin >> q;
    int T[q];
    for (int i = 0; i < q; i++)
        scanf("%d", &T[i]);

    int n_matches = 0;
    for (int i_q = 0; i_q < q; i_q++) {
        int i_n = 0;
        S[n] = T[i_q];
        while ( S[i_n] != T[i_q] )
            i_n++;
        if (i_n < n)
            n_matches++;
    }

    std::cout << n_matches << std::endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007


    int main(void){
        int n, m;
        cin >> n >> m;
        
        //SWとLightの条件をまとめた配列
        vector<vector<int>> sw_l(m);

        for (int i = 0; i < m;i++){
            int k;
            cin >> k;
            sw_l.at(i).resize(k);   //配列数を追加
            for (int j = 0; j < k; j++)
            {
                cin >> sw_l.at(i).at(j);
                sw_l.at(i).at(j)--;//０スタートに修正
            }
        }
        //電球がつく条件をまとめた配列
        vector<int> p(m);
        for (int i = 0; i < m;i++){
            cin >> p.at(i);            
        }
        //答えの準備
        int ans = 0;
        
        //bit演算
        for (int i = 0; i < (1 << n);i++){//swの個数分チェック
            bool check = true;
            for (int j = 0; j < m;j++){//それぞれの電球に対して
                int sw_cnt = 0;    //bit演算の値を設定  
                for(int id : sw_l.at(j)){   //電球に対するSWの個数分を加算（範囲for文で）←電球ごとに、SWの数画が違うため
                    if((i >> id) & 1){//sw_lの要素を一つずつチェック
                        sw_cnt++;//押されたSWの合計
                    }
                }
                sw_cnt %= 2;   
                if(sw_cnt!=p.at(j)) //点灯条件チェック
                    check = false;
            }
            if(check)
                ans++;
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []

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

judge = "APPROVED"
for i in range(n):
    if a[i]%2 == 0:
        if (a[i]%3 != 0 and a[i]%5 != 0):
            judge = "DENIED"

print(judge)




Measured memory_bytes: 2940
while True:
    n,m=map(int,input().split())
    if n==0:
        break
    l1=[int(input()) for _ in range(n)]
    l2=[int(input()) for z in range(m)]
    sum1=sum(l1)
    sum2=sum(l2)
    l1.sort()
    l2.sort()
    a1=0
    a2=0
    while True:
        if a1+1>n or a2+1>m:
            print("-1")
            break
        else:
            if sum1-l1[a1]+l2[a2]==sum2+l1[a1]-l2[a2]:
                print("{} {}".format(l1[a1],l2[a2]))
                break
            elif sum1-l1[a1]+l2[a2]>sum2+l1[a1]-l2[a2]:
                a1+=1
            else:
                a2+=1




Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int A,B,T;
cin >> A >> B >> T;

int t = T/A;
cout << t*B << endl;


return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
b=list(map(int,input().split()))
ans=b[0]
for i in range(n-2):
    ans+=min(b[i],b[i+1])
ans+=b[n-2]
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[101],t[101];
    int n;cin >> n;
    cin >> s;
    cin >> t;
    int k = 0;
    char ans[2*n + 1];
    for(int i = 0;i < n;i++)
    {
        ans[k++] = s[i];
        ans[k++] = t[i];
    }
    ans[k] = '\0';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	priority_queue <int> mq;
	int to=0;
	while(n--){
		int en;
		cin>>en;
		mq.push(en);
		to+=en;
	}
	int lim = to/(4*m);
	if(to%(4*m))lim++;
	while(m--){
		if(mq.top()<lim){
			cout<<"No\n";
			return 0;
		}
		mq.pop();
	}
	cout<<"Yes\n";
	
	return 0;
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim hn As Long() = Cin.LngArr()
    Dim h As Long = hn(0)
    Dim n As Long = hn(1)
    Dim a As Long() = Cin.LngArr()
    Dim ans As String = "No"
    Array.Sort(a)
    Dim aSum As Long = 0
    For i As Long = n - 1 To 0 Step -1
      aSum += a(i)
      If h <= aSum Then
        ans = "Yes"
        Exit For
      End If
    Next
    Console.WriteLine(ans)
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 24612
#include <algorithm>
#include <deque>
#include <iostream>
#include <vector>

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

int H, N;
int A[100001];

int main() {
    int sum = 0;
    cin >> H >> N;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum >= H) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define maxn	500005
#define mod		int(1e9+7)
#define db		double
#define ll		long long
#define si 		stack<int>
#define qi 		queue<int>
#define vi 		vector<int>
#define pi 		pair<int, int>
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod;
	for (; b; b >>= 1)
		res = (res * ((b & 1) ? a : 1)) % mod,
		a = a * a % mod;
	return res;
}
ll gcd(ll a, ll b) {
	return b ? gcd(a, b) : a;
}
/** GRAPH
int edgenum, head[maxn], vet[2 * maxn], nxt[2 * maxn], wt[2 * maxn];
void addedge(int u, int v) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
}
void addedge(int u, int v, int w) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
	wt[edgenum] = w;
}
GRAPH **/

using namespace std;
int main() {
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC";
	else cout << "ABC";
	return 0;
}

Measured memory_bytes: 3628
Scanf.scanf "%d %d %d" (fun a b c ->
    let ( *@) = min in
    let check a b c =
        let q = a / 2 in
        b * c * (a - 2 * q)
    in
    Printf.printf "%d\n" @@ check a b c *@ check b c a *@ check c a b 
)

Measured memory_bytes: 3764
s = input()
n = len(s)

res = 0
for i in range(n):
    for j in range(i, n):
        sub = s[i: j+1]
        
        flg = True
        for c in sub:
            if(c not in ['A', 'G', 'C', 'T']): flg = False
        
        if(flg): res = max(res, len(sub))

print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, temp;
    cin >> a >> b >> c;

    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b, c);
    if (a > b)
        swap(a, b);

    cout << a << " " << b << " " << c << endl;
}



Measured memory_bytes: 3092
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = map(int, input().split())
print(len(set(prime_factorize(a)) & set(prime_factorize(b)))+1)

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

#define M 1046527 // 適当な素数
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch)
{
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;
    else
        return 0;
}

// keyの生成
long long getKey(char str[])
{
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++)
    {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

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

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

int insert(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++)
    {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)
            // もう入っていたらエラー
            return 1;
        else if (strlen(H[h]) == 0)
        {
            // H[h] = strではだめなんだね
            // 参照渡しだからかなあ
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++)
    {
        // c++の文字列の最後にはヌル文字(\0)が入っているんだって
        // これだと文字列の最初に\0が入ってそうだけど？
        H[i][0] = '\0';
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        // 命令と値を受け取る
        scanf("%s %s", com, str);

        if (com[0] == 'i')
        {
            insert(str);
        }
        else
        {
            if (find(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16992
S = input()
ans = "WA"
if S[0] == "A":
    check = 0
    for s in S[2:-1]:
        if s == "C":
            check += 1
    if check == 1:
        count = 0
        for s in S:
            if s.islower():
                count += 1
        if len(S) - count == 2:
            ans = "AC"
print(ans)

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

int main(){
 int k; cin >>k;
 string s; cin >>s;
 int a=s.size();
 vector<char> ans(a);
  if(a<=k)cout << s << endl;
  else{
    for(int i=0;i<k;i++){
      cout << s[i];
    }
    cout << "...";
  }

}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int x;
	cin >> x;
	if (x >= 30)puts("Yes");
	else puts("No");*/


	ll n, d;
	cin >> n >> d;
	int ans = 0;
	ll x, y;
	rep(i, n) {
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= d)ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define ERR 0.00000001
typedef long long ll;

int main(void)
{
	double N;
	cin >> N;
	double ans = ceil(N/1.08);
	if(floor(ans*1.08)==N) cout << ans << endl;
	else cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> ans(n);
    for (int i=0; i<n-1; i++) cin >> a[i];
    for (int i=0; i<n-1; i++) ans[a[i]-1]++;

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

Measured memory_bytes: 4464
#include<stdio.h>
#define MAXN 200010
int main()
{
	int n;
	scanf("%d",&n);
	long long a[MAXN]={0};
	
	
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	
	long long minv=a[0];
	long long max=a[1]-a[0];
	
	for(int j=1;j<n;j++)
	{
		if(max<a[j]-minv) max=a[j]-minv;
		if(minv>a[j]) minv=a[j];
		
		
		
		
		//for(int i=0;i<j;i++)
		//{
		//	if(max<a[j]-a[i]) max=a[j]-a[i];
		//}
	}
	
	printf("%lld\n",max);
	return 0;
 } 


Measured memory_bytes: 3420
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int d = scanner.nextInt();
			if (d == 0)
				break;
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			int[] p = new int[n + 1];
			for (int i = 0; i < n - 1; i++)
				p[i] = scanner.nextInt();
			p[n] = d;
			Arrays.sort(p);
			int ans = 0;
			for (int i = 0; i < m; i++) {
				int k = scanner.nextInt();
				int pos = Arrays.binarySearch(p, k);
				if (pos < 0) {
					pos = -pos - 2;
					int c = Math.min(k - p[pos], p[pos + 1] - k);
					ans += c;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 63176
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<=s.size();j++)
			{
				if(s[j]=='F') 
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = []
for i in range(h):
	a.append(list(map(int,input().split())))
import copy
b = copy.deepcopy(a)

x = 0

for i in range(h):
	for j in range(w):
		if a[i][j]%2==1 and i!=h-1:
			a[i][j] = a[i][j]-1
			a[i+1][j] = a[i+1][j]+1
			x +=1
		elif a[i][j]%2==1 and j!=w-1:
			a[i][j] = a[i][j]-1
			a[i][j+1] = a[i][j+1]+1	
			x +=1

print(x)

for i in range(h):
	for j in range(w):
		if b[i][j]%2==1 and i!=h-1:
			b[i][j] = b[i][j]-1
			b[i+1][j] = b[i+1][j]+1
			print(i+1,j+1,i+2,j+1)

		elif b[i][j]%2==1 and j!=w-1:
			b[i][j] = b[i][j]-1
			b[i][j+1] = b[i][j+1]+1	
			print(i+1,j+1,i+1,j+2)


Measured memory_bytes: 10424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	string s;
	ci2(n,s);
	vi h[2];
	unordered_map<int ,bool> B;
	fo(i,n){
		if(s[i]=='R'){
			h[0].pb(i);
		}
		else if(s[i]=='G'){
			h[1].pb(i);
		}
		else{
			B[i]=true;
		}
	}
	int m =B.size();
	ll cnt=(h[0].size())*(h[1].size())*m;
	for(auto r: h[0]){
		for(auto g: h[1]){
			if((r+g)%2==0 && B[(r+g)/2]){
				cnt--;
			}
						int diff= r-g;
			if(B[r+diff] == true){
				cnt--;
			}
			if(B[r-diff]==true){
				cnt--;
			}
			if(B[g+diff] == true){
				cnt--;
			}
			if(B[g-diff]==true){
				cnt--;
			}
		}
	}
	co(cnt);
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll ds(ll n) {
  ll res=0;
  while(n>0) {
    res+=n%10;
    n/=10;
  }
  return res;
}

int main(void) {
  ll i, j, k;
  ll N;
  cin >> N;
  
  ll t=N;
  ll d=-1;
  while(t>0) {
    t/=10;
    d++;
  }
  
  if((N+1)%(ll)pow(10, d)==0) {
    pt(ds(N));
  }else {
    ll s=N/(ll)pow(10, d);
    pt(s-1+9*d);
  }
  
  
  
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;
  int result = 0;
  rep(i, N) {
    int h; cin >> h;
    if (h>=K) result++;
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}

////////////////////////////////////////////////////////////////////

int main(){
ll m;
cin>>m;
ll k;
cin>>k;

ll l=1;
for(int i=0;i<m;i++){
l*=2;
}
--l;

if(m==1 && k==1){
    cout<<-1<<endl;
    return 0;
}
  if(m==1 && k==0){
    cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
    return 0;}
if(l<k){
    cout<<-1<<endl;
    return 0;
}

for(int i=l;i>=0;i--){
    if(i!=k){
        cout<<i<<" ";
    }
}

cout<<k<<" ";

for(int i=0;i<=l;i++){
if(i!=k){
    cout<<i<<" ";
}
}

cout<<k<<endl;
return 0;




}



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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;
    // 処理
    double x;
    string u;
    double ans;
    rep(i, n) {
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000;
        }
    }

    // 出力
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;

int n;
int a[N], b[N];

int main()
{
    cin >> n;
    memset(b, 0x3f, sizeof b);
    for(int i = 1; i < n; i++) cin >> b[i];

    for(int i = 1; i <= n; i++) a[i] = min(b[i - 1], b[i]);

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


Measured memory_bytes: 640
import java.util.Scanner;

class Main {

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

        int n = scan.nextInt();
        int i = 1;
        int a;
        long Sum = 0;
        int Max = -1000000;
        int Min = 1000000;
        while (i <= n) {
            a = scan.nextInt();
            Sum += a;
            if (Max < a) {
                Max = a;

            }
            if (Min > a) {
                Min = a;
            }
            i++;
        }
        System.out.println(Min + " " + Max + " " + Sum);
    }
}


Measured memory_bytes: 41936
n = int(input())
dp = [[0, 0, 0] for i in range(n+1)]
for i in range(1, n+1) :
    a,b,c = map(int,input().split())
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c

print(max(dp[i]))

    

Measured memory_bytes: 59424
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 2e5;
//const double PI = 3.1415926535897932384626;
const double PI = acos(-1);

LL sx, sy, tx, ty;
int n, tot;
double res;
struct point
{
	LL x, y;
}PP[MaxN + 5];
point tmp[MaxN + 5];

bool cmpx(point a, point b) {
	if(a.x == b.x) return a.y < b.y;
	else return a.x < b.x;
}

void emit() {
	tot = 0;
	for(int i = 1; i <= n; i++) {
		if((min(sx, tx) <= PP[i].x && PP[i].x <= max(sx, tx))
				&& (min(sy, ty) <= PP[i].y && PP[i].y <= max(sy, ty)))
			tmp[++tot] = PP[i];
	}
	/*for(int i = 1; i <= tot; i++) {
	  printf("%lld %lld\n", tmp[i].x, tmp[i].y);
	}*/
}

int len;
LL a[MaxN + 5], d[MaxN + 5];

int bin_search(LL x) {
	int l = 0, r = len;
	int mid = 0, ans = 0;
	while(l <= r) {
		mid = (l + r) >> 1;
		if(d[mid] >= x) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	return ans;
}

void get_LIS(bool c)
{
	len = 0;
	d[len] = -INF;
	if(c == 1) {
		for(int i = 1; i <= tot; i++) 
			a[i] = tmp[i].y;
	}
	else {
		for(int i = 1; i <= tot; i++)
			a[i] = tmp[tot - i + 1].y;
	}
	//printf("\n");
	for(int i = 1; i <= tot; i++) {
		if(a[i] > d[len]) d[++len] = a[i];
		else {
			int pos = bin_search(a[i]);
			d[pos] = a[i];
		}
	}
}

int main()
{
	res = 0.0;
	scanf("%lld %lld %lld %lld", &sx, &sy, &tx, &ty);
	if(sx > tx) {
		swap(sx, tx); swap(sy, ty);
	}
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld %lld", &PP[i].x, &PP[i].y);
	}
	//sort(PP + 1, PP + n + 1, cmpx);
	emit();
	sort(tmp + 1, tmp + tot + 1, cmpx);
	if(sy > ty) {
		get_LIS(0);
	}
	else if(sy <= ty) {
		get_LIS(1);
	}
	int num = min(abs(tx - sx), abs(ty - sy)) + 1;
	//printf("len = %d num = %d\n", len, num);
	if(len == num) {
		res = (100.0 * (abs(tx - sx) + abs(ty - sy)) - 20.0 * (LL)len) + (LL)(len - 1) * 5 * PI + 10 * PI;
	}
	else {
		res = (100.0 * (abs(tx - sx) + abs(ty - sy)) - 20.0 * (LL)len) + (LL)len * 5 * PI;
	}
	printf("%.15lf\n", res);
	return 0;
}

Measured memory_bytes: 9472
def main():
    _ = input()
    aa = list(map(int, input().split()))
    counts = [0] * 100001
    for a in aa:
        counts[a] += 1
    res = max(counts[0] + counts[1], counts[10000-1] + counts[100000])
    for i in range(1, 100000):
        res = max(res, counts[i - 1] + counts[i] + counts[i + 1])
    print(res)


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    vector <int> p(n);
    for (int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> p[tsumugi];
    }

    int ans = 0;
    for (int matsuri = 1; matsuri < n - 1; matsuri++){
        if (p[matsuri] != max({p[matsuri - 1], p[matsuri], p[matsuri + 1]}) and 
            p[matsuri] != min({p[matsuri - 1], p[matsuri], p[matsuri + 1]})){
            ans++;
            }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  string s;
  cin >> s;
  int a,z ;
  for(int i=0;i<s.size();i++){
    if(s[i] == 'A'){
      a = i; 
      break;
    }
  }
  for(int i=s.size() -1;i >= 0;i --){
    if(s[i] == 'Z'){
      z = i ;
      break ;
    }
  }
  cout << z-a+1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<string>
#include<time.h>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;


const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main() {
    COMinit();
	int x, y;
	cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl; 
        return 0;
    }
	int s = (x + y) / 3;
    if (x < s || y < s) {
        cout << 0 << endl;
        return 0;
    }
    cout << COM(s, x - s) << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

template <typename T>
class BIT {
private:
  std::vector<T> arr;
  int n;

public:
  BIT(int n_): arr(n_ + 1, 0), n(n_) {}

  T sum(int i) {
    T ret = 0;
    while (i > 0) {
      ret += arr[i];
      i -= (i & (-i));
    }
    return ret;
  }

  T sum(int from, int to) {
    T left = sum(from - 1);
    T right = sum(to);
    return right - left;
  }
  
  void add(int i, T x) {
    while (i <= n) {
      arr[i] += x;
      i += (i & (-i));
    }
  }

};

int main() {
  int n;
  string s;
  int q;
  cin >> n >> s >> q;
  vector< BIT<ll> > bits;
  for (int i = 0; i < 26; ++i) {
    BIT<ll> bit = BIT<ll>(n);
    bits.push_back(bit);
  }
  
  for (int i = 0; i < n; ++i) {
    int pos = s[i] - 'a';
    bits[pos].add(i + 1, 1);
  }


  while (q--) {
    int com;
    cin >> com;
    if (com == 1) {
      int i;
      char c;
      cin >> i >> c;
      char cur = s[i - 1];
      int pos = cur - 'a';
      bits[pos].add(i, -1);

      int next_pos = c - 'a';
      bits[next_pos].add(i, 1);

      s[i - 1] = c;
    } else {

      int l, r;
      cin >> l >> r;
      int ans = 0;
      for (int i = 0; i < 26; ++i) {
	ans += bits[i].sum(l, r) > 0? 1: 0;
      }
      cout << ans << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 106304