akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
bool operator<(const edge& rhs) const {
return len > rhs.len;
}
};

ll const MAX = 300005;
vll G[MAX];
ll color[MAX] = {};
ll dis[MAX] = {};

void dfs(ll v, ll d, ll c) {
	if (dis[v] >= d) {
		return;
	}
	dis[v] = d;
	if (color[v] == 0) {
		color[v] = c;
	}
	REP(i, 0, SIZE(G[v]) - 1) {
		ll next = G[v][i];
		dfs(next, d - 1, c);
	}
}

ll v[MAX];
ll d[MAX];
ll c[MAX];

int main() {
	ll n, m;
	cin >> n >> m;
	REP(i, 0, MAX - 1) {
		dis[i] = -1;
	}
	REP(i, 1, m) {
		ll a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ll q;
	cin >> q;
	REP(i, 1, q) {
		cin >> v[i] >> d[i] >> c[i];
	}
	PER(i, q, 1) {
		dfs(v[i], d[i], c[i]);
	}
	REP(i, 1, n) {
		cout << color[i] << endl;
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int a,b;cin>>a>>b;
  int result=0;
  rep(i,b-a){
    result+=(i+1);
  }
  result-=b;
  cout<<result;

  return 0;
}

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

using namespace std;

struct Point {
	double x,y;
	Point operator-(const Point &a) { return {x-a.x,y-a.y}; }
	double norm() { return x*x+y*y; }
	double abs() { return sqrt(norm()); }
};

double f(double a,double b,double c) {
	double s=(a+b+c)/2;
	double S=sqrt(s*(s-a)*(s-b)*(s-c));
	return S/s;
}

int main() {
	Point p[3];
	for(int i=0;i<3;++i) cin >> p[i].x >> p[i].y;
	double a=(p[1]-p[0]).abs(),b=(p[2]-p[1]).abs(),c=(p[0]-p[2]).abs();
	double maxi=max({a,b,c});
	printf("%.12f\n",maxi/(maxi/f(a,b,c)+2));
	
	return 0;
}


Measured memory_bytes: 764
n,k=map(int, input().split())
*a,=map(int, input().split())

ans=1
mod=10**9+7

a.sort()
if a[0]>=0:
    for i in range(n-1,n-k-1,-1):
        ans*=a[i]
        ans%=mod
    print(ans)
    exit()
if a[-1]<=0:
    if k%2:
        for i in range(n-1,n-k-1,-1):
            ans*=a[i]
            ans%=mod
    else:
        for i in range(k):
            ans*=a[i]
            ans%=mod
    print(ans)
    exit()
l=0;r=n-1
if k%2:
    ans=a[-1]
    r-=1
    k-=1
while k:
    if a[l]*a[l+1]>a[r]*a[r-1]:
        ans*=a[l]*a[l+1]
        l+=2
    else:
        ans*=a[r]*a[r-1]
        r-=2
    k-=2
    ans%=mod
   
print(ans)
    
    



Measured memory_bytes: 105324
#include <iostream>
using namespace std;
int main() 
{
  int x[3];
  int seven = 0;
  int five = 0;
  cin >> x[0] >> x[1] >> x[2];
  for (int i; i < 3; i++){
    if (x[i] == 5){
      five++;
    }
    else if (x[i] == 7){
      seven++;
    }
  }
  if((five == 2) && (seven == 1)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res=0;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

vector<char> v;
map<vector<char> ,int> d1;
map<vector<char> ,int> d2;
int N;
vector<char> sorted;

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    v.push_back(a);
  }
  sorted=v;
  sort(v.begin(),v.end());
  queue<vector<char> > q1,q2;
  d1[v]=0;
  d2[sorted]=0;
  q1.push(v);
  q2.push(sorted);
  int ans=1<<30;
  while(q1.size()||q2.size()){
    {
      vector<char> now=q1.front();q1.pop();
      int ccost=d1[now];
      if(now==sorted){
	cout<<ccost<<endl;
	return 0;
      }
      for(int i=0;i<N;i++){
	for(int j=i+1;j<N;j++){
	  vector<char> nv=now;
	  reverse(nv.begin()+i,nv.begin()+j+1);
	  if(d2.count(nv)!=0&&d1.count(nv)==0)
	    ans=min(ans,ccost+1+d2[nv]);
	  else if(d1.count(nv)==0){
	    d1[nv]=ccost+1;
	    q1.push(nv);
	  }
	}
      }
    }
    {
      vector<char> now=q2.front();q2.pop();
      int ccost=d2[now];
      if(v==now){
	cout<<ccost<<endl;
	return 0;
      }
      for(int i=0;i<N;i++){
	for(int j=i+1;j<N;j++){
	  vector<char> nv=now;
	  reverse(nv.begin()+i,nv.begin()+j+1);
	  if(d1.count(nv)!=0&&d2.count(nv)==0)
	    ans=min(ans,ccost+1+d1[nv]);
	  else if(d2.count(nv)==0){
	    d2[nv]=ccost+1;
	    q2.push(nv);
	  }
	}
      }
    }
    if(q1.size()&&q2.size()){
      int sum=d1[q1.front()]+d2[q2.front()]+1;
      if(sum>=ans)break;
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 83764
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;

int main(){
  int H, N;
  int damage[1010], mp[1010];
  int dp[20010];

  cin >> H >> N;
  for(int i=0; i<N; i++){
    cin >> damage[i] >> mp[i];
  }
  
  int max = 0;
  for(int i=0; i<N; i++){
    if(max < damage[i]){
      max = damage[i];
    }
  }

  for(int i=0; i<=H+max; i++){
    dp[i] = -1;
  }
  dp[0] = 0;

  for(int i=0; i <= H+max; i++){
    ll min = INF;
    for(int j=0; j<N; j++){
      if(i-damage[j] >= 0 && dp[i-damage[j]] != -1){
        if(min >= dp[i-damage[j]]+mp[j]){
          min = dp[i-damage[j]]+mp[j];
          dp[i] = dp[i-damage[j]]+mp[j];
        }
      }
    }
  }

  int answer = INF;
  for(int i=H; i <= H+max; i++){
    if(answer >= dp[i] && dp[i] != -1){
      answer = dp[i];
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
//マージシート
using System;
using System.Linq;

namespace tst
{
    
    class Program
    {
        public static void Main()
        {
            //intの羅列読み込み
            string[] text=Console.ReadLine().Split(' ');
            int[] S = text.Select(s => int.Parse(s)).ToArray();
            //計算
            int sum = S[0] + S[1] + S[2];
            //結果表示
            if (sum >= 22)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }

    }
}

Measured memory_bytes: 13268
from bisect import bisect, bisect_left

N = int(input())
A = list(map(int, input().split()))
I = [0]*N
J = [0]*N
i = 0
while i < N:
  I[i] = A[i]+i
  J[i] = i-A[i]
  i += 1
I.sort()
ans = 0
for j in J:
  ans += bisect(I, j)-bisect_left(I, j)
print(ans)


Measured memory_bytes: 92984
N = int(input())
P = [int(p) for p in input().split()]
Q = [int(q) for q in input().split()]

import itertools

L = []
for temp in itertools.permutations(P):
    L.append(temp)
    
L.sort()
for i in range(len(L)):
    if list(L[i]) == P:
        a = i
    if list(L[i]) == Q:
        b = i
        
print(abs(a-b))

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

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

using namespace std;

int c[101];

int main(){
	ios::sync_with_stdio(false);
	int n;
	while (cin>>n){
		c[n]++;
	}
	int ma=0;
	REP(i,101){
		ma=max(ma,c[i]);
	}
	REP(i,101){
		if (c[i]==ma){
			cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
char*p,x[1<<17],b[1001],*q;A(){for(;p>x&&p[-1]-10;)p--;}E(){for(;*p>10;)p++;}F(){if(*p)p++;}B(){if(p>x)p--;}main(c){for(p=x;p<x+13||strcmp(p-13,"\nEND_OF_TEXT\n");p++)*p=getchar();p[-13]=0;for(p=x;~scanf("%s",&c);)c-'a'?c-'e'?c-'p'?c-'n'?c-'f'?c-'b'?c-'d'?c-'k'?c-'y'?puts(x):(memmove(p+strlen(b),p,strlen(p)+1),memcpy(p,b,strlen(b)),p+=strlen(b)):(q=p,*p-10?E():p++,b[p-q]=!memcpy(b,q,p-q),p=memmove(q,p,strlen(p)+1)):*p&&memmove(p,p+1,strlen(p)):B():F():A(F(E())):A(B(A())):E():A();}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main()
{ string s;
int counter,i;
cin >> s;
counter = 0;
for(i=0;i<s.length()-1;i++)
{
	if(s[i] == s[i+1])
	{
		if(s[i] == '0')
		{
			s[i+1] = '1';
		}else s[i+1] = '0';
		counter++;
	}
}
cout << counter << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string t, p;
    cin>>t>>p;
    for(int pos=0; pos<t.length(); pos++) {
        pos = t.find(p, pos);
        if(pos==string::npos) break;
        cout<<pos<<'\n';
    }
    return 0;
}

Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
int main1()
{
    int a[1000],n,c=0,p;
    a[0]=1;
    cout<<"Enter a Number: ";
    cin>>n;//100
    
    while(n>=2)
    {
        p=0;
        for(int i=0;i<=c;i++)
        {
            p=(a[i]*n)+p;
            a[i]=p%10;
            p/=10;
        }
        
        while(p>0)
        {
            a[++c]=p%10;
            p/=10;
        }
        
        n--; 
    }
    
    for(int i=c;i>=0;i--)
    {
        cout<<a[i];
    }
}


int main()
{
    int x;cin>>x;
    x>=30?cout<<"Yes\n":cout<<"No\n";
}

Measured memory_bytes: 3596
import sys
from io import StringIO
import unittest
import os


# 実装を行う関数
def resolve():
    # 数値取得サンプル
    #   1行N項目 x, y = map(int, input().split())
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]
    n = int(input())
    bricks = list(map(int, input().split()))

    # 1が無ければ-1
    if 1 not in bricks:
        print(-1)
        return

    num = 1
    ban = 0
    for brick in bricks:
        if brick == num:
            num += 1
            continue
        ban += 1

        # dev
        1 == 1

    print(ban)





    # 文字取得サンプル
    #   1行1項目 x = input()
    pass


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
2 1 2"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3
2 2 2"""
        output = """-1"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """10
3 1 4 1 5 9 2 6 5 3"""
        output = """7"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """1
1"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 88064
#include <bits/stdc++.h>
#define ll long long int
#define sd(x) scanf("%d",&x)
#define F first
#define S second
#define sz(x) (int)(x.size())
#define sd2(x,y) scanf("%d%d",&x,&y);
#define mp make_pair
#define pb push_back
#define pi pair <int, int > 
#define pl pair <ll, int >
#define infl (1ll << 60)
#define inf (1 << 30)
#define nax  100020
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
std::vector< pi > v[nax];
int col[nax];

void dfs(int s, int p)
{
    for(int i = 0 ; i < sz(v[s]); i++)
    {
        if(v[s][i].F != p)
        {
            if(v[s][i].S % 2 == 1)
                col[v[s][i].F]  = col[s] ^ 1;
            else
                col[v[s][i].F] = col[s];
            dfs(v[s][i].F, s);
        }
    }
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,a,b,c;
    sd(n);
    for(int i = 1; i < n; i++)
    {
        sd2(a, b);
        sd(c);
        v[a].pb(mp(b, c));
        v[b].pb(mp(a, c));
    }
    dfs(1, 0);
    for(int i = 1; i <= n; i++)
        printf("%d\n", col[i]);
    return 0;
}


Measured memory_bytes: 9984
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 100000;

class UnionFind {
    public:
    int n;
    vector<int> par, rank, size;  //親, 深さ, その木の要素数

    UnionFind(int n): n(n) {
        for(int i=0;i<n;++i){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
    }

    //根を求める
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int p = find(par[x]);
            size[x] = size[p];
            return par[x] = p;
        }
    }

    //xとyの属する集合の併合
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        
        size[x] += size[y];
        size[y] = size[x];
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //同じ集合に属するか否か
    bool is_same(int x, int y){
        return find(x) == find(y);
    }
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    UnionFind uf = UnionFind(2*N_MAX);
    int x, y;
    for(int i=0;i<n;++i){
        cin >> x >> y;
        --x; --y;
        uf.unite(x, N_MAX+y);
    }

    vector<ll> count_x(2*N_MAX, 0), count_y(2*N_MAX, 0);
    for(int i=0;i<N_MAX;++i) {
        ++count_x[uf.find(i)];
        ++count_y[uf.find(N_MAX+i)];
    }

    ll ans = 0LL;
    for(int i=0;i<2*N_MAX;++i) {
        ans += count_x[i] * count_y[i];
    }
    ans -= n;

    cout << ans << endl;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

ll c(ll n, ll k) {
    static ll memo[1000][1000];
    if (memo[n][k] != 0)
        return memo[n][k];
    else if (n == k)
        return memo[n][k] = 1;
    else if (k == 0)
        return memo[n][k] = 1;
    else
        return memo[n][k] = (c(n-1, k-1) + c(n-1, k));
}

signed main() {
    ll A,B,N;
    cin>>N>>A>>B;
    vector<ll> v(N);
    map<ll,ll> hist; // value -> # of values
    rep(i,0,N){
        cin>>v[i];
        hist[v[i]]++;
    }
    sort(begin(v),end(v));
    double avg = 0.0;
    set<ll> _set;
    rep(i,N-A,N){
        avg += v[i];
        _set.insert(v[i]);
    }
    avg /= A;
    printf("%.10f\n", avg);

    ll t = v[N-A];
    ll n_pattern = 0;
    rep(k,A,B+1){
        ll s=0;
        rep(i,N-k,N){
            if (v[i]!=t)
                break;
            s++;
        }
        // cout<<"k="<<k<<" s="<<s<<endl;
        if (s == 0 || _set.size()>1 && k>A)
            break;
        n_pattern += c(hist[t], s);
    }
    cout<<n_pattern<<endl;
    return 0;
}


Measured memory_bytes: 512
/******************************************

******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define vll vector<ll>
#define fo(i, n) for(int i=0;i<n;i++)
#define MOD 1000000007

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	ll t=0;
	cin >> t;
	cout << 2 * 3.14159 * t;
	return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  if (n >= 30) puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

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

int main()
{

    int n, p[11] = {};

    cin >> n;
    FOR(i, 0, n)
    {
        cin >> p[i];
    }

    sort(p, p + n, greater<int>());

    int sum = p[0] / 2;
    FOR(i, 1, n)
    sum += p[i];
    cout << sum << endl;
    return 0;
}


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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

string S;

ll calc(string exp){
    ll ret = 0;
    ll now = 0;
    for(int i=0; i<exp.length(); i++){
        if(exp[i] == '+'){
            ret += now;
            now = 0;
        }
        else now = now* 10 + (exp[i]-'0');
    }
    return ret+now;
}

ll dfs(string exp, int p){
    if(p == S.length()){
        ll ret = calc(exp);
        return ret;
    }
    ll s1, s2;
    s1 = dfs(exp+S[p], p+1);
    s2 = dfs(exp+"+"+S[p], p+1);
    return s1 + s2;
}

int main(){
    cin >> S;

    ll ans = dfs(S.substr(0, 1), 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n, p; cin >> n >> p;
  V cnt(2);
  rep(i, n) {
    int x; cin >> x;
    ++cnt[x&1];
  }

  ll ans = 1;
  rep(i, cnt[0]) ans *= 2;
  rep(i, cnt[1]-1) ans *= 2;
  if (cnt[1] == 0 && p == 1) ans = 0;

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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
struct hopcroft{
	vector<int> dist, pair_l, pair_r;
	vector<bool> seen;
	vector<vector<int>> to;
	int n1, n2;
	hopcroft(int n1, int n2) : n1(n1), n2(n2){
		to.resize(n1);
		pair_l.assign(n1, -1);
		pair_r.assign(n2, -1);
		dist.resize(n1);
		seen.resize(n1);
	}
	void add_edge(int u, int v){
		to[u].push_back(v);
	}
	bool bfs(){
		fill(dist.begin(), dist.end(), -1);
		queue<int> q;
		for (int i = 0; i < n1; i++){
			if (pair_l[i] == -1){
				dist[i] = 0;
				q.push(i);
			}
		}
		bool reach_minus = false;
		while (!q.empty()){
			int u = q.front();
			q.pop();
			for (int adj : to[u]){
				int radj = pair_r[adj];
				if (radj == -1){
					reach_minus = true;
				} else if (dist[radj] == -1){
					dist[radj] = dist[u] + 1;
					q.push(radj);
				}
			}
		}
		return reach_minus;
	}
	bool dfs(int u){
		seen[u] = true;
		for (int adj : to[u]){
			int radj = pair_r[adj];
			if (radj == -1 || (!seen[radj] && dist[radj] == dist[u] + 1 && dfs(radj))){
				pair_l[u] = adj;
				pair_r[adj] = u;
				return true;
			}
		}
		return false;
	}
	int max_matching(){
		int res = 0;
		while (bfs()){
			fill(seen.begin(), seen.end(), false);
			for (int i = 0; i < n1; i++)
				if (pair_l[i] == -1 && dfs(i))
					res++;
		}
		return res;
	}
};
const int maxn = 111;
int g[maxn][maxn];
int cnt[maxn][maxn];
int res[maxn][maxn];
vector<int> ready[maxn][maxn];
int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> g[i][j];
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) g[i][j]--;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cnt[i][g[i][j] / m]++;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) ready[i][g[i][j] / m].push_back(g[i][j]);
	for(int i = 0; i < m; i++){
		int nds = 0;
		hopcroft ho(n, n);
		for(int j = 0; j < n; j++){
			for(int k = 0; k < n; k++){
				if(cnt[j][k]){
					ho.add_edge(j, k);
				}
			}
		}
		assert(ho.max_matching() == n);
		for(int j = 0; j < n; j++){
			int val = ho.pair_l[j];
			res[j][i] = ready[j][val].back();
			ready[j][val].pop_back();
			cnt[j][val]--;
		}
	}
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) printf("%d%c", res[i][j] + 1, " \n"[j + 1 == m]);
	for(int i = 0; i < m; i++){
		vector<int> tmp;
		for(int j = 0; j < n; j++) tmp.push_back(res[j][i]);
		sort(tmp.begin(), tmp.end());
		for(int j = 0; j < n; j++) res[j][i] = tmp[j];
	}
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) printf("%d%c", res[i][j] + 1, " \n"[j + 1 == m]);
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll ans = a * (int)(b*100+0.5);
     ans /= 100;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

public class Main{


	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static int nextInt() throws IOException {
		return Integer.parseInt(br.readLine());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(br.readLine());
	}

	public static String next() throws IOException {
		return br.readLine();
	}

	public static int[] sortArr(int arr[]) throws IOException {
		ArrayList<Integer> a = new ArrayList<Integer>();
		for (int i : arr)
			a.add(i);

		Collections.sort(a);

		for (int i = 0; i < a.size(); i++)
			arr[i] = a.get(i);
		return arr;
	}

	public static int[] desortArr(int arr[]) throws IOException {
		ArrayList<Integer> a = new ArrayList<Integer>();
		for (int i : arr)
			a.add(i);

		Collections.sort(a, Collections.reverseOrder());

		for (int i = 0; i < a.size(); i++)
			arr[i] = a.get(i);
		return arr;
	}

	public static int[] nextArr() throws IOException {
		String elements[] = br.readLine().split(" ");
		int arr[] = new int[elements.length];
		for (int j = 0; j < elements.length; j++)
			arr[j] = Integer.parseInt(elements[j]);
		return arr;
	}

	public static void printArr(int arr[]) {
		for (int i = 0; i < arr.length; i++)
			System.out.print(arr);
	}

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

		int T = 1;
		while (T-- > 0) {

			int a = next().charAt(0);
			if (a >= 97 && a <= 122)
				System.out.println("a");
			else
				System.out.println("A");

		}
	}


}


Measured memory_bytes: 32688
#include <stdio.h>
#include <string.h>
#define SIZE 200020
int main(){
  char t[SIZE];
  int len;
  int i;

  scanf("%s",t);
  len = strlen(t);

  for(i=0;i<len;i++){
    if(t[i]=='P' && t[i+1]=='?'){
      t[i+1]='D';
    }else if(t[i]=='D' && t[i+1]== '?' && t[i+2]=='D'){
      t[i+1]='P';
    }else if(t[i]=='D' && t[i+1]== '?' && t[i+2]=='P'){
      t[i+1]='D';
    }else if(t[i]=='D' && t[i+1]== '?' && t[i+2]=='?'){
      t[i+1]='P';
      t[i+2]='D';
    }else if(t[i]=='D' && t[i+1]=='?'){
      t[i+1]='D';
    }else if(t[i]=='?' && t[i+1]=='?'){
      t[i]='P';
      t[i+1]='D';
    }else if(t[i]=='?' && t[i+1]=='P'){
      t[i]='D';
    }else if(t[i]=='?' && t[i+1]=='D'){
      t[i]='P';
    }else if(t[i]=='?' && t[i+1]=='\0'){
      t[i]='D';
    }
  }
  printf("%s\n",t);

  return 0;
}


Measured memory_bytes: 1856
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    double ans=0;
    rep(i,n){
        rep(j,n){
            if(i!=j){
                ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+
                (y[i]-y[j])*(y[i]-y[j]));
            }
        }
    }
    double sum=1;
    for(int i=1; i<=n; ++i){
        sum*=i;
    }
    cout<<fixed<<setprecision(10)<<ans/n<<endl;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int T; cin >> T;

    while(T--) {
        int A, B, C, D; cin >> A >> B >> C >> D;

        if(A < B || B > D) printf("No\n");
        else {
            int g = __gcd(B, D);

            if(B - g + (A % g) > C) printf("No\n");
            else printf("Yes\n");
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
    K=i_input()
    a = []
    
    a.append(7 % K)
    for i in range(1,K):
            a.append((a[i-1]*10+7)%K)
    
    for i in range(0,len(a),1):
        if(a[i] == 0):
            print(i+1)
            return

    print(-1)
    return
        
if __name__ == '__main__':
    main()

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll sx,sy,tx,ty ;
  cin >> sx >> sy >> tx >> ty;
  REP(i,sy,ty) cout << 'U';
  REP(i,sx,tx) cout << 'R';
  REP(i,sy,ty) cout << 'D';
  REP(i,sx,tx) cout << 'L';
  cout << 'L';
  REP(i,sy,ty+1) cout << 'U';
  REP(i,sx,tx+1) cout << 'R';
  cout << 'D';
  cout << 'R';
  REP(i,sy,ty+1) cout << 'D';
  REP(i,sx,tx+1) cout << 'L';
  cout << 'U';
  cout << endl;
  return 0;
}


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

using namespace std;

const int MX = 300;

char s[MX + 2];
int dp[MX + 2][MX + 2][MX + 1];

int main() {
	int k;
	ignore = scanf("%s %d", s + 1, &k);
	
	int n = strlen(s + 1);
	for (int l = n; l > 0; l--)
		for (int r = l; r <= n; r++)
			for (int p = 0; p <= k; p++) {
				if (s[l] == s[r]) {
					dp[l][r][p] = dp[l + 1][r - 1][p] + (l == r ? 1 : 2);
				}
				else {
					dp[l][r][p] = max(dp[l + 1][r][p], dp[l][r - 1][p]);
					if (p > 0) dp[l][r][p] = max(dp[l][r][p], dp[l + 1][r - 1][p - 1] + (l == r ? 1 : 2));
				}
			}
	
	printf("%d\n", dp[1][n][k]);
	
	return 0;
}


Measured memory_bytes: 106368
#include <stdio.h>

int main(void){
  char S[10] = {};
  int i, j, k;
  int flag1 = 0;
  int flag2 = 0;
  int flag3 = 0;
  scanf("%s", S);
  for(i = 0; i < 3; i++){
    if(S[i] == 'a'){
      flag1 = 1;
    }
    if(S[i] == 'b'){
      flag2 = 1;
    }
    if(S[i] == 'c'){
      flag3 = 1;
    }
  }
  if(flag1 == 1 && flag2 == 1 && flag3 == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

long gcd(long n, long m) {
	if (n == 0)return m;
	if (n < m)swap(n, m);
	return gcd(n % m, m);
}

int main() {
	int N, M; cin >> N >> M;
	int l[110000], r[110000];
	int L = 0, R = N;
	for (int i = 0; i < M; i++){
		cin >> l[i] >> r[i];
	}
	for (int i = 0; i < M; i++) {
		L = max(L, l[i]);
		R = min(R, r[i]);
	}
	if (R < L)cout << 0;
	else cout << R - L + 1;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdint.h>

static uint64_t
gcd (
  int a,
  int b
  )
{
  if ( a == 0 ) return ( b );

  return
  gcd ( b % a, a );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    uint64_t a, b;
    uint64_t res;

    if ( scanf ( "%llu%llu", &a, &b ) != 2 ) break ;

    res = gcd ( a, b );
    printf ( "%llu %llu\n", res, a * b / res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int n;
    string s, t, u;
    cin>>n>>s;
    if(n%2){cout<<"No";return ;}
    f(i,n/2)t.pb(s[i]);
    for(int i =  n/2; i < n; i++)u.pb(s[i]);
    if(u == t)cout<<"Yes";
    else cout<<"No";
}


int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e6;
int t[5][5];
ll h,a,b,c,d,e;
int ans = 1;
ll mod = 1e9+7;
bool memo[15][15] = {0};
int main(){
  ll m,n;
  cin >> n >> m;
  ll ans = 0;
  if(n >= m/2){
    ans = m/2;
  }else{
    m -= 2*n;
    ans = n + m/4;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < n-2; i++){
        if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C' ){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void) {
  string str;
  cin >> str;
  int len = str.length();
  int count = 0;
  for(int s = 0, t = len - 1; s < len / 2; s++, t--) {
    if(str[s] != str[t]) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};


#define MAXN 100010

int xcount[MAXN * 2], ycount[MAXN * 2];

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

	long long n, i, j, k, x, y, ans;
	cin >> n;

	UnionFind uf(MAXN * 2);
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		uf.unionSet(x, y + MAXN);
	}

	for (i = 0; i < MAXN * 2; i++) {
		if (uf.sizeOfSet(i) != 1) {
			if (i < MAXN) xcount[uf.findSet(i)]++;
			else ycount[uf.findSet(i)]++;
		}
	}

	ans = 0;
	for (i = 0; i < MAXN * 2; i++) {
		ans += (long long)xcount[i] * ycount[i];
	}
	ans -= n;

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


Measured memory_bytes: 3328
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>
#include <vector>
#include <string>

using namespace std; using ll=long long; const int INF=1e9; using P=pair<int,int>;

int main() {
  int n; cin>>n;
  int p[n]; for(int i=0;i<n;i++) {cin>>p[i]; p[i]--;}
  int an=0;
  for(int i=0;i<n;i++) {
    if (i != n-1) {
      if (p[i] == i) swap(p[i], p[i+1]), an++;
    } else {
      if (p[i] == i) swap(p[i], p[i-1]), an++;
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,i,x;

  scanf("%d",&n);

  for(i = 1;i <= n;i++){

    x = i;

    if(x % 3 == 0){
      printf(" %d",i);
    }
    else{
      for(;x>0;){
        if(x % 10 == 3 && i != 3){
	  printf(" %d",i);
	  break;
        }
	else{
	  x = x / 10;
	}
      }
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 596
def main():
    num = int(input())
    data = list(map(int, input().split()))
    data_kari = data.copy()
    data_kari.sort()
    # print(data_kari)
    min_chuou = data_kari[(num // 2) - 1]
    max_chuou = data_kari[num // 2]

    # print(min_chuou, max_chuou)

    # print(data)

    for i in range(num):
        if data[i] <= min_chuou:
            print(max_chuou)
        elif data[i] >= max_chuou:
            print(min_chuou)






if __name__ == '__main__':
    main()



Measured memory_bytes: 26772
#include <iostream>
#include <vector>
using namespace std;
 
const int MAXN = (1 << 20) + 10, MAXM = 5e5 + 10, MOD = 1e9 + 7;
long long ans, T, dp[MAXM][2];
vector<int> r[MAXN];
int ps[MAXN], C;
int n, X;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		X ^= a;
		if (X == 0) {
			if (T == 0)
				T = 1;
			else
				T *= 2;
			T %= MOD;
			ps[i]++;
		}
		else
			r[X].push_back(i);
	}
	for (int i = 1; i < n; i++)
		ps[i] += ps[i - 1];
	for (int i = 1; i < MAXN; i++)
		if ((X == 0 || X == i) && r[i].size() > 0) {
			dp[0][0] = 1;
			dp[0][1] = 0;
			for (int j = 0; j < r[i].size(); j++) {
				int k = j + 1, cnt = 0;
				if (j > 0)
					cnt = ps[r[i][j]] - ps[r[i][j - 1]];
				dp[k][1] = dp[k - 1][0] + dp[k - 1][1] * (cnt + 1);
				dp[k][0] = dp[k - 1][1] * cnt + dp[k - 1][0];
				dp[k][0] %= MOD;
				dp[k][1] %= MOD;
			}
			if (X == 0)
				ans += dp[r[i].size()][1];
			else
				ans += dp[r[i].size()][1] - dp[r[i].size() - 1][1];
			ans %= MOD;
		}
	if (X == 0)
		ans += T, ans %= MOD;
	if (ans < 0)
		ans += MOD;
	cout << ans;
}

Measured memory_bytes: 37760
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>


int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(void)
{
	long long x, ans = 100,i = 0;
	scanf("%lld",&x);
	while (ans < x) {
		ans = ans*1.01;
		i++;
	}
	printf("%lld",i);
	
	
	return 0;
}

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

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N), b(N);
	for(ll i=0; i<N; i++) cin >> a[i];
	for(ll i=0; i<N; i++) cin >> b[i];

	map<ll,ll> am,bm;
	for(ll i=0; i<N; i++){
		am[a[i]]++;
		bm[b[i]]++;
	}
	for(auto&& pr:am){
		if(pr.second + bm[pr.first]> N){
			cout << "No\n";
			return 0;
		}
	}
	
	reverse(b.begin(), b.end());
	ll index=0;
	for(ll i=0; i<N; i++){
		if(a[i]==b[i]){
			while(a[index]==a[i] || b[index]==a[i])index++;
			swap(b[index],b[i]);
			index++;
		}
	}

	cout << "Yes\n";
	for(ll i=0; i<N; i++) cout << b[i] << " \n"[i==N-1];

	return 0;
}


Measured memory_bytes: 31416
N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

par = list(range(N+1))
rank = [0]*(N+1)


def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
    if rank[x] == rank[y]:
        rank[x] += 1


def same(x, y):
    return find(x) == find(y)


ans = 0
for i in range(M):
    unite(xy[i][0], xy[i][1])

for i in range(N):
    if same(p[i], par[i+1]):
        ans += 1
print(ans)


Measured memory_bytes: 36056
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
  int n,k,q; cin >> n >> k >> q;
  vector<int>c(1e5,k-q);
  rep(i,q){
    int a; cin >> a;
    a--;
    c[a]++;
  }
  rep(i,n){
    if(c[i]>0)puts("Yes");
    else puts("No");
  }
  return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}
const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	string s; cin>>s;
	if(s.back() != 's') cout<<s + 's'<<"\n";
	else cout<<s + "es"<<"\n";
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    int a;
    cin >> a;
    
    cout << a + a * a + a * a * a << '\n';
    return 0;
}


Measured memory_bytes: 3584
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
s = input()
if n%2 != 0 or s[:len(s)//2] != s[len(s)//2:]:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	int n,i;
	
	cin >> n;
	
	cout << n << ":";
	
	for(i=2;n!=1;i++)
	{
		if(i>sqrt(n))
		{
			cout << " " << n;
			n=1;
			continue;
		}
		while(n%i==0)
		{
			cout << " " << i;
			n/=i;
		}
	}
	cout << endl;
	
	return 0;
}

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


int main(void){
    double a, b, x;
    cin >> a >> b >> x;
    
    double s = x / a;
    
    double rad;
    
    if (s >= a * b / 2){
        double h = (a*b-s) * 2 / a;
        rad = atan2(h, a);
    }
    else{
        double w = s * 2 / b;
        rad = atan2(b, w);
    }
    
    double pi = acos(-1);
    double deg = rad / (2*pi)*360;
    
    printf("%.10lf\n", deg);
    
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;

typedef long long ll;

int a[100010];

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

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

   int cnt=0;
   for(int i=0; i < N; i++){
       if(a[i] % 2 == 1)cnt++;
   }
   if(cnt%2==0){
       cout << "YES" << endl;
   }else{
       cout << "NO" << endl;
   }

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string S;
  cin >> S;
  if (S.at(5) == '1') {
    cout << "TBD" << endl;
  }
  else if (S.at(6) == '5' || S.at(6) == '6' || S.at(6) == '7' || S.at(6) == '8'
           || S.at(6) == '9') {
    cout << "TBD" << endl;
  }
  else {
    cout << "Heisei" << endl;
  }
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
    int n,i,sum=0,r,m;
    scanf("%d",&n);
    m=n;
    while(m!=0){
        r=m%10;
        sum=sum+r;
        m=m/10;
    }
    if(n%sum==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128