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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n , m;
	cin >> n >> m;
	vector<ll> x(m),y(m);
	rep(i,m){
		cin >> x[i] >> y[i];
	}
	vector<pair<ll,bool>> boal(n); //個数 赤がありうるかそうかどうか
	rep(i,n){
		boal[i].first = 1;
		boal[i].second = false;
	}
	boal[0].second = true;

	ll ans = 0;
	rep(i,m){
		ll from = x[i]-1;
		ll to = y[i]-1;

		boal[from].first -- ;
		boal[to].first ++;
		if(boal[from].second){
			if(boal[from].first == 0){
				boal[from].second = false;
			}
			boal[to].second = true ;
		}
	}
	rep(i,n){
		if(boal[i].second){
			ans ++ ;
		}
	}
	cout << ans << endl;
}


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

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 0, 3) rep(j, 0, 3) cin >> a[i][j];

    int n;
    cin >> n;

    vector<int> b(n);
    rep(i, 0, n) cin >> b[i];

    vector<vector<bool>> table(3, vector<bool>(3, false));
    rep(i, 0, n) {
        rep(j, 0, 3) rep(k, 0, 3) {
            if (b[i] == a[j][k]) {
                table[j][k] = true;
            }
        }
    }

    bool flag = false;
    if (table[0][0] && table[0][1] && table[0][2]) {
        flag = true;
    } else if (table[1][0] && table[1][1] && table[1][2]) {
        flag = true;
    } else if (table[2][0] && table[2][1] && table[2][2]) {
        flag = true;
    } else if (table[0][0] && table[1][0] && table[2][0]) {
        flag = true;
    } else if (table[0][1] && table[1][1] && table[2][1]) {
        flag = true;
    } else if (table[0][2] && table[1][2] && table[2][2]) {
        flag = true;
    } else if (table[0][0] && table[1][1] && table[2][2]) {
        flag = true;
    } else if (table[0][2] && table[1][1] && table[2][0]) {
        flag = true;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1e9+7
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef pair<double,P> Pd;

struct edge{
  int to;
  double cost;
};

signed main(){
  while(1){
  int n,m,p,a,b;
  cin>>n>>m>>p>>a>>b;
  if(n==0)break;
  a--,b--;
  vector<int> t(n);
  for(int i=0;i<n;i++)cin>>t[i];

  vector<vector<edge> > g(m);
  for(int i=0;i<p;i++){
    int x,y;
    double z;
    cin>>x>>y>>z;
    x--,y--;
    g[x].pb({y,z});
    g[y].pb({x,z});
  }
  
  double INF=100000000;
  vector<vector<double> > d(m,vector<double>(1<<n,INF));
  d[a][0]=0;
  priority_queue<Pd> que;
  que.push(Pd(0,P(a,0)));
  while(que.size()){
   double cost=que.top().fi;
   int v=que.top().se.fi;
   int s=que.top().se.se;
   que.pop();
   if(cost>d[v][s])continue;
   for(int i=0;i<g[v].size();i++){
	for(int j=0;j<n;j++){
	  if(s>>j&1)continue;
	  int tov=g[v][i].to;
	  double tocost=g[v][i].cost/t[j];
	  int tos=s+(1<<j);
	  if(cost+tocost<d[tov][tos]){
	    d[tov][tos]=cost+tocost;
	    que.push(Pd(cost+tocost,P(tov,tos)));
	  }
	}
   }
  }
  double ans=INF;
  for(int i=0;i<1<<n;i++){
	ans=min(ans,d[b][i]);
  }
  if(ans==INF)cout<<"Impossible"<<endl;
  else printf("%.10lf\n",ans);
}
  return 0;
}



Measured memory_bytes: 3408
n, k = map(int, input().split())
array = {int(x) for x in input().split()}
mihon = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}^array

for i in range(n, 100001):
    tmp = list(str(i))
    tmp = {int(x) for x in tmp}
    if tmp.issubset(mihon) and i >= n:
        print(i)
        break


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    string n; cin >> n;
    cout << "ABC"+n << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

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

int n,m;

