akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		double sum=0;
		for(int i=0; i<n; i++){
			double a=sc.nextDouble();
			sum+=1/a;
		}
		System.out.println(1/sum);
	}
}


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

int main()
{
    string s;
    map<char, int> m;
    cin >> s;
    for(auto u : s)
        m[u]++;
    for(auto u : m)
    {
        if(u.second%2)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}



Measured memory_bytes: 3600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    string a, b, c;
    cin >> a >> b;

    c = a + b;

    int K = stoi(c);

    if (ceil(sqrt(K)) == floor(sqrt(K))) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int n;
  static int[] a;
  static final int MAX = 100000;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    n = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    int[] count = new int[MAX + 1 + 1];
    for(int i = 0; i < n; i++){
      int v = a[i] + 1;
      ++count[v];
      ++count[v + 1];
      ++count[v - 1];
    }

    int max = 0;
    for(int i = 0; i < count.length; i++){
      max = Math.max(max, count[i]);
    }

    System.out.println(max);
  }
}


Measured memory_bytes: 50324
#include <bits/stdc++.h>
using namespace std;
 
int h, w, n;
char m[1010][1010];
int d[1010][1010];
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
 
void init()
{
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      d[i][j] = 1e9 + 9;
    }
  }
}
 
int main()
{
  int sx, sy;
 
  cin >> h >> w >> n;
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cin >> m[i][j];
      if (m[i][j] == 'S') sx = j, sy = i;
    }
  }
 
  int ans = 0;
  for (int i = 1; i <= n; i++){
    queue<pair<int, int> > q;
    q.push(make_pair(sy, sx));
 
    init();
    d[sy][sx] = 0;
    while (!q.empty()){
      pair<int, int> nv = q.front();
      q.pop();
 
      if (m[nv.first][nv.second] == '0' + i){
        sy = nv.first;
        sx = nv.second;
        ans += d[sy][sx];
        while (!q.empty()) q.pop();
        break;
      }
 
      for (int j = 0; j < 4; j++){
        int ny = nv.first + dy[j];
        int nx = nv.second + dx[j];
        if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
        if (d[ny][nx] != 1e9 + 9) continue;
        if (m[ny][nx] == 'X') continue;
        d[ny][nx] = d[nv.first][nv.second] + 1;
        q.push(make_pair(ny, nx));
      }
    }
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 7972
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

ll calc(ll a, ll b, ll p) {
    if (b == 0) {
        return 1;
    }
    if (b % 2 == 0) {
        ll d = calc(a, b / 2, p);
        return (d * d) % p;
    }
    else {
        return (a * calc(a, b - 1, p) % p);
    }
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    ll fact[200010];
    fact[0] = 1;
    for (int i = 1; i < 200010; i++) {
        fact[i] = (fact[i - 1] * i) % MOD;
    }
    ll ans = 0;
    for (int i = b + 1; i <= w; i++) {
        int n = (h - a - 1) + (i - 1);
        int m = h - a - 1;
        ll tmp1 = (((fact[n] * calc(fact[n - m], MOD - 2, MOD)) % MOD) * calc(fact[m], MOD - 2, MOD)) % MOD;
        n = (a - 1) + (w - i);
        m = a - 1;
        ll tmp2 = (((fact[n] * calc(fact[n - m], MOD - 2, MOD)) % MOD) * calc(fact[m], MOD - 2, MOD)) % MOD;
        ans += (tmp1 * tmp2) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long llint;

const int MAXL = 11;


int N, sol;
int pwr10[MAXL];
char A[MAXL], B[MAXL], C[MAXL];

void num_to_str(llint x, char C[]) {
	for (int i = 0; i < MAXL; ++i) C[i] = 0;
	for (int i = 0; x > 0; ++i, x /= 10) {
		C[i] = (x % 10) + '0';
	}
	reverse(C, C+strlen(C));
}

bool cmp_lesseq(llint x, llint y) {
	num_to_str(x, A);
	num_to_str(y, B);
#ifdef DEBUG
	printf("CONVERTED: %s %s %d\n", A, B, strcmp(A, B));
#endif
	return strcmp(A, B) <= 0;
}

bool ask(llint x) {
	bool ret;
	#ifdef DEBUG
		ret = (x <= N && cmp_lesseq(x, N)) || (x > N && !cmp_lesseq(x, N));
		printf("%lld ANS:%d\n", x, ret);
	#else
		printf("? %lld\n", x);
		fflush(stdout);
		scanf("%s", C);
		ret = strcmp("Y", C) == 0;
	#endif
	return ret;
}

int main() {
	#ifdef DEBUG
	N = rand() % ((int)1e9 - 1) + 1;
	N = 1;
	printf("NUM:%d\n", N);
	#endif
	pwr10[0] = 1;
	for (int i = 1; i < 10; ++i)
		pwr10[i] = 10 * pwr10[i-1];
	bool t = ask(1e9);
	if (t) {
		int lo = 0, hi = 9;
		while (lo < hi) {
			int mid = (lo+hi+1)/2;
			bool res = ask(2 * pwr10[mid-1]);
			if (res) {
				hi = mid-1;
			} else {
				lo = mid;
			}
		}
		sol = pwr10[lo];
	} else {
		int lo = 0, hi = 9;
		while (lo < hi) {
			int mid =(lo+hi+1)/2;
			bool res = ask(pwr10[mid]);
			if (res) {
				lo = mid;
			} else {
				hi = mid-1;
			}
		}
		hi = pwr10[lo+1]-1;
		lo = pwr10[lo];

		//printf("%d %d\n", lo, hi);

		while (lo < hi) {
			llint mid = (lo+hi)/2;
			bool res = ask(10*mid);
			if (res) {
				hi = mid;
			} else {
				lo = mid+1;
			}
		}
		sol = lo;
	}
	printf("! %d\n", sol);
	fflush(stdout);
	return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back

#define N 1000100
#define MOD 1000000007

int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a) % MOD;

		a = (a * a) % MOD; 
		b >>= 1;
	}
	return res;
}

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

int ptime[1000000] = {};
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n;
	cin >> n;
	int a[n];
	int lc = 1;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		int cur = a[i];
		int p = 2;
		while(cur > 1 && p*p <= cur)
		{
			if(cur%p == 0)
			{
				int cnt = 0;
				while(cur % p == 0)
				{
					cur = cur/p;
					cnt++;
				}
				ptime[p] = max(ptime[p],cnt);

			}
			p++;
		}
		if(cur > 1)
			ptime[cur] = max(1ll,ptime[cur]);
	}

	for (int i = 0; i < 1000000; ++i)
	{
		if (ptime[i])
			lc = lc * bexp(i, ptime[i]) % MOD;
	}

	int ans = 0;

	for (int i = 0; i < n; ++i)
	{
		ans = (ans + (lc * bexp(a[i], MOD - 2)) % MOD) % MOD;
	}

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


