akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>

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

int N;
P pos[50];
map<P, bool> M;
map<P, int> taiou;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> pos[i].first >> pos[i].second;
		M[pos[i]] = true;
		taiou[pos[i]] = i;
	}
	int ans = 1000000;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			//i番目の点とj番目の点の間が通れるようにp, qを設定
			ll p = pos[i].first - pos[j].first, q = pos[i].second - pos[j].second;
			int cnt = 0;
			bool used[50] = {};
			for (int k = 0; k < N; k++) {
				if (!used[k]) {
					ll x = pos[k].first, y = pos[k].second;
					int l = 1;
					while (1) {
						if (M[P(x + p * l, y + q * l)] && !used[taiou[P(x + p * l, y + q * l)]]) {
							used[taiou[P(x + p * l, y + q * l)]] = true;
							l++;
						}
						else {
							break;
						}
					}
					l = -1;
					while (1) {
						if (M[P(x + p * l, y + q * l)] && !used[taiou[P(x + p * l, y + q * l)]]) {
							used[taiou[P(x + p * l, y + q * l)]] = true;
							l--;
						}
						else {
							break;
						}
					}
					cnt++;
				}
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
 	int n;
  	cin>>n;
  	vector<int> a(n);
  	for(int i = 0 ; i < n ; i++)
    {
     	cin>>a[i]; 
    }
  	vector<int> dp(n);
  	dp[0] = 0;
  	dp[1] = abs(a[1]-a[0]);
  	for(int i = 2 ; i<n ;i++)
    {
     	 dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
  	cout<<dp[n-1]<<endl;
  
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  vll A(N), B(N);
  vvll C(N, vll(N, 0));
  REP(i,N) IN(A[i]);
  REP(i,N) IN(B[i]);
  REP(i,N-1) IN(C[i][i+1]);
  REP(i,N) A[i]--;
  ll ans = 0;
  ans = B[A[0]];
  REP(i,N-1) ans += B[A[i+1]] + C[A[i]][A[i+1]];
  OUT(ans);

  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[20202];
int x[20202], y[20202];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for(int i = 1; i <= n; i++){
		x[i] = i*30000;
		y[i] = (n-i)*30000;
	}
	
	for(int i = 1; i <= n; i++){
		y[a[i]] += i;
	}
	
	for(int i = 1; i <= n; i++){
		cout << x[i];
		if(i != n) cout << " ";
	}
	cout << endl;
	for(int i = 1; i <= n; i++){
		cout << y[i];
		if(i != n) cout << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = { 0, 0, 0 };
            a[0] = int.Parse(str[0]); 
            a[1] = int.Parse(str[1]);
            a[2] = int.Parse(str[2]);

            int x =  int.Parse(Console.ReadLine());
            int max = Max(a);
            int res = Max(a);
            for(int i = 0; i < x; i++)
            {
                res = res * 2;
            }
            Console.WriteLine(res + a[0] + a[1] + a[2] - max);

        }
        public static int Max(params int[] nums)
        {
            // 引数が渡されない場合
            if (nums.Length == 0) return 0;

            int max = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                max = max > nums[i] ? max : nums[i];
                // Minの場合は不等号を逆にすればOK
            }
            return max;
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

#define x first
#define y second

#define MAXN 100009

std::pair <int, int> ix[MAXN], igrec[MAXN];

int t[MAXN], x[MAXN], y[MAXN];

int sef(int x){
    if ( x== t[x]) return x;
    else return t[x] = sef(t[x]);
}

struct myc{
    int x, y, z;
    inline bool operator < (const myc & u) const {
        return x < u.x;
    }
}e[2 * MAXN];

inline myc makeMyc(int _x, int _y, int _z) {
    myc aux;
    aux.x = _x;
    aux.y = _y;
    aux.z = _z;
    return aux;
}

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

    for(int i = 1; i <= n; i++) {
        scanf("%d%d", &x[i], &y[i]);
        ix[i].x = x[i];
        ix[i].y = i;
        igrec[i].x = y[i];
        igrec[i].y = i;
    }

    std::sort(ix + 1, ix + n + 1);
    std::sort(igrec + 1, igrec + n + 1);

    int k =0;
    for (int i = 2; i <= n; i++)
        e[++k] = makeMyc(ix[i].x - ix[i-1].x, ix[i].y, ix[i - 1].y);
    for (int i = 2; i <= n; i++)
        e[++k] = makeMyc(igrec[i].x - igrec[i-1].x, igrec[i].y, igrec[i - 1].y);

    std::sort(e +1, e +k + 1);

    for (int i = 1; i <= n; i++)
        t[i] = i;

    long long ans = 0;

    for (int i = 1; i <= k; i++) {
        //printf("%d %d %d\n", e[i].x, e[i].y, e[i].z);
        if(sef(e[i].y) != sef(e[i].z)) {
            ans += e[i].x;
            t[sef(e[i].y)] = sef(e[i].z);
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
using namespace std;
int main(){
string a;
int b;
int c;
int f;
int g;
while(cin>>a){
b=a.size();
int e[b];
c=0;
while(c<b){
string d(a,c,1);
if(d=="J"){e[c]=1;}
else if(d=="O"){e[c]=2;}
else if(d=="I"){e[c]=3;}
else{e[c]=0;}
c=c+1;}
f=0;
g=0;
c=0;
while(c<b-2){
if(e[c]==1){if(e[c+1]==2){if(e[c+2]==3){f=f+1;}}}
if(e[c]==3){if(e[c+1]==2){if(e[c+2]==3){g=g+1;}}}
c=c+1;}
cout << f<<endl;
cout << g<<endl;}
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007

// void dfs(int x, int y, vector<vector<int>>& grid, vector<vector<int>>& ans,int& n, int& m)
// {
// 	ans[x][y]++;
// 	ans[x][y]%=M;

// 	if(x+1 < n && grid[x+1][y]==1)
// 		dfs(x+1,y,grid,ans,n,m);
// 	if(y+1 < m && grid[x][y+1]==1)
// 		dfs(x,y+1,grid,ans,n,m);
// }

int main()
{

	#ifndef ONLINE_JUDGE
			freopen("input", "r", stdin);
			freopen("output","w",stdout);
	#endif

	int n,m;	cin>>n>>m;
	vector<vector<int>> v(n,vector<int>(m,0)), ans(n,vector<int>(m,0));
	// int v[n][m], ans[n][m];
	//memset(v,0,sizeof(v));

	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
		{
			char c;	cin>>c;
			if(c=='.')	v[i][j]=1;
		}

	ans[0][0]=1;
	

	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
			if(v[i][j]==1 && (j!=0 || i!=0))
				ans[i][j] = ((i-1>=0?ans[i-1][j]:0) + (j-1>=0?ans[i][j-1]:0))%M;

	cout<<ans[n-1][m-1]<<endl;

}

Measured memory_bytes: 11468
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing spaces

H, W = rl()
A = [rl() for _ in range(H)]
l = []
for i in range(H):
    for j in range(W-1):
        if A[i][j] % 2 == 1:
            A[i][j+1] += 1
            l.append((i, j, i, j+1))

for i in range(H-1):
    if A[i][W-1] % 2 == 1:
        A[i+1][W-1] += 1
        l.append((i, W-1, i+1, W-1))

print(len(l))
print('\n'.join('{} {} {} {}'.format(a+1, b+1, c+1, d+1) for a, b, c, d in l))
# 31

Measured memory_bytes: 31236
N, M= [int(i) for i in input().split(' ')]
graph = {}
 
for i in range(1,N+1):
  graph[i] = []
 
for j in range(M):
  a, b= [int(i) for i in input().split(' ')]
  graph[a].append(b)
  graph[b].append(a)
    
 
def bfs(graph, start):
  queue = [start]
  miti = [-1 for _ in range(N)]

  while queue:
    label = queue.pop(0)
    for i in graph[label]:
      if miti[i-1] < 0:
        queue.append(i)
        miti[i-1] = label
  return miti
 
miti = bfs(graph, 1)
if miti:
  print('Yes')
  for i in range(2,N+1):
    print(miti[i-1])
else:
  print('No')

Measured memory_bytes: 41664
n = int(input())
*A, = map(int, input().split())

m = max(A)
is_prime = [True] * (m + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, m + 1):
    for j in range(i * 2, m + 1, i):
        is_prime[j] = False
primes = [i for i in range(m + 1) if is_prime[i]]

Amap = {a: 0 for a in range(1, m + 1)}
for a in A:
    Amap[a] += 1

# Pmap[p]はAにでてくるpの倍数の数
Pmap = {p: 0 for p in primes}
for p in primes:
    for a in range(p, m + 1, p):
        Pmap[p] += Amap[a]

try:
    score = max(Pmap.values())
except BaseException:
    print('pairwise coprime')
    exit()
if score == 1:
    print('pairwise coprime')
elif score != n:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 288952
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] board = new String[H];
		boolean[] goodx = new boolean[110];
		boolean[] goody = new boolean[110];

		for (int i = 0; i < H; i++) {
			board[i] = sc.next();
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (board[i].charAt(j) == '#') {
					goodx[i] = true;
					goody[j] = true;
				}
			}
		}

		for (int i = 0; i < H; i++) {
			if (goodx[i]) {
				for (int j = 0; j < W; j++) {
					if (goody[j]) {
						System.out.print(board[i].charAt(j));
					}
				}
				System.out.println("");
			}
		}
	}
}

Measured memory_bytes: 25020
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long num = 100;
        long count = 0;
        while (num < x) {
            count++;
            num += num / 100;
        }
        long result = count;

        // 出力
        System.out.println(result);
    }
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, x;
    cin >> a >> b >>x;
    int sum = a+b;
    if(x <= sum && x >= a){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


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

int main(void)
{
    int A,B,N;
    cin>>N>>A>>B;
    if(N==1)
    {
        if(A==B)
            cout<<"1";
        else
            cout<<"0";
    }
    else 
    {
        if(A>B)
            cout<<"0";
        else
            printf("%lld\n",(long long )(B-A)*(N-2)+1);
    }
    return 0;
}


Measured memory_bytes: 256
# ABC155 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict as dd
from operator import itemgetter
n=ni()
d=dd(int)
# s=[si() for i in range(n)]
for i in range(n):
    s=input()
    d[s]+=1

mv=0
for k,v in d.items():
    mv=max(mv,v)
ans=set()
for k,v in d.items():
    if mv==v:
        ans.add(k)
ans=list(ans)
ans.sort()
for aaa in ans:
    print(aaa)



Measured memory_bytes: 42716
import java.util.*
import java.lang.Math.*


val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1_000_000_007L
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun solve(A: IntArray, B: IntArray, C: IntArray): LongArray {
    val N = A.size
    val Q = B.size

    val hist = IntArray(100_001){0}
    for (i in 0 until N) {
        hist[A[i]] += 1
    }

    var sum = 0L
    for (i in 0 until N) {
        sum += A[i].toLong()
    }
    
    val res = LongArray(Q){0}
    for (q in 0 until Q) {
        val db = hist[B[q]]
        hist[B[q]] = 0
        sum -= B[q].toLong() * db
        sum += C[q].toLong() * db
        hist[C[q]] += db
        res[q] = sum
    }

    return res
}


fun main(args: Array<String>) {
    val N = readInt()
    val A = readIntArray()
    val Q = readInt()
    val B = IntArray(Q)
    val C = IntArray(Q)
    for (i in 0 until Q) {
        val (b, c) = readIntArray()
        B[i] = b; C[i] = c
    }

    val ans = solve(A, B, C)

    for (a in ans) {
        println(a)
    }
}


Measured memory_bytes: 68432
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub, or_

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)