int main(){
  cin >> n >> m;
  vector<P> v;
  int l = 1;
  int r = (n+1)/2;
  while(r>l){
    v.push_back(P(l,r));
    l++;r--;
  }
  l = (n+1)/2;
  l++;
  r=n;
  if(n%2==0)r--;
  while(r>l){
    v.push_back(P(l,r));
    l++;r--;
  }
  rep(i,0,m){
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    ll N = 10000000;
    vector <ll> lp(N+1);
    vector <ll> pr;
    for (ll i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
    for (ll j=0; j<(ll)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
        lp[i * pr[j]] = pr[j];
    }
    while(t--){
        ll n;
        cin>>n;
        ll ans=1ll;
        vector <ll> arr(N+1);
        vector <ll> val(N+1);
        val[1]=1;
        arr[1]=1;
        lp[1]=1;
        for(ll i=2;i<=n;i++){
            if(lp[i]==lp[i/lp[i]]){
                arr[i]=arr[i/lp[i]]+1;
                val[i]=val[i/lp[i]];
                ans+=val[i]*arr[i]*i;
            }
            else{
                arr[i]=2;
                val[i]=arr[i/lp[i]]*val[i/lp[i]];
                ans+=val[i]*2*i;
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 243056
#include<cstdio>
#include<cstring>
using namespace std;
const int N=200005;
char s[N];
int last[26],n,f[N],ans[N],nxt[N];
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    memset(f,0x3f,sizeof f);
    for (int i=0;i<26;++i) last[i]=n+1;
    f[n+2]=0;
    for (int i=n;i;--i){
        last[s[i]-'a']=i;
        for (int j=0;j<26;++j)
            if (f[last[j]+1]+1<f[i]){
                f[i]=f[last[j]+1]+1;
                ans[i]=j;
                nxt[i]=last[j]+1;
            }
    }
    int i=1;
    while (i<=n){
        printf("%c",ans[i]+'a');
        i=nxt[i];
    }
    return 0;
}

Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(in.readLine());
            int[] A = Arrays.stream(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

            int cnt = 0;

            for (int i = 0; i < N; i++) {
                int minj = i;
                for (int j = i; j < N; j++) {
                    if (A[j] < A[minj]) {
                        minj = j;
                    }
                }

                if (i != minj) {
                    cnt++;
                    int tmp = A[i];
                    A[i] = A[minj];
                    A[minj] = tmp;
                }
            }

            System.out.println(Arrays.stream(A).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
            System.out.println(cnt);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;
#define PI 3.141592653589793
void solve() {
	int n;
	cin >> n;

	string s;
	cin >> s;

	for(int i = 0; i < min(n, (int)s.length()); ++i) cout << s[i];
	if(n < s.length()) cout << "...";
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 3652
import Data.Bool
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as IM
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:k:as)=fst.foldl' f(0,foldr g IM.empty cs)$zip[0..]$zip(ds++repeat k)bs where
  bs=scanl'(\s a->(s+a+k-1)`mod`k)0$as
  (cs,ds)=splitAt k bs
  f(j,m)(i,(c,b))=(j+IM.findWithDefault 0 b n,g c n)where n=IM.update h b m
g b m=IM.insertWith(+)b 1 m
h i=bool Nothing(Just$i-1)$i>1

Measured memory_bytes: 356868
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans=0;
  string s;cin>>s;
  N=s.size();
  j=N-1;
  i=0;
  while(i<j){
    if(s[i]!=s[j])ans++;
    i++;j--;
  }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
int n;
ll ans;
set<ll>o;
ll a[200005];
int main(void){
    scanf("%d",&n);
    o.insert(0);
    o.insert(n+1);
    for(int i=0;i<n;i++){
        ll x;
        scanf("%lld",&x);
        a[x]=i+1;
    }
    for(ll i=1;i<=n;i++){
        auto itr=o.upper_bound(a[i]);
        ll r=*itr;
        itr--;
        ll l=*itr;
        ans+=i*(a[i]-l)*(r-a[i]);
        o.insert(a[i]);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 11136
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	return b != 0 ? gcd(b, a % b) : a;
}

int main() {
	int n; cin >> n;
	LL ans = 0;
	for (int i = 1; i < n+1; i++) {
		for (int j = 1; j < n+1; j++) {
			for (int k = 1; k < n+1; k++) {
				LL v; v = gcd(i, j);
				ans += gcd(v, k);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s,t,ans="No";
  cin >> s >> t;
  for(long i=0;i<150;i++) {
    if(s==t) ans="Yes";
    char a=s.back();
    auto b=s.end();
    b--;
    s.erase(b);
    s=a+s;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<limits.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define LARGE 100001

int a[LARGE];
int lazy[LARGE];
int b,n;

void update(int x){

	for(int i=x*b;i<=MIN(n-1,(x+1)*b-1);i++){
		a[i]=lazy[x];
	}
	lazy[x]=-1;
	
	return;
}

int main(){

	int q,i,j,com;
	int x,y,z;
	
	scanf("%d %d",&n,&q);
	
	b=sqrt(n);
	
	for(i=0;i<n;i++){
		a[i]=INT_MAX;
		lazy[i]=-1;
	}
	
	for(j=0;j<q;j++){
	
		scanf("%d",&com);
		
		if(com==1){/*find*/
			scanf("%d",&x);
			if(lazy[x/b]!=-1)update(x/b);
			printf("%d\n",a[x]);
		}
		
		else {/*update*/
			scanf("%d %d %d",&x,&y,&z);
			if(lazy[x/b]!=-1)update(x/b);
			for(i=x;i<=MIN(y,(x/b+1)*b-1);i++)a[i]=z;
			
			for(i=x/b+1;i<y/b;i++)lazy[i]=z;
			
			if(lazy[y/b]!=-1)update(y/b);
			for(i=MAX(x,y/b*b);i<=y;i++)a[i]=z;
		}
		
	}
	
	return 0;
	
}


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

int main() {
  int N,M;
  cin>>N>>M;
  dsu d(N);
  int u,v;
  for(int i=0;i<M;i++){
    cin>>u>>v;
    u--;
    v--;
    d.merge(u,v);
  }
  map<int,int>mp;
  for(int i=0;i<N;i++){
    mp[d.leader(i)]++;
  }
  cout<<mp.size()-1<<endl;
  return 0; 
}




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

int main() {
  int64_t w, h, x, y;
  cin >> w >> h >> x >> y;
  
  cout << 1.0 * h * w / 2 << ' ' << ((w % 2 == 0 && w / 2 == x) && (h % 2 == 0 && h / 2 == y)) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++) for(int j=0;j<3;j++) cin>>arr[i][j];
    long long int dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    long long int ans;
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+arr[i][j];
        }
    }
    ans=dp[n-1][0];
    ans=max(max(ans,dp[n-1][1]),dp[n-1][2]);
    cout<<ans<<"\n";
}


Measured memory_bytes: 3840
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    std::string s;
    std::cin >> s;

    if (s[0] != 'A') {
        std::cout << "WA" << std::endl;
        return 0;
    }

    std::string lower = "abcdefghijklmnopqrstuvwxyz";

    if (lower.find(s[1]) == std::string::npos) {
        std::cout << "WA" << std::endl;
        return 0;
    }

    int count = 0;
    for (int i = 2; i < s.length(); i++) {
        if (lower.find(s[i]) == std::string::npos) {
            count++;
        }
    }

    if (lower.find(s.back()) == std::string::npos) {
        std::cout << "WA" << std::endl;
        return 0;
    }

    if (count == 1) {
        std::cout << "AC" << std::endl;
        return 0;
    }

    std::cout << "WA" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2005;
int n,x,y;
int cnt[N];
int main() {
	int i,j;
	cin>>n>>x>>y;
	for (i=1;i<n;i++)
		for (j=i+1;j<=n;j++) {
			if (i<x&&j<x) cnt[j-i]++;
			else if (i>y&&j>y) cnt[j-i]++;
			else if (i<x&&j>y) cnt[j-y+x-i+1]++;
			else if (i<x&&j>=x) cnt[min(j-i,y-j+1+x-i)]++;
			else if (i<=y&&j>y) cnt[min(j-i,i-x+1+j-y)]++;
			else cnt[min(j-i,i-x+y-j+1)]++;
//			cout<<i<<' '<<j<<' '<<cnt[1]<<endl; 
		}
	for (i=1;i<=n-1;i++) cout<<cnt[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

a = ['','KIH','B','R']

for i in range(2**4):
    b = format(i,'b').zfill(4)
    ans = ''
    for i in range(4):
        ans += a[i]
        if b[i]=='1':
            ans += 'A'
    if s==ans:
        print('YES')
        exit()

print('NO')

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	StringBuffer max;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		
		String[] b = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
		String[] s = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
		
		max = new StringBuffer();
		
		String min = scan.nextLine();
		for (int i = 0; i < min.length(); i++) {
			String str = min.substring(i, i+1);
			if (str.equals(".") || str.equals(" ")) {
				max.append(str);
			}else {
				for (int j = 0; j < s.length; j++) {
					if (str.equals(s[j])) {
						max.append(b[j]);
						continue;
					}
				}
			}
		}
		System.out.println(max);
	}
	
	private void debug() {
		System.out.println();
	}

}

Measured memory_bytes: 17316
r = []
r += ['y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm']

while 1:
    s = input()
    if s == '#':
        break
    
    ans = 0
    for i in range(len(s)-1):
        if r.count(s[i]) != r.count(s[i+1]):
            ans += 1

    print(ans)




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

using namespace std;
using ll = long long;

const int N = 1e6 + 5;
const int INF = 1e9 + 7;

mt19937 rnd(51515);

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

main() {
#ifdef ONPC
  freopen("a.in", "r", stdin);
#endif
  ios :: sync_with_stdio(0);
  cin.tie(0);
  int h, n;
  cin >> h >> n;
  for (int i = 1; i <= 1e6; ++i) dp[i] = INF;
  for (int i = 1; i <= n; ++i)
  {
    cin >> a[i] >> b[i];
  }
  int mn = INF;
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 0; j <= h; ++j)
    {
      dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
    }
  }
  for (int i = h; i <= 1e6; ++i)
  {
    mn = min(mn, dp[i]);
  }
  cout << mn;
  return 0;
}

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

  int n;
  double result = 0;
  int max;
  
  cin >> n;
  int a[n];
  
  rep(i,n){
    cin >> a[i];
  }
  max = a[0];
  rep(i,n){
    if(max%a[i]!=0){
      max*=a[i];
    }else if(max<a[i]){
      max=a[i];
    }
  }
  rep(i,n){
    result+=max/a[i];
  }
  
  cout << (max/result) << endl;
     
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(100,0);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  int d = 0;
  int j = 0;
  for(int i=0; i<n; i++){
    if(p[i] != i+1){
      d++;
      if(d > 2){
        cout << "NO" << endl;
        break;
      }
      else if(p[p[i]-1] != i+1){
        cout << "NO" << endl;
        break;
      }
    }
    j++;
  }
  if(j == n && d < 3){
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
s = sum([input().split() for _ in range(N)],[])
M = int(input())
t = sum([input().split() for _ in range(M)],[])
getmax = 0

for i in range(N):
    tmp = s.count(s[i])-t.count(s[i])
    if tmp > getmax:
        getmax = tmp

print(max(getmax,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  s.replace(0, 4, "2018");
  cout << s << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s, t, u;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  cin >> u;
  if(u == s){
    cout << a-1 << " ";
  }else{
  	cout << a << " ";
  }
  if(u == t){
    cout << b-1;
  }else{
  	cout << b;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define LINF 1LL<<60

struct SegTree {
	int N;
	ll init_v = 0;
	vector<ll> node, lazy;

	SegTree(int _N) {
		N = 1;
		while (N < _N) N *= 2;
		node.resize(2 * N - 1, init_v);
		lazy.resize(2 * N - 1, init_v);
	}

	void lazy_evaluate(int k) {
		node[k] += lazy[k];
		if (k < N - 1) {
			lazy[2 * k + 1] += lazy[k] / 2;
			lazy[2 * k + 2] += lazy[k] / 2;
		}
		lazy[k] = 0;
	}

	/* [a,b) ?????°??????????????¨???!! s~t?????§?????´??°???update(s,t+1,~) */
	ll update(int a, int b, int x) { return update(a, b, 0, 0, N, x); }
	ll update(int a, int b, int k, int l, int r, int x) {
		if (r <= a || b <= l) {
			lazy_evaluate(k);
			return node[k];
		}
		if (a <= l && r <= b) {
			lazy[k] += (r - l) * x;
			lazy_evaluate(k);
			return node[k];
		}
		else {
			lazy_evaluate(k);
			ll vl = update(a, b, 2 * k + 1, l, (l + r) / 2, x);
			ll vr = update(a, b, 2 * k + 2, (l + r) / 2, r, x);
			return node[k] = vl + vr;
		}
	}

	/* [a,b) ?????°??????????????¨???!! */
	ll query(int a, int b) { return query(a, b, 0, 0, N); }
	ll query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_v;
		if (a <= l && r <= b) {
			lazy_evaluate(k);
			return node[k];
		}
		else {
			lazy_evaluate(k);
			ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
			ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return vl + vr;
		}
	}
};

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegTree ST(n);
	for (int i = 0; i < q; i++) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			s--; t--;
			ST.update(s, t + 1, x);
		}
		else {
			int s, t; cin >> s >> t;
			s--; t--;
			cout << ST.query(s, t + 1) << endl;
		}


		/*cout << "-----------------------------------" << endl;
		for (auto X : ST.node) {
		  if (X == INF) { cout << "INF "; }
		  else cout << setw(3) << X << " ";
		}
		cout << endl;
		for (auto Y : ST.lazy) {
		  cout << setw(3) << Y << " ";
		}
		cout << endl;
		cout << "==================================" << endl;*/
	}
}

Measured memory_bytes: 7072
n=int(input())
list=[input() for i in range(n)]
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(0,n):
    if list[i] == 'AC':
        AC = AC + 1
    if list[i] == 'WA':
        WA = WA + 1
    if list[i] == 'TLE':
        TLE = TLE + 1
    if list[i] == 'RE':
        RE = RE + 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 16156
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

void solve()
{
	int n; cin>>n;
	int arr[n];
	rep(i,0,n)
	{
		char x; cin>>x;
		if(x=='W') arr[i]=1;
		else arr[i]=0;
	}
	int red=0,white=0;
	
	rep(i,0,n)
	{
		if(arr[i]==0) red++;
		else white++;
	}
	
	int ans=min(red,white);
	
	int cnt=0;
	rep(i,0,red)
	{
		if(arr[i]) cnt++;
	}
	ans=min(ans,cnt);
	
	cout<<ans<<endl;
}

signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    int k,t;cin>>k>>t;
    vector<int> a(t);
    rep(i,t)cin>>a[i];
    sort(a.begin(),a.end());
    bool flag=false;
    if(a[t-1]<=k/2)flag=true;
    int res=0;
    if(flag)res=0;
    else{
        res=2*a[t-1]-k-1;
        res=max(res,(int)0);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
long double ans=0;
void calc(long long n,long double sum)
{
	ans+=sum/(2*n);
	if(n==1)
		return;
	calc(n-1,sum-sum/(n*n));
}

int main()
{
	long long n,d,x;
	cin>>n>>d>>x;
	long double sum=(d+d+(2*n-1)*x)*n;
	calc(n,sum);
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;
}

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

int main(void){
    int n,ans[101];
    int max = 0,c,m = 0;
    cin >> n;
    for(int i = 1;i <= n;i++){
        ans[i] = 0;
        c = i;
        for(;;){
            if(c % 2 != 0)break;
            c /= 2;
            ans[i] +=1;
        }
        if(ans[i] >= m){
             max = i;
             m = ans[i];
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
    IOS;
    int N, D;
    cin >> N >> D;
    vector<vector<int>> nd_vec(N, vector<int>(D));
    int cnt = 0;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < D; j++){
            int t;
            cin >> t;
            nd_vec.at(i).at(j) = t;
        }
    }
    for (int i = 0; i < N; i++){
        for (int ii = 0; ii < N; ii++){
            if(i == ii){
                continue;
            }
            int sum = 0;
            for (int j = 0; j < nd_vec.at(i).size(); j++){
                sum += pow((nd_vec.at(i).at(j) - nd_vec.at(ii).at(j)),2);
            }
            double d = sqrt(sum);
            int in = sqrt(sum);
            if(d == in){
                cnt++;
            }
        }
    }
    cout << cnt / 2<< endl;
}

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

int main() {
    int n,m;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    vector<int> com(n);
    com.at(0)=1;
    for(int i=1;i<n;i++){
        if(s.at(i)==s.at(i-1)){
            com.at(i)=com.at(i-1)+1;
        }
        else{
            com.at(i)=1;
        }
    }
    cin >> m;
    vector<string> t(m);
    for(int i=0;i<m;i++){
        cin >> t.at(i);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s.at(i)==t.at(j)){
                com.at(i)--;
            }
        }
    }
    sort(com.begin(),com.end());
    cout << max(0,com.at(n-1)) << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n=int(input())
    a=sorted(list(map(int,input().split())))
    mnum=0
    for i,x in enumerate(a):
        if x>=0:
            mnum=i
            break
    m,p=-a[i-1],a[i]
    if i%2==0:
        print(-sum(a[:i])+sum(a[i:]))
    else:
        print(-sum(a[:i])+sum(a[i:])-2*min(m,p))

if __name__ == '__main__':
    main()

Measured memory_bytes: 15180
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <cstring>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
double dp[301][301][301];
int N;

double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0;

    double ret = 0;
    if (i > 0) ret += i * rec(i-1, j, k);
    if (j > 0) ret += j * rec(i+1, j-1, k);
    if (k > 0) ret += k * rec(i, j+1, k-1);
    ret += N;
    ret /= i + j + k;

    return dp[i][j][k] = ret;
}

signed main() {
    cin >> N;
    int one = 0;
    int two = 0;
    int three = 0;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a == 1) one++;
        if (a == 2) two++;
        if (a == 3) three++;
    }

    memset(dp, -1, sizeof(dp));

    cout << fixed << setprecision(10) << rec(one, two, three) << endl;

    return 0;
}

Measured memory_bytes: 213376
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    var ans = 0
    for (i in 0 until N) {
        val l = sc.nextInt()
        val r = sc.nextInt()
        ans += r - l + 1
    }
    println(ans)
}




Measured memory_bytes: 32564
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(ll i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for( j = p; j < r; ++j){
       if(A[j] <= x ) {
          ++i;
          t = A[i]; A[i] = A[j]; A[j] = t;
       }
    }
    t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
    return i + 1;
}

int main(void){
    int i, q;

    cin >> n;
    rep(i,n) cin >> A[i];

    q = partition(0, n - 1);

    rep(i,n){
        if( i ) cout << " ";
        if( i == q ) cout << "[";
        cout << A[i];
        if ( i == q ) cout << "]";
    }
    cout << endl;

    
}


Measured memory_bytes: 3512
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		while (true) {
			int w = sc.nextInt();
			int d = sc.nextInt();
			if (w == 0 && d == 0)
				break;
			int[] hw = new int[21];
			int[] hd = new int[21];
			for (int i = 0; i < w; i++)
				hw[sc.nextInt()]++;
			for (int i = 0; i < d; i++)
				hd[sc.nextInt()]++;
			int result = 0;
			for (int i = 1; i < 21; i++)
				result += i * Math.max(hw[i], hd[i]);
			System.out.println(result);
		}
		sc.close();
	}
}

Measured memory_bytes: 23276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	double r;cin>>r;
	cout<<fixed<<setprecision(10)<<2.0*pi*r<<endl;
}

Measured memory_bytes: 3788
//ΔARC093E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 2222;
const int mod = 1e9+7;
int f[N];
int fnd(int x){
	if(f[x]==x)
		return x;
	return f[x]=fnd(f[x]);
}
int n,m,a[N],b[N],c[N];
pair<int,int> p[N];
LL k,t;
LL MST(int r){
	int i,j;
	LL w=0;
	for(i=1;i<=n;i=i+1)
		f[i]=i;
	w+=c[r];
	f[fnd(a[r])]=fnd(b[r]);
	for(j=1;j<=m;j=j+1){
		i=p[j].second;
		if(i==r)
			continue;
		if(fnd(a[i])!=fnd(b[i])){
			w+=c[i];
			f[fnd(a[i])]=fnd(b[i]);
		}
	}
	return w;
}
int main()
{
	int i,s0=0,s1=0,s2=0,ans=1;
	cin>>n>>m>>k;
	if(n<3){
		cout<<0;
		return 0;
	}
	for(i=1;i<=m;i=i+1){
		cin>>a[i]>>b[i]>>c[i];
		p[i]=make_pair(c[i],i);
	}
	sort(p+1,p+m+1);
	for(i=1;i<=m;i=i+1){
		t=MST(i);
		if(t<k)
			s0++;
		if(t==k)
			s1++;
		if(t>k)
			s2++;
	}
	if(!s1){
		cout<<0;
		return 0;
	}
	if(s0)
		s1++;
	while(s1--){
		ans=ans*2%mod;
	}
	ans-=2;
	if(ans<0)
		ans+=mod;
	while(s2--){
		ans=ans*2%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

void Binary_Search(int *A, int n, int key);

int main() {
	
	int *A;
	int n;
	cin >> n;
	
	A = new int [n];
	
	for(int i=0;i<n;i++)
		cin >> A[i];
	
	int n2;
	cin >> n2;
	
	int key;
	
	for(int i=0;i<n2;i++) {
		cin >> key;
		Binary_Search(A, n, key);
	}
	
	return 0;
}

void Binary_Search(int *A, int n, int key) {
	int low = 0;
	int up = n - 1;
	while(low <= up) {
		int mid = low + (up - low) / 2;
		if( A[mid] == key) {
			cout << "1\n";
			return ;
	}
		else if ( A[mid] > key )
			up = mid - 1;
			
		else
			low = mid + 1;
	}
		cout << "0\n";
}


Measured memory_bytes: 3416
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, c[N];
int x[N], y[N], deg[N], g[N];
int cnt, head[N];
struct edge {int to, nxt, id;} e[N << 1];
void ins(int u, int v, int id) {
	e[++cnt] = (edge) {v, head[u], id};
	head[u] = cnt;
} 
void dfs(int u, int fa, int col) {
	int now = 0;
	for(int i = head[u]; i; i = e[i].nxt) {
		int v = e[i].to;
		if(v == fa) continue;
		++now;
		if(now == col) ++now;
		g[e[i].id] = now;
		dfs(v, u, now);
	}
}

int main() {
	cin >> n;
	for(int i = 1; i < n; ++i) {
		cin >> x[i] >> y[i];
		deg[x[i]]++; deg[y[i]]++;
		ins(x[i], y[i], i), ins(y[i], x[i], i);
	}
	int ans = 0;
	for(int i = 1; i <= n; ++i) 
		if(deg[i] > deg[ans]) ans = i;
	cout << deg[ans] << endl;
	dfs(ans, ans, 0);
	for(int i = 1; i < n; ++i) printf("%d\n", g[i]);
} 

Measured memory_bytes: 10708
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " : ";
    err(++it, args...);
}

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for(ll i = 0; i < n; i++)
        for(ll d = 1; d < n; d++)
        {
            ll x = i,  y = i + d, z = i + 2 * d;
            if(z < n and s[x] != s[y] and s[x] != s[z] and s[y] != s[z])
                ans++;

        }
    map<char, ll>lol;
    for(auto i : s) lol[i]++;
    ans = lol['R'] * lol['G'] * lol['B'] - ans;

    cout << ans;



}


int main()
{

  
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;


    while(t--)
    {
        solve();
        cout << endl;
    }


}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=(a);i<(int)(n);i++)
using namespace std;
typedef long long ll;
struct start { start() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
}; }start;
void in() {}
template <class Head , class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(move(tail)...);
}
template <class T>
  void out(T& t) {
  cout << t << '\n';
}
template <class Head , class... Tail>
void out(Head& head , Tail&... tail) {
  cout << head << ' ';
  out(move(tail)...);
}
int main(void) {
  int a,b,ans;
  in(a,b);
  ans = (a-1) * (b-1);
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int a,b;
  cin>>a>>b;
  if(a>=13){
    cout<<b;
  }
  else if (6<=a&&a<=12){
    cout<<b/2;
  }
  else{
    cout<<'0';
  }
}

