akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>
using namespace std;
 
int Pow(int x, int y) {
    int k = 1;
    for (int i = 1; i <= y; i++)k = k * x;
    return k;
}
 
int main()
{
 
    int a,n,m;
    int ans = 0;
    int x;
    cin >> a >> n >> m;
     
    int y = 1;
        while (Pow((y+a),n)<=m) {
            x =Pow( (y+ a),n);
            if (y == x % 10 + (x / 10) % 10 + (x / 100) % 10 + (x / 1000) % 10 + (x / 10000) % 10 + (x / 100000) % 10 + (x / 1000000) % 10 + (x / 10000000) % 10) { 
                ans++;
                //cout << x << endl;////
            }
            y++;
        }
     
    cout << ans << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
    int N,K; cin >> N >> K;
    int ans = K;
    N--;
    while(N--) ans *= (K-1);
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, k;

  cin >> n >> k;

  vector<int> a(n);

  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      a.at(tmp - 1) = 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a.at(i) == 0) ans++;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 3608
#include <iostream>

int main() {
    std::ios::sync_with_stdio(false);
    int64_t n, m;
    std::cin >> n >> m;

    int64_t a = std::min(n,m), b = std::max(n,m);
    if(a <= 2){
        if(a == 2){
            std::cout << 0 << '\n';
        }
        else if(b == 1){
            std::cout << 1 << '\n';
        }
        else if(b == 2){
            std::cout << 0 << '\n';
        }
        else {
            std::cout << b-2 << '\n';
        }
    }
    else {
        std::cout << (n-2)*(m-2) << '\n';
    }
}

Measured memory_bytes: 256
def sum_dict(d):
    num = 0
    for k, v in d.items():
        num += k * v
    return num


def create_dict(A):
    d = {}
    for a in A:
        if d.get(a) is None:
            d[a] = 1
        else:
            d[a] += 1
    return d


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    BC = []
    for i in range(Q):
        BC.append(tuple(map(int, input().split())))

    d = create_dict(A)

    ans = sum_dict(d)
    for b, c in BC:
        db = d.get(b)
        if db is None:
            db = 0
        if d.get(c) is None:
            d[c] = 0
        d[c] += db
        d[b] = 0

        ans += (c - b) * db
        print(ans)


Measured memory_bytes: 34992
x, k, d = map(int, input().split())

def sol(x, k, d):

    x = abs(x)

    temp = x // d

    if temp >= k:
        return x - d * k

    x -= temp * d
    k -= temp

    if k % 2 == 0:
        return x
    
    return abs(x - d)

print (sol(x, k, d))



Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[110];
signed main(){
	int n, m, x;
	scanf("%lld%lld%lld", &n, &m, &x);
	rep(i,m)scanf("%lld", &a[i]);
	int ans[2] = {};
	rep(i,m){
		if(a[i] < x)ans[0]++;
		else ans[1]++;
	}
	printf("%lld\n", min(ans[0], ans[1]));
	return 0;
}


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

int main(void){
    int n, a[11][11], i, j ;
    cin >> n;
    
    while(n != 0){
        //初期化
        for(i=0; i<=10; i++){
            for(j=0; j<=10; j++){
                a[i][j]=0;
            }
        }
        
        for(i=0; i<n; i++){
            for(j=0; j<n; j++){
                cin >> a[i][j];
                a[i][n] += a[i][j];
                a[n][j] += a[i][j];
                cout << setw(5) << a[i][j];
            }
            a[n][n] += a[i][n];
            cout << setw(5) << a[i][n] << endl;
        }
        for(j=0; j<=n; j++){
            cout << setw(5) << a[n][j];
        }
        cout << endl;
        cin >> n;
    }
    return 0;
}



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

int main(){
  int N;
  cin >>N;
  long long int a;
  int zeros=0,ones=0,twoes=0;
  for(int i=0;i<N;i++){
    cin >>a;
    if(a%2 != 0) zeros++;
    else if(a%4 == 2) ones++;
    else if(a%4 == 0) twoes++;
  }
  if(ones==0 && zeros-1==twoes) cout << "Yes" <<endl;
  else if(twoes>=zeros) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)1000000007
// Big two primes 
#define X 1011001110001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int int
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vii vector<pi>
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 



