akhauriyash/Code-Regression huggingface dataset:
def getStart(field):
    search_field = field[1:]     # cut the first [H,W,N] for min_path matrix
    for y in range(len(search_field)):
        for x in range(len(search_field[0])):
            if search_field[y][x] == "S":
                return x,y+1


def bfs(field,start_x,start_y,goal_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    gotten_cheese = 1
    distance = 0
    que = []
    que.append([start_x,start_y,gotten_cheese,distance])
    INF = 1
    min_path = [[INF for j in range(field[0][1])] for i in range(field[0][0])]
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < field[0][1] and 1 <= ny < field[0][0]+1 and field[ny][nx] != "X" and min_path[ny-1][nx] == INF:
                if field[ny][nx] == current[2]: # at the same cheese-power number
                    if field[ny][nx] == goal_N: # goal
                        print(current[3]+1)
                        return
                    else: # not goal, but could eat cheese
                        que = []
                        que.append([nx,ny,current[2]+1,current[3]+1])
                        min_path = [[INF for j in range(field[0][1])] for i in range(field[0][0])]
                        break
                else:
                    que.append([nx,ny,current[2],current[3]+1])
                    min_path[ny-1][nx] = 0


def main(field):

    # field = [[10,10,9],
    # [".","X",".",".",".","X",".","S",".","X"],
    # [6,".",".",5,"X",".",".","X",1,"X"],
    # [".",".",".","X","X","X","X",".",".","X"],
    # ["X",".",".",9,"X",".",".",".","X","."],
    # [8,".","X",2,"X",".",".","X",3,"X"],
    # [".",".",".","X","X",".","X",4,".","."],
    # ["X","X",".",".",".",".",7,"X",".","."],
    # ["X",".",".","X",".",".","X","X",".","."],
    # ["X",".",".",".","X",".","X","X",".","."],
    # [".",".","X",".",".",".",".",".",".","."]]

    sx,sy = getStart(field)
    bfs(field,sx,sy,field[0][2])

# field = []
# while True:
#     row = input().split()
#     for i in range(len(row)):
#         try:
#             row[i] = int(row[i])
#         except:
#             continue
#     field.append(row)
#     if len(field) == field[0][0] + 1:
#         main(field)
#         break



matrix = []
while True:
    row = input().rstrip().split()
    if len(row) == 3:
        re_row = []
        for i in row:
            re_row.append(int(i))
        matrix.append(re_row)
    else:
        re_row = []
        for char in row[0]:
            if char.isdigit():
                re_row.append(int(char))
            else:
                re_row.append(char)
        matrix.append(re_row)
    if len(matrix) == int(matrix[0][0]) + 1:
        main(matrix)
        break

Measured memory_bytes: 34180
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

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

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N;
  cin >> N;
  VI A(N);

  REP(i, N) {
    cin >> A[i];
  }

  GSORT(A);
  int pre = A[0];
  ll medge1 = 0, medge2 = 0;
  int flag = false;

  NREP(i, N - 1) {
    if (A[i] == pre) {
      if (!flag) {
        medge1 = pre;
        // test(medge1);
        pre = 0;
        flag = true;
      } else {
        medge2 = pre;
        // test(medge2);
        break;
      }
    } else {
      pre = A[i];
    }
  }

  cout << medge1 * medge2 << endl;

  return 0;
}

Measured memory_bytes: 640
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	#print(name)
	sys.stdin = open(name)

s = input()

#print(len(s))

ans=[]
for i in range(len(s)):
    ans.append("x")

print("".join(ans))




Measured memory_bytes: 61848
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;


  
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    map<ll, ll> m;
    for (int i = 0; i < n; i++) {
        ll a;   cin >> a;
        m[a]++;
    }
    int ans = 0;
    for (pair<ll, ll> p: m) {
        if (p.first <= p.second)
            ans += p.second - p.first;
        else 
            ans += p.second;
    }

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

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,Q;
    string S;
    int l[114514],r[114514];
    cin >> N >> Q >> S;
    REP(i,Q){
        cin >> l[i] >> r[i];
        l[i]--;r[i]--;
    }
    
    int D[114514]={};
    
    REP(i,N-1){
        if(S[i]=='A'&&S[i+1]=='C'){
            D[i+1]=D[i]+1;
        }else{
            D[i+1]=D[i];
        }
    }
    
    REP(i,Q){
        int E;
        if(l[i]==0){
            E = D[r[i]];
        }else{
            E = D[r[i]]-D[l[i]];
        }
        /*if(r[i]-l[i]==1 && S[l[i]]=='C' && S[r[i]]=='A'){
            E--;
        }*/
        cout << E << endl;
    }
    REP(i,N){
        //cout << D[i] << " ";
    }
    
    return 0;
}