def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret


@mt
def slv(N, S, Q):
    st = SegmentTree([1 << (ord(c) - ord('a')) for c in S], or_, 0)

    for q in Q:
        if q[0] == '1':
            i = int(q[1]) - 1
            c = q[2]
            st.update(i, 1 << (ord(c) - ord('a')))
        if q[0] == '2':
            i = int(q[1]) - 1
            j = int(q[2]) - 1
            ans = 0
            v = st.query(i, j+1)
            for k in range(26):
                if (1 << k) & v:
                    ans += 1
            print(ans)
    # return ans


def main():
    N = read_int()
    S = read_str()
    Q = [read_str_n() for _ in range(read_int())]
    (slv(N, S, Q))

if __name__ == '__main__':
    main()


Measured memory_bytes: 119036
import sys

s = input()
n = len(s)

s_2 = s[0:(n-1)//2]
s_3 = s[(n+3)//2:n]

for i, k in enumerate(s):
    if k != s[(n-1) - i]:
        print('No')
        sys.exit()

for i, k in enumerate(s_2):
    if k != s[(len(s_2)-1) - i]:
        print('No')
        sys.exit()

for i, k in enumerate(s_3):
    if k != s[(len(s_3)-1) - i]:
        print('No')
        sys.exit()


print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k; cin >> n >> k;
    if((n-1)%(k-1)==0) cout << (n-1)/(k-1) << endl;
    else cout << (n-1)/(k-1)+1 << endl;
}



Measured memory_bytes: 256
from math import gcd
from collections import defaultdict
mod = 10**9+7
_, *S = open(0)
mp = defaultdict(lambda: [0, 0])
O = 0
for s in S:
    a, b = map(int, s.split())
    if a == b == 0:
        O += 1
    else:
        g = gcd(a, b)
        a //= g
        b //= g
        if a < 0 or a == 0 < b:
            a, b = -a, -b
        f = 0
        if b < 0:
            a, b, f = -b, a, 1
        mp[(a, b)][f] += 1
ans = 1
for k in mp:
    x, y = mp[k]
    ans = ans*(pow(2, x, mod)+pow(2, y, mod)-1) % mod
print((ans+O-1) % mod)


Measured memory_bytes: 81148
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
int main() {fio; // remove during scanf

    int N;
    cin >> N;
    pair <int, int> prev = {0,0};
    int pt = 0;
    while(N--) {
        int t, x, y;
        cin >> t >> x >> y;
        int dist = abs(x - prev.first) + abs(y - prev.second);
        int g = t - pt;
        if(dist <= g && dist%2 == g%2) {
            ;  
        }
        else {
            cout << "No";
            return 0;
        }
        prev = {x, y};
        pt = t;
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int n = sc.nextInt();

		int a = sc.nextInt();

		int b = sc.nextInt();

		System.out.println(Math.min(a*n,b));

	}
}


Measured memory_bytes: 22868
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  int N,a;
  double sum=0;

  cin>>N;

  for(int i=0;i<N;i++){
    cin>>a;
    sum+=(double)1/a;
  }
  printf("%.6f\n",1/sum);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



string s,t,u;
long long int a,b;
int main() {
	cout << fixed << setprecision(18);
	cin>>s>>t>>a>>b>>u;
	if(s==u){
		cout<<a-1<<" "<<b;
	}else{
		cout<<a<<" "<<b-1;
	}
} 

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

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n), c(n);
	for (int i = 0; i < m; i++) {
		int p;
		string s;
		cin >> p >> s;
		p--;
		if (a[p] > 0) continue;
		if (s == "AC") a[p] = 1;
		else c[p]++;
	}
	int ans1 = 0, ans2 = 0;
	for (int i = 0; i < n; i++)
		if (a[i]) ans1++, ans2 += c[i];

	cout << ans1 << ' ' << ans2 << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int x, y;
    bool flag=false;
    cin>>x>>y;
    int a[]={1,3,5,7,8,10,12};
    int b[]={4,6,9,11};
    int j=0,k=0;

    for(int i=0;i<7;i++){
        if(a[i]==x){
            j++;
        }
        if(a[i]==y){
            j++;
        }
    }
    if(j==2){
        flag=true;
    }

    for(int i=0;i<4;i++){
        if(b[i]==x){
            k++;
        }
        if(b[i]==y){
            k++;
        }
    }
    if(k==2){
        flag=true;
    }
    
    if(flag){
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;

int n, k, a[105];
ll dp[105][100005];

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

    cin >> n >> k;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    dp[0][k] = 1;

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[i][j] = (dp[i - 1][min(k, j + a[i])] - (j ? dp[i - 1][j - 1] : 0)) % mod;

            if (j)
                dp[i][j] += dp[i][j - 1];
        }
    }

    cout << dp[n][0];

    return 0;
}

