akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    dd = defaultdict(int)
    res=0

    for i in a:
        dd[i]+=1 
    for i in dd.keys():
        if dd[i]<i:
            res += dd[i]
        elif dd[i]>i:
            res += dd[i]-i 
            dd[i] = i 
    print(res)
            



if __name__ == "__main__":
    main()


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


int main(){


    int d, i;


    cin >> d;


    cout << "Christmas" ;


    for( i = 0 ; i < 25 - d ; i = i + 1 ){

         cout << " Eve" ;

         }


    cout << endl;

    
    return 0;


    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define sec second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
const ll INF=LLONG_MAX,MOD=1e9+7;
const int L=17,N=1<<L;

ll n;

int main(){
	ios::sync_with_stdio(false);
	string s;cin>>s;n=s.size();
	for(int i=1;i<n;i++){
		if(s[i]=='C'&&s[i-1]=='A')
			return cout<<"Yes",0;
	}
	cout<<"No";
	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 n = sc.nextInt();
        for(int i=1; i<10; i++) {
            for(int j=1; j<10; j++) {
                if(i*j == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35628
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

const string YES = "Yes";
const string NO = "No";
string S;

void solve(){
	sort(ALL(S));
	if(S[0] == S[1] and S[2] == S[3] and S[0]!=S[2]){
		cout<<YES<<endl;
	}else{
		cout<<NO<<endl;
	}
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> S;
	solve();
	return 0;
}
//}}}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(n);
  string list_input(a, n);
  string MARCH = "MARCH";
  long long fields[MARCH.size()];
  memset(fields, 0, sizeof fields);
  map<char, int> index;
  rep(i, MARCH.size()) {
    index[MARCH[i]] = i;
  }

  forin(i, a) {
    if(
        i[0] == 'M' or
        i[0] == 'A' or
        i[0] == 'R' or
        i[0] == 'C' or
        i[0] == 'H'
        ) {
      fields[index[i[0]]]++;
    }
  }

  long long result = 0;
  int m = MARCH.size();
  FOR(i, 0, m) {
    FOR(j, i + 1, m) {
      FOR(k, j + 1, m) {
        result += fields[i] * fields[j] * fields[k];
      }
    }
  }
  out(result);
}


Measured memory_bytes: 6144
r, n = map(int, input().split())
num = list(map(int, input().split()))
ans = 0
for i in range(n-1):
  max_bet = abs(num[i] - num[i+1])
  ans = max(ans, max_bet)
bet = r-num[n-1]+num[0]
ans = max(ans, bet)
print(r-ans)


Measured memory_bytes: 26420
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; ++i) {
    if (s[i] == '?') {
      s[i] = 'D';
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int w[n];
	int s=0;
	for(int i=0;i<n;i++){
		cin>>w[i];
		s+=w[i];
	}
	int ls=0;
	int rs=s;
	int mn=INT_MAX;
	for(int i=0;i<n;i++){
		ls+=w[i];
		rs-=w[i];
		mn=min(abs(ls-rs),mn);
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
struct T{ int to, nxt; } way[maxn << 2];
int h0[maxn], h1[maxn], num;
inline void link(int x,int y,int * h) {
	way[++num] = {y,h[x]}, h[x] = num;
	way[++num] = {x,h[y]}, h[y] = num;
}
int n, x, y;
int fa[maxn], dep[maxn];
inline void dfs0(int x,int f = 0) {
	fa[x] = f, dep[x] = dep[f] + 1;
	for(int i = h1[x];i;i = way[i].nxt) if(way[i].to != f)
		dfs0(way[i].to, x);
}
int a[maxn], b[maxn];
int import[maxn], vis[maxn];
inline bool chk(int x,int y) {
	if(dep[x] > dep[y]) x = fa[x]; else y = fa[y];
	if(x == y) return 0;
	if(dep[x] > dep[y]) x = fa[x]; else y = fa[y];
	return x != y;
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> x >> y;
	for(int i = 1;i < n;++i) cin >> a[i] >> b[i], link(a[i], b[i], h0);
	for(int i = 1, x, y;i < n;++i) cin >> x >> y, link(x, y, h1);
	dfs0(y);
	for(int i = 1;i < n;++i) if(chk(a[i], b[i])) import[a[i]] = import[b[i]] = 1;
	std::queue<int> q; q.push(x); vis[x] = 1;
	int ans = dep[x];
	for(;!q.empty();) {
		int t = q.front(); q.pop();
		if(import[t]) return puts("-1"), 0;
		for(int i = h0[t];i;i = way[i].nxt) {
			if(!vis[way[i].to]) {
				vis[way[i].to] = vis[t] + 1;
				if(vis[way[i].to] < dep[way[i].to]) {
					q.push(way[i].to);
					ans = std::max(ans, dep[way[i].to]);
				}
			}
		}
	}
	std::cout << ans * 2 - 2 << '\n';
}


Measured memory_bytes: 16768
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
K=gets.to_i
N=S.size
ans=[]
N.times do|i|
  s=""
  i.upto(min(N-1,i+K-1)) do|j|
    s+=S[j] 
    ans.push(s)
  end
end
puts ans.sort.uniq[K-1]

Measured memory_bytes: 16444
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  int ans = 0;
  while (n != 0) {
    ans++;
    n = n/k;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x=7,k,i,j;
	cin>>k;
	for(i=1;i<k+10;i++){
		if(x%k==0){
			cout<<i<<endl;
			return 0;
		}
		x%=k;
		x=x*10+7;
	}
	cout<<-1<<endl;
	return 0;
}


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

int main() {
	int N;
	string str;
	cin >> str;
	cin >> N;
	int goodR=0;
	for(int i=0;i<N;i++){
		string ring;
		cin >> ring;
		ring+=ring;
		int now=0;
		for(int j=0;j<20;j++){
			if(str[now]==ring[j])
			now++;
			else if(str[0]==ring[j])
			now=1;
			else
			now=0;
			if(now==str.length()){
			goodR++;
			break;
			}
		}
	}
	cout << goodR << endl;
	return 0;
}

Measured memory_bytes: 1208
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)

for i in p[:X]:
    r.append(i)
for j in q[:Y]:
    r.append(j)
r.sort(reverse=True)
print(sum(r[:X + Y]))

Measured memory_bytes: 22560
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

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

int main() {
    int N;
    cin >> N;

    int X[N], L[N];
    rep(i, N) cin >> X[i] >> L[i];

    typedef pair<int, int> P;
    vector<P> V;
    rep(i, N) {
        int a = X[i] - L[i];
        int b = X[i] + L[i] - 1;
        V.push_back(P(a, b));
    }
    sort(all(V));
    reverse(all(V));

    int ans = 0;
    int a, b;
    for (auto iter = V.begin(); iter != V.end(); ++iter) {
        P v = *iter;
        if (iter == V.begin()) {
            a = v.first;
            b = v.second;
            ++ans;
            continue;
        }
        if (v.second < a) {
            a = v.first;
            b = v.second;
            ++ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 2168
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	l := p.NextInts()
	a, b := l[0], l[1]
	max := a + b
	if (a - b) > max {
		max = a - b
	}
	if a*b > max {
		max = a * b
	}
	p.PrintInt(max)
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

string s;
int n, k;
int a[100],b[100],c[100];
int ans;
signed main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    for (int i=0;i<n;i++) {
        cin >> b[i];
    }
    for (int i=0;i<n-1;i++) {
        cin >> c[i];
    }
    int tmp = a[0];
    for (int i=0;i<n;i++) {
        ans += b[i];
        if (i>=1 && a[i] == tmp + 1) ans += c[tmp-1];
        tmp = a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a*b*c == 175)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	if (k==1)
	{
		cout<<"0\n";
	}
	else
	{
		cout<<n-k<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll calCost(vector<ll> &a, ll x){
    ll cost = 0;
    for(ll i=0; i< a.size(); i++){
        cost += (a[i]-x)*(a[i]-x);
    }
    return cost;
}

void solve(long long N, std::vector<long long> a){
    sort(a.begin(), a.end());
    ll best, best_cost=1LL << 60;
    for(ll i=a[0]; i <= a[N-1]; i++){
        ll tmp = calCost(a, i);
        if(tmp < best_cost){
            best_cost = tmp;
            best = i;
        }
    }
    cout << best_cost << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

string ab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, key[100];
    string cip;
    while(cin >> n && n){
        for(int i = 0; i < n; i++){
            cin >> key[i];
        }
        cin >> cip;
        for(int i = 0; i < cip.size(); i++){
            int ind = lower_bound(ab.begin(), ab.end(), cip[i])-ab.begin();
            cout << ab[(ind - key[i%n] + 52) % 52];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()

dp = [-1 for _ in range(N+1)]
dp[0] = 0
queue = deque([0])

while len(queue) > 0:
    current = queue.popleft()
    
    pow6 = 1
    while current+pow6 <= N:
        if dp[current+pow6] == -1:
            queue.append(current+pow6)
            dp[current+pow6] = dp[current]+1
        pow6 *= 6

    pow9 = 1
    while current+pow9 <= N:
        if dp[current+pow9] == -1:
            queue.append(current+pow9)
            dp[current+pow9] = dp[current]+1
        pow9 *= 9
print(dp[N])
    
        


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


int main(){
    int x, n;
    cin >> x >> n;
    int p[110];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=0; ; i++){
        bool isok = true;
        for(int j=0; j<n; j++){
            if(x-i == p[j]) isok = false;
        }
        if(isok){
            cout << x-i << endl;
            break;
        }
        isok = true;
        for(int j=0; j<n; j++){
            if(x+i == p[j]) isok = false;
        }
        if(isok){
            cout << x+i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d,e,f;

int u=17*60+30,v=19*60+30;

int t[8][8]={
  {0,0,0,0,0,0,0,0},
  {0, 0, 300, 500, 600, 700,1350,1650},
  {0, 6,   0, 350, 450, 600,1150,1500},
  {0,13,   7,   0, 250, 400,1000,1350},
  {0,18,  12,   5,   0, 250, 850,1300},
  {0,23,  17,  10,   5,   0, 600,1150},
  {0,43,  37,  30,  25,  20,   0, 500},
  {0,58,  52,  45,  40,  35,  15,   0}
};

bool check(){
  if(t[max(a,d)][min(a,d)]>40)return false;
  
  int x=b*60+c,y=e*60+f;

  if((x<u||v<x)&&(y<u||v<y)){
    return false;
  }

  return true;
}
int change(int x){
  if(x%100==50){
    x-=50;
    return x/2+50;
  }else{
    return x/2;
  }
}

int main(){
  while(cin>>a&&a){
    cin>>b>>c>>d>>e>>f;
    if(check()){

      cout<<change(t[min(a,d)][max(a,d)])<<endl;
    }else{
      cout<<t[min(a,d)][max(a,d)]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<char> Vec(8);
	vector<char> VecMax(8);
	vector<char> VecMin(8);
	while(n--)
	{
		for(int i = 0; i < 8; ++i)
		{
			cin >> Vec[i];
		}
		VecMax = Vec;
		VecMin = Vec;
		sort(VecMax.begin(), VecMax.end(), greater<char>());
		sort(VecMin.begin(), VecMin.end());
		int Max = 0;
		int Min = 0;
		int count = 1;
		for(int i = 7; i >= 0; --i)
		{
			Max += (VecMax[i] - '0') * count;
			Min += (VecMin[i] - '0') * count;
			count *= 10;
		}
		cout << Max - Min << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(list(input()))
    #S.append(list(i for i in input()))
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            cnt = 0
            if i != 0:
                cnt += S[i-1][max(0,j-1):min(j+1,W-1)+1].count('#')
            cnt += S[i][max(0,j-1):min(j+1,W-1)+1].count('#')
            if i != H-1:
                cnt += S[i+1][max(0,j-1):min(j+1,W-1)+1].count('#')
            S[i][j] = str(cnt)
for i in range(H):
    print(''.join(S[i]))

Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(' ').map { it.toInt() }

    val ans = if (c >= Math.min(a, b) && c <= Math.max(a, b)) {
        "Yes"
    } else {
        "No"
    }

    println(ans)
}

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

using namespace std;

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

  int N; cin>>N;
  string S; cin>>S;
  int l = 0;
  int ans = 0;
  auto abc = "ABC";
  for (char c : S) {
    if (c == abc[l]) {
      l++;
      if (l == 3) {
        ans++;
        l = 0;
      }
    } else {
      l = 0;
      if (c == abc[l])
        l++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	ll res = 0;
	rep(i,1,n+1){
		if(i % 3 && i % 5){
			res += i;
		}
	}
	cout << res << '\n';
}


Measured memory_bytes: 3648
N = int(input())
A = [int(input()) for _ in range(N)]


mydict = dict()
cnt = 0

for i in range(N):
    if not (A[i] in mydict):
        mydict[A[i]] = i
        
counter = [0] * N
for a in A:
    counter[mydict[a]] += 1
    
ans = 0
for c in counter:
    if c%2 == 1: ans += 1
    
print(ans)

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

using namespace std;
 
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(x) (int) ((x).size()) 
#define forn(i, n) for (int i = 0; (i) < (n); ++i)
#define fornr(i, n) for (int i = (n) - 1; (i) >= 0; --i)
#define forab(i, a, b) for (int i = (a); (i) < (b); ++i)
#define forba(i, a, b) for (int i = (b) - 1; (i) >= (a); --i)
#define forit(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end() 

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) static_cast<void>(0)   
#endif

#ifdef _WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector <int> vi;
typedef pair <int, int> pii;

#define FNAME ""

int main() {
#ifdef LOCAL    
	freopen(FNAME".in", "r", stdin);
	freopen(FNAME".out", "w", stdout); 
#endif    

	char s[100];

	scanf("%s", s);
	forn (i, 4)
		printf("%c", s[i]);
	printf(" ");
	forab (i, 4, 12)
		printf("%c", s[i]);
	puts("");
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[101];
    char c;
    int ans = 0;
    int ANS = 0;
    for(int i=0; i<n; i++) {
        cin>>c;
        a[i] = c - 'a';
    }
    for(int i=1; i<n; i++) {
        ans = 0;
        int x[26], y[26];
        memset(x, 0, sizeof(x));
        memset(y, 0, sizeof(y));
        for(int j=0; j<i; j++)
            x[a[j]] = 1;
        for(int j=i; j<n; j++)
            y[a[j]] = 1;
        for(int j=0; j<26; j++) {
            if(x[j] == 1 && y[j] == 1) {
                ans ++;
                //cout<<j<<'\t'<<y[j]<<endl;
            }
            //cout<<endl;
        }
        ANS = max(ANS, ans);
    }
    cout<<ANS<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cmath>
#include<string>
using namespace std;
 
int main(){
    long long int N,c=0,d=0;
    char g[11];
    
  cin>>N;
  string j[N];
  
  for(int i=0;i<N;i++){
      cin >> g;
     sort(g,g+10);
      j[i]=g;
  }
  sort(j,j+N);
  for(int i=0;i<N;i++){
    
      if(j[i]==j[i+1]){
          d++;
      continue;
      }
      else{ for(int j=d;j>0;j--)    
          c+=j;
   
      }
      d=0;
  }
  cout <<c;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    vi abc(3);
    int* a;
    int* b;
    int* c;

    a = &(abc[0]);
    b = &(abc[1]);
    c = &(abc[2]);
    cin>>(*a)>>(*b)>>(*c);
    sort(ALL(abc));
    if((*a==*b && *b!=*c) || (*b==*c && *b!=*a)){
       cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    int n,m;cin>>n>>m;
    vi v(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        v[a-1]++;
        if(b!=n)v[b]--;
    }
    rep(i,n-1)v[i+1]+=v[i];
    ll ans=0;
    rep(i,n)if(v[i]==m)ans++;
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n,m;cin>>n>>m;
	ll ans=0;
	ans=1900*m+100*(n-m);
	ll k=1;
	rep(i,m)k*=2;
	ans*=k;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int n, LEN = 402;
	int[] ar;
	int[] d;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt();
			if(n == 0) break;
			ar = new int[n*(n-1) / 2];
			for(int i=0;i<n*(n-1)/2;i++) ar[i] = sc.nextInt();
			d = new int[LEN];
			for(int i: ar) d[i]++;
			ans = new int[n]; ans[n-1] = ar[0];
			d[ar[0]]--;set = new HashSet<V>();
			dfs(1, n-2);
			System.out.println("-----");
		}
	}
	
	int[] ans;
	HashSet<V> set;
	void dfs(int l, int r) {
//debug("l", l, r, d,ans);
		if(l > r) {
			if(!set.contains(new V(ans)))for(int i=1;i<n;i++) 
				System.out.print(ans[i]-ans[i-1] + (i==n-1? "\n": " "));
			set.add(new V(ans));
			return;
		}
		int dist;
		for(dist=LEN-1;;dist--) if(d[dist]>0) break;
		
		//left
		ans[l] = ans[n-1] - dist;
		boolean ok = true;
		for(int i=0;i<l;i++) {
			d[ans[l]-ans[i]]--;
			if(d[ans[l]-ans[i]] < 0) ok = false;
		}
		for(int i=r+1;i<n;i++) {
			d[ans[i]-ans[l]]--;
			if(d[ans[i]-ans[l]] < 0) ok = false;
		}
		if(ok) dfs(l+1, r);
		for(int i=0;i<l;i++) d[ans[l]-ans[i]]++;
		for(int i=r+1;i<n;i++) d[ans[i]-ans[l]]++;

//debug("r", l, r, d,ans, ans[r+1]-dist);
		//right
		ans[r] = ans[0] + dist;
		ok = true;
		for(int i=0;i<l;i++) {
			d[ans[r]-ans[i]]--;
			if(d[ans[r]-ans[i]] < 0) ok = false;
		}
		for(int i=r+1;i<n;i++) {
			d[ans[i]-ans[r]]--;
			if(d[ans[i]-ans[r]] < 0) ok = false;
		}
		if(ok) dfs(l, r-1);
		for(int i=0;i<l;i++) d[ans[r]-ans[i]]++;
		for(int i=r+1;i<n;i++) d[ans[i]-ans[r]]++;
	}
	
	class V {
		int[] a;
		V(int[] a) {
			this.a = new int[n];
			System.arraycopy(a, 0, this.a, 0, n);
		}
		
		public int hashCode() {
			int h=0, p=1;
			for(int i=0;i<n;i++,p*=400) h += p*a[i];
			return p;
		}
		
		public boolean equals(Object o) {
			if(o instanceof V) {
				V v = (V)o;
				for(int i=0;i<n;i++) if( a[i] != v.a[i] ) return false;
				return true;
			}
			return false;
		}
	};

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

#define MAX_V 310
#define INF 1e9

struct edge{
  int to,cap,cost,rev;
  edge(int to,int cap,int cost,int rev) :
    to(to),cap(cap),cost(cost),rev(rev) {}
};

vector<edge> G[MAX_V];
int dist[MAX_V],prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(edge(to,cap,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

 
int min_cost_flow(int s,int t,int f){
  int res = 0;
  while(f > 0){
    fill(dist,dist+MAX_V,INF); dist[s] = 0;
    bool update = true;
    while(update){
      update = false;
      for(int v = 0 ; v < MAX_V ; v++){
        if(dist[v] == INF) continue;
        for(int i = 0 ; i < (int)G[v].size() ; i++){
          edge &e = G[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
            dist[e.to] = dist[v] + e.cost;
            prevv[e.to] = v; preve[e.to] = i; update = true;
          }
        }
      }
    }
    if(dist[t] == INF) return -1;
    int d = f;
    for(int v = t ; v != s ; v = prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].cap);
    }
    f -= d; res += d * dist[t];
    for(int v = t ; v != s ; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d; G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int N,p[MAX_V];
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> p[i];
  }
  int s = 2*N+1,t = s+1;
  for(int i = 0 ; i < N ; i++){
    add_edge(s,i+1,1,0);
    add_edge(N+i+1,t,1,0);
  }
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      if(i+1 == p[j]) continue;
      add_edge(i+1,N+j+1,1,p[j]*abs(i-j));
    }
  }
  cout << min_cost_flow(s,t,N) << endl;
  return 0;
}

Measured memory_bytes: 1632
import java.util.*

fun main(args:Array<String>) {
    val scanner= Scanner(System.`in`)
    var ae=IntArray(5)
    var t=IntArray(5)
    var m=10
    for (i in 0 until 5){
        ae[i]=scanner.nextInt()
        t[i]=ae[i]%10
        if (t[i]!=0){
            if (m>t[i]) m=t[i]
        }
    }

    println(ae.sum()+(10*(5-t.count { it==0 }))-t.sum()-10+m)
}


Measured memory_bytes: 36040
// AOJ 2019 "お姫様の嫁入り" (ICPC模擬国内予選 2008 Problem B)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final int MAX_P = 10;
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            int num = 0; // 刺客に襲われる回数の期待値の最大値
            int[] e = new int[MAX_P+1]; // e[i]: 期待値iの総距離長
            for (int i = 0; i < n; i++) {
                int d = sc.nextInt();
                int p = sc.nextInt();
                e[p] += d;
                num += d * p;
            }
            
            for (int i = MAX_P; i >= 1; i--) {
                int pay = Math.min(e[i], m);
                num -= i * pay;
                m -= pay;
                if (m <= 0) {
                    break;
                }
            }
            System.out.println(num);
        }
    }
}

Measured memory_bytes: 65240
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,h,i,j,k,l,m,n,v,w,x,y;
	ll		ans = 0;
	char	c;
	string	s;
	cin >> c;
	if (c>='a') cout << 'a' << endl;
	else cout << 'A' << endl;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

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


Measured memory_bytes: 3620
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,c = li()
print(b + min(a+b+1, c))

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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  int ans = a[N-1] - a[0];
  cout << ans  << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}

int cnt(int a, int p) {
    int d = p;
    int res = 0;
    while (d <= a) {
        res += a / d;
        d *= p;
    }
    return res;
}



void oneCase () {
    int n;
    cin >> n;
    vector<int> d;
    for (int i = 2; i <= n; ++i) {
        if (isPrime(i) == 0) {
            continue;
        }
        d.push_back(1 + cnt(n, i));
    }
    ll res = 1;
    ll mod = 1e9 + 7;
    for (auto v : d) {
        res = (res * v) % mod;
    }
    cout << res << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=list(input() for i in range(n))
mc=ac=rc=cc=hc=0
cnt=0
for i in range(n):
    if s[i][0] == "M":
        mc+=1
    elif s[i][0] == "A":
        ac+=1
    elif s[i][0] == "R":
        rc+=1
    elif s[i][0] == "C":
        cc+=1
    elif s[i][0] == "H":
        hc+=1
lis = [mc,ac,rc,cc,hc]
if sum(lis) == 0:
    print(0)
else:
    for i in range(5):
        for j in range(i+1,5):
            for k in range(j+1,5):
                cnt+=lis[i]*lis[j]*lis[k]
    print(cnt)

Measured memory_bytes: 9764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 100000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;


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

	ll n;
	cin >> n;
	vi a(n),b(n);
	int x = 0;
	REP(i,1, n+1) {
		cin >> a[i-1];
		b[i - 1] = abs((i - 1) - (n - i));
		//cout << a[i - 1] << b[i - 1] << endl;
	}
	sort(all(a));
	sort(all(b));
	if (a != b) {
		puts("0");
		return 0;
	}
	ll ans = 1;
	rep(i, n / 2) {
		ans *= 2;
		ans %= 1000000000 + 7;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n=3;
    int i;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<abs(a[2]-a[1])+abs(a[1]-a[0])<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;

#define ll long long
#define mst(a) memset(a, 0, sizeof a)

const int mod = 1e9+7;
const int maxn = 1e5+50;
const int inf = 1e9;

int a[maxn];
int c[105][105];

int main()
{
//    freopen("in", "r", stdin);
    int n;
    int m;
    int k;
    scanf("%d %d %d", &n, &m, &k);
    for (int i = 0; i < k; ++i)
        scanf("%d", &a[i]);
    int cnt = 0;
    int now = 0;
    for (int i = 0; i < n; ++i)
    {
        if (i & 1)
        {
            for (int j = m-1; j >= 0; --j)
            {
                c[i][j] = now + 1;
                cnt ++;
                if (cnt == a[now])
                {
                    cnt = 0;
                    now ++;
                }
            }
        }
        else 
        {
            for (int j = 0; j < m; ++j)
            {
                cnt ++;
                c[i][j] = now + 1;
                if (cnt == a[now])
                {
                    cnt = 0;
                    now ++;
                }
            }
        }
    }   
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
        {
            if (j < m-1) printf("%d ", c[i][j]);
            else printf("%d\n", c[i][j]);
        }
    return 0;
}

Measured memory_bytes: 384
# Contest: AtCoder Beginner Contest 143 (https://atcoder.jp/contests/abc143)
# Problem: B

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


n = rint()
d = rints()
s = 0
for i in range(n):
    for j in range(i + 1, n):
        s += d[i] * d[j]
print(s)


Measured memory_bytes: 38512
def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [input() for _ in range(height)]

    def bit_patterns(height, width):
        for num_h in range(2 ** height):
            for num_w in range(2 ** width):
                yield num_h, num_w

    def count_black(height, width, num_h, num_w):
        for bit_h in range(height):
            for bit_w in range(width):
                if num_h >> bit_h & 1 or num_w >> bit_w & 1:
                    continue
                yield table[bit_h][bit_w] == '#'

    def black_matched(height, width):
        for ii, jj in bit_patterns(height, width):
            yield sum(count_black(height, width, ii, jj)) == leave_black

    print(sum(black_matched(height, width)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n;
char s1[100],s2[100];

int a[2][2] = {
	{2,2},
	{1,3}
};

int main(){
	cin >> n;
	cin >> s1;
	cin >> s2;

	int i = 0;

	ll ans;

	if(s1[i] == s2[i]) {
		ans = 3;
		i++;
	}else {
		ans = 6 ;
		i += 2;
	}

	while(i < n) {
		int p = (s1[i - 1] != s2[i - 1]);
		int q = (s1[i] != s2[i]);

		ans *= a[p][q];

		ans %= 1000000007;

		if(q) {
			i += 2;
		}else{
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k;
string s;
vector<int> val;
vector<int> rval;

signed main() {
	int i;
	
	cin >> n >> k >> s;
	
	if (s[0] == '0') val.push_back(0);
	
	int len = 0;
	rep(i, n) {
		if (i > 0 && s[i] != s[i - 1]) {
			val.push_back(len);
			len = 1;
		}
		else {
			len++;
		}
	}
	val.push_back(len);
	
	//rep(i, val.size()) cout << "val[" << i << "] = " << val[i] << endl;
	
	rval.resize(val.size() + 1);
	rval[0] = 0;
	rep(i, val.size()) rval[i + 1] = rval[i] + val[i];
	
	int ans = 0;
	for (i = 0; i < rval.size(); i += 2) {
		int score = rval[min((int)val.size(), i + 2 * k + 1)] - rval[i];
		ans = max(ans, score);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

    unordered_map<string,int> mp ={ {"RE", 0 }, {"TLE", 0}, {"WA", 0}, {"AC", 0} };
    string str;
    int n;
    cin >>n;
    for (int i =0; i < n; i++){
        cin>>str;
        mp[str]++;
    }

    for (auto m : mp)
        cout << m.first << " x " << m.second <<endl;


}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int n, k;
    cin >> n >> k;
    rep(i,n) {
        int a;
        cin >> a;
    }
    n -= k;
    int cnt = 1;
    while(n > 0) {
        n -= k-1;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vl A(N);
    rep(i, N) {
        cin >> A[i];
    }

    int r = 0;
    for (int l = 0; l < N; l++) {
        while (r < N && r - l < K) {
            r++;
        }

        if (r - l < K) break;
        if (r == N) break;

        if (A[l] < A[r]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	string s;cin>>s;
	int p=0,n=0;
	for(char c:s){
		if(c=='p')p++;
		n++;
	}
	cout<<n/2-p<<endl;;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    sort(ALL(s));
    REP(i,SZ(s)-1){
        if(s[i]==s[i+1]){
            cout << "no" << "\n";
            return 0;
        }
    }
    cout << "yes"
         << "\n";
    return 0;
}

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

const int sz = 100005;
long long a[sz];
long long k;
const long long inf = 1000000000000000000LL;

int f(int n)
{

    cout<<n<<": ";
    for(int i = 1; i<=k; i++)
    {

        int x = n%a[i];
        n-=x;
    }

    cout<<n<<endl;
    if(n==2) return 1;
    return 0;

}

long long foo(long long n)
{

    for(int i = 1; i<=k; i++)
    {

        int x = n%a[i];
        n-=x;
    }
    return n;
}


int main()
{

    scanf("%lld", &k);

    for(int i = 1; i<=k; i++) scanf("%lld", &a[i]);


    // finding upper bound;

    long long lo = 1, hi = 1e18, mid, top = -1, lolo = inf;

    for(int j = 0; j<100; j++)
    {

        mid = (hi+lo)/2;

        long long x = foo(mid);

        if(x==2)
        {

            top = max(top, mid);
            lo = mid+1;
        }
        else if(x<2)
        {
            lo = mid+1;
        }

        else hi = mid;

    }

    lo = 1;
    hi = 1e18;
    for(int j = 0; j<100; j++)
    {

        mid = (hi+lo)/2;

        long long x = foo(mid);

        if(x==2)
        {

            lolo = min(lolo, mid);
            hi = mid;
        }
        else if(x<2)
        {
            lo = mid+1;
        }

        else hi = mid;

    }

    if(top == -1) cout<<-1<<endl;

    else cout<<lolo<<" "<<top<<endl;


}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sz=1e5+5;
vector<bool>prime(sz,true);
void sieve(){
	for(ll p=2;p*p<=sz;p++){
		if(prime[p]==true){
			for(ll i=p*p;i<=sz;i+=p)
			prime[i]=false;
		}
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	sieve();
	ll x,i;
	cin>>x;
	for(i=x;i<=sz;i++){
		if(prime[i]){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256