akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int arr[3][3];
bool v[3][3];

bool check3(int wkX, int wkY)
{
    if (wkX >= 0 && wkX < 3 && wkY >= 0 && wkY < 3)
    {
        // cout << arr[wkX][wkY] << " " << v[wkX][wkY] << endl;
        return v[wkX][wkY];
    }

    return false;
}

bool check(int x, int y)
{
    if (!check3(x, y))
        return false;

    int i = 0;
    i += check3(x - 2, y);
    i += check3(x - 1, y);
    i += check3(x + 1, y);
    i += check3(x + 2, y);
    if (i == 2)
    {
        return true;
    }
    i = 0;
    i += check3(x, y - 2);
    i += check3(x, y - 1);
    i += check3(x, y + 1);
    i += check3(x, y + 2);
    if (i == 2)
    {
        return true;
    }
    i = 0;
    i += check3(x - 2, y - 2);
    i += check3(x - 1, y - 1);
    i += check3(x + 1, y + 1);
    i += check3(x + 2, y + 2);
    if (i == 2)
    {
        return true;
    }
    i = 0;
    i += check3(x - 2, y + 2);
    i += check3(x - 1, y + 1);
    i += check3(x + 1, y - 1);
    i += check3(x + 2, y - 2);
    if (i == 2)
    {
        return true;
    }

    return false;
}

void add(int aa)
{
    rep(i, 3)
    {
        rep(j, 3)
        {

            if (arr[i][j] == aa)
            {
                v[i][j] = true;
                return;
            }
        }
    }
}

int main()
{
    rep(i, 3)
    {
        rep(j, 3)
        {
            cin >> arr[i][j];
            v[i][j] = false;
        }
    }

    int n, aa;
    cin >> n;
    rep(a, n)
    {
        cin >> aa;
        add(aa);
    }
    rep(i, 3)
    {
        rep(j, 3)
        {

            if (check(i, j))
            {
                cout << "Yes" << endl;
                return (0);
            }
        }
    }

    cout << "No" << endl;
}


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

using namespace std;



int main()
{
	int a, b, c, k;
	cin>>a>>b>>c>>k;
	int m = 0;
	while(b <= a)
	{
		b *= 2;
		m++;
	}
	while(c <= b)
	{
		c *= 2;
		m++;
	}
	if(m <= k) cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll ans;
int main()
{
	cin>>s;
	ll len=s.size();
	for(int i=1;i<len;i++)
	if(s[i]!=s[i-1]) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
def calc_comb(N, MOD):
    dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0] = 1
        dp[0][i] = 1
        dp[i][1] = i
    for i in range(2, N + 1):
        for j in range(2, i + 1):
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1]
            dp[i][j] %= MOD
    return dp


def main():
    MOD = 10**9 + 7
    N, K = list(map(int, input().split(' ')))
    # (N-K+1)_C_i * (K-1)_C_(i-1)
    comb = calc_comb(N, MOD)
    for i in range(1, K + 1):
        answer = comb[N - K + 1][i] * comb[K - 1][i - 1] % MOD
        print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 99032
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2) % MOD;
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

ll MUL(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }

ll DIV(ll a, ll b) { return MUL(a, POW(b, MOD - 2)); }

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vvl DP = VVL(61, 3, 0);
  bitset<60> bs(N);
  DP[60][0] = 1;
  RREP(i, 60) {
    if (bs[i] == 1) {
      //+1
      DP[i][0] = DP[i + 1][0];
      //+0 +2
      DP[i][1] = DP[i + 1][0] + DP[i + 1][1];
      // +0,+1 +0,+1,+2
      DP[i][2] = 2 * DP[i + 1][1] + 3 * DP[i + 1][2];
    } else {
      //+0 +2
      DP[i][0] = DP[i + 1][0] + DP[i + 1][1];
      //+1
      DP[i][1] = DP[i + 1][1];
      // +0 +0,+1,+2
      DP[i][2] = DP[i + 1][1] + 3 * DP[i + 1][2];
    }
    DP[i][0] %= MOD;
    DP[i][1] %= MOD;
    DP[i][2] %= MOD;
  }

  cout << ((DP[0][0] + DP[0][1]) % MOD + DP[0][2]) % MOD << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

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

    System.out.println(a + a*a + a*a*a);
    
    

    


    
    


    


    
    


    
	}
}