Measured memory_bytes: 79360
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

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

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

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

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

typedef TIII state;
int INF;
int distS[222][222];
int distL[222][222];
int z[1111];
int DP[2][222];

int main(){
	INF = 500000000;
	while(1){
		int n,m,r;
		cin>>n>>m;
		if(n==0)return 0;
		REP(i,n)REP(j,n)distS[i][j] = INF;
		REP(i,n)REP(j,n)distL[i][j] = INF;
		REP(i,m){
			int x,y,t;
			char sl;
			cin>>x>>y>>t>>sl;
			x--, y--;
			if(sl=='L')distL[y][x] = distL[x][y] = min(distL[x][y], t);
			else distS[y][x] = distS[x][y] = min(distS[x][y], t);
		}
		REP(i,n)distL[i][i] = 0;
		REP(i,n)distS[i][i] = 0;
		REP(k,n){
			REP(i,n){
				REP(j,i){
					distL[i][j] = distL[j][i] = min(distL[i][j], distL[i][k] + distL[k][j]);
					distS[i][j] = distS[j][i] = min(distS[i][j], distS[i][k] + distS[k][j]);
				}
			}
		}
		cin>>r;
		REP(i,r){
			scanf("%d", &z[i]);
			z[i]--;
		}
		REP(i,n)DP[0][i] = INF;
		DP[0][z[0]]=0;
		FOR(i,1,r){
			REP(j,n)DP[i%2][j]=INF;
			REP(j,n){
				REP(k,n){
					if(j==k)DP[i%2][k] = min(DP[i%2][k], DP[(i+1)%2][j]+distL[z[i-1]][z[i]]);
					else DP[i%2][k] = min(DP[i%2][k], DP[(i+1)%2][j]+distL[z[i-1]][j]+distS[j][k]+distL[k][z[i]]);
				}
			}
		}
		int ret=INF;
		REP(i,n)ret = min(ret, DP[(r+1)%2][i]);
		cout << ret << endl;
	}
}