int main()
{
    fio;
	
	multiset<int> s;
	int a,b,c;
	in(a);
	in(b);
	in(c);

	s.insert(a);
	s.insert(b);
	s.insert(c);

	if(s.count(5) == 2 && s.count(7) == 1)
		cout<<"YES\n";

	else cout<<"NO\n";

	rr;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var b = 0d;
        for (int i = 0; i < n; i++) b += 1d / a[i];
        Console.WriteLine(1d / b);
    }
}


Measured memory_bytes: 13140
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>


string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    ll L;
    ll R;
    
    cin >> L;
    cin >> R;

    ll Ll = L % 2019;
    ll Rr = R % 2019;

    if( R - L >= 2019  ) cout << 0 << endl;
    else{

        if(Rr < Ll) Rr += Rr + 2019;

        ll ans = 2019 * 2019;
        ll tmp;
        //cout << Ll << endl;
        //cout << Rr << endl;
        for( int n1 = Ll ; n1 <= Rr-1 ; n1++ ){
            for( int n2 = n1 + 1 ; n2 <= Rr ; n2++ ){
                tmp = (n1 * n2) % 2019;        
                if(tmp < ans ) ans = tmp;
            }
            
        }
        cout << ans << endl;

    }
}

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

const int MAXN = 2e5 + 5;

int n;
int c[10][10];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x = i % 10;
		int y = i;
		while (y / 10 > 0) {
			y /= 10;
		}
		c[x][y]++;
	}
	long long res = 0;
	for (int i = 1; i <= 9; i++) {
		res += c[i][i] * c[i][i];
		for (int j = i + 1; j <= 9; j++) {
			res += 2LL * c[i][j] * c[j][i];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

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

func abs(A int) int {
	if A < 0 {
		return -A
	}
	return A
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Traveling Plan
	var N int
	fmt.Scan(&N)

	sc.Split(bufio.ScanWords)
	A := make([]int, N+2)
	A[0] = 0
	A[N+1] = 0
	var ans int
	for i := 1; i <= N; i++ {
		A[i] = nextInt()
	}

	for i := 1; i <= N+1; i++ {
		ans += abs(A[i] - A[i-1])
	}

	var temp int
	for i := 1; i <= N; i++ {
		temp = abs(A[i+1]-A[i-1]) - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i])
		fmt.Println(ans + temp)
	}

}


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

typedef long long int ll;

int main()
{
	ll n;
	scanf("%lld",&n);
	ll arr[n][3];
	for(ll i=0;i<n;i++)
		scanf("%lld %lld %lld",&arr[i][0],&arr[i][1],&arr[i][2]);
	ll dp[n][3]={0};
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for(ll i=1;i<n;i++)
	{
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	printf("%lld\n",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
}


Measured memory_bytes: 8424
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int N=2e5+5;
struct edge
{
	int to,next;
};
struct edge e[2*N];
ll cnt=0,head[N]={0};
void add(ll from,ll to)
{
	e[++cnt].next=head[from];
	e[cnt].to=to;

	head[from]=cnt;
}
ll sum[N]={0};
void dfs(ll u,ll p)
{
	for(ll i=head[u];i;i=e[i].next)
	{
		 ll v=e[i].to;
		 if(v==p)continue;
		 sum[v]+=sum[u];
		 dfs(v,u);
	}
}
int main()
{
ll n,q;
scanf("%lld %lld",&n,&q);
rep(i,0,n-1)
{
	ll x,y;
	scanf("%lld %lld",&x,&y);
	add(x,y);
	add(y,x);
}
rep(i,0,q)
{
  	ll num,adt;
  	scanf("%lld %lld",&num,&adt);
  	sum[num]+=adt;
}
dfs(1,0);
repb(i,1,n)
printf("%lld ",sum[i]);
}




Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define ll long long int
#define M 1000000007

using namespace std;

const int mxN=100,mxX=1e9;
int n,k;
int dp[100001] = {0};
int a[100];

int main()
{
    cin>>n>>k;
    for(int i = 0; i<n; i++)
    {
        cin>>a[i];
        dp[a[i]] = 1;
    }
    sort(a,a+n);
    dp[0] = 2;
    for(int i = 1; i<=k; i++)
    {
        if(dp[i] == 1)
            continue;
        dp[i] = 2;
        for(int j = 0; j<n; j++)
        {
            if(i-a[j]<0)
                break;
            if(dp[i-a[j]] != 1)
            {
                dp[i] = 1;
                break;
            }
        }
    }
    if(dp[k] == 1)
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}

Measured memory_bytes: 3932
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static bool[] cardState = new bool[9];
        static int[] card = new int[9];
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var n = nm[0];
            var m = nm[1];

            var result = new int[n];
            for (var i = 0; i < n; i++)
            {
                result[i] = -1;
            }

            for (var i = 0; i < m; i++)
            {
                var sc = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
                var s = sc[0] - 1;
                var c = sc[1];
                if (result[s] != -1 && result[s] != c)
                {
                    Console.WriteLine(-1);
                    return;
                }
                result[s] = c;
            }

            for (var i = 0; i < n; i++)
            {
                if (n != 1 && i == 0)
                {
                    if (result[i] == 0)
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                    else if (result[i] == -1)
                    {
                        result[i] = 1;
                    }
                }
                else
                {
                    if (result[i] == -1)
                    {
                        result[i] = 0;
                    }
                }
            }

            for (var i = 0; i < n; i++)
            {
                Console.Write(result[i]);
            }
        }
    }
}