Measured memory_bytes: 256
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]

X.sort()
diff = []
for i in range(1,len(X)):
    diff.append((X[i] - X[i-1]))

diff.sort()
diff = diff[:M-N]
if(N<M):
    print(sum(diff))
else:
    print("0")


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int n;
    string s;
    cin >> n >> s;
    int dx = 0, dy = 0;
    for(int i = 0; i < n; ++i){
        int c = s[i];
        if('A' <= c && c <= 'M')
            ++dy;
        if('N' <= c && c <= 'Z')
            --dy;
        if('a' <= c && c <= 'm')
            ++dx;
        if('n' <= c && c <= 'z')
            --dx;
    }
    cout << abs(dx) + abs(dy) << endl;
    for(int i = 0; i < abs(dy); ++i)
        cout << (dy < 0 ? 'N' : 'A');
    for(int i = 0; i < abs(dx); ++i)
        cout << (dx < 0 ? 'n' : 'a');
    if(abs(dx) + abs(dy))
        cout << endl;
}



Measured memory_bytes: 3340
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    import math

    n, k = map(int, input().split())

    ans = 0

    for i in range(1,n+1):
        ans += 1/(2**max(0,math.ceil(math.log2(k/i))))

    print(ans/n)


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

bitset<60> a[111111];
int main() {
	int n;
	cin >> n;
	long y = 0;
	for (int i = 0; i < n; i++) {
		long x;
		scanf("%ld", &x);
		y ^= x;
		a[i] = x;
	}
	for (int i = 0; i < n; i++)
		a[i] &= ~y;
	int r = [](bitset<60> *m, int R, int C) {
		int i = 0;
		for (int j = C; j--;) {
			int k;
			for (k = i; k < R; k++)
				if (m[k][j]) goto p;
			continue;
		p:
			swap(m[k], m[i]);
			for (k = 0; k < R; k++)
				if (k != i && m[k][j])
					m[k] ^= m[i];
			i++;
		}
		return i;
	}(a, n, 60);
	long x = 0;
	for (int i = 0; i < r; i++)
		if (x < (x^a[i].to_ulong()))
			x ^= a[i].to_ulong();
	cout << x + x + y << endl;
	return 0;
}