Measured memory_bytes: 35708
#include<iostream>
#include<vector>
#include<map>
#include<cstring>
#define ll long long int
using namespace std;

struct flower {
    ll height;
    ll beauty;
};

ll flowers(vector<flower> &v, int n) {
    vector<ll> dp(n + 1);
    map<ll, ll> meaningful;
    // Base Case
    dp[1] = v[1].beauty;
    meaningful[v[1].height] = dp[1];
    // Bottom Up Approach
    ll ans = dp[1];
    for(int i = 2; i <= n; i++) {
        dp[i] = v[i].beauty;
        auto it = meaningful.lower_bound(v[i].height + 1);
        if(it != meaningful.begin()) {
            it--;
            dp[i] += it->second;
        }
        meaningful[v[i].height] = dp[i];
        it = meaningful.upper_bound(v[i].height);
        while((it != meaningful.end()) && (it->second <= dp[i])) {
            auto temp = it;
            temp++;
            meaningful.erase(it);
            it = temp;
        }
        ans = max(ans, dp[i]);
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<flower> v(n + 1);
    for(int i = 1; i <= n; i++) cin >> v[i].height;
    for(int i = 1; i <= n; i++) cin >> v[i].beauty;
    cout << flowers(v, n) << endl;
    return 0;
}

Measured memory_bytes: 20408
# coding: utf-8
import math

a,b,C = map(float,input().split())

C_rad = math.pi * C / 180
h = b * math.sin(C_rad)
S = a * h / 2
L = a + b + math.sqrt((a ** 2 + b ** 2 - 2 * a * b * math.cos(C_rad)))

print("{:.6f}".format(S))
print("{:.6f}".format(L))
print("{:.6f}".format(h))

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

struct Stu {
	int m;
	int f;
	int r;
};

int main() {
	Stu stu[51];
	int i = 0;
	do {
		cin >> stu[i].m >> stu[i].f >> stu[i].r;
	} while (!(stu[i].m == -1 & stu[i].f == -1 & stu[i++].r == -1));
	for (int j = 0; j < i - 1; j++) {
		int total = stu[j].m + stu[j].f;
		if (stu[j].m == -1 || stu [j].f == -1)
		    cout << "F\n";
		else if (total >= 80)
			cout << "A\n";
		else if (total >= 65)
			cout << "B\n";
		else if (total >= 50 || (total >= 30 && stu[j].r >= 50))
			cout << "C\n";
		else if (total >= 30)
			cout << "D\n";
		else cout << "F\n";
	}
	return 0;
}


Measured memory_bytes: 3024
dataNum = 0
combNum = [0] * 100
while True:
    n,x=map(int, input().split())
    if n is x is 0:
        break
    else:
        for a in range(1,n-1):
            for b in range(a+1,n):
                for c in range(b+1,n+1):
                    calcResult = a + b + c
                    if calcResult == x:
                        combNum[dataNum] += 1
                    else:
                        pass
    dataNum += 1

for index in range(dataNum):
    print(combNum[index])


Measured memory_bytes: 5600
n,a,b,c,d = map(int,input().split())
s = input()
if d<c:
    if "##" not in s[a-1:d] and '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')
    
else:
    if "##" not in s[a-1:d]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3572
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
a = [0,0,0]
for x in LI():
    a[x-1] += 1
dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]

for k in range(a[2]+1):
    for j in range(a[1]+a[2]+1):
        for i in range(N+1):
            if not (0 < i+j+k <= N): continue
            x = 0.0
            if i > 0: x += dp[i-1][j][k] * (i/N)
            if j > 0: x += dp[i+1][j-1][k] * (j/N)
            if k > 0: x += dp[i][j+1][k-1] * (k/N)
            x += 1.0
            x *= N / (i+j+k)
            dp[i][j][k] = x
print(dp[a[0]][a[1]][a[2]])



Measured memory_bytes: 256392
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)