Measured memory_bytes: 28292
#include <cstdio>

using namespace std;

static const int MAX_N = 100;
int A[MAX_N];
int N;

void show(int *a, int n) {
	for (int i = 0; i < n; i++) {
		printf("%d", *(a + i));
		if (i != n - 1) {
			printf(" ");
		}
	}
	printf("\n");
}

void bobleSort(int *a, int n);

void solve() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", A + i);
	}
	bobleSort(A, N);
}

int main() {
	solve();
}

void bobleSort(int *a, int n) {
	bool f = true;
	int temp;
	int count = 0;

	while (f) {
		f = false;
		for (int j = n - 1; j != 0; j--) {
			if (A[j] < A[j - 1]) {
				temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				f = true;
				count++;		// ?????¢??°
			}
		}
	}
	show(a, N);
	printf("%d\n", count);
}

Measured memory_bytes: 2740
def func(d, cnt9, cnt0):
    if cnt9 < 1 : return d == 0
    n = int("9" * cnt9 + "0" * cnt0)
    return sum(func(d + i * n, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1)) for i in range(-9, 10) if abs(d + i * n) < n)

D = input()
print sum(func(D, i, 0) * (10 - i % 2 * 9) for i in range(1, 21))

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

typedef long long ll;

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

      string s; cin >> s;
      long long n = s.size();
      long long ans = n*(n-1)/2 + 1;

      vector<long long> f(256);
      for (char c: s) {
            f[c]++;
      }

      for (int i = 'a'; i <= 'z'; i++) {
            ans -= f[i]*(f[i] - 1)/2;
      }
      cout << ans;

      return 0;
}


Measured memory_bytes: 720
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"



