akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  int key;
  struct node *pref;
  struct node *next;

};
typedef struct node * NP;
NP head;
void init();
NP insert(int);
void delete(int);
void deleteFirst();
void deleteLast();
NP make1_node(int,NP,NP);
void show();
int main(){
  int n,i,j,num;
  char str[12];
  init();

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0){
      scanf("%d",&num);
      insert(num);
    }
    else if(strcmp(str,"delete")==0){

     scanf("%d",&num);
      delete(num);
    }
    else if(strcmp(str,"deleteFirst")==0)
      deleteFirst();
    else if(strcmp(str,"deleteLast")==0)
      deleteLast();
  }

  show();
  return 0;
}
NP make1_node(int key,NP pre,NP next){
  NP newnode;
  if((newnode=(NP)malloc(sizeof(struct node)))==NULL){
    printf("Error:Memory Over\n");
    exit(0);
  }
  newnode->key=key;
  newnode->pref=pre;
  newnode->next=next;
  newnode->next->pref=newnode;
  ///////////////////koko ni henkou ireru
  return newnode;
}
NP insert(int key){
  NP newnode;
  static int flag=0;
  newnode=make1_node(key,head,head->next);
  head->next=newnode;
  if(flag++==0)
    head->pref=newnode;
  
  return newnode;
}
void delete(int key){
  NP p,q;
  for(p=head;p->next!=head;p=p->next){
    if(p->next->key==key){
      q=p->next;
      q->next->pref=p;
      p->next=q->next;
      free(q);
      return;
	}
      
  }

}
void deleteFirst(){
  NP q;
  q=head->next;
q->next->pref=head;
  head->next=q->next;

  free(q);
}
void deleteLast(){
  NP q;
   q=head->pref;
  head->pref=q->pref;
  q->pref->next=head;
  free(q);
}
void show(){
  NP p;
  int n=0;
  for(p=head->next;p!=head;p=p->next){
    if(n!=0)
      printf(" ");
    n++;
    printf("%d",p->key);
  }
  printf("\n");

}

void init(){
  head=malloc(sizeof(struct node));
  head->next=head;
  head->pref=head;
  

}



Measured memory_bytes: 32984
#include <stdio.h>

int A = 0;
int d;
bool ng = false;

int main(){
	scanf("%d", &A);
	int get;
	int ward = 0;
	int back = 0;
	int now;
	for(int i = 0; i < A; i++){
		scanf("%d", &d);
		if( ng ) continue;
		if( ward < i ){
			ng = true;
		}
		get = i + d / 10;
		if( ward < get){
			ward = get;
		}
		get = i - d / 10;
		if( back >= get ){
			back = i;
		}
	}

	if(back != A-1){
		ng = true;
	}


	if(ng){
		printf("no\n");
	}else{
		printf("yes\n");
	}

	return 0;
}


Measured memory_bytes: 2692
import numpy as np

n, t = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort()

dp = np.zeros(t, dtype=np.int64)

ans = 0
for a, b in ab:
    ans = max(ans, dp[-1] + b)
    np.maximum(dp[a:], dp[:-a] + b, out=dp[a:])


print(ans)


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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

const ll MOD = 1e9 + 7;
const int MX = 120000;

ll fc[MX];
ll bfc[MX];
ll lst[MX];
int a[MX];
int n;

ll pw(ll a, ll b) {
    ll ans = 1;
    while (b) {
        while (!(b & 1))
            b >>= 1, a = (a * a) % MOD;
        --b;
        ans = (ans * a) % MOD;
    }
    return ans;
}

void init() {
    fc[0] = 1;
    for (int i = 1; i < MX; ++i)
        fc[i] = (fc[i - 1] * i) % MOD;
    for (int i = 0; i < MX; ++i)
        bfc[i] = pw(fc[i], MOD - 2);
}

ll cnk(int n, int k) {
    if (k > n)
        return 0;
    return fc[n] * bfc[k] % MOD * bfc[n - k] % MOD;
}