Measured memory_bytes: 6656
s = list(input())
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
if a+b+c+d == 7:
    print(s[0]+'+'+s[1]+'+'+s[2]+'+'+s[3]+'='+'7')
elif a-b+c+d == 7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'+'+s[3]+'='+'7')
elif a+b-c+d == 7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'+'+s[3]+'='+'7')
elif a+b+c-d == 7:
    print(s[0]+'+'+s[1]+'+'+s[2]+'-'+s[3]+'='+'7')
elif a-b-c+d == 7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'+'+s[3]+'='+'7')
elif a-b+c-d == 7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'-'+s[3]+'='+'7')
elif a+b-c-d == 7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'-'+s[3]+'='+'7')
elif a-b-c-d == 7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'-'+s[3]+'='+'7')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;

int main(int argc, char *argv[])
{
	ll n ,k, q;

	vector<ll> p(n+1,0);
	cin >> n >> k >> q;
	for (int i=0; i<q; i++)
	{
		ll a;
		cin >> a;
		p[a]++;
	}
	for (int i=1; i<=n;i++)
	{
		cout << (((k-(q-p[i])) > 0) ? "Yes": "No") << endl;
	}
	return 0;
}


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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int A[3][3];
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++) cin >> A[i][j];
		int n;
		cin >> n;
		int b;
		int f[3][3]={0};
		for(int k=0;k<n;k++){
			cin >> b;
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					if(b == A[i][j]) f[i][j]=1;
				}
			}
		}
		bool flag=false;
		for(int i=0;i<3;i++){
			int r=0;
			for(int j=0;j<3;j++){
				r += f[i][j];
			}
			if(r==3){
				flag=true;
				break;
			}
		}
		for(int i=0;i<3;i++){
			int r=0;
			for(int j=0;j<3;j++){
				r += f[j][i];
			}
			if(r==3){
				flag=true;
				break;
			}
		}
		if(f[0][0]==1 && f[1][1]==1 && f[2][2]==1) flag=true;
		if(f[0][2]==1 && f[1][1]==1 && f[2][0]==1) flag=true;
		if(flag) cout << "Yes";
		else cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;

        vector<Int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        int max_key = -1;
        Int max_val = -1;


        for (int i = 0; i < N; ++i) {
            if (max_val < abs(A[i])) {
                max_val = abs(A[i]);
                max_key = i;
            }
        }

        vector<pair<int, int>> ans;
        auto tapi = [&](int i, int j) {
            ans.emplace_back(i + 1, j + 1);
            A[j] += A[i];
        };

        bool minus = A[max_key] < 0;
        for (int i = 0; i < N; ++i) {
//            ans.emplace_back(max_key + 1, i + 1);
//            A[i] += max_key;
            tapi(max_key, i);
        }


        if (minus) {
            for (int i = N - 1; i > 0; --i) {
                tapi(i, i - 1);
            }
        } else {
            for (int i = 0; i + 1 < N; ++i) {
                tapi(i, i + 1);
            }
        }


        cout << ans.size() << endl;
        for (auto e : ans) {
            cout << e.first << " " << e.second << endl;
        }

        for (int i = 0; i + 1 < N; ++i) {
            if (A[i] > A[i + 1]) {
                cerr << "damedesu" << endl;
            }
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string str;
  V<> a;
  while (getline(cin, str)) {
    a.push_back(stoi(str));
  }
  sort(rbegin(a), rend(a));
  for (int i = 0; i < 3; ++i) {
    cout << a[i] << '\n';
  }
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int p[k+1];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<k+1;i++)p[i]=-1;
    int t=0;
    for(int i=0;i<k+1&&t<1;i++){
        for(int j=0;j<n&&t<1;j++){
            if(i+a[j]<=k)if(p[i+a[j]]!=1)p[i+a[j]]=-1*p[i];
            if(p[k]==1)t++;
        }
    }
    if(p[k]==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
	return 0;
}