Measured memory_bytes: 1608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#define inf 99999999
using namespace std;
const int MAX=100+10;
char mapa[MAX][MAX],mapb[MAX][MAX];
int n,m;
int map(int x,int y,int xb,int yb){
    int i,j,flag=1;
    for(i=0;i<m;i++){
        for(j=0;j<m;j++){
            //cout<<mapa[i+x][j+y]<<mapb[i][j]<<endl;
            if(i+x>=n||j+y>=n){  flag=0;break;  }
            if(mapa[i+x][j+y]!=mapb[i][j]){
                flag=0;break;
            }
        }
        if(flag==0) break;
    }
    //cout<<flag<<endl;
    if(flag==0)     return 0;
    else  return 1;
}
int main(){
    #ifdef SIYU
    //freopen("in.txt","r",stdin);
    #endif // SIYU
    int i,j;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        scanf("%s",mapa[i]);
    for(i=0;i<m;i++)
        scanf("%s",mapb[i]);
    //cout<<mapb[0]<<endl;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(map(i,j,0,0))
                break;
        }
        if(j!=n)
            break;
    }
    if(i!=n)    cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int point[100], N, A, B, C, D, rank[100];

int main(){
  scanf("%d", &N);
  rep(i, N*(N-1)/2){
    scanf("%d%d%d%d", &A, &B, &C, &D); A--; B--;
    if(C == D){ point[A]++; point[B]++; }
    else point[C>D?A:B] += 3;
  }

  rep(i, N) rep(j, N)
    if(point[i] < point[j]) rank[i]++;

  rep(i, N) printf("%d\n", rank[i]+1);
  return 0;
}