Measured memory_bytes: 3712
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

const ull ma = (1ull << 52) - 1;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	ull AB[200001];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = N - 1;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		if (a < 0) {
			a = -a;
			b = -b;
		}
		bool p = (b > 0);
		if (!p) {
			b = -b;
			swap(a, b);
		}

		ull tmp = 0;
		rep(i, 3) {
			if (b) {
				int k = __builtin_clzll(a) - __builtin_clzll(b);
				if (k > 0) a <<= k;
				else b <<= -k;
				if (a > b) {
					b <<= 1;
					k--;
				}
				double d = double(b) / a;
				ull tmp1 = *(ull*)& d;
				ull c = tmp1 & ma | (1ull << 52);
				lll sa = (lll(b) << 52) - lll(a) * c;
				while (sa >= 0) {
					sa -= a;
					c++;
				}
				while (sa < 0) {
					sa += a;
					c--;
				}
				tmp += ull(k + 127) << 53 | c;
				tmp *= 3;
				b = sa;
			}
		}

		if (p) AB[ka++] = tmp;
		else AB[kb--] = tmp;
	}
	auto BA = AB + kb + 1;
	kb = N - 1 - kb;
	ll kotae = 1;
	sort(AB, AB + ka);
	sort(BA, BA + kb);
	BA[kb] = ~(ull)0;

	ull mae = AB[0];
	int p = 0;
	int kA = 0;
	rep(i, ka) {
		if (mae != AB[i]) {
			int tmp = 0;

			ull mae2 = BA[p];
			int kB = 0;
			while (BA[p] <= mae) {
				if (mae2 != BA[p]) {
					kotae = kotae * modpow(2, kB) % mod;
					mae2 = BA[p];
					kB = 1;
				}
				else kB++;
				p++;
			}

			if (mae == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}

			if (tmp) {
				kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
			}
			else {
				kotae = kotae * modpow(2, kA) % mod;
			}

			mae = AB[i];
			kA = 1;
		}
		else kA++;
	}

	int tmp = 0;
	ull mae2 = BA[p];
	int kB = 0;
	while (p < kb) {
		if (mae2 != BA[p]) {
			if (AB[ka - 1] == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}
			mae2 = BA[p];
			kB = 1;
		}
		else kB++;
		p++;
	}

	if (AB[ka - 1] == mae2) {
		tmp = kB;
	}
	else {
		kotae = kotae * modpow(2, kB) % mod;
	}

	if (tmp) {
		kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
	}
	else {
		kotae = kotae * modpow(2, kA) % mod;
	}

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}

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

int main() {

	int x, y;
	for (int i = 1; ; i++) {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		if (x > y) {
			cout << y <<" "<< x << endl;
		}
		else {
			cout << x <<" "<< y << endl;
		}
	}
}



Measured memory_bytes: 2988
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
    
 
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
 
        while(H != 0 || W != 0){
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 0; i < H; i++) {
                if(i % 2 == 0){
                    for(int j = 0; j < W; j++) {
                        if(j % 2 == 0) {
                            System.out.print("#");
                        }else if(j % 2 == 1){
                            System.out.print(".");
                        }
                    }
                }else if(i % 2 == 1){
                    for(int j = 0; j < W; j++) {
                        if(j % 2 == 0) {
                            System.out.print(".");
                        }else if(j % 2 == 1){
                            System.out.print("#");
                        }
                    }
                }
                System.out.println("");
            }
            System.out.println("");
            H = sc.nextInt();
            W = sc.nextInt();
        }
 
    }
 
}