Measured memory_bytes: 640
import sys


def main():
    N, M = map(int, sys.stdin.readline().rstrip().split())

    num = ["#"] * N

    for _ in range(M):
        # print(num)
        s, c = map(int, sys.stdin.readline().rstrip().split())

        if N > 1 and s == 1 and c == 0:
            break

        if num[s - 1] == "#":
            num[s - 1] = c
            continue

        if num[s - 1] != c:
            break

        # print(num)

    else:

        if N>1 and num[0] == "#":
            num[0] = 1

        for i in range(N):
            if num[i] == "#":
                num[i] = 0

        print("".join(map(str, num)))
        return

    print(-1)
    return


main()


Measured memory_bytes: 9116
#include <stdio.h>

int main() {
    int n, i, score;
    int max, min, sum;

    while (1) {
        scanf("%d", &n);

        if (n == 0) { break; }

        sum = 0; max = -1; min = 1001;

        for (i = 0; i < n; i++) {
            scanf("%d", &score);
            sum += score;

            if (score > max) { max = score; }
            if (score < min) { min = score; }
        }

        printf("%d\n", (sum - max - min) / (n - 2));
    }

    return 0;
}


Measured memory_bytes: 2036
//y13-1
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    for(int i=0; i<7; i++){
        int a,b;
        cin >> a >> b;
        cout << a - b << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll yan[10000] = { 1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99,199,299,399,499,599,699,799,899,999,1099,1199,1299,1399,1499,1599,1699,1799,1899,1999,2999,3999,4999,5999,6999,7999,8999,9999,10999,11999,12999,13999,14999,15999,16999,17999,18999,19999,20999,21999,22999,23999,24999,25999,26999,27999,28999,29999,39999,49999,59999,69999,79999,89999,99999};
int main() {
	ll n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
	}
	ll ans = 1;
	n -= k;
	ans += (n + k - 2) / (k - 1);
	cout << ans << endl;
	return 0;
}


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, exists_black, perfect_col, least_row_cost;
char s[505][505];

void solve(){
	FI(i, 1, n){
		int cnt = 0;
		FI(j, 1, n) if(s[j][i] == '#') cnt++;
		if(cnt == n) perfect_col++;
	}
	
	least_row_cost = n;
	
	FI(i, 1, n){
		int c = 0, ok = false;
		FI(j, 1, n) if(s[j][i] == '#'){
			ok = true;
			break;
		}
		FI(j, 1, n) if(s[i][j] == '.') c++;
		if(!ok) c++;
		least_row_cost = min(least_row_cost, c);
	}
	printf("%d\n", least_row_cost + n - perfect_col);
	return;
}