Measured memory_bytes: 1188
n=int(input())
l=list(map(int,input().split()))
m=0
b=0 #n,l入力　m,b定義

for i in range(n):
   b=i
   for j in range((n-i)-1):
       b=b+1
       m=m+l[i]*l[b]

print(m)

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define beg begin()
#define end end()

void _main(){
    int n,m,d; cin >> n >> m >> d;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }

    int min = pow(10,8);
    int nflag = 1;
    for(int bit = 0; bit < (1<<n);bit++){
        vector<int> x(m,0);
        int sum = 0;
        rep(i,n){
            if(bit&(1<<i)){
                sum += c[i];
                rep(j,m){
                    x[j] += a[i][j];
                }
            }
        }
        auto index = min_element(x.beg, x.end)-x.beg;
        if(x[index] >= d){
            nflag = 0;
            if(sum <= min) min = sum;
        }
    }
    if(nflag) cout << -1 << endl;
    else cout << min << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3204
#include<iostream>
using namespace std;
int n,sum;
int main(){
int a;
    while(cin>>n){
        sum=0;
        for(int i=0;i<n;i++){
            cin>>a;
if(a&1)sum++;
}
if(sum&1){cout<<"NO"<<endl;}
else{cout<<"YES"<<endl;}
}
return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		int[] array = {a, b, c};
		Arrays.sort(array);

		System.out.println(array[2] * 10 + array[1] + array[0]);
	}
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 998244353;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// head