Measured memory_bytes: 1152
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, P = getNM()
A = getList()
for i in range(N):
    if A[i] % 2 == 0:
        A[i] = 0
    else:
        A[i] = 1

dp = [[0] * 2 for i in range(N)]
if A[0] == 0:
    dp[0][0] = 2
else:
    dp[0][0] = 1
    dp[0][1] = 1

for i in range(1, N):
    if A[i] == 0:
        # 選ぶ場合、選ばない場合
        dp[i][0] += 2 * dp[i - 1][0]
        dp[i][1] += 2 * dp[i - 1][1]
    else:
        dp[i][0] += (dp[i - 1][0] + dp[i - 1][1])
        dp[i][1] += (dp[i - 1][0] + dp[i - 1][1])

print(dp[N - 1][P])

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

int main(){
  int n;
  string a = "Three";
  cin >> n;
  for (int i = 0;i < n;i++){
    string b;
    cin >> b;
    if (b == "Y"){
      a = "Four";
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,p;
  cin >> n >> p;
  int a[n];
  rep(i,n) cin >> a[i];
  ll dp[5555];
  mem(dp);
  dp[0]=1;
  rep(i,n) {
    rrep(j,5555) {
      if(j+a[i]<5555) dp[j+a[i]]+=dp[j];
    }
  }
  ll ans=0;
  rep(i,5555) if(i%2==p) ans+=dp[i];
  pr(ans);
}

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


Measured memory_bytes: 256