using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	char c = s[0];
	srep(i,1,n){
		if(s[i] != c){
			ans ++;
			c = s[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
n = gets.chomp.to_i
arr = []
(0..n-1).each do |i|
  arr[i] = gets.chomp.to_i
end

hash = {}

(0..arr.length-1).each do |i|
  hash[arr[i]] = i
end

hash_sorted = hash.sort {|(k1, v1), (k2, v2)| k1 <=> k2 }.to_h

max_asc = 1
now_asc = 1

(1..hash_sorted.length-1).each do |i|
  if hash_sorted[i] < hash_sorted[i+1]
    now_asc += 1
  else
    now_asc = 1
  end

  if now_asc > max_asc
    max_asc = now_asc
  end
end

p arr.count - max_asc


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

#define iPair pair<string,int>

using namespace std;

typedef long long int ll;

bool sortValThenKey(const iPair& a,
	const iPair& b)
{
	if (a.second == b.second) {
		return a.first < b.first;
	}
	return (a.second > b.second);
}

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

	vector<iPair> vec;
	map<string,int> store;

	for (int i = 0; i < t; i++) {
		string s;
		cin >> s;
		if (store.find(s) == store.end()) {
			store.insert(make_pair(s, 1));
		}
		else {
			store[s]++;
		}
	}

	for (auto i = store.begin(); i != store.end(); i++) {
		vec.push_back(make_pair(i->first, i->second));
	}
	sort(vec.begin(), vec.end(), sortValThenKey);
	int mxN = vec[0].second;
	for (int i = 0; i < vec.size(); i++) {
		if (vec[i].second == mxN) {
			cout << vec[i].first << endl;
		}
		else {
			break;
		}
	}
}


Measured memory_bytes: 29344
n,t = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(n)]

dp1 = [[0 for i in range(n+1)] for j in range(t+1)]
dp2 = [[0 for i in range(n+1)] for j in range(t+1)]

q = 0
for i in range(1,n+1):
    q = max(q,data[i-1][0])
    dp2[1][i] = q

for i in range(1,t+1):
    for j in range(1,n+1):
        if i-data[j-1][0] >= 0:
            dp1[i][j] = max(dp1[i][j-1],dp1[i-data[j-1][0]][j-1]+data[j-1][1])
            dp2[i][j] = max(dp2[i][j-1],dp2[i-data[j-1][0]][j-1]+data[j-1][1],dp1[i-1][j-1]+data[j-1][1])
        else:
            dp1[i][j] = dp1[i][j-1]
            dp2[i][j] = max(dp2[i][j-1],dp1[i-1][j-1]+data[j-1][1])


print(dp2[t][n])

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

int main() {
  int n,ans;
  ans=0;
  cin>>n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int l;
    cin>>l;
    vec.at(i) =l;
  }
  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if(vec.at(i)!=vec.at(j)&&vec.at(j)!=vec.at(k)&&vec.at(k)!=vec.at(i)){
          vector<int> vec_2(3);
          vec_2.at(0)=vec.at(i);
          vec_2.at(1)=vec.at(j);
          vec_2.at(2)=vec.at(k);
          sort(vec_2.begin(), vec_2.end());
          if(vec_2.at(0)+vec_2.at(1)>vec_2.at(2))
            ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
        long n = sc.nextLong();
        List<Long> list=new ArrayList<Long>();
        for(int i=0;5>i;i++) {
        	long a = sc.nextLong();
        	list.add(a);
        }
        Collections.sort(list);
        long min = list.get(0);
        long answer = n/min+4;
        if(n%min==0)
        	System.out.println(answer);
        else
        	System.out.println(answer+1);

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,a,sum=0;
    vector<lli> vec;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        vec.push_back(a);
    }
    rep(i,0,n){
        sum+=vec[i]/2;
        if(i<n-1){
            vec[i]%=2;
            if(vec[i]==1&&vec[i+1]>0){
                sum++;
                vec[i]--;
                vec[i+1]--;
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1400
import sys
si = sys.stdin.readline


def main():
    l = [int(e) for e in si().split()]
    found = False
    for i in range(l[0]+1):
        legs = i*2+(l[0]-i)*4
        if l[1] == legs:
            print("Yes")
            found = True
            break
    if not found:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include<iostream>
using namespace std;
typedef long long LL;
LL a[100010];
int main(){
	int n;
	cin>>n;
	LL X=0,S=a[1]+a[2];
	for(int i=1;i<=n;++i) {
		cin>>a[i];
		if(i<=2) S=S+a[i];
		else X=X^a[i];
	}
	if((a[1]+a[2]-X)%2||(a[1]+a[2]-X)<0){
		puts("-1");
		return 0;
	}
	LL D=(a[1]+a[2]-X)/2;
	if(D>a[1]){
		puts("-1");
		return 0;
	}
	LL s1=D,s2=0;
	for(int i=45;i>=0;--i){
		int xi=(X>>i)&1ll,di=(D>>i)&1ll;
		if(xi&&!di){
			if(s1+(1ll<<i)<a[1]){
				s1=s1+(1ll<<i);
			}
			else s2+=(1ll<<i);
		}
		else if(xi&&di){
			puts("-1");
			return 0;
		}
	}
	if(s1==0) puts("-1");
	else 
	cout<<a[1]-s1<<endl;
	return 0;
} 

Measured memory_bytes: 3168
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xx first
#define yy second
#define sci(n) scanf("%d",&n)
#define scii(n,m) scanf("%d%d",&n,&m)
#define sciii(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define sclll(n,m,w) scanf("%lld%lld%lld",&n,&m,&w)
#define pf(a)   printf("%d\n",a)
#define CASE(a) printf("Case %d:\n",a)
#define dbg(i) printf("yo %lld\n", i)
#define endl '\n'
#define READ  freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout);
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define SQR(a) (a)*(a)
#define all(v) v.begin(),v.end()
#define pb push_back
#define pri priority_queue<int>
#define rev_pri priority_queue<int,vector<int>,greater<int> >
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define inf INT_MAX
#define eps 1e-9

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

using namespace __gnu_pbds;
using namespace std;


#define mxn 100005


//bool vis[1LL << 19];
const ll nax=100005;
vector<ll>v[nax],ts;
ll ar[nax],LP,stme[nax],ftme[nax],ti;
bool vis[nax];
void dfs(ll sr)
{
    vis[sr]=1;
    ti++;
    stme[sr]=ti;
    for(ll i=0;i<v[sr].size();i++){
        if(vis[v[sr][i]]==0){
            dfs(v[sr][i]);
        }
    }
    ti++;
    ts.push_back(sr);
    ftme[sr]=ti;
}
void solve()
{
    ll a,b,n,w,k=0,c,i,q=0,j,l,m,mx=-1;
    cin>>n>>m;
    FOR(i,1,m+1){
        scll(a,b);
        v[a].pb(b);
    }
    FOR(i,1,n+1)if(vis[i]==0){
        ti=0;
        ts.clear();
        dfs(i);
        for(j=0;j<ts.size();j++){
            for(a=0;a<v[ts[j]].size();a++){
                ar[ts[j]]=max(ar[ts[j]],1+ar[v[ts[j]][a]]);
                mx=max(mx,ar[ts[j]]);
            }
        }
        //for(auto u:ts)cout<<u<<' ';
        //cout<<endl;
    }cout<<mx<<'\n';
}
int main()
{
    //IOS;
    double start_time = clock();
    ll t=1,mex=1;
   //cin>>t;
    while(t--){
        solve();
    }
    double end_time = clock();
    //fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=105;

int main()
{
    IO;
    int n,a;
    cin >> n >> a;
    if(n%500<=a)cout<<"Yes\n";
    else cout<<"No\n";
    re 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
LL N;
LL a[MAX];
LL aseg[MAX];
LL ans[MAX];

int main(void) {
    memset(ans, 0, sizeof(ans));
    scanf("%lld", &N);
    REP(i, N) scanf("%lld", a + i);
    REP(i, N) {
        aseg[i] = a[(i + 1) % N] - a[i];
    }
    if (N == 1) {
        cout << "YES" << endl;
        return 0;
    }
    bool ok = true;
    const LL oneope = N * (N + 1) / 2;
    const LL sum = accumulate(a, a + N, 0ll);
    if (sum % oneope != 0) ok = false;
    const LL CNT = sum / oneope;
    LL cnt = 0;
    REP(i, N) {
        LL buf = CNT - aseg[i];
        if (buf < 0 || buf % N) ok = false;
        cnt += buf / N;
    }
    cout << (ok && cnt == CNT ? "YES" : "NO") << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main()
{
  int N, M, a, b, i;
  
  scanf("%d %d", &N, &M);
  
  for(i=0; i<1011; i++){
  	a=i*0.08;
  	b=i*0.1;
  	if(N==a && M==b){
  		printf("%d", i);
  		return 0;
  	}
  }
  
  printf("-1");
  
 return 0;
}

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

int main() {
    int h,w;
    cin >> h >> w;

    string S0,S1,S2;
    cin >> S1;
    cin >> S2;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(S1.at(j) == '.'){
                int c = 0;
                if(i > 0){
                    if(j > 0) if(S0.at(j-1) == '#') c++;
                    if(S0.at(j) == '#') c++;
                    if(j < w-1) if(S0.at(j+1) == '#') c++;
                }
                if(j > 0) if(S1.at(j-1) == '#') c++;
                if(S1.at(j) == '#') c++;
                if(j < w-1) if(S1.at(j+1) == '#') c++;
                if(i < h-1){
                    if(j > 0) if(S2.at(j-1) == '#') c++;
                    if(S2.at(j) == '#') c++;
                    if(j < w-1) if(S2.at(j+1) == '#') c++;
                }
                cout << c;
            } else {
                cout << S1.at(j);
            }
        }
        cout << endl;
        S0 = S1;
        S1 = S2;
        if(i < h-1) cin >> S2;
    }
}


Measured memory_bytes: 256
import math

while True:
    student_num = int(input())
    if student_num == 0:
        exit()
    
    points = list(map(int, input().split()))
    ave = sum([point for point in points]) / student_num
    sigma = sum([(num - ave) ** 2 for num in points]) / student_num
    alpha = math.sqrt(sigma)
    print(alpha)



Measured memory_bytes: 5708
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  // 処理の方法はわかるけれど、全然整理できたコードにならない。。
  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val v = new Array[Int](n)
    for (i <- 0 until n) {
      v(i) = sc.nextInt
    }

    val evenMap = scala.collection.mutable.Map[Int, Int]()
    for (i <- 0 until n by 2) {
      val num = v(i)
      if (evenMap.contains(num)) evenMap(num) += 1
      else evenMap(num) = 1
    }
    val evenList = evenMap.toList.sortBy(_._2).reverse

    val oddMap = scala.collection.mutable.Map[Int, Int]()
    for (i <- 1 until n by 2) {
      val num = v(i)
      if (oddMap.contains(num)) oddMap(num) += 1
      else oddMap(num) = 1
    }
    val oddList = oddMap.toList.sortBy(_._2).reverse

    val e1 = evenList(0)._1
    val e2 = if (evenList.size > 1) evenList(1)._1 else -1
    val o1 = oddList(0)._1
    val o2 = if (oddList.size > 1) oddList(1)._1 else -1

    if (e1 != o1) {
      println(n - evenMap(e1) - oddMap(o1))

    } else {
      println(math.min(
        (n - evenMap(e1) - oddMap.getOrElse(o2, 0)),
        (n - oddMap(o1) - evenMap.getOrElse(e2, 0)))
      )
    }
  }

}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long H;
    std::cin >> H;
    long long W;
    std::cin >> W;
    ll ans = (H * W + 1) / 2;

    if (H == 1 || W == 1) ans = 1;
    cout << ans << endl;

    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string t;
    t = s.substr(0, 3);
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


int main(){
  int n;cin>>n;
  long long a,b;
  long long x[100005];
  long long m[100005];
  cin>>a>>b;
  for(int i=0;i<n;i++)cin>>x[i];
  m[0] = 0LL;
  for(int i=1;i<n;i++){
    m[i] = min(m[i-1]+a*(x[i]-x[i-1]),m[i-1]+b);
  }
  //for(int i=0;i<n;i++)cout<<m[i]<<" ";cout<<endl;
  cout<<m[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::vector<ll> va(3);
  ll K;
  std::cin >> va[0] >> va[1] >> va[2] >> K;

  std::vector<ll>::iterator it = std::max_element(va.begin(), va.end());
  for (ll i = 0; i < K; i++) {
    *it *= 2;
  }

  ll ans = std::accumulate(va.begin(), va.end(), 0);
  print(ans);
  return 0;
}


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

int main()
{
    int x,y;

    while( cin >> x >> y )
    {
        if( x == 0 && y == 0 )
            break;
        else
            if( x > y )
            {
                int tmp = x;
                x = y;
                y = tmp;
            }
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














char c;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> c;
	if ('A' <= c && c <= 'Z') cout << "A" << endl;
	else cout << "a" << endl;
}







Measured memory_bytes: 3608
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

	string s;
	cin >> s;
	int i;
	for (i = 0; i < 7; i++)
	{
		if (S[i] == s)break;
	}

	cout << 7 - i << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = 0;aux = n
while(aux>0):
  aux//=10
  d+=1
ans = 0

if(d&1): ans+= n-10**(d-1)+1
if(d>1): ans+=9
if(d>3): ans+=999-100+1
if(d>5): ans+=99999-10000+1
print(ans)


Measured memory_bytes: 3060
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<int> p(N, 0);
	REP(i, N) cin >> p[i];
	sort(p.begin(), p.end());

	int sum = 0;
	REP(i, N - 1) sum += p[i];
	sum += (p[N - 1] / 2);
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
void main() {
    int n = readln.chomp.to!int;
    string s = readln.chomp;
    int cnt;
    foreach (i; 1 .. n) {
        int tmp;
        foreach (x; lowercase) {
            if (s[0..i].canFind(x) && s[i..$].canFind(x)) {
                ++tmp;
            }
        }
        cnt = max(cnt, tmp);
    }
    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> okasi(N);
    for (int i=0; i<K; i++) {
        int d;
        cin >> d;
        for (int j=0; j<d; j++) {
            int A;
            cin >> A;
            okasi[A-1]++;
        }
    }
    ll sum = 0;
    for (int i=0; i<N; i++) {
        if (okasi[i] == 0) sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,a;
	cin>>n>>a;
	vi out;
	if(n%2){
		rep(i,n/2+1)out.pb(0);
		rep(i,n/2)out.pb(a);
	}else{
		rep(i,n/2-1)out.pb(0);
		rep(i,n/2+1)out.pb(a);
	}
	rep(i,out.size()-1)cout<<out[i]<<" ";
	cout<<out[n-1]<<endl;
}

Measured memory_bytes: 3136
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
long long f[2][3],ans,w;
int main(){
	scanf("%lld%lld%lld",&f[0][0],&f[0][1],&f[0][2]);
	while (1){
		if ((f[w][0]&1)||(f[w][1]&1)||(f[w][2]&1)) break;
		if (f[w][0]==f[w][1]&&f[w][0]==f[w][2]&&f[w][1]==f[w][2]){
			printf("-1\n");
			return 0;
		}
		//if ((f[w][0]&1)||(f[w][1]&1)||(f[w][2]&1)) break;//!!!!
		w^=1;
		f[w][0]=(f[w^1][1]+f[w^1][2])>>1;
		f[w][1]=(f[w^1][0]+f[w^1][2])>>1;
		f[w][2]=(f[w^1][1]+f[w^1][0])>>1;
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    int ans;
    double t,a;
    cin >> n >> t >> a;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    double diff = double(inf);
    rep(i,n){
        if(abs(a - (t - v[i]*0.006)) < diff){
            diff = abs(a - (t - v[i]*0.006));
            ans = i;
        }
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define intl long long int

vector<intl> fact(2e6+3); 

const intl mod=1e9+7;

intl pow1(intl x,intl y){
	intl res=1;
	while(y){
		if(y%2){
			res*=x;
			res%=mod;
		}
		x*=x;
		x%=mod;
		y/=2;
	}
	return res;
}

void factorial(){
	fact[0]=1;
	for(intl i=1;i<2e6+3;i++){
		fact[i]=i;
		fact[i]*=fact[i-1];
		fact[i]%=mod;
	}
}

intl ncr(intl n,intl r){

	intl n1=fact[n];
	intl n2=fact[n-r];
	intl n3=fact[r];
	n2*=n3;
	n2%=mod;
	n3=pow1(n2,mod-2);
	n1*=n3;
	n1%=mod;
	return n1;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,k;
	factorial();
	cin>>k;
	string s;
	cin>>s;
	intl n=s.length();
	j=pow1(26,k+n);
	intl x=n+k;
	intl j1=0;
	for(i=0;i<n;i++){
		intl tmp1=ncr(x,i);
		intl tmp2=pow1(25,x-i);
		tmp1*=tmp2;
		tmp1%=mod;
		j1+=tmp1;
		j1%=mod;
	}
	j-=j1;
	if(j<0){
		j+=mod;
	}
	cout<<j<<"\n";
}


Measured memory_bytes: 19868
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define Mid ((l+r)/2)
#define pi pair<int,int>
#define pii pair<int,pi>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n,m,pa[200200];
vector <int> adj[200200];
int main()
{
    go;
    cin>>n>>m;
    for(int i=0,x,y;i<m;i++)
    {
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    memset(pa,-1,sizeof pa);
    queue <int> q;
    q.push(1);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int v : adj[u])
        {
            if(pa[v]+1) continue;
            pa[v]=u;
            q.push(v);
        }
    }
    cout<<"Yes\n";
    for(int i=2;i<=n;i++)
    cout<<pa[i]<<endl;
    return 0;
}


Measured memory_bytes: 13260
N, *P = map(int, open(0).read().split())
pairs = sorted((P[i], i) for i in range(N))

sub = 1
right = 0
for left in range(N):
    while right < N - 1 and pairs[right + 1][1] > pairs[right][1]:
        right += 1

    sub = max(sub, right - left + 1)

    if left == right:
        right += 1
print(N - sub)


Measured memory_bytes: 38724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    ll N,K;
    cin >> N >> K;
    vec<ll> A(N);
    rep(i,N) cin >> A[i];

    ll msk = 0;
    for(int i=40;i>=0;--i){
        int cnt = 0;
        rep(j,N) if((A[j]>>i)&1) ++cnt;
        if(cnt*2<=N && (msk+(1LL<<i))<=K) {
            msk |= (1LL<<i);
        }
    }
    ll ans = 0;
    rep(i,N) ans+=(msk^A[i]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
let scan_float () = Scanf.scanf " %f" (fun x -> x)
let print_float n = Printf.printf "%.12f\n" n

let solve a b x =
  let capacity = a *. a *. b in
  if x < (capacity /. 2.0) then
    let c = x *. 2.0 /. b /. a in atan2 b c
  else
    let c = b *. 2.0 -. x *. 2.0 /. a /. a in atan2 c a

let to_degree rad = rad *. 180.0 /. (acos (-1.0))

let () =
  let a = scan_float() and b = scan_float() and x = scan_float() in
  print_float (to_degree (solve a b x)) 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  int u=0,v=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    v+=a[i];
  }
  int mi=(int)1e9;
  for(int i=0;i<n;i++){
    u+=a[i];
    v-=a[i];
    mi=min(mi,abs(u-v));
  }
  cout<<mi;
  return 0;
}


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

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

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int n=sc.nextInt();
      int m=sc.nextInt();
      Set<Integer> foods = new HashSet<Integer>();
      for(int i=0;i<m;i++){
        foods.add(i);
      }
      Set<Integer> tmp = new HashSet<Integer>();
      for(int i=0;i<n;i++){
        int x=sc.nextInt();
        for(int j=0;j<x;j++){
          tmp.add(sc.nextInt()-1);
        }
        foods.retainAll(tmp);
        tmp.clear();
      }
      System.out.println(foods.size());
    }
}

Measured memory_bytes: 22484
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
long long int dp[100020] = {};
int main() {
	int a, b;
	string s;
	cin >> a >> b;
	cin >> s;
	for (int i = 0; i < a; i++) {
		if (s[i] == '-') {
			cout << "No";
			return 0;
		}
	}

	if (s[a] != '-') {
		cout << "No";
		return 0;
	}

	for (int i = a+1; i < a + b + 1; i++) {
		if (s[i] == '-') {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var a = s[0] - '0';
        var b = s[1] - '0';
        var c = s[2] - '0';
        var d = s[3] - '0';

        var o = new[] { "+", "-" };
        var op = new[] { 1, -1 };

        for (int i = 0; i < 2; i++)
        {
            for (int j = 0; j < 2; j++)
            {
                for (int k = 0; k < 2; k++)
                {
                    if (a + op[i] * b + op[j] * c + op[k] * d == 7)
                    {
                        Console.WriteLine($"{a}{o[i]}{b}{o[j]}{c}{o[k]}{d}=7");
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13140
//Equal Total Scores

#include<iostream>
using namespace std;

#define MAX_N 100
#define MAX_M 100

void solve(int n,int m){
	int s[MAX_N],t[MAX_M],ss=0,st=0;
	for(int i=0;i<n;++i){
		cin>>s[i];
		ss+=s[i];
	}
	for(int j=0;j<m;++j){
		cin>>t[j];
		st+=t[j];
	}
	for(int i=0;i<n;++i) for(int j=0;j<m;++j){
		if(ss-s[i]+t[j]==st-t[j]+s[i]){
			cout<<s[i]<<" "<<t[j]<<endl;
			return;
		}
	}
	cout<<-1<<endl;
	return;
}

int main(){
	while(true){
		int n,m;
		cin>>n>>m;
		if(n!=0) solve(n,m);
		else break;
	}
}

Measured memory_bytes: 3088
import sys
input = sys.stdin.readline
H, W = [int(x) for x in input().strip().split()]
N = int(input())
A = [int(x) for x in input().strip().split()]
M = [[-1] + [0] * (W) + [-1] for _ in range(H+2)]
M[0] = [-1] * (W+2)
M[-1] = [-1] * (W+2)

vec = [(0, 1), (1, 0), (0, -1), (-1, 0)]

k = 0
h, w = 1, 1
for i, a in enumerate(A, start=1):
    for _ in range(a):
        M[h][w] = i
        if M[h+vec[k][0]][w+vec[k][1]] != 0:
            k = (k + 1) % 4
        h += vec[k][0]
        w += vec[k][1]

for m in M[1:len(M)-1]:
    print(*m[1:len(m)-1])

Measured memory_bytes: 3828
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();

        if(x<a){
            System.out.println(0);
        }else{
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int a[510],vis[510][4];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        scanf("%d%d%d",&vis[i][0],&vis[i][1],&vis[i][2]);
    for(int j=1;j<n;j++)
    {
        memset(a,0,sizeof(a));
        a[j-1]=0;
        for(int i=j;i<n;i++)
        {
            if(a[i-1]<=vis[i][1]) a[i]=vis[i][1]+vis[i][0];
            else 
            {
                int ans=a[i-1]-vis[i][1];
                ans=(ans/vis[i][2]+(ans%vis[i][2]==0?0:1))*vis[i][2];
                a[i]=vis[i][1]+ans+vis[i][0];
            }
        }
        printf("%d\n",a[n-1]);
    }
    printf("0\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <utility>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> pii;
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        rep(i,sz)par[i] = i;
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
struct edge{
    int u,v;
    int cost;
};
bool operator<(const edge&a, const edge&b){
    return a.cost < b.cost;
}
int main(){
    int n;
    cin >> n;
    vector<pii>x(n);
    vector<pii>y(n);
    rep(i,n){
        cin >> x[i].first  >> y[i].first;
        x[i].second = y[i].second = i;
    }
    sort(x.begin(),x.end(),[&](pii a,pii b){return a.first < b.first;});
    sort(y.begin(),y.end(),[&](pii a,pii b){return a.first < b.first;});
    vector<edge>a;
    rep(i,n-1){
        a.push_back({x[i].second,x[i+1].second,x[i+1].first-x[i].first});
        a.push_back({y[i].second,y[i+1].second,y[i+1].first-y[i].first});    
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    UnionFind uf(n);
    for(auto &e:a){
        if(uf.same(e.u,e.v))continue;
        uf.unite(e.u,e.v);
        ans += e.cost;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6388