static uint MD;
struct ModInt {
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M& set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M& r) const { return M().set_v(v + r.v); }
	M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M& r) const { return *this * r.inv(); }
	M& operator+=(const M& r) { return *this = *this + r; }
	M& operator-=(const M& r) { return *this = *this - r; }
	M& operator*=(const M& r) { return *this = *this * r; }
	M& operator/=(const M& r) { return *this = *this / r; }
	bool operator==(const M& r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n) {
			if (n & 1) r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt;

const int MAXN = 100000 + 5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	//	freopen("a.in","r",stdin);
	//	freopen("a.out","w",stdout);

	int n;
	cin >> n >> MD;
	
	int N = 2 * n;
	vector<vector<Mint>> dp(3 * n + 1, vector<Mint>(5 * n + 1));
	dp[0][N] = 1;
	rep(i, 0, 3 * n)
	{
		rep(j, 0, 5 * n)
		{
			if (dp[i][j] == 0) continue;
			dp[i + 1][j + 1] += dp[i][j];
			if (i + 2 <= 3 * n) dp[i + 2][j - 1] += dp[i][j] * (i+1);
			if (i + 3 <= 3 * n) dp[i + 3][j] += dp[i][j] * (i + 1)*(i + 2);
		}
	}

	Mint ans = 0;
	rep(j, N, 5 * n + 1)
	{
		ans += dp[3 * n][j];
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 237056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    ll x,y,z,a,b,c,n;
    cin >>x >>y >>z >>a >>b >>c >>n;

    auto dist = [&](ll p, ll q, ll r){
        return (abs(p-a)+abs(q-b)+abs(r-c))%n;
    };

    vector<ll> ct(n);
    rep(i,x) ++ct[dist(i,0,0)];

    vector<ll> ct_y(n);
    int diff = 0;
    rep(i,y){
        ++ct_y[diff];
        if(i<b) diff = (diff-1+n)%n;
        else diff = (diff+1)%n;
    }

    vector<ll> ct_z(n);
    diff = 0;
    rep(i,z){
        ++ct_z[diff];
        if(i<c) diff = (diff-1+n)%n;
        else diff = (diff+1)%n;
    }

    auto shift = [&](const vector<ll> &v){
        vector<ll> ret(n);
        rep(i,n-1) ret[i+1] = v[i];
        ret[0] = v[n-1];
        return ret;
    };

    auto make_ct = [&](vector<ll> f, vector<ll> m){
        vector<ll> nct(n);
        rep(i,n){
            rep(j,n) nct[j] += m[i]*f[j];
            f = shift(f);
        }
        return nct;
    };

    ct = make_ct(ct, ct_y);
    ct = make_ct(ct, ct_z);

    rep(i,n) cout << ct[i] << " \n"[i==n-1];
    return 0;
}



Measured memory_bytes: 3192
N,D=map(int,input().split())
cnt=0
X=[[0]*D for _ in range(N)]
for i in range(N):
    X[i]=list(map(int,input().split()))
for i in range(N-1):
    for j in range(i+1,N):
        total=0
        for k in range(D):
            total+=(X[i][k]-X[j][k])**2
        if total**0.5==int(total**0.5):
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    Double r = scanner.nextDouble();
    String s = String.format("%.6f", r * r * Math.PI);
    String l = String.format("%.6f", 2 * r * Math.PI);
    System.out.println(s + " " + l);
  }
}