int main() {
	int N, W; cin >> N >> W;
	vector<pair<int, int>>ps;
	for (int i = 0; i < N; ++i) {
		int v, w; cin >> v >> w;
		ps.emplace_back(w,v);
	}
	vector<vector<int>>dp(N + 1, vector<int>(W + 1));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= W; ++j) {
			dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
			if (j + ps[i].first <= W) {
				dp[i][j + ps[i].first] = max(dp[i][j + ps[i].first], dp[i][j] + ps[i].second);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= W; ++i) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6852
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000000
using namespace std;

typedef long long ll;

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

int main()
{
    ll n, x[N] = {};
    cin >> n >> x[0];
    FOR(i, 1, n + 1)
    cin >> x[i];

    sort(x, x + n + 1);

    ll d = 0;
    FOR(i, 0, n)
    {
        d = gcd(x[i + 1] - x[i], d);
    }

    cout << d << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int a, b;
    cin >> a >> b;
    
    cout << max(0, a - 2*b) << endl;

    return 0;
}

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

int main(){
    unsigned long x=100,y;
    cin >> y;
    unsigned long i = 0;

    while(true){
        ++i;
        unsigned long b = x*0.01;
        x += b;

        if(x>=y){
            break;
        }
    }
    cout << i;

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int mat[100001][101];
int supp[100001][101];
int main(){
	#ifdef EVAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	string a;
	int D;
	cin>>a;
	cin>>D;
	for(int i=1;i<=9;i++)mat[0][i%D]++;
	for(int i=1;i<a.length();i++){
		for(int j=1;j<=9;j++){
			mat[i][j%D]++;
		}
		for(int j=0;j<D;j++){
			for(int ki=0;ki<=9;ki++){
				mat[i][(ki+j)%D]+=mat[i-1][j];
				mat[i][(ki+j)%D]%=1000000007;
			}
		}
	}
	int sum=0;
	int sol=0;
	for(int i=0;i<a.length()-1;i++){
		for(int j=0;j<D;j++){
			for(int h=0;h<a[i]-48;h++){
				if((j+h+sum)%D==0)sol+=mat[a.length()-1-i-1][j];
				sol%=1000000007;
			}
		}
		sum+=a[i]-48;
	}
	sum+=a[a.length()-1]-48;
	for(int i=1;i<=sum;i++){
		if(i%D==0)sol++;
		sol%=1000000007;
	}
	cout<<sol;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    ll N;
    cin >> N;
    ll ans=IINF;
    for (ll i=1;i*i<=N;i++){
        if (N%i==0){
            chmin(ans,i+N/i-2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    println!("{}", 1 - n);
}


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

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

    for(int i = 0; i < n.length(); i++){
        if(n[i] == '7'){ 
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define F first
#define S second
#define int long long

using ll = long long;
using ld = double;
using pii = pair <int, int>;

const int oo = 1e9 + 4;
const int SZ = 2e5 + 4;
const ll M = 998244353;

int n, s;
vector <int> a;
ll k[3010];

void read() {
    cin >> n >> s;
    a.resize(n);
    for (auto &t : a) cin >> t;
}

void solve() {
    k[0] = 1;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (s - a[i] >= 0) ans += 1ll * k[s - a[i]] * (n - i) % M;
        ans %= M;
        for (int j = s; j >= a[i]; j--)
            k[j] = (k[j] + k[j - a[i]]) % M;
        k[0]++;
    }
    cout << ans;
}

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

    read();
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

struct UnionFind {
    vector<int> par;
    vector<int> rnk;

    UnionFind(int n) {
        par.assign(n, 0);
        rnk.assign(n, 1);
        for(int i=0; i<n; i++) {
            par[i] = i;
        }
    }

    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        if(rnk[x] < rnk[y]) swap(x, y);
        rnk[x] += rnk[y];
        par[y] = x;
    }

    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return rnk[find(x)];
    }
};

signed main() {
    int N, M;
    cin >> N >> M;
    vi p(N);
    rep(i, N) cin >> p[i];

    UnionFind uf(100050);

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    int res = 0;
    FOR(i, 1, N+1) {
        if(uf.same(i, p[i-1])) res++;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 2560
import math
n ,d = map(int, input().split())
x = []
answer = 0
for i in range(n):
    x.append(list(map(int, input().split())))

for i in range(n):
    y = x[i]
    for z in x[i+1:]:
        dis = 0
        for j in range(d):
            dis += (y[j] - z[j])**2
        a = math.sqrt(dis)
        if int(a) == a:
            answer += 1
print(answer)

Measured memory_bytes: 3064
# Cは整数のC
# a + b + c = yなのでそういうことです
# オーダーの見積もり典型問題

n, y = map(int, input().split())

for a in range(2000+1):
    for b in range(2000+1):
        c = n - a - b
        if c < 0:
            break
        if a * 10000 + b * 5000 + c * 1000 == y:
            print("{} {} {}".format(a, b, c))
            exit()

print(-1, -1, -1)


Measured memory_bytes: 40684
N,L=list(map(int,input().split()))
A=list(map(int,input().split()))


def find():
    for i in range(N-1):
        if A[i]+A[i+1] >=L:
            return i
    return False

n=find()
if n is False:
    print('Impossible')
    exit(0)

n+=1
print('Possible')
for i in range(1,n):
    print(i)
for i in range(N-1,n,-1):
    print(i)
print(n)

Measured memory_bytes: 14152
class Solution(object):
    def __init__(self):
        pass
        
    def Sol(self, n, k, r):
        fq = dict([(i, 0) for i in range(0, n + 1)]) 
        t = 0
        for _r in r:
            fq[_r] += 1
            t += 1
        
        player = [k for i in range(0, n)]
        for i in range(0, n):
            player[i] = k - t + fq[i + 1]
        return player


def main():
    info = [int(e) for e in input().split()]
    r = []
    for _ in range(0, info[2]):
        r.append(int(input()))
    pl = Solution().Sol(info[0], info[1], r)
    for sc in pl:
        if sc <= 0:
            print('No')
        else:
            print('Yes')
    return 0

if __name__ == "__main__":
    main()

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

template<typename T>
struct SegementTree {
    using F = function<T(T, T)>;

    SegementTree(F func, T id)
            : merge(func), identity(id) {}

    void init(ll n) {
        offset = 1;
        while (offset < n)
            offset <<= 1;
        node.assign(offset << 1, identity);
    }

    void build(const vector<T> &v) {
        int n = static_cast<int>(v.size());
        init(n);
        for (int i = 0; i < n; ++i) {
            node[offset + i] = v[i];
        }
        for (int i = offset - 1; i >= 0; --i) {
            node[i] = merge(node[(1 << i) | 0], node[(1 << i) | 1]);
        }
    }

    void set(int n, T value) {
        int index = n + offset;
        node[index] = value;
        while (index >>= 1) {
            node[index] = merge(node[(index << 1) | 0], node[(index << 1) | 1]);
        }
    }

    //! [left, right)
    T get(int left, int right) {
        left += offset;
        right += offset + 1;

        T val = identity;
        while (left < right) {
            if (left & 1)
                val = merge(val, node[left++]);
            if (right & 1)
                val = merge(val, node[--right]);

            left >>= 1;
            right >>= 1;
        }
        return val;
    }

    T identity;
    F merge;
    vector<T> node;
    int offset;
};

int main() {
    ll N;
    cin >> N;
    auto func = [](ll a, ll b) { return std::min(a, b); };
    SegementTree<ll> seg(func, (1LL << 31) - 1);
    seg.init(N);
    ll Q;
    cin >> Q;
    REP(i, Q) {
        ll c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            seg.set(x, y);
        }
        else {
            cout << seg.get(x, y) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
#include <stdlib.h>
#define MAX 100010
#define INFTY 10000000
#define NIL -1

struct Node {
	int value;
	struct Node *next;
};
typedef struct Node node_t;


int N;
int M;
int id =1;
node_t *G[MAX];
int color[MAX];

node_t* addNode(node_t *node, int value)
{
	node_t *new = (node_t*)malloc(sizeof(node_t));
	new->value = value;
	new->next = node;
	return new;
}

void dfs(int r)
{
	color[r] = id;
	node_t *n;
	for (n=G[r]; n!=NULL; n=n->next) {
		int v = n->value;
		if (color[v] == NIL) {
			color[v] = id;
			dfs(v);
		}
	}
}

void assignColor()
{
	int i, u;
	for (i=0; i<N; i++) {
		color[i] = NIL;
	}
	for (u=0; u<N; u++) {
		if (color[u] == NIL) {
			dfs(u);
			id++;
		}
	}
}


int main()
{
	int i, n, u, v;	
	scanf("%d %d", &N, &M);	
	for (i = 0; i < M; i++) {
		scanf("%d %d", &n, &v);
		G[n] = addNode(G[n], v);
		G[v] = addNode(G[v], n);
	}
	
	assignColor();
	
	int Q;
	scanf("%d", &Q);
	for (i = 0; i < Q; i++) {
		scanf("%d %d", &u, &v);
		if (color[u] == color[v]) {
			puts("yes");			
		}
		else {
			puts("no");
		}
	}

	return 0;
}

Measured memory_bytes: 9560
#include<stdio.h>
#include<string.h>
using namespace std;

int f_min(int a, int b){
	return a > b ? b : a;
}

int main(){
	int N, X, m, sum = 0, min = 0x7fffffff;
	scanf("%d %d", &N, &X);
	for (int i = 0; i < N; ++i){
		scanf("%d", &m);
		sum += m;
		min = f_min(min, m);
	}
	X -= sum;
	int ans = X/min + N;

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

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=1050;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int f[N][N],n,d1,d2,cnt;
void solve(int d){
    int t=0;
    while(d%4==0)
	d/=4,++t;
    if (d%2)
	for (int i=0; i<2*n; ++i)
	    for (int j=0; j<2*n; ++j)
		f[i][j]|=(i>>t&1)^(j>>t&1);
    else
	for (int i=0; i<2*n; ++i)
	    for (int j=0; j<2*n; ++j)
		f[i][j]|=(i>>t&1);
    return;
}
int main(){
    cin>>n>>d1>>d2,cnt=n*n;
    solve(d1),solve(d2);
    for (int i=0; i<2*n; ++i)
	for (int j=0; j<2*n; ++j)
	    if (cnt&&!f[i][j])
		--cnt,cout<<i<<" "<<j<<endl;
    return 0;
}


Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

bool cmp(pair<pi, pair<int,string>>a, pair<pi, pair<int,string>>b){
    return a.se<b.se;
}

void run(){
    int n,m;
    cin>>n>>m;
    vector<pair<pi,pair<int,string>>> s(m);
    rep(i,m){
        cin>>s[i].fi.fi>>s[i].fi.se;
        s[i].se.fi=i;
        char t[10];
        sprintf(t,"%06lld",s[i].fi.fi);
        s[i].se.se=t;
    }
    sort(all(s));
    pi b;
    b.fi=0;
    b.se=0;
    rep(i,m){
        if(b.fi!=s[i].fi.fi){
            b.fi=s[i].fi.fi;
            b.se=1;
        }
        char t[10];
        sprintf(t,"%06lld",b.se);
        s[i].se.se+=t;
        b.se ++;
    }
    sort(all(s),cmp);
    rep(i,m)cout<<s[i].se.se<<endl;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll aa[1000000];
string ss[10000];
int main()
{
	ll a,b=0;
	cin>>a;
	aa[0]=a;
	while(1){
		b++;
		if(aa[b-1]%2==0){
			aa[b]=aa[b-1]/2;
		}else{
			aa[b]=aa[b-1]*3+1;
		}
		for(ll i=0;i<b;i++){
			if(aa[i]==aa[b]){
				cout<<b+1;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

vector< vector<bool> > foot;
int H,W;


bool check(int y,int l,int r){
	REP(x,W){
		if(x >= l && x <= r){
			if(!foot[x][y])return false;
		}else{
			if(foot[x][y])return false;
		}
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W;
	foot = vector< vector<bool> > (W,vector<bool>(H,false));;
	REP(i,H){
		REP(j,W){
			char c;
			cin >> c;
			if(c == '#')foot[j][i] = true;
		}
	}
	int x = 0;
	REP(y,H){
		int l = x;
		while(x<W-1){
			if(foot[x+1][y])x++;
			else break;
		}
		if(!check(y,l,x)){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout  << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
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();
        long sum=0;
        for(int i=0;i<10000;i++){
            sum=i*A;
            if(sum%B==C){
                System.out.println("YES");
                break;
            }
            if((i==9999)&&(sum%B!=C)){
                System.out.println("NO");
            }
        }
        
    }
        
     
    }


Measured memory_bytes: 21844
N=int(input())
A=list(map(int,input().split()))

import fractions
if N==2:
  print(max(A))
else:
  L=[0]*(N)
  R=[0]*(N)
  L[0]=A[0]
  R[N-1]=A[N-1]
  for i in range(1,N):
    L[i]=fractions.gcd(L[i-1],A[i])
  for i in range(N-1,0,-1):
    R[i-1]=fractions.gcd(R[i],A[i-1])
  ans=0
  for i in range(1,N-1):
    x=fractions.gcd(L[i-1],R[i+1])
    ans=max(ans,x)

  print(max(ans,L[N-2],R[1]))


Measured memory_bytes: 14400
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;


typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    map<char, int> dict;
    for (int i=0;i<s.size();i++){
        dict[s[i]] += 1;
    }
    if (dict.size() == 2 && dict[s[0]] == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

int n, m;
vector<vector<int>> v(111111);

int dfs(int now, int pre, int s, int t){
	if(now == s)return 1;
	if(now == t)return 0;
	REP(i, v[now].size())if(v[now][i] != pre)return dfs(v[now][i], now, s, t);
	return 0;
}

int checkForm(int s, int t){
	int ret = 0;
	REP(i, 4)ret += dfs(v[s][i], s, s, t);
	return ret;
}

void input(){
	cin >> n >> m;
	REP(i, m){
		int a, b;cin >> a >> b;
		a--;b--;
		v[a].EB(b);
		v[b].EB(a);
	}
}

int main(){
	input();

	vector<int> four;
	int six = 0;

	REP(i, n){
		if(v[i].size() % 2){
			cout << "No" << endl;
			return 0;
		}

		if(v[i].size() == 4)four.PB(i);
		if(v[i].size() > 4)six++;
	}

	if(six > 0 || four.size() > 2){
		cout << "Yes" << endl;
		return 0;
	}

	if(four.size() == 2 && checkForm(four[0], four[1]) == 2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M, K;
	cin >> N >> M >> K;
	for(int x = 0; x <= M; x++) {
		for(int y = 0; y <= N; y++) {
			if(M * y + N * x - 2 * x * y == K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

// 素数判定
bool isPrime(ll n) {
    ll i = 2;
    while (i*i <= n) {
        if(n%i==0) return false;
        i++;
    }
    return true;
}


int main() {
    int n,r; cin >> n >> r;
    if(n >= 10) {
        cout << r << endl;
    } else {
        cout << r  + (100*(10-n)) << endl;
    }
    return 0;
}


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


void solve(int A,int B){
   vector<vector<int>> a8(1200);
   vector<vector<int>> a10(1200);
   for (int i=0;i<=10001;i++){
       a8[int(floor(i*1.08))-i].push_back(i);
       a10[int(floor(i*1.1))-i].push_back(i);
   }
   for ( const int  elem8 : a8[A]){
       for (const int elem10: a10[B]){
           if (elem10 == elem8) {
               cout << elem8 <<endl;
               return;
           }
       }
   }
   cout << -1 << endl;
   return ;

    

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int A;
    scanf("%d",&A);
    int B;
    scanf("%d",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N, M; cin >> N >> M;
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a; m[a]++;
  }
  for (int i = 0; i < M; ++i) {
    int b, c; cin >> b >> c;
    m[c] += b;
  }

  LL sum = 0;
  for (auto it = m.rbegin(); it != m.rend(); ++it) {
    auto [k, cnt] = *it;
    LL v = k;
    if (N > cnt) {
      sum += v * cnt;
      N -= cnt;
    } else {
      sum += v * N;
      break;
    }
  }
  cout << sum << endl;
}


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

int main() {
  int N, M;

  while (true) {
    cin >> N >> M;
    if (N == 0 && M == 0) break;
    swap(N, M);
    cout << min(N, M) << " " << max(N, M) << endl;
  }
}


Measured memory_bytes: 2988
#include <iostream>

using namespace std;

int h[200000];

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

    int64_t sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> h[i];
        sum += h[i];
    }

    for (int gap = n/2; gap > 0; gap /= 2)
    {
        for (int i = gap; i < n; ++i)
        {
            for (int j = i - gap; j >= 0 && h[j] < h[j+gap]; j -= gap)
            {
                swap(h[j], h[j+gap]);
            }
        }
    }

    for (int i = 0; i < k; ++i)
    {
        sum -= h[i];
    }

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 1024
import sys
from heapq import heappush, heappop
from collections import Counter

n, t, *a = map(int, sys.stdin.read().split())

def main():
  cand = []
  hq = [a[0]]
  for x in a[1:]:
    y = heappop(hq)
    cand.append(x - y)
    heappush(hq, x)
    heappush(hq, y)
  c = Counter(cand)
  ans = c[max(c.keys())]
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 23512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    int n, b[42] = {}, c[42] = {};
    ll a[100005] = {}, k, d[42][2] = {};
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < 40; j++) {
            if (a[i] & (1ll << j)) b[j]++;
            else c[j]++;
        }
    }
    d[40][1] = -1ll * mod * mod;
    for (int i = 39; i >= 0; i--) {
        d[i][0] = d[i][1] = -1ll * mod * mod;
        if (k & (1ll << i)) {
            d[i][1] = max(d[i][1], d[i + 1][0] + b[i] * (1ll << i));
            d[i][1] = max(d[i][1], d[i + 1][1] + b[i] * (1ll << i));
            d[i][0] = max(d[i][0], d[i + 1][0] + c[i] * (1ll << i));
            d[i][1] = max(d[i][1], d[i + 1][1] + c[i] * (1ll << i));
        } else {
            d[i][0] = max(d[i][0], d[i + 1][0] + b[i] * (1ll << i));
            d[i][1] = max(d[i][1], d[i + 1][1] + b[i] * (1ll << i));
            d[i][1] = max(d[i][1], d[i + 1][1] + c[i] * (1ll << i));
        }
    }
    cout << max(d[0][0], d[0][1]);
}


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

int main(){
  int a[3],count=0;
  cin>>a[0]>>a[1]>>a[2];
	if(a[0]!=a[1]){
      count++;
    }
  	if(a[2]!=a[1]){
      count++;
    }
  	if(a[0]!=a[2]){
      count++;
    }
  if(a[0]==a[1]&&a[1]==a[2]){
    count=1;
  }
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int[] m = in.nextIntArray(n);

            Arrays.sort(m);

            for (int i = 0; i < n; i++) {
                x -= m[i];
            }

            out.println(n + x / m[0]);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
#include <stdlib.h>
int main(){
  int N,count,ans,i;
  count=0;
  ans=0;
  scanf("%d",&N);
  char C[N+1];
  scanf("%s",C);
  for(i=0;i<N;i++){
    if(strncmp("R",&C[i],1)==0) count++;
  }
  for(i=0;i<count;i++){
    if(strncmp("W",&C[i],1)==0) ans++;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <iostream>
using namespace std;
typedef long long LL;
const LL N = 50;
const int MAXN = 50;


LL A[MAXN + 5];
LL K;
int main()
{
	scanf("%lld", &K);
	LL a = K / N, b = K % N;
	for(int i = 1; i <= N; i++) A[i] = N - 1 + a;
	for(int i = 1; i <= b; i++){
		A[i] += N;
		for(int j = 1; j <= N; j++){
			if(i != j) A[j]--;
		}
	}
	printf("%lld\n", N);
	for(int i = 1; i <= N; i++){
		if(i == N) printf("%lld\n", A[i]);
		else printf("%lld ", A[i]);
	}
}


Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<int> > edge(N);
  int u, v;
  for(int i=0;i<M;++i){
    cin>>u>>v;
    u--;
    v--;
    edge[u].push_back(v);
  }
  int S, T;
  cin>>S>>T;
  S--;
  T--;
  queue<int> que;
  queue<int> numque;
  map<int, vector<int> > amap;
  bool ok[N];
  que.push(S);
  numque.push(0);
  int state, num;
  bool aru;
  while(!que.empty()){
    state = que.front();que.pop();
    num = numque.front();numque.pop();
    aru = false;
    for(int i=0;i<amap[state].size();++i){
      if(amap[state][i]%3==num%3) aru = true;
    }
    if(aru) continue;
    amap[state].push_back(num);
    for(int i=0;i<edge[state].size();++i){
      aru = false;
      for(int j=0;j<amap[edge[state][i]].size();++j){
        if(amap[edge[state][i]][j]%3==(num+1)%3) aru = true;
      }
      if(aru) continue;
      que.push(edge[state][i]);
      numque.push(num+1);
    }
  }
  int ans = -1;
  aru = false;
  for(int i=0;i<amap[T].size();++i){
    if(amap[T][i]%3==0) {
      ans = amap[T][i];
      aru = true;
    }
  }
  if(aru) cout<<ans/3<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 19444
#include <stdio.h>
#include <string.h>
#define ll long long
const int N=2e5+5;
char str[N];

int main()
{
    memset(str,'\0',sizeof(str));
    while(scanf("%s",str)!=EOF)
    {   ll ans,cnt;
        ans=cnt=0;
        for(int i=0;str[i]!='\0';i++)
        {
            if(str[i]=='B')
                cnt++;
            else
                ans+=cnt;
        }
        printf("%lld\n",ans);
        memset(str,'\0',sizeof(str));
    }
    return 0;
}


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

int main() {
	int a,b,c,d,e,ans=0;
	cin >> a >> b >> c >> d >> e;
	if(a<=0){
		ans+=(-a*c+d+e);
		a=1;
	}
	cout << ans+(b-a)*e << endl;
}


Measured memory_bytes: 3120
<?php
// Your code here!
$N = fgets(STDIN);  
$m = 1;
while(true){
    if(1000 * $m >= $N){
        $ans = 1000 * $m - $N;
        echo $ans;
        return $ans;
        break;
    } else {
        $m++;
    }
}

?>


Measured memory_bytes: 16216
n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
a=[]
count=[]
buf=1
count_max=1
for i in range(n):
    s_i=s[i]
    if s_i==s[i+1]:
        buf+=1
    else:
        if buf>=count_max:
            a.append(s_i)
            count.append(buf)
            if buf>count_max:
                count_max=buf
        buf=1
count_max=max(count)
for i in range(len(a)):
    if count[i]==count_max:
        print(a[i])

Measured memory_bytes: 22080
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
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 pair<int, int> PII;
const ll mod = 1000000007;
const double eps = 1e-6;
const double PI = acos(-1);
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; }
const int iadd[] = {0, 1, 0, -1}, jadd[] = {1, 0, -1, 0};
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
int n;
int a[maxn];

void solve(){
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] == i) {
			swap(a[i], a[i + 1]);
			ans++;
		}
	}
	printf("%d\n", ans);
}
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	solve();
}






Measured memory_bytes: 640