Measured memory_bytes: 33176
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll a, b, c;
        in >> a >> b >> c;
        string ans = "NO";
        int sum = 0;
        for (int i = a; i <= a*b; i += a) {
            if (i % b == c) {
                ans = "YES";
                break;
            }
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m,l = list(map(int, input().split()))
from collections import defaultdict
ns = defaultdict(set)
for i in range(m):
    a,b,c = map(int, input().split())
    a-=1
    b-=1
    if c<=l:
        ns[a].add((c,b))
        ns[b].add((c,a))

def wf(ns):
    """全頂点間距離
    """
    d = [[float("inf")]*n for _ in range(n)]
    for i in range(n):
        for t,j in ns[i]:
            d[i][j] = t
        d[i][i] = 0
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d
dist = wf(ns)
ns2 = defaultdict(set)
for i in range(n):
    for j in range(i+1,n):
        if dist[i][j]<=l:
            ns2[i].add((1,j))
            ns2[j].add((1,i))
ddist = wf(ns2)
q = int(input())
ans = [None]*q
for i in range(q):
    s,t = map(int, input().split())
    s-=1
    t-=1
    if dist[s][t]==float("inf"):
        ans[i] = -1
    else:
        ans[i] = ddist[s][t] - 1
write("\n".join(map(str, ans)))

Measured memory_bytes: 95260
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int N;
int main(){
  cin >> N;
  int sum = 0;
  for(int i=1;i<=N;i++){
    sum += i;
    if(sum>=N){
      for(int j=1;j<=i;j++){
        if(sum-N==j)continue;
        cout << j << endl;
      }
      return 0;
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n,k,di;
  cin>>n>>k>>di;
  vector<int> v(n,-1);
      int ddd=0;

  rep(j,k){
  rep(i,di){
    cin>> ddd;
    v[ddd-1]++;
  
  }  cin>>di;
  }
  int cnt=0;
  rep(p,n){   cerr<<v[p];
    if(v[p]==-1){
      cnt++;
    }
  }
  cout<<cnt;
}

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

int main(){
  int x;
  cin >> x;
  
  int ans = 1;
  for(int i = 2; i < 40; i++){
    int k = i * i;
    while(k <= x){
      ans = max(ans, k);
      k *= i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	final static int MAX = 10000;
	public static void main(String args[]) {
		new Main().run();
	}
	
	void run() {
		Scanner in = new Scanner(System.in);
		boolean[] prime = new boolean[MAX + 1];
		Arrays.fill(prime, true);
		prime[0] = prime[1] = false;
		for(int i = 2; i <= MAX; i++)
			if(prime[i])
				for(int j = 2 * i; j <= MAX; j += i)
					prime[j] = false;
		while(true) {
			int N = in.nextInt();
			if(N == 0) break;
			for(int i = N; i > 0; i--) {
				if(prime[i] && prime[i - 2]) {
					System.out.printf("%d %d\n", i - 2, i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 13000
// ABC 088

// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0],10); //要素数
  var a = input[1].split(" ");
  var alice = new Array();
  var bob = new Array();

  // 降順
  a.sort(
    function(a,b){
      return (parseInt(a,10) < parseInt(b,10) ? 1 : -1);
    }
  );

  // 各配列に数値を割り振る
  for(var i=0;i<N;i++) {
    var s = parseInt(a[i],10);
    if(i%2 == 0) {
      alice.push(s);
    } else {
      bob.push(s);
    }
  }

  // 産出
  var alice_total = total(alice);
  var bob_total = total(bob);
  var result = alice_total - bob_total;
  console.log(result);
}

function total(tmp) {
  var sum = 0;
  for(var i=0;i<tmp.length;i++)sum+=tmp[i];
  return sum;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
#define display(v) f(v.size())cout << v[i] << " "
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ll n,k;  cin>>n>>k;
   ll val = n%k;
   cout << min(val,abs(k-val));
   return 0;
}     

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
ll M = 1e9 + 7;
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	ll n,k; cin>>n>>k;
	ll ans = 0; ll sum = (n*(n+1))/2;
	for(ll i=k;i<=n;i++)
	{
	    ll s1 = (i*(i-1))/2;
	    ll p = n-i;
	    ll s2 = sum - (p*(p+1))/2;
	    ans = (ans + (s2-s1+1)%M)%M;
	    //cout<<s1<<' '<<s2<<' '<<ans<<endl;
	}
	cout<<(ans+1)%M;
	
	
	return 0;
}

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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	
	ll ans = 1;
  rep(i,n) {
    if (a[i] == 0) {
      ans = 0;
      cout << ans << endl;
      return 0;
    } 
  }
	rep(i, n) {
      if (ans > 1000000000000000000/a[i]) {
        ans = -1;
        break;
      }
		ans *= a[i];
//      cout << ans << endl;
/*		if (ans > 1000000000000000000 || ans < 0) {
			ans = -1;
          break;
		}
        */
    }
	
	cout << ans << endl;
}


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

#include <vector>

using namespace std;
using ll = long long;

int dh[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dw[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S(H + 2);
    for (int i = 1; i <= H; i++) {
        string tmp;
        cin >> tmp;
        tmp = "." + tmp + ".";
        S[i] = tmp;
    }

    for (int i = 0; i < W + 2; i++) {
        S[0] += ".";
        S[H + 1] += ".";
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i + 1][j + 1] == '#') {
                cout << "#";
                continue;
            }
            int c = 0;
            for (int k = 0; k < 8; k++) {
                if (S[i + 1 + dh[k]][j + 1 + dw[k]] == '#') c++;
            }
            cout << c;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(void){
  string s;cin>>s;
int n=s.length(),c=0;
REP(i,0,n)c+=s[i]=='p';
cout<<n/2-c<<endl;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()

	if a%2 == 0 || b%2 == 0 || c%2 == 0 {
		fmt.Println(0)
		return
	}

	fmt.Println(minInt(minInt(a*b, b*c), c*a))
}


Measured memory_bytes: 640
a = list(map(int,input().split()))
b = abs(a[0] - a[2])
c = abs(a[0] - a[1])
d = abs(a[1] - a[2])
if b <= a[3]:
    print("Yes")
elif c <= a[3] and d <= a[3]:
    print("Yes")
else:
    print("No")

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int odd = 0;

    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 1) odd++;
    }

    YES(odd % 2 == 0);

    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M,vector<int>(2));
  for(int i=0; i<M; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
  }
  int64_t m_max = 10000000000;
  int m_min = 0;
  
  for(int i=0; i<M; i++){
    if(vec.at(i).at(0) > m_min){
      m_min = vec.at(i).at(0);
    }
    if(vec.at(i).at(1) < m_max){
      m_max = vec.at(i).at(1);
    }
  }
  
  if(m_max - m_min + 1 >= N){
    cout << N << endl;
  }
  else if(m_max - m_min + 1 >= 0){
    cout << m_max - m_min + 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
  
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;

const int MAX_LEN = 100;
char name[MAX_LEN];

struct Proc
{
    char name[MAX_LEN];
    int t;
    Proc(char _name[], int _t) : t(_t) {
        strncpy(name, _name, MAX_LEN);
    }
};

queue<Proc> procs;

void schedule(const int q)
{
    int t = 0;
    while (!procs.empty())
    {
        Proc p = procs.front();
        procs.pop();
        if (p.t <= q)
        {
            t += p.t;
            printf("%s %d\n", p.name, t);
        } else {
            t += q;
            p.t -= q;
            procs.push(p);
        }
    }
}

int main()
{
    int n, q;
    scanf("%d %d\n", &n, &q);

    int t;
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d\n", name, &t);
        procs.push(Proc(name, t));
    }

    schedule(q);

    return 0;
}

Measured memory_bytes: 6292
a,b,c,x,y = map(int,input().split())
p = [a,b]
xy = [x,y]
if a+b <= c*2:
    print(a*x+b*y)
else:
    if p[xy.index(max(xy))] > c*2:
        print(c*2*max(xy))
    else:
        print(c*2*min(xy) + p[xy.index(max(xy))]*(max(xy)-min(xy))) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
string s1, s2, t;
 
int main()
{
    cin >> s1 >> s2;
    int a, b;
    cin >> a >> b;
    cin >> t;
    if(t == s1) a--;
    else b--;
    cout << a << " " << b << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    long i, j, N;
    cin >> N;
    long dp[N];
    for(i=0; i<=N; i++){
        dp[i] = i; 
    }
    for(i=1; i<=N; i++){
        for(j=6; j<=i; j*=6){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
        for(j=9; j<=i; j*=9){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
    }
    cout << dp[N] <<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int q; cin>>q;
    for(int i=0;i<q;++i){
	int a,b,c,d; cin>>a>>b>>c>>d;
        int cnt=0;
	for(int j=a;j<=c;++j)
	    for(int k=b;k<=d;++k)
		if(j%2==0||k%2==1) ++cnt;
	cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main()
{
    int h[10] = {0},i,cnt = 0,box;
    for(i = 0;i < 10;i++){
        scanf("%d",&h[i]);
    }
    while(cnt < 10){
        cnt = 0;
        for(i = 0;i < 10;i++){
            if(h[i] < h[i+1]){
                box = h[i];
                h[i] = h[i+1];
                h[i+1] = box;
            }
            else{
                cnt++;
            }
        }
    }
    for(i = 0;i < 3;i++){
        printf("%d\n",h[i]);
    }
    return 0;
}

Measured memory_bytes: 600
/*************************************
>>> Author:  xiaofan
>>> Blog:    https://xiaofan7.cn
>>> Date:    2020-01-17 23:20:23
**************************************/

#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;
#define ls ro<<1
#define fi first
#define se second
#define rs ro<<1|1
#define ll long long
#define pb push_back
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define lson ro<<1,l,mid
#define rson ro<<1|1,mid+1,r
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int INF = 0x3f3f3f3f;

int a[26],b[26];
int c[26],d[26];
signed main() {
	string s,t;
	cin>>s>>t;
	for(auto i:s)
		a[i-'a']++;
	for(auto i:t)
		b[i-'a']++;
	int k1=0,k2=0;
	for(int i=0;i<26;i++){
		if(a[i]){
			c[k1++]=a[i];
		}
		if(b[i]){
			d[k2++]=b[i];
		}
	}
	sort(c,c+k1);
	sort(d,d+k2);
	if(k1!=k2){
		cout<<"No"<<endl;
		return 0;	
	}
	int f=0;
	for(int i=0;i<k1;i++){
		if(c[i]!=d[i]){
			f=1;
			break;
		}
	}
	if(f)	cout<<"No"<<endl;
	else cout<<"Yes"<<endl;



	



	return 0;
}



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

int main()
{
    int i = 0, n = 0, t = 0, x = 0, c[110] = {1001, 0}, m[110] = {0};
    cin >> n >> t;
    for(i = 1; i <= n; i++)
    {
        cin >> c[i] >> m[i];
        if(m[i] > t)
        {
            c[i] = 0;
        }
    }
    for(i = 1; i <= n; i++)
    {
        if(c[i] != 0)
        {
            if(c[0] >= c[i])
            {
                c[0] = c[i];
            }
        }
    }
    if(c[0] == 1001)
    {
        cout << "TLE";
    }
    else
    {
    cout << c[0];
    }



return 0;
}

Measured memory_bytes: 256
# coding: utf-8

N, K, S = map(int,input().split())
if S == 10**9:
    A = [str(S-1)] * (N-K) + [str(S)] * K
else:
    A = [str(S+1)] * (N-K) + [str(S)] * K

print(' '.join(A))

Measured memory_bytes: 7012
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s=sc.next();
if(s.contains("a")||s.contains("i")||s.contains("u")||s.contains("e")||s.contains("o")){
System.out.println("vowel");
}else{System.out.println("consonant");}
}}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAXN = 1e5 + 5;

int ar[MAXN];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n, k;
    scanf("%d %d", &n, &k);
    int L = -1, R = -1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &ar[i]);
        if (ar[i] == 1) L = R = i;
    }
    int ans = 0;
    for (int i = 1; i < n; i += k - 1) {
        ans++;
    }
    /*while (L > 1 || R < n) {
        if (L > 1) {
            if (L - k + 1 < 1)
                R = max(R, k);
            L -= (k - 1);
            ans++;
        }
        if (R < n) {
            if (R + k - 1 < n)
                L = min(L, n - k + 1);
            R += (k - 1);
            ans++;
        }
    }*/
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
const int m=2000000;
 vi arr(105);
 vi wrr(105);
 int dp[105][100005];
  int memo(int n,int w)
  {
       if(n==0||w<=0)
       {
           return dp[n][w]=0;
       }
       if(dp[n][w]!=-1)
       return dp[n][w];
       if(arr[n]>w)
       return dp[n][w]=memo(n-1,w);
       return dp[n][w]=max((memo(n-1,w-arr[n])+wrr[n]),memo(n-1,w));
  }
 
int32_t main()
{
    c_p_c();
    memset(dp,-1,sizeof(dp));
   int n,w;
   cin>>n>>w;
   for(int i=1;i<=n;i++)
   {
       cin>>arr[i];
       cin>>wrr[i];
   }
   
   int x=memo(n,w);
    
     cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 82304
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)4e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
int d[MAXN];

unordered_map <int,int> mp;
unordered_map <int,int> ct;


bool check(int t,int k)// can i do t groups with k element
{
	ll res = 0;
	for (auto i : ct)
		res += min(i.first,t) * i.second;

	return res >= t*k; 
}
void solve(int k)
{
	int l = 0, r = n / k;
	ll res = 0;
	while( l <= r )
	{
		bool ret = check(mid,k);

		// TRACE2(l,r);
		// TRACE(ret);

		if(ret)
		{
			res = mid;
			l = mid+1;
		}
		else
			r = mid-1;
	}

	cout << res << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
		mp[d[i]]++;
	}

	for (auto i : mp)
		ct[i.second]++;

	cout << n << endl;
	for (int i = 2; i <= n; ++i)
		solve(i);

}

Measured memory_bytes: 15304
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
char A[51][51];
//1:forest 2:tree
long long dp1[51][51][51][51],dp2[51][51][51][51];
bool vis1[51][51][51][51],vis2[51][51][51][51];
long long solve1(int,int,int,int);
long long solve2(int,int,int,int);
long long solve1(int x,int y,int p,int q)
{
	if(x>y||p>q)
	{
		if(x>y&&p>q)return 1ll;
		return 0ll;
	}
	if(vis1[x][y][p][q])return dp1[x][y][p][q];
	dp1[x][y][p][q]=0;
	for(int i=x;i<=y;i++)
		for(int j=p;j<=q;j++)
			dp1[x][y][p][q]+=solve2(x,i,j,q)*solve1(i+1,y,p,j-1);
	vis1[x][y][p][q]=true;
	return dp1[x][y][p][q];
}
long long solve2(int x,int y,int p,int q)
{
	if(vis2[x][y][p][q])return dp2[x][y][p][q];
	dp2[x][y][p][q]=0;
	for(int i=x;i<=y;i++)
		for(int j=p;j<=q;j++)
			if(A[i][j]=='1')
				dp2[x][y][p][q]+=solve1(x,i-1,i+1,y)*solve1(p,j-1,j+1,q);
	vis2[x][y][p][q]=true;
	return dp2[x][y][p][q];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*2;i++)
		scanf("%s",A[i]+1);
	long long ans=0;
	for(int i=2;i<=n*2;i++)
		if(A[1][i]=='1')
			ans+=solve1(2,i-1,i+1,n*2);
	printf("%lld\n",ans);
	return 0;
}
/*
3
011011
101111
110111
011011
111101
111110
*/

Measured memory_bytes: 91520
#include <iostream>
#include <string>

using namespace std;

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

  for(int i = 0; i < s.size(); i++) {
    int cnt = 0;
    for(int j = 0; j < s.size(); j++) {
      if(s[i] == s[j]) cnt++;
    }
    if(cnt > 1) {
      cout << "no" << endl;
      return 0;
    }
  }

  cout <<"yes" << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll N, M, Q;
vector<ll> A, B, C, D, tar;

ll f(ll now) {
    ll res = 0;
    if (now == N) {
        rep(i, Q) {
            ll a = A[i];
            ll b = B[i];
            ll c = C[i];
            ll d = D[i];
            if (tar[b - 1] - tar[a - 1] == c) {
                res += d;
            }
        }
        return res;
    }
    ll last = now == 0 ? 1 : tar[now - 1];
    rep2(i, last, M + 1) {
        tar[now] = i;
        res = max(res, f(now + 1));
    }
    return res;
}

void solve() {
    cin >> N >> M >> Q;
    A.resize(Q);
    B.resize(Q);
    C.resize(Q);
    D.resize(Q);
    rep(i, Q) cin >> A[i] >> B[i] >> C[i] >> D[i];
    tar.assign(N, 1);
    cout << f(0) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int main()
{
    int a, b, br=0;
    scanf("%d%d", &a, &b);

    if(a==1) br+=300000;
    if(a==2) br+=200000;
    if(a==3) br+=100000;

    if(b==1) br+=300000;
	if(b==2) br+=200000;
	if(b==3) br+=100000;

    if(a==1 && b==1) br+=400000;

    printf("%d", br);

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
    var N = parseInt(input[0], 10);
    var A = input.slice(1, 2)[0].split(' ').map(n => parseInt(n));
    var B = input.slice(2, 3)[0].split(' ').map(n => parseInt(n));
    var C = input.slice(3, 4)[0].split(' ').map(n => parseInt(n));

    var result = 0;

    for(var i = 0; i < N; i++) {
        if (i === 0) {
            result += B[A[i] - 1];
        } else {
            result += B[A[i] - 1];
            if (A[i] - 1 === A[i - 1]) {
                result += C[A[i - 1] - 1];
            }
        }
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
    // 配列の最大値を取得
    int max = *max_element(vec.begin(), vec.end());
    // 配列の最大値のイテレータを取得
    vector<int>::iterator maxIt = max_element(vec.begin(), vec.end());
    // 配列の最大値までの距離を取得
    int maxIndex = distance(vec.begin(), maxIt);
*/

int main () {
    string S;
    cin >> S;

    vector<int> num;
    for (int i = 0; i < S.size() - 2; ++i) {
        num.push_back( abs(753 - stoi(S.substr(i, 3))) );
    }

    cout << *min_element(num.begin(), num.end()) << endl;
}



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

int main() {
  int N;
  cin >> N;
  int x[N];
  int result=0;
  for(int i=0;i<N;i++){
      cin >> x[i];
  }
  int i=0;
  while(x[i]%2==0){
    x[i]/=2;
    i++;
    if(i%N==0) result++;
    if(i>=N)i=0;
  }
  cout<<result<<endl;
}

Measured memory_bytes: 256
my $S = <>;chomp $S;
my @dat = split(//,$S);
my $T = <>; chomp $T;
my @dat2 = split(//,$T);
my $ans=0;

for(my $i=0;$i<=$#dat;$i++){
    #print "$i $dat[$i] $dat2[$i]\n";
    if(!($dat[$i] eq $dat2[$i])){
        $ans++;
    }
}


print "$ans";


Measured memory_bytes: 36340
n = int(input())
a = [int(i) for i in input().split()]
s = 0
b = 0
d = [0]*n
if n % 2 == 0:
    for i in a:
        d[i] += 1 
    for i in range(1,n,2):
        if d[i] != 2:
            s = 1
            break
        else:
            b += 1
    ans = 2 ** b % (10**9 + 7)
else:
    for i in a:
        d[i] += 1 
    
    for i in range(0,n,2):
        if i == 0 and d[0] == 1:
            ans = 1
        elif d[i] != 2:
            s = 1
            break
        else:
            b += 1
    ans = 2 ** (b) % (10**9 + 7)

if s == 0:
    print(ans)
elif s == 1:
    print('0')

Measured memory_bytes: 13880
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<int>v(M);
	for (auto &i : v) {
		cin >> i;
		i--;
	}
	vector<int>sum(N);
	for (int i = 1; i < M; i++) {
		int a = v[i], b = v[i - 1];
		if (a > b)swap(a, b);
		sum[a]++;
		sum[b]--;
	}
	for (int i = 1; i < N; i++)sum[i] += sum[i - 1];
	long long int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		cin >> L >> R >> K;
		ans += min(L*sum[i], R*sum[i] + K);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
def main():
  h, n = map(int,input().split())
  magics = []
  for i in range (n):
    a, b = map(int,input().split())
    magics.append([a,b])
  # Using Secondary Array in For Loop
  dp = [0] * (h + max(a for a, b in magics))
  for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in magics)
  print(dp[h])  

if __name__ == '__main__':
  main()

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
    int n, k; cin >> n >> k;
    vector<int> x(n);
    vector<int> ans(k * 2, 1 << 30);

    for (int i = 0; i < n; ++i) cin >> x[i];

    int st = 0;
    while (x[st++] < 0);
    int l = st - k;
    if (l < 0) l = 0;
    int r = st + k - 1;
    if (r > n-1) r = n-1;
    int idx = 0;
    for (int i = l; (i < (l + k)) && ((i + k - 1) < n); ++i) {
        ans[idx++] = abs(x[i]) + abs(x[i+k-1] - x[i]);
    }
    for (int i = r; (i > (r - k)) && ((i - k + 1) >= 0); --i) {
        ans[idx++] = abs(x[i]) + abs(x[i] - x[i-k+1]);
    }

    cout << *min_element(ans.begin(), ans.end()) << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

vector<int> to[100005];
vector<int> num(100005);
int cnt=0;

void dfs(int v, int p=-1){
  if(num[v]>0)return;
  if(p==-1){
    cnt++;
  }
  num[v]=cnt;
  for(int nv:to[v]){
    dfs(nv, v);
  }
}

int main(){
  int n, m;
  cin >> n >> m;
  rep(i, m){
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  rep(i, n){
    dfs(i);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 12176
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 0; i < k; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                int m = sc.nextInt();
                arr[m]++;
            }
        }

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (arr[i] == 0) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 46248
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

prev_dish = -1
satisfaction = 0
for dish in A:
    satisfaction += B[dish-1]
    if dish - prev_dish == 1:
        satisfaction += C[prev_dish-1]
    
    prev_dish = dish

print(satisfaction)


Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.conv;
void main()
{
	string[] input = split(readln());
	int A = to!int(input[0]);
	int B = to!int(input[1]);
    if(A + B >= 10){
        writeln("error");
    }
    else {
        writeln(A + B);
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int N=Integer.valueOf(cmd[0]);
		int K=Integer.valueOf(cmd[1]);
		cmd=br.readLine().split(" ");
		int[] arr=new int[N];
		for(int i=0;i<N;i++)
		{
			arr[i]=Integer.valueOf(cmd[i]);
		}
		int[] minCost=new int[N];
		minCost[0]=0;
		minCost[1]=Math.abs(arr[1]-arr[0]);
		for(int i=2;i<N;i++)
		{
			int low=minCost[i-1]+Math.abs(arr[i]-arr[i-1]);
			for(int j=2;j<=Math.min(i, K);j++)
			{
				if(minCost[i-j]+Math.abs(arr[i]-arr[i-j])<low)
					low=minCost[i-j]+Math.abs(arr[i]-arr[i-j]);
			}
			minCost[i]=low;
		}
		System.out.println(minCost[N-1]);
	}

	/*private static int minCost(int[] arr, int i, int j) {
		// TODO Auto-generated method stub
		if(j==0)
			return 0;
		if(j==1)
			return Math.abs(arr[1]-arr[0]);
		return Math.min(Math.abs(arr[j]-arr[j-1])+minCost(arr,i,j-1), Math.abs(arr[j]-arr[j-2])+minCost(arr,i,j-2));
	}*/
}


Measured memory_bytes: 38652
N=int(input())
s = [input() for i in range(N)]
M=int(input())
t = [input() for i in range(M)]
tmp=[0]
for i in range(N):
    point=0
    point+=s.count(s[i])
    point-=t.count(s[i])
    tmp.append(point)
print(max(tmp))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  vector <int> a;
  for(int i = 0;i<3;i++){
    int b;
    cin >> b;
    a.push_back(b);
  }
  sort(a.begin(),a.end());
  if(a[0]+a[1] == a[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 10005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
int n,m;
const ll INF = 1LL << 60;
double dp[MAX][MAX];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	cin>>n;
	double p[n+1];
	for(int i=1;i<=n;i++)
		cin>>p[i];
	dp[0][0]=1.0;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0]*(1-p[i]);
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
		}
	}
	double ans=0;
	for(int i=(n+1)/2;i<=n;i++)
		ans+=dp[n][i];
	printf("%.15lf",ans);
	return 0;	
}


Measured memory_bytes: 234112
<?php
# 整数の入力
$a = fgets(STDIN);

$n1 = substr($a , 0 ,5 );
$n2 = substr($a , 6 ,5 );

$ans = 0;

for ($i = $n1; $i <= $n2 ;$i++){
$chk1 = substr($i , 0 ,1);
$chk2 = substr($i , 1 ,1); 
$chk4 = substr($i , 3 ,1);
$chk5 = substr($i , 4 ,1);
  
if($chk1 == $chk5){
  if($chk2 == $chk4){
    $ans++;
  }
}
}
  echo $ans;

?>


Measured memory_bytes: 3700