int main(){
	scanf("%d", &n);
	FI(i, 1, n){
		scanf("\n%s", s[i] + 1);
		FI(j, 1, n) if(s[i][j] == '#') exists_black = true;
	}
	
	if(!exists_black){
		printf("-1\n");
		return 0;
	}
	
	solve();
	
	return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll dsum(ll N, ll p){
    ll ans = 0;
    while(N > 0){
        ans += N%p;
        N /= p;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, S; cin >> N >> S;
    ll k = N-S;
    if(k == 0){
        cout << N+1 << endl; return 0;
    }
    ll ans = LINF;
    for(ll i = 1; i*i <= k; i++){
        if(k%i != 0) continue;
        ll p = i+1; ll q = (k/i)+1;
        if(p >= 2 && dsum(N, p) == S){
            ans = min(ans, p);
        }
        if(q >= 2 && dsum(N, q) == S){
            ans = min(ans, q);
        }
    }
    cout << (ans == LINF ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
ps = [0] * (1 << 16)
for i in range(1 << 16):
    temp = 0
    x = 1    
    for j in range(16):
        if (i >> j) & 1:
#                temp += (-2) ** (2 *j)
            temp += x
        x *= 4
    ps[i] = temp

pattern1 = None
pattern2 = None

for i in range(1 << 16):
    temp2 = 0
    x = 2
    for j in range(16):
        if (i >> j) & 1:
#                temp2 += (-2) ** (2 *j + 1)
            temp2 += x
        x *= 4
    n2 = n + temp2
    pattern1 = bisect.bisect_left(ps, n2)
    if pattern1 != (1 << 16) and ps[pattern1] == n2:
        pattern2 = bin(i)[2:].zfill(16)
        pattern1 = bin(pattern1)[2:].zfill(16)
        break

ans = ""
for i in range(16):
    ans += pattern2[i]
    ans += pattern1[i]
    
true_ans = ""
flag = False
for i in range(len(ans)):
    if ans[i]=="1":
        true_ans += "1"
        flag = True
    elif flag:
        true_ans += "0"

if true_ans == "":
    true_ans = "0"
        
print(true_ans)

Measured memory_bytes: 43996
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m, d = map(int, input().split())
    print((m - 1) / n if d == 0 else (m - 1) * (n - d) * 2 / pow(n, 2))


if __name__ == '__main__':
    resolve()


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

using namespace std;

int main()
{

int N,A,S ,D;
cin >>N>>A ;
S=N/500;
D=S*500;
if(N<=A)
    cout << "Yes";
else
if (D+A>=N)
    cout << "Yes";
else
    cout << "No";


    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <algorithm>
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
ll mod = 1e9+7;
#include <cmath>

int main(){

    int n;
    cin >> n;

    ll ans = 0;

    for(int i=1; i<=n; i++){
        int tmp = log10(i);
        if(tmp%2 == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------

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

  int n; cin >> n;
  string s,t; cin >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  
  cout << endl;
  
  return 0;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> C;
    int last = -1;
    REP(i,N){
        int c;
        cin >> c;
        if(c != last)
            C.push_back(c);
        last = c;
    }

    int L = C.size();
    map<int, ll> X;
    vector<ll> DP(L+1);
    set<int> A;

    ll ans = 0;
    DP[0] = 1;
    REP(i,L){
        int c = C[i];

        A.insert(c);
        DP[i+1] = DP[i] + X[c];
        DP[i+1] %= MOD;
        //X[c] += DP[i] + 1;
        X[c] += DP[i];
        X[c] %= MOD;
    }

    ans = DP[L] % MOD;
    //ans += 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> s(n);
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int A;
            cin >> A;
            A--;
            s[A] = 1;
        }
    }
    int ans = 0;
    rep(i,n) if(s[i] != 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, A[1 << 19];
long long L[1 << 19], R[1 << 19];
priority_queue<long long, vector<long long>, greater<long long>> Q1;
priority_queue<long long, vector<long long>, less<long long>> Q2;

int main() {
	cin >> N;
	for (int i = 1; i <= 3 * N; i++) cin >> A[i];

	long long sum1 = 0;
	for (int i = 1; i <= 3 * N; i++) {
		sum1 += A[i]; Q1.push(A[i]);
		if (Q1.size() > N) { sum1 -= Q1.top(); Q1.pop(); }
		L[i] = sum1;
	}

	long long sum2 = 0;
	for (int i = 3 * N; i >= 1; i--) {
		sum2 += A[i]; Q2.push(A[i]);
		if (Q2.size() > N) { sum2 -= Q2.top(); Q2.pop(); }
		R[i] = sum2;
	}

	long long maxn = -(1LL << 60);
	for (int i = N; i <= 2 * N; i++) maxn = max(maxn, L[i] - R[i + 1]);
	cout << maxn << endl;
	return 0;
}

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

struct Bomb {
    int64_t A, B;
};

struct Code {
    int64_t L, R, index;
};

struct Edge {
    int64_t to, index;
};

int main() {
    int64_t N, M;
    cin >> N >> M;
    vector<Bomb> bombs(N);
    for (Bomb& b : bombs) {
        cin >> b.A >> b.B;
    }
    vector<Code> codes(M);
    for (int64_t i = 0; i < M; i++) {
        cin >> codes[i].L >> codes[i].R;
        codes[i].index = i;
    }

    //爆弾をソート
    sort(bombs.begin(), bombs.end(), [&](Bomb& lhs, Bomb& rhs){
        return lhs.A < rhs.A;
    });

    vector<int64_t> bomb_pos(N);
    for (int64_t i = 0; i < N; i++) {
        bomb_pos[i] = bombs[i].A;
    }

    //差分系列を考える
    vector<int64_t> diff(N + 1);
    diff[0] = bombs[0].B;
    for (int64_t i = 0; i < N - 1; i++) {
        diff[i + 1] = bombs[i + 1].B ^ bombs[i].B;
    }
    diff[N] = bombs[N - 1].B;

    //爆弾のインデックスで考えたときの影響範囲に直す
    vector<vector<Edge>> connect(N + 1);
    for (Code& c : codes) {
        c.L = lower_bound(bomb_pos.begin(), bomb_pos.end(), c.L) - bomb_pos.begin();
        c.R = upper_bound(bomb_pos.begin(), bomb_pos.end(), c.R) - bomb_pos.begin();
        if (c.L == c.R) {
            continue;
        }
        connect[c.L].push_back({ c.R, c.index });
        connect[c.R].push_back({ c.L, c.index });
    }

    //まず連結成分内の1の個数が偶数であることを確認する
    vector<bool> visit(N + 1, false);
    for (int64_t i = 0; i < N + 1; i++) {
        if (visit[i]) {
            continue;
        }

        //dfsして連結成分内の1の個数をカウント
        int64_t num1 = 0;
        stack<int64_t> st;
        st.push(i);
        while (!st.empty()) {
            int64_t top = st.top();
            st.pop();
            if (visit[top]) {
                continue;
            }

            num1 += diff[top];
            visit[top] = true;

            for (const Edge edge : connect[top]) {
                if (!visit[edge.to]) {
                    st.push(edge.to);
                }
            }
        }

        if (num1 % 2 == 1) {
            cout << -1 << endl;
            return 0;
        }
    }

    //各連結成分を回って適切なものを切る
    vector<bool> cut(M, false);
    function<int64_t(int64_t, int64_t)> f = [&](int64_t curr_node, int64_t edge_id) {
        int64_t value = diff[curr_node];
        visit[curr_node] = true;
        for (const Edge& edge : connect[curr_node]) {
            if (visit[edge.to]) {
                continue;
            }

            value ^= f(edge.to, edge.index);
        }

        if (value) {
            //edge_idを使う
            cut[edge_id] = true;
        }

        return value;
    };
    visit.assign(N + 1, false);
    for (int64_t i = 0; i < N + 1; i++) {
        if (visit[i]) {
            continue;
        }

        f(i, (int64_t)-1);
    }

    vector<int64_t> ans;
    for (int64_t i = 0; i < M; i++) {
        if (cut[i]) {
            ans.push_back(i + 1);
        }
    }

    cout << ans.size() << endl;
    for (uint64_t i = 0; i < ans.size(); i++) {
        cout << ans[i] << " \n"[i == ans.size() - 1];
    }
}

Measured memory_bytes: 27356
use std::cmp;

const INF: u32 = 1 << 30;

fn main() {
    let stdin = std::io::stdin();
    let mut sc = scanner::Scanner::new(stdin.lock());
    let s: Vec<u32> = sc
        .read::<String>()
        .chars()
        .map(|c| c as u32 - 'a' as u32)
        .collect();
    let n = s.len();
    let mut hash: Vec<u32> = vec![0; n + 1];
    for i in 0..n {
        hash[i + 1] = hash[i] ^ (1 << s[i]);
    }

    let mut prefix: Vec<u32> = vec![0];
    for i in 0..26 {
        prefix.push(1 << i);
    }

    let mut opt = vec![INF; n + 1];
    let mut dp = vec![INF; 1 << 26];
    opt[0] = 0;
    dp[0] = 0;

    for i in 0..n {
        let hash = hash[i + 1];
        for &prefix in prefix.iter() {
            let suffix = hash ^ prefix;
            opt[i + 1] = cmp::min(opt[i + 1], dp[suffix as usize] + 1);
        }
        dp[hash as usize] = cmp::min(dp[hash as usize], opt[i + 1]);
    }

    println!("{}", opt[n]);
}

pub mod scanner {
    use std::fmt::Debug;
    use std::io::Read;
    use std::str::{self, FromStr};

    pub struct Scanner<R: Read> {
        reader: R,
    }

    impl<R: Read> Scanner<R> {
        pub fn new(reader: R) -> Self {
            Scanner { reader: reader }
        }

        pub fn read<T>(&mut self) -> T
        where
            T: FromStr,
            T::Err: Debug,
        {
            let buf: Vec<u8> = self
                .reader
                .by_ref()
                .bytes()
                .map(|b| b.unwrap())
                .skip_while(|&b| (b as char).is_whitespace())
                .take_while(|&b| !(b as char).is_whitespace())
                .fold(Vec::new(), |mut buf, c| {
                    buf.push(c);
                    buf
                });

            unsafe { str::from_utf8_unchecked(&buf) }
                .parse()
                .expect("Parse error.")
        }
    }
}


Measured memory_bytes: 268668
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

for h in range(3):
    for w in range(3):
        for i in range(N):
            if b[i] == A[h][w]:
                A[h][w] = 0
if [0,0,0] in A:
    print('Yes')
elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('Yes')
elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    print('Yes')
else:
    ans = 'No'
    for i in zip(*A):
        if i == (0,0,0):
            ans = 'Yes'
            break
    print(ans)

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

int R[200010];
int M[200010];
// const int infty = 1000000010;

int main() {
  int n;
  cin >> n;
  for (auto i = 0; i < n; i++) {
    cin >> R[i];
  }
  int kau = R[0];
  for (auto i = 1; i < n; i++) {
    M[i] = R[i] - kau;
    // cerr << M[i] << " = " << R[i] << " - " << kau << endl;
    kau = min(kau, R[i]);
  }
  int ans = M[1];
  for (auto i = 2; i < n; i++) {
    ans = max(ans, M[i]);
  }
  cout << ans << endl;
}

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

public class Main {
   
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int m = in.readInt();
		int arr[] = new int[n];
		int k = in.readInt();
		for(int i = 0; i<m; i++) {
		  int x = in.readInt();
		  arr[x-1] = 1; 
		}
		int m1 = 0; 
		for(int i = 0; i<k; i++){
			m1 += arr[i]; 
		}
		int m2 = 0; 
		for(int i = k-1; i<n; i++) {
			m2 += arr[i]; 
		}
		System.out.println(Math.min(m1, m2)); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

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

int main(){
    int R;  cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
    } else if(R < 2800){
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
mod = 10 ** 9 + 7
t = [1, 1, 2, 3, 5, 8, 13, 21]
if w == 1:
    print(1)
    exit()
s = [1] + [0 for _ in range(w - 1)]
for i in range(h):
    ss = [None for _ in range(w)]
    ss[0] = (s[0] * t[w - 1] + s[1] * t[w - 2]) % mod
    ss[w - 1] = (s[w - 1] * t[w - 1] + s[w - 2] * t[w - 2]) % mod
    for j in range(1, w - 1):
        ss[j] = (s[j - 1] * t[j - 1] * t[w - j - 1] + s[j] * t[j] * t[w - j - 1] + s[j + 1] * t[w - j - 2] * t[j]) % mod
    s = ss
print(s[k - 1])

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

int main() {
	string s;
	string ans;
	cin >> s;
	if (s == "ABC")ans = "ARC";
	else ans = "ABC";
	cout << ans;
	return 0;

}






Measured memory_bytes: 3548
n, m = map(int, input().split())		# 5 7
#####################################################################

L = [[] for i in range(8)]		#=> [[], [], []]

def zm(x,i):
	if i==0: return x
	if i==1: return -1*x

for _ in range(n):
	x,y,z = map(int, input().split())		# 5 7

	for ix in range(2):
		for iy in range(2):
			for iz in range(2):
				a=zm(x,ix)+zm(y,iy)+zm(z,iz)
				i=(ix*4)+(iy*2)+iz
				L[i].append(a)

#print(L)

ans=float("-inf")
for l in L:
	l.sort(reverse=True)
	ans=max(ans, sum(l[:m]))


print(ans)




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

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

  int n = s.size();
  for(int i = 0; i <= n - 1; i++){
    int x = s[n-1];
    for(int i = n-1; i >= 1; i--){
      s[i] = s[i-1];
    }
    s[0] = x;
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 300
#define INF 99999999999999

//問題文のとおり
int N;
int A[N_MAX][N_MAX];
int B[N_MAX][N_MAX];

//ワーシャルフロイド
bool normalFloid() {
	REP(i, N)REP(j, N)B[i][j] = A[i][j];
	REP(k, N)REP(i, N)REP(j, N)B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
	REP(i, N)REP(j, N)if (A[i][j] != B[i][j])return false;
	return true;
}

LL checkFloid() {
	LL ans = 0;
	REP(i, N)REP(j, N) B[i][j] = (i==j ? INF : A[i][j] - 1);
	REP(k, N)REP(i, N)REP(j, N)B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
	
	REP(i, N)REP(j, N) {
		if (i == j)continue;
		if (A[i][j] == B[i][j] + 1)ans += A[i][j];
	}
	return ans;
}

int main() {
	//入力
	cin >> N;
	REP(i, N)REP(j, N)cin >> A[i][j];

	if (normalFloid() == false)cout << "-1" << endl;
	else cout << checkFloid()/2 << endl;
	cin >> N;

	return 0;
}

Measured memory_bytes: 896
//
//  Created by Andrey Borzenkov on 21/07/2019.
//  Copyright © 2019 Andrey Borzenkov. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define size(_x) _x.size()
#define all(_x) _x.begin(),_x.end()

using i64 = long long;
using i32 = int;
using ui32 = unsigned int;
using ui64 = unsigned long long;


using namespace std;

template<typename T = i32>
__inline__ T read() {
    T x;
    cin >> x;
    return x;
}

class TSegmentTree {
public:
    TSegmentTree(ui32 n, vector<int>& arr)
        : Tree_(vector<int>(n * 4, 0))
    {
        Build(0, 0, n, arr);
    }
    
    int Get(int v, int tl, int tr, int l, int r) {
        if (tl >= r || tr <= l) {
            return 0;
        }
        if (tl >= l && tr <= r) {
            return Tree_[v];
        } else {
            int tm = (tl + tr) / 2;
            return std::max(
                        Get(v * 2 + 1, tl, tm, l, r),
                        Get(v * 2 + 2, tm, tr, l, r)
                    );
        }
    }
    
private:
    vector<int> Tree_;
    void Build(int v, int tl, int tr, vector<int>& arr) {
        if (tl + 1 == tr) {
            Tree_[v] = arr[tl];
        } else {
            int tm = (tl + tr) / 2;
            Build(v * 2 + 1, tl, tm, arr);
            Build(v * 2 + 2, tm, tr, arr);
            Tree_[v] = max(Tree_[v * 2 + 1], Tree_[v * 2 + 1]);
        }
    }
};

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 S = read<i64>();
    i64 left = 1;
    i64 right = 1e9;
    i64 mid;
    i64 Sqrt = 0;
    while(left <= right) {
        mid = (left + right) / 2;
        if (mid * mid >= S) {
            Sqrt = mid;
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
    i64 x1 = 0, y1 = 0,
        x2 = Sqrt, y2 = 0,
        x3 = 0, y3 = Sqrt;
    i64 dlt = Sqrt * Sqrt - S;
    if (dlt) {
        x3 = 1;
        y2 = dlt;
    }
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

string memo[10000];
string bina(ll i){
    if(memo[i]!=""){
        return memo[i];
    }
    ll ii=i;
    string ans="";
    while(i>0){
        if(i%2==1){
            ans='1'+ans;
            i=i/2;
        }else{
            ans='0'+ans;
            i=i/2;
        }
    }
    
     while(ans.size()<10){
     ans='0'+ans;
     }
     memo[ii]=ans;
    
    return ans;
}

int main(){
    ll n;cin>>n;
    ll f[n+1][6][3];
    ll p[n+1][11];
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=5;j++){
            for(ll k=1;k<=2;k++){
                cin>>f[i][j][k];
            }
        }
    }
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=10;j++){
            cin>>p[i][j];
        }
    }
    string bi;
    ll psum;
    ll csum;
    ll we,ji;
    ll ans=-inf;
    for(ll i=1;i<=1023;i++){
        bi=bina(i);
        psum=0;
        for(ll j=1;j<=n;j++){
            csum=0;
            for(ll k=0;k<10;k++){
                we=(k/2)+1;
                ji=(k%2)+1;
                if(f[j][we][ji]==1 && bi[k]=='1'){
                    csum++;
                }
            }
            psum+=p[j][csum];
        }
        ans=max(ans,psum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
from collections import Counter
N = int(input())
T = [int(hoge) for hoge in input().split()]
A = T[::2]
B = T[1::2]
Adic = Counter(A)
AA = sorted(list(Adic.items()),key = lambda x: x[1],reverse=True)
AA.append((-2,0))
Bdic = Counter(B)
BB = sorted(list(Bdic.items()),key = lambda x: x[1],reverse=True)
BB.append((-1,0))
print(N - max([AA[x][1]+BB[y][1] 
for x,y in((0,0),(1,0),(0,1),(1,1)) 
if AA[x][0] != BB[y][0] ]))

Measured memory_bytes: 66668
op = 0
while op != "?":
    a,op,b = input().split()
    a = int(a)
    b = int(b)

    if op == "+":
        ans = a + b
    elif op == "-":
        ans = a - b
    elif op == "*":
        ans = a * b
    elif op == "/":
        ans = int(a / b)
    elif op == "?":
        break
    print(ans)


Measured memory_bytes: 5596
#include<iostream>

using namespace std;

int countDivisor(int N){
    int ans = 0;
    for (int i = 1; i <= N; i++){
        if (N % i == 0) ans++;
    }
    return ans;
}


int main(void){
    int n;
    cin >> n;

    int cnt = 0;

    for (int i = 1; i <= n; i += 2){
        if (countDivisor(i) == 8) cnt++;
    }

    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner  ;
public class Main{
public static void main(String[]args){

Scanner sc = new Scanner(System.in);
while(true){
int m = sc.nextInt(); 
int f = sc.nextInt();
int r = sc.nextInt();

if(m == -1 && f == -1 && r == -1 ){
    break;
    }
    if(m == -1 || f == -1){
        System.out.println("F");
    }
    else{
if ( (m + f)>=80 ){
    System.out.println("A");
}else{
     if ((m + f)< 80 && (m + f)>=65){
    System.out.println("B");
     }
     if ((m + f)< 65 && (m + f)>=50){
    System.out.println("C");
     }
     if ((m + f)< 50 && (m + f)>=30){
         if(r>=50){
    System.out.println("C");
         }else{
    System.out.println("D");
         }
        }
     if ( (m + f)<30 ){
    System.out.println("F");
     }
    
    
}

}
}
}
}


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

main() {
  int N; cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end(), greater<ll>());
  int cnt = 0;
  ll l1 = 0, l2 = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A[i] == A[i + 1]) {
      switch (cnt) {
        case 0: l1 = max(l1, A[i]);
                i++;
                cnt++;
                break;
        case 1: l2 = max(l2, A[i]);
                cnt++;
                break;
      }
    }
    if (cnt > 1) break;
  }
  cout << l1 * l2 << endl;
}


Measured memory_bytes: 1024
import sys

# sys.stdin = open('a1.in')


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


def read_str_list():
    return input().split()


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


def read_str():
    return input()


def main():
    a, b, c = read_int_list()
    p = sorted([a, b, c])
    res = p[0] + p[1]
    print(res)


main()


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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector<int>
#define vvi         vector<vi>
#define pii         pair<int,int>
#define vii         vector<pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define mkpr        make_pair
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         998244353


signed main() {
        IO;
        int n;
        cin >> n;
        vii p(n);
        for (auto &it : p) {
            cin >> it.first >> it.second;
        }
        for (int i = 0; i < n - 2; i++) {
            int cnt = 0;
            for (int j = 0; j < 3; j++) {
                if (p[i + j].first == p[i + j].second)  cnt++;
            }
            if (cnt == 3) {
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
}


Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

signed main(){
    int L;
    cin>>L;
    int n=0;
    int t=1;
    while(t<=L){
        n++;
        t*=2;
    }
    t/=2;
    cout<<n<<" "<<(int)__builtin_popcount(L)-1+(n-1)*2<<endl;
    t=1;
    for(int i=1;i<=n-1;i++){
        cout<<i<<" "<<i+1<<" "<<0<<endl;
        cout<<i<<" "<<i+1<<" "<<t<<endl;
        t*=2;
    }
    int sum=0;
    int s=1;
    for(int i=1;i<=n-1;i++){
        if(bit(L,i-1)){
            cout<<i<<" "<<n<<" "<<t<<endl;
            t+=sum+1;
        }
        sum+=s;
        s*=2;
    }

}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int res = 0;
         char curr = input.charAt(0);
         int size = 1;
         for(int i=1; i < 3; i++)
         {
            if(input.charAt(i) == curr)
               size++;
            else
            {
               if(curr == 'R')
                  res = Math.max(res,size);
               size = 1;
               curr = input.charAt(i);
            }
         }
         if(curr == 'R')
            res = Math.max(res,size);
         System.out.println(res);
      }
   }

Measured memory_bytes: 32652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		String message = null;

		if (a * b * c != 175) {
			message = "NO";
		} else {
			message = "YES";
		}

		System.out.println(message);

		sc.close();
	}

}

Measured memory_bytes: 21844