Measured memory_bytes: 18904
import sys
sys.setrecursionlimit(1000000)

#ノードの数,橋の数
N,M = map(int, input().split())

#最初は自分自身が親（根）
par = [i for i in range(N+1)]
#ランク(深さ）
rank = [0]*(N+1)
#各要素が属するグループのサイズ（連結成分の個数）
size = [1]*(N+1)

#木の根を求める
def root(x):
    if par[x] == x:  #自分が親のときは自分が根ということ
        return x
    else:
        #経路圧縮
        par[x] = root(par[x])#自分が親ではないときは，根を自分の親に設定
        return par[x]

#xとyが同じ集合（連結成分）に属するかどうか
def same(x, y):
    return root(x) == root(y)

#xとyの属する集合を併合
def unite(x,y):
    xx = root(x)
    yy = root(y)
    #xとyのルートが同じなので操作は必要ない（同じ集合に属する）
    if xx == yy:
        return
    ####ランクあり
    if rank[xx] < rank[yy]:
        par[xx] = yy
        size[yy] += size[xx]
    else:
        par[yy] = xx
        size[xx] += size[yy]
        if rank[xx] == rank[yy]:
            rank[yy] += 1

    ####ランクなし
    ###
    ### #ｘとyのrootが異なるので,xの親をyのrootに設定
    #par[x] = yy

#出力する不便度
ans = [0]*M
#すべての橋が壊れているときの不満度はN個の島から2個の島の選び方の総数と等しい
ans[M-1] = N*(N-1)//2

#橋の情報
B = [list(map(int,input().split())) for i in range(M)]

#橋の情報を逆順に取り出す
for i in range(M-1,0,-1):
    a = B[i][0]
    b = B[i][1]
    if root(a) != root(b):
        ans[i-1] = ans[i] -size[root(a)]*size[root(b)]
    else:
        ans[i-1] = ans[i]
    #橋をつなげる
    unite(a,b)