int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        lst[i] = -1;
    int l = -1, r = -1;
    for (int i = 0; i < n + 1; ++i) {
        scanf("%d", a + i);
        --a[i];
        if (lst[a[i]] == -1)
            lst[a[i]] = i;
        else {
            l = lst[a[i]];
            r = i;
        }
    }
    init();
    for (int i = 1; i <= n + 1; ++i) {
        ll ans = cnk(n + 1, i);
        ans = (ans - cnk(n + 1 - (r - l + 1), i - 1) + MOD) % MOD;
        printf("%lld\n", ans);
    }
    return 0;
}




Measured memory_bytes: 4224
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    mat A(3,vec(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A[i][j];
        }
    }
    int N;cin>>N;
    vec v(110,false);
    for(int i=0;i<N;i++){
        int b;cin>>b;
        v[b]=true;
    }
    for(int i=0;i<3;i++){
        if(v[A[i][0]] && v[A[i][1]] && v[A[i][2]]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    for(int i=0;i<3;i++){
        if(v[A[0][i]] && v[A[1][i]] && v[A[2][i]]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(v[A[0][0]] && v[A[1][1]] && v[A[2][2]]){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(v[A[0][2]] && v[A[1][1]] && v[A[2][0]]){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
res = 0
cnt = 0
ATGC = ['A', 'T', 'G', 'C']
for i in range(len(s)):
    if s[i] in ATGC:
        cnt += 1
    else:
        res = max(res, cnt)
        cnt = 0
else:
    res = max(res, cnt)
print(res)

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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

int main() {
    set<int> a, b, c;
    int n; cin >> n;
    while (n--) {
        int x; cin >> x; a.insert(x);
    }
    int m; cin >> m;
    while (m--) {
        int x; cin >> x; b.insert(x);
    }
    set_intersection(all(a), all(b), inserter(c, c.begin()));
    for (auto& x : c) {
        cout << x << endl;
    }
}


Measured memory_bytes: 23700
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    map<string, int> m;
    int n; cin >> n;
    int sum = 0;
    rep(i, n) {
        string s; cin >> s;
        int a; cin >> a;
        sum += a;
        m[s] = sum;
    }

    string X; cin >> X;

    cout << sum - m[X] << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,r=0;
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d",&x);
		r+=x%2;
	}
	puts(r%2==0?"YES":"NO");
	return 0;
}


Measured memory_bytes: 256
s=input()
while len(s)>4:
  if s[-5:]=='dream':
    s=s[:-5]
  elif s[-5:]=='erase':
    s=s[:-5]
  elif len(s)<6:
    print('NO')
    exit()
  elif s[-6:]=='eraser':
    s=s[:-6]
  elif len(s)<7:
    print('NO')
    exit()
  elif s[-7:]=='dreamer':
    s=s[:-7]
  else:
    print('NO')
    exit()
print('YES')



Measured memory_bytes: 3188
fn main(){
  let n: usize = read();
  let balls: Vec<u32> = read_vec();

  let mut color: u32 = balls[0];
  let mut cnt: u32 = 1;
  let mut ans: u32 = 0;

  for i in 1 .. n {
    if color == balls[i] {
      cnt += 1;
    } else {
      ans += cnt / 2;
      cnt = 1;
      color = balls[i];
    }
  }

  ans += cnt / 2;
  
  println!("{}", ans);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,q;
    cin >> n >> q;
    vector<pair<ll,pair<ll,ll>>> v;
    for(i = 0;i < n;++i){
        ll s,t,x;
        cin >> s >> t >> x;
        v.emplace_back(s-x, make_pair(-1, x));
        v.emplace_back(t-x, make_pair(0, x));
    }

    for(i = 0;i < q;++i){
        ll d;
        cin >> d;
        v.emplace_back(d, make_pair(1, i));
    }

    vector<ll> ans(q);
    multiset<ll> ms;
    sort(all(v));
    for(auto p:v){
        ll x = p.first;
        ll type = p.second.first;
        ll val = p.second.second;
        if(type == -1) ms.insert(val);
        else if(type == 0) ms.erase(ms.lower_bound(val));
        else{
            if(ms.empty()) ans.at(val) = -1;
            else ans.at(val) = *(ms.begin());
        }
    }

    for(auto x: ans) cout << x << endl;

    return 0;
}

Measured memory_bytes: 28140
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int nagasa = scan.nextInt();
		String moziretu = scan.next();
		int index = 0;
		int count = 0;

		while(true) {
			index = moziretu.indexOf("ABC",index)+1;
		if(index == 0) {
			break;
		}else
		{
			count++;
		}
		}

		System.out.println(count);
		scan.close();

	}

}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define ll long long
int a[N];
int main()
{
    int n,m;
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    if(m>=n){printf("0\n");return 0;}
    sort(a+1,a+1+n);
    ll sum=0;
    for(int i=1;i<n;i++)
        a[i]=abs(a[i+1]-a[i]),sum+=a[i];
    sort(a+1,a+n);
    for(int i=n-1,j=1;j<m;i--,j++)
        sum-=a[i];
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<iostream>
#include<stdlib.h>
#include<vector>
using namespace std;
typedef long long ll;


int main(void) {
	int a[3], K;
	cin >> a[0] >> a[1] >> a[2];
	cin >> K;
	sort(a, a + 3);
	int x = a[2];
	for (int i = 0;i < K;i++) x *= 2;
	cout << a[0] + a[1] + x << endl;
	return 0;
}

Measured memory_bytes: 256
r,c=map(int,input().split())
m=[[int(_) for _ in input().split()] for i in range(r)]
for i in range(r):m[i].append(sum(m[i]))
m.append([sum([m[i][j] for i in range(r)]) for j in range(c+1)])
for i in range(r+1):print(*m[i])

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

int main()
{
    int M, N;
    int D[255];

    while ( cin >> M, M ) {
        bool road[255];
        bool flag[255] = {};

        cin >> N;
        for ( int i = 1; i <= N; i++ ) {
            cin >> D[i];
        }
        D[0] = 0, D[N + 1] = 0;

        function < bool(int) > dfs = [&]( int v )
        {
            bool ret = 0;
            if ( flag[v] ) return ( false );
            flag[v] = true;
            if ( v == N + 1 ) return ( true );

            for ( int i = 1; i <= M && v + i <= N + 1; i++ ) {
                int place = min( N + 1, max ( v + i + D[v + i], 0 ) ) ;
                ret |= dfs ( place );
            }
            return ( ret );
        };

        dfs ( 0 );
        for ( int i = 0; i <= N + 1; i++ ) {
            road[i] = flag[i];
        }

        bool is_agari = true;
        for ( int i = 0; i <= N; i++ ) {
            fill_n ( flag, 255, false );
            if ( road[i] && !dfs(i) ) {
                is_agari = false;
            }
        }

        cout << (is_agari ? "OK" : "NG") << endl;

    }

    return ( 0 );
}


Measured memory_bytes: 3092
cin = input()
count_0 = 0
count_1 = 0
for i in range(len(cin)):
  if int(cin[i]) == 0:
    count_0 = count_0 + 1
  else:
    count_1 = count_1 + 1
m = min(count_0,count_1)
ans = m*2
print(ans)

Measured memory_bytes: 3188
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;
}
#endif
string S;
int N;
ll ans;

void calc(vi& use) {
    string t = {S[0]};
    REP(i,N-1) {
        if (use[i]==1){
            t += "+";
        }
        t += S[i + 1];
    }

    vs terms = split(t, '+');
    for(string tm : terms) {
        ans += stoll(tm);
    }
}

void dfs(int n, vi& use) {
    if (n >= N - 1) {
        calc(use);
        return;
    }

    REP(i,2) { // 1:+, 0:nop
        use[n] = i;
        dfs(n + 1, use);
    }
}

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

    cin >> S;
    N = S.size();

    ans = 0;
    vi use(N - 1, 0);
    dfs(0, use);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		System.out.println(Math.max(A * B, C * D));
	}
}