for a in ans:
    print(a)


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S, T;
  cin >> S >> T;
  int ans = 0;
  REP(i, 3) {
    if (S.at(i) == T.at(i)) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
x = [int(i) for i in input().split()]

ans = abs(x[-1]-x[0])*2
for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    if r<0:
        ans=min(ans,-l)
    elif l>0:
        ans=min(ans,r)
    else:
        ans=min(ans,-2*l+r)
        ans=min(ans,2*r-l)
print(ans)

Measured memory_bytes: 14536
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

void solve(ll N, ll R) {
  cout << R + (N<10 ? 1000 - 100*N : 0) << endl;
}

int main() {
  ll N;
  cin >> N;
  ll R;
  cin >> R;
  solve(N, R);
  return 0;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e3 + 10;
const int inf = 0x3f3f3f3f;


int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
  double l; cin >> l;
  l /= 3;
  printf("%0.6f", l * l * l);
return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MAXN 105
using namespace std;
bool usd[MAXN];

int main() {
	int a, b, c, d, ans = 0;
	cin >> a >> b >> c >> d;
	for(int i = a; i <= b; i++)
		usd[i] = 1;
	for(int i = c; i <= d; i++)
		if(usd[i])
			ans++;
	if(ans) ans--;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int n;
    int k;
    int count=0;
    int h;

    cin>>n>>k;

    FOR(i,1,n){
        cin>>h;
        if(h>=k){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,a[15];
bool vis[15];
vector<int>v[15];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x;
        scanf("%d",&x);
        while(x--)
        {
            int y;
            scanf("%d",&y);
            v[i].push_back(y);
        }
    }
    for(int i=1;i<=m;i++)
        scanf("%d",&a[i]);
    int ans=0;
    for(int i=0;i<1<<n;i++)
    {
        memset(vis,false,sizeof(vis));
        for(int j=0;j<n;j++)
            if(1<<j&i) vis[j+1]=true;
        bool flag=true;
        for(int j=1;j<=m;j++)
        {
            int res=0;
            for(int k=0;k<v[j].size();k++)
                if(vis[v[j][k]]) res^=1;
            if(res!=a[j]) flag=false;
        }
        ans+=flag;
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N)
    {
        cin >> a.at(i);
    }
    vector<ll> b(N, 0);
    rep(i, N)
    {
        b.at(a.at(i) - 1)++;
    }
    ll sum = 0;
    rep(i, N)
    {
        if (b.at(i) == 0 || b.at(i) == 1)
        {
            continue;
        }
        sum += (b.at(i) * (b.at(i) - 1)) / 2;
    }
    rep(k, N)
    {
        ll sum_k = sum;
        sum_k -= b.at(a.at(k) - 1) - 1;
        cout << sum_k << endl;
    }
    return 0;
}

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d;
  e = a + b;
  f = c + d;
  string ans;
  if (e > f) {
    ans = "Left";
  } else if (e < f) {
    ans = "Right";
  } else {
    ans = "Balanced";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;


int main(){
	int st[500];
	int p = 0;
	for(;;){
		string s;
		if(!(cin >> s)) break;
		char op = s.at(0);
		int num;

		if(op>='0' && op<='9'){
			num = atoi(s.c_str());
			st[p] = num;
			p++;
		}else{
			if(op=='+') st[p-2] = st[p-2]+st[p-1];
			if(op=='-') st[p-2] = st[p-2]-st[p-1];
			if(op=='*') st[p-2] = st[p-2]*st[p-1];
			p--;
		}
	}
	cout << st[p-1] << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
/*
Author: Arham_doshi
@quote "Code like there's no tommorow!"
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if



using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}



signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n;
cin>>n;
string s;
cin>>s;
if(n%2!=0){cout<<"No";return 0;}
    
    fo(i,0,n/2){
        if(s[i]!=s[i+n/2]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {

    val dice1 = read
    val dice2 = read

    for(side <- dice1){if(!dice2.contains(side)){println("No");return}}
    println(if(find(dice1,dice2)){"Yes"}else{"No"})
  }

  def find(dice1:Array[Int],dice2:Array[Int]) : Boolean = {
    var d1_1 = dice1
    for(c1 <- "IWNNNW".toCharArray){
      d1_1 = getNextStatus(c1,d1_1)
      var d1_2 = d1_1
      for(c2 <- "IHHH".toCharArray){
        d1_2 = getNextStatus(c2,d1_2)
        if(diceMatch(d1_2,dice2)){return true}
      }
    }
    return false
  }

  def diceMatch(dice1:Array[Int],dice2:Array[Int]):Boolean = (dice1 zip dice2).forall(x => x._1 == x._2)

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = {
    cmd match {
      case 'N' => Array(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
      case 'W' => Array(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
      case 'H' => Array(dice(0), dice(2), dice(4), dice(1), dice(3), dice(5))
      case 'I' => dice
    }
  }

  def read() : Array[Int] = {readLine().split(" ").map(_.toInt)}
}

Measured memory_bytes: 44212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt(),m = obj.nextInt(),H[] = new int[n+1];
        for(int i=1;i<n+1;i++) H[i] = obj.nextInt();
        ArrayList<Integer> data[] = new ArrayList[n+1];
        for(int i=1;i<data.length;i++) data[i] = new ArrayList<>();
        for(int i=0;i<m;i++)
        {
            int u = obj.nextInt(),v =obj.nextInt();
            data[u].add(v);
            data[v].add(u);
        }
        int count=0;
        for(int i=1;i<data.length;i++)
        {
            boolean flag = false;
            if(data[i].isEmpty()){count++;continue;}
            for(int j:data[i])
            {
                if(H[i]<=H[j])
                {
                    flag = true;
                    break;
                }
            }
            if(!flag) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 70504