Measured memory_bytes: 21204
#include <iostream>

int main ()
{
    int a_info, a_math, a_sci, a_eng;
    int b_info, b_math, b_sci, b_eng;

    std::cin >> a_info;
    std::cin >> a_math;
    std::cin >> a_sci;
    std::cin >> a_eng;
    std::cin >> b_info;
    std::cin >> b_math;
    std::cin >> b_sci;
    std::cin >> b_eng;

    int a_S,b_S;

    a_S = a_info + a_math + a_sci + a_eng;
    b_S = b_info + b_math + b_sci + b_eng;


    if (a_S >= b_S) {
        std::cout << a_S << std::endl;
    } else {
        std::cout << b_S << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main() {
    char c[3];
    cin >> c;

    for (int i = 0; i < 3; ++i) {
        if (c[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

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

    long long a, b, c, k;

    cin >> a >> b >> c >> k;

    if (k % 2 == 0)
        cout << a - b << endl;
    else
        cout << b - a << endl;

    return 0;
}

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


def st(line):
    tmp = ''
    for l in line:
        if l == '\n':
            yield tmp
        elif l == ' ':
            yield tmp
            tmp = ''
        else:
            tmp += l


def solve():
    N = int(input())
    As = st(readline())

    d = dict()
    total = 0
    for a in As:
        a = int(a)

        if a in d:
            d[a] += 1
        else:
            d[a] = 1
        total += a

    Q = int(input())
    queries = (map(int, readline().strip().split()) for _ in range(Q))

    for que in queries:
        b, c = que

        if b not in d:
            print(total)
            continue

        n_b = d[b]
        d[b] = 0

        if c not in d:
            d[c] = 0

        d[c] += n_b
        total += (c - b) * n_b

        print(total)


def main():
    solve()


if __name__ == "__main__":
    main()


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


int main(){
    string s;
    cin>>s;
    stack<char> st;
    rep(i,(int)s.size()){
        if(st.empty()) st.push(s[i]);
        else{
            if(s[i]!=st.top()) st.pop();
            else st.push(s[i]);
        }
    }
    cout<<(int)s.size()-(int)st.size()<<endl;
}

Measured memory_bytes: 3824
using System;

namespace tst
{
    class Program
    {
        public static int N;//N回じゃんけん
        public static int K;//ちょうどK回前と同じ手はだせない
        public static int R;//グーで勝った時の点
        public static int S;//チョキで勝った時の点
        public static int P;//パーで勝った時の点
        public static int max=0;
        public static void Tansaku(string T, char[] Log,int cnt, int score)
        {
            if (cnt == N)
            {
                if (score > max)
                {
                    max = score;
                }
            }
            else
            {
                if (cnt < K)
                {//Kのしばりなし
                    if (T[cnt] == 'r')
                    {
                        Log[cnt] = 'p';
                        Tansaku(T, Log, cnt + 1, score + P);
                    }
                    else if (T[cnt] == 's')
                    {
                        Log[cnt] = 'r';
                        Tansaku(T, Log, cnt + 1, score + R);
                    }
                    else if (T[cnt] == 'p')
                    {
                        Log[cnt] = 's';
                        Tansaku(T, Log, cnt + 1, score + S);
                    }
                }
                else
                {//Kの縛りがあるとき
                    if (Log[cnt-K]!='p'&&T[cnt] == 'r')
                    {
                        Log[cnt] = 'p';
                        Tansaku(T, Log, cnt + 1, score + P);
                    }
                    else if (Log[cnt - K] != 'r' && T[cnt] == 's')
                    {
                        Log[cnt] = 'r';
                        Tansaku(T, Log, cnt + 1, score + R);
                    }
                    else if (Log[cnt - K] != 's' && T[cnt] == 'p')
                    {
                        Log[cnt] = 's';
                        Tansaku(T, Log, cnt + 1, score + S);
                    }
                    else
                    {
                        Tansaku(T, Log, cnt + 1, score);
                    }
                }
            }
        }
        public static void Main()
        {
            string[] In1 = Console.ReadLine().Split(' ');
            N = int.Parse(In1[0]);
            K = int.Parse(In1[1]);
            string[] In2 = Console.ReadLine().Split(' ');
            R = int.Parse(In2[0]);
            S = int.Parse(In2[1]);
            P = int.Parse(In2[2]);
            string T = Console.ReadLine();
            char[] Log = new char[N];
            Tansaku(T, Log, 0, 0);
            Console.WriteLine(max);
        }

    }
}

Measured memory_bytes: 16224
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin>>S;
  bool ok=true;
  for(int i=0;i<S.length();i++)
    if(i%2&&S[i]!='i'||i%2==0&&S[i]!='h')
      ok=false;
  if(ok&&(int)(S.length())%2==0)
    puts("Yes");
  else	puts("No");
  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = list(map(int, input()))
    l = len(n)
    dp = [[-float("inf")]*2 for i in range(l+1)]
    dp[0][0] = 0
    for i in range(l):
        ni = i+1
        for j in range(2):
            x = 9 if j else n[i]
            for d in range(x+1):
                nj = j|(d<n[i])
                c = dp[i][j]+d
                if dp[ni][nj] < c:
                    dp[ni][nj] = c
    print(max(dp[l]))
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39024
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 3
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define mod 998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
// ll fact[1000005];
//ll modIN[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//    modIN[n]=modInverse(fact[n],MOD);
//    for(ll i=n-1;i>=1;i--)
//    {
//        modIN[i] = (modIN[i+1]*(i+1))%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modIN[b]);
//    ret%=MOD;
//    ret*=modIN[a-b];
//    ret%=MOD;
//    return ret;
//}
bool check(vi c)
{
    return (c[2]<(c[0]+c[1]));
}
void solve()
{
    ll n;cin>>n;
    ll ans=0;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    vi v;
    set<ll>s;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            for(ll k=j+1;k<n;k++)
            {
                v.clear();
                v.pb(a[i]);
                v.pb(a[j]);
                v.pb(a[k]);
                s.clear();
                s.insert(v.begin(),v.end());
                if(s.size()!=3)continue;
                sort(v.begin(),v.end());
                ans+=check(v);
               
                
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
   Need_for_speed(activated);
  
//    satisfy
//    {
//        solve();
//    }
   
    solve();
    
    return 0;
}
//Concentrate while implementing,,,!!!
 


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int a, b, c, fix[200], ans;
int main(){
    cin>>a>>b>>c;
    if(a==b&&b==c){cout<<1<<endl;}
    else if(a==b||b==c||a==c)cout<<2<<endl;
    else cout<<3<<endl;
}

Measured memory_bytes: 256
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
#define rep2(i, N, s) for(int (i) = (s); (i) < (N) + (s); (i) ++)
#define rrep(i, N) for(int (i) = (N) - 1; (i) >= (0); (i) --)
#define rrep2(i, N, s) for(int (i) = (s); (i) >= (s) - (N) + 1; (i) --)
#define INF 1e9

#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long ll;
typedef  pair<int, int> pint;


int main(){
    int N;
    cin >> N;
    vector<int> as(3 * N);
    vector<ll> sum(N + 1);
    priority_queue<int, vector<int>, greater<>> q1;//???
    priority_queue<int, vector<int>> q2;

    rep(i, 3 * N){
        cin >> as[i];
    }

    rep(i, N){
        sum[0] += as[i];
        q1.push(as[i]);
    }

    rep2(i, N, N){
        ll tmp = sum[i - N];
        if(as[i] > q1.top()){
            tmp += - q1.top() + as[i];
            q1.pop();
            q1.push(as[i]);
        }
        sum[i - N + 1] = tmp;
    }

    ll tmp = 0;
    rep2(i, N, 2 * N){
        q2.push(as[i]);
        tmp += as[i];
    }

    ll ans = - tmp  + sum[N];

    rrep2(i, N, 2 * N - 1){
        if(q2.top() > as[i]){
            tmp += - q2.top() + as[i];
            q2.pop();
            q2.push(as[i]);
        }
        ans = max(ans, - tmp + sum[i - N]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    int K;
    cin >> K;
    cin >> S;
    if(K>=(int)S.length()){
        cout<<S<<endl;
    }
    else{
        string add;
        S = S.substr(0,K);
        add = "...";
        cout<<S+add<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n, temp;
int main(){
    cin >> n;
    int a, stuff[n+1];
    for (int i=1; i<=n; i++){
        cin >> a;
        stuff[a] = i;
    }
    for (int i=1; i<=n; i++){
        cout << stuff[i] << " ";
    }
}

Measured memory_bytes: 1152
N = int(input())
lst_s = [int(input()) for _ in range(N)]
lst_s.sort()
max_grade = sum(lst_s)
ans = 0


if max_grade % 10 != 0:
    ans = max_grade
else:
    for s in lst_s:
        tmp_grade = max_grade - s
        if tmp_grade % 10 != 0:
            ans = max(ans, tmp_grade)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <map>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int q, com;
	std::string key;
	long x;
	std::multimap<std::string, long> m;
	std::string L, R;
	std::string buf;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif
	
	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> com;
#else
		std::cin >> com;
#endif
		if(com == 0){
#if INPUT_FROM_FILE
			ifs >> key >> x;
#else
			std::cin >> key >> x;
#endif
			m.emplace(key, x);
		}
		else if(com == 1){
#if INPUT_FROM_FILE
			ifs >> key;
#else
			std::cin >> key;
#endif
			auto p = m.equal_range(key);
			for(auto it = p.first; it != p.second; it++){
				std::cout << it->second << std::endl;
			}
		}
		else if(com == 2){
#if INPUT_FROM_FILE
			ifs >> key;
#else
			std::cin >> key;
#endif
			m.erase(key);
		}
		else{
#if INPUT_FROM_FILE
			ifs >> L >> R;
#else
			std::cin >> L >> R;
#endif
			std::map<std::string, long>::iterator it = m.lower_bound(L);
			std::map<std::string, long>::iterator end = m.upper_bound(R);
			for(; it != end; it++){
				std::cout << it->first << " " << it->second << std::endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 24856
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int x[101], y[101];

int main(){
    cin >> n;
    REP(i, n){
        cin >> x[i] >> y[i];
    }
    double ans = 0.0;
    REP(i, n){
        if(x[i] == 0 && y[i] == 0)continue;
        double a = -atan2(y[i], x[i]) + 1e-9;
        double tmpx1 = 0.0, tmpy1 = 0.0, tmpx2 = 0.0, tmpy2 = 0.0;
        REP(j, n){
            double dx = cos(a) * x[j] - sin(a) * y[j];
            double dy = sin(a) * x[j] + cos(a) * y[j];
            if(dy > 0.0){
                tmpx1 += dx;
                tmpy1 += dy;
            }else{
                tmpx2 += dx;
                tmpy2 += dy;
            }
        }
        ans = max(ans, hypot(tmpx1, tmpy1));
        ans = max(ans, hypot(tmpx2, tmpy2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#define Max 100
#define Inf 2147483647
#define w 0
#define x 1
#define z 2

int n, m[Max][Max];

void d(){
  int min;
  int d[Max],alpha[Max];
  int i;
  for(i = 0 ;i< n;i++){
    d[i] = Inf;
    alpha[i] = Inf;
  }
  d[0]=0;
  alpha[0]=x;
  int u;
  while(1){
    min = Inf;
    u = -1;
    for(i = 0;i<n;i++){
      if(min > d[i] && alpha[i] != z){
        u = i;
        min = d[i];
      }
    }
    if(u == -1)break;
    alpha[u] = z;
    for(i = 0;i<n;i++){
      if(alpha[i]!= z &&m[u][i] != Inf){
        if(d[i] > d[u] + m[u][i]){
          d[i] = d[u] + m[u][i];
        }
      }
    }
  }
  int v;
  for(i = 0 ;i< n;i++){
    v = d[i];
    if(d[i] == Inf) v = -1;
    printf("%d %d\n",i,v);
  }
}

int main(){
  scanf("%d",&n);
  int i,j;
  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
      m[i][j] = Inf;
    }
  }
  int k,c,u,v;
  for(i = 0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j = 0;j<k;j++){
      scanf("%d %d",&v,&c);
      m[u][v] = c;
    }
  }
  d();
  return 0;
}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N,M;
  cin >> N >> M;

  ll ans=0;
  for(ll i=1;i*i<=M;i++){
    if(M%i!=0)  continue;
    if(M/i >= N)  chmax(ans,i);
    if(M/(M/i) >= N)  chmax(ans,(M/i));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{int a[3];
  for(int i=0;i<3;i++)
  {
    cin>>a[i];
  }
 sort(a,a+3);
 if(a[0]==5&&a[1]==5&&a[2]==7)
   cout<<"YES";
 else
   cout<<"NO";
   
  return 0;}


Measured memory_bytes: 2964
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int i,j;
  int a[100004]={0,0,1,1},b[100001]={0,1,2},c[100001]={0,1,2};
  for(i=4;i<100002;++i){
    a[i]=(a[i-1]<<1)-a[i-4];
    if(a[i]<0)
      a[i]+=100000007;
    else
      a[i]%=100000007;
    b[i-1]=(b[i-2]+a[i])%100000007;
  }
  a[2]=a[3]=0;
  a[4]=a[5]=1;
  for(i=6;i<100004;++i){
    a[i]=(a[i-1]<<1)-a[i-6];
    if(a[i]<0)
      a[i]+=100000007;
    else
      a[i]%=100000007;
    c[i-3]=(c[i-4]+a[i])%100000007;
  }
  char s[100001];
  while(scanf("%s",s),s[0]!='#'){
    int ct=1;    
    for(i=0;s[i]!='\0';i=j){
      for(j=i+1;s[i]==s[j];++j);
      if((s[i]-'0')%8){
	ct=(long long)ct*c[j-i]%100000007;
      }else{
	ct=(long long)ct*b[j-i]%100000007;
      }
    }
    printf("%d\n",ct);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;
bool check(int a,int b,int c)
{    if(a!=b && b!=c && a!=c)
     {if((a+b)>c && (b+c)>a && (c+a)>b)
      {  if((a-b)<c && (b-c)<a && (c-a)<b)
            return true;
            return false;
       }
       } 
    return false;
}
void solve()
{ 
  int n;
  cin>>n;
  int l[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>l[i];
  }
  int ct=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=i+1;j<=n;j++)
    {
      for(int k=j+1;k<=n;k++){

        if(check(l[i],l[j],l[k]))
          {//debug2(i,j);
            //debug(k);
            ct+=1;
          }
      }
    }
  }
  cout<<ct;
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

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

#define int long long 

#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define pb push_back
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MP make_pair
#define sqr(x) ((x) * (x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int calc(int n, int k) {
	if (n % k == 0) return n / k;
	if (n < k) return 0;
	int d = n / k;
	assert(d > 0);
	int can = (n - d * k - 10) / (d + 1);
	can = max(can, 1ll);
	return calc(n - can * (d + 1), k);
}

signed main() {
	fastio;
	#ifdef FlameDragon
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, k;
		cin >> a >> k;
		ans ^= calc(a, k);
	}
	cout << (ans ? "Takahashi\n" : "Aoki\n");
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	private static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {

		String s = scan.next();
		int a = (s.length() -1)/2;
		int b = (s.length()+3)/2-1;
		String fString = s.substring(0 , a);
		String lString = s.substring(b, s.length());

		if(fString.equals(lString)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21844
n = int(input())
ans = list(input())
for i in range(n - 1):
    s = list(input())
    tmp = []
    for i in range(len(s)):
        if s[i] in ans:
            tmp.append(s[i])
            ans.remove(s[i])
    ans = tmp
ans.sort()
print("".join(ans))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;

int main()
{
    stat();
    ull ans=1;
    int n;cin>>n;
    rep(i,n){
ans*=(i+1);
ans%=mod;
    }
    cout<<ans<<endl;

    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

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

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

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

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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> a(n,0);
    REP(i,n) cin>>a[i];
    llong ans=0;
    sort(a.begin(),a.end());
    int cnt=0;
    int ll=0;
    if(n==1)
    {
        if(a[0]==0) cout<<1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    else if(n==2)
    {
        if(a[0]==1&&a[1]==1) cout<<2<<endl;
        else cout<<0<<endl;
        return  0;
    }
    
    for(int i=0; i<n-1; i++)
    {
        if(a[i]==a[i+1]) ++cnt;

    }
    ll=n-cnt;

        if (cnt == n / 2) {
            if (n % 2 != 0) {
                if (a[0] == 0 && a[1] != 0&&ll==(n+1)/2) ans = modpow(2, n / 2, MOD);
            } else if (n % 2 == 0) {
                if (a[0] == 1 && a[2] != 1&&ll==n/2) ans = modpow(2, n / 2, MOD);
            } else ans = 0;
        }

    cout<<ans<<endl;

    return  0;
}


Measured memory_bytes: 640
n = int(input())
s = []
t = []
ans = 0
for i in range(n):
    s1,t1 = input().split()
    s.append(str(s1))
    t.append(int(t1))
x = str(input())
for j in range(n):
    if s[j] == x:
        print(sum(t[j+1:n+1]))

Measured memory_bytes: 3064
M, D = map(int, input().split())
c=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1 = d%10
    d10 = d//10
    if d1>1 and d10>1 and d1*d10==m:
      c+=1
print(c)

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
	ll n;
	cin >> n;
	cout << (n+1)/2 << endl;
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 

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

int main(){
    int a, b;
        cin >> a >> b;
        cout << a/b << " ";
        cout << a%b << " " << flush;

        cout << fixed << setprecision(6);
        cout << (double)a/(double)b << endl;
    }
    


Measured memory_bytes: 3260
function Main(input){
    // 入力値取得
    input = input.split(" ");

    // 変数定義
    var total = parseInt(input[0], 10);
    var make1 = parseInt(input[1], 10);
    var time1 = parseInt(input[2], 10);
    var result = 0;
    var amari = 0;

    //全ての数を一度に作れる最大個数で割る
    result = total / make1;
    
    //割った数に余りがあれば小数点以下を切り上げ
    result =Math.ceil(result);
    
    //一気に作れる時間に結果をかける
    result = result * time1;
    
console.log('%s', result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29540
#include<bits/stdc++.h>
using namespace std;
struct point
{
    double x,y;
};
double dist(point a,point b)
{
    return (sqrt((((b.x-a.x)*(b.x-a.x))+((b.y-a.y)*(b.y-a.y)))));
}
int orientation(point a,point b,point c)
{
    double val=((b.y-a.y)*(c.x-b.x))-((c.y-b.y)*(b.x-a.x));
    if(val==0)
    {
        if(dist(a,c)+dist(c,b)==dist(a,b))
            return 0;
        else if(dist(a,c)>dist(c,b))
            return 1;
        else
            return 2;
    }
    return (val>0)? 3:4;
}
int main()
{
    int t,res;
    double x1,y1,x2,y2,x3,y3;
    point p,q,r;
    cin>>x1>>y1>>x2>>y2;
    p.x=x1;
    p.y=y1;
    q.x=x2;
    q.y=y2;
    cin>>t;
    while(t--)
    {
        cin>>x3>>y3;
        r.x=x3;
        r.y=y3;
        res=orientation(p,q,r);
        if(res==0)
        {
            cout<<"ON_SEGMENT"<<endl;
        }
        else if(res==1)
        {
            cout<<"ONLINE_FRONT"<<endl;
        }
        else if(res==2)
        {
            cout<<"ONLINE_BACK"<<endl;
        }
        else if(res==3)
        {
            cout<<"CLOCKWISE"<<endl;
        }
        else if(res==4)
        {
            cout<<"COUNTER_CLOCKWISE"<<endl;
        }
    }

}



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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

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

  vector<ll> csum{0};
  partial_sum(va.begin(), va.end(), back_inserter(csum));
  map<ll, ll> cnts;
  for (auto s : csum) {
    cnts[s % m]++;
  }

  ll ans = 0;
  for (auto &p : cnts) {
    ans += (p.second * (p.second - 1)) / 2;
  }

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

Measured memory_bytes: 8624
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int a, b;
            cin >> a >> b;
                if(a%3==0 || b%3==0 || (a+b)%3==0){
                    cout << "Possible" << endl;
                }else{
                    cout << "Impossible" << endl;
                }
    return 0;}

Measured memory_bytes: 256