akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	int N; cin >> N;
	vector<P>p;
	for (int i = 0; i < N-1;++i) {
		int a, b;
		cin >> a >> b; --a; --b;
		tree[a].emplace_back(b);
		p.emplace_back(make_pair(a,b));
	}

	color[0] = 0;
	dfs(0);

	cout << m << endl;
	for (int i = 0; i < N - 1; ++i) {
		P l = p[i];
		cout << colorMap[l] << endl;
	}
}

Measured memory_bytes: 13812
n,x = map(int,input().split())
l = list(map(int,input().split()))
counter = 0
now = 0
cum = [0]
for i in range(n):
    cum.append(cum[i]+l[i])

for i in range(n+1):
    if cum[i] <= x:
        counter += 1
    else:
        break
print(counter)

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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> round(N, 0);
  rep(i, Q) {
    int A;
    cin >> A;
    A--;
    round.at(A) +=1;
  }
  vector<int> score(N, K);
  rep(i, N) {
    score.at(i) += round.at(i) - Q;
  }
  rep(i, N) {
    if (score.at(i) < 1) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
} 


Measured memory_bytes: 1408
n = int(input())
link = [[] for _ in range(n)]
for i in range(n-1):
    a,b = list(map(int,input().split()))
    link[a-1].append(b-1)
    link[b-1].append(a-1)

from collections import deque
Q = deque()
Q.append([0,0])
visited=[-1]*n
visited[0]=0
mx_dist=0
mx_ind=0
while Q:
    now,cnt = Q.popleft()
    for nxt in link[now]:
        if visited[nxt]!=-1:
            continue
        visited[nxt]=cnt+1
        Q.append([nxt,cnt+1])
        if mx_dist < cnt+1:
            mx_dist=cnt+1
            mx_ind = nxt

Q = deque()
Q.append([mx_ind,0])
visited=[-1]*n
visited[mx_ind]=0
mx_dist=0
while Q:
    now,cnt = Q.popleft()
    for nxt in link[now]:
        if visited[nxt]!=-1:
            continue
        visited[nxt]=cnt+1
        Q.append([nxt,cnt+1])
        if mx_dist < cnt+1:
            mx_dist=cnt+1
            mx_ind = nxt

if (mx_dist-1)%3==0:
    print("Second")
else:
    print("First")

Measured memory_bytes: 121548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll ncr[3001][3001];
const int MOD = 1e9 + 7;

ll choose(int n, int r)
{
	if(r==0) return 1;
	if(n<r) return 0;
	if(ncr[n][r]!=-1) return ncr[n][r];
	ncr[n][r]=(choose(n-1,r-1)+choose(n-1,r))%MOD;
	return ncr[n][r];
}

ll dp[3001][3001];
ll modinv[3001];
ll fact[3001];

ll modpow(ll a, ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1) r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

ll inv(ll a)
{
	return modpow(a,MOD-2);
}

int pre[3001];
int countone(int l, int r)
{
	if(l==0) return pre[r];
	return pre[r]-pre[l-1];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(ncr,-1,sizeof(ncr));
	for(int i = 1; i <= 3000; i++) modinv[i] = inv(i);
	fact[0]=1;
	for(int i = 1; i <= 3000; i++) fact[i]=(fact[i-1]*i)%MOD;
	int n, m; cin>>n>>m;
	string s; cin >> s;
	for(int i = 0; i < n; i++)
	{
		if(s[i]=='1') pre[i]=1;
		if(i>0) pre[i]+=pre[i-1];
	}
	vector<ii> vec;
	for(int i = 0; i < m; i++)
	{
		int l, r; cin>>l>>r;
		l--; r--;
		vec.pb(mp(l,r));
	}	
	vector<ii> move;
	sort(vec.begin(),vec.end());
	int cur = -1;
	for(int i = 0; i < m; i++)
	{
		if(vec[i].se>cur)
		{
			move.pb(vec[i]);
			cur=vec[i].se;
		}
	}
	move.pb(mp(n,n));
	m = move.size();
	//dp[0][countone(move[0].fi,move[0].se)] = choose(move[0].se-move[0].fi+1, countone(move[0].fi,move[0].se));
	for(int i = 0; i <= n; i++)
	{
		int l = move[0].fi;
		int mid = min(move[1].fi-1, move[0].se);
		int r = move[0].se;
		int cnt = countone(l,r);
		//i is [mid+1,r]
		if(i>cnt) break;
		if(i>r-mid) break;
		dp[0][i] = choose(mid-l+1,cnt-i);
		//cerr<<0<<' '<<i<<' '<<dp[0][i]<<'\n';
	}
	for(int i = 1; i < m - 1; i++)
	{
		int l = move[i].fi;
		int mid = min(move[i+1].fi-1, move[i].se);
		int r = move[i].se;
		int cnt = countone(l,r);
		if(move[i].fi>move[i-1].se)
		{
			ll an = 0;
			for(int j = 0; j <= n; j++)
			{
				an=(an+dp[i-1][j])%MOD;
			}
			for(int j = 0; j <= r-mid; j++)
			{
				if(j>cnt) break;
				dp[i][j] = (an*choose(mid-l+1,cnt-j))%MOD;
			}
		}
		else
		{
			cnt = countone(move[i-1].se+1,r);
			//this is the number of ones in the later part
			//Naive way
			for(int x = 0; x <= r-mid; x++)
			{
				for(int j = n; j >= max(0,x - cnt); j--)
				{
					dp[i][x] = (dp[i][x]+(dp[i-1][j]*choose(mid-l+1,j+cnt-x))%MOD)%MOD;
				}
			}
			/*
			for(int j = n; j >= max(0,r-mid - cnt); j--)
			{
				
				dp[i][x] = (dp[i][x]+(dp[i-1][j]*choose(mid-l+1,j+cnt-x))%MOD)%MOD;
			}
			for(int x = r-mid; x >= 0; x--)
			{
				
			}
			*/
		}
		/*
		for(int j = 0; j <= n; j++)
		{
			cerr<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
		}
		*/
	}
	ll ans = dp[m-2][0];
	cout<<ans<<'\n';
}


Measured memory_bytes: 77056
import itertools
n,m,q=map(int,input().split())
Se=[]
for i in range(q):
    Se.append(list(map(int,input().split())))
#print(Se)
integerset={i for i in range(1,m+1)}
#print(integerset)
everyset=itertools.combinations_with_replacement(integerset,n)
max=0
for v in everyset:
  #  print(v)
 #   print(len(v))
    sum=0
    for i in range(len(Se)):
        if v[Se[i][1]-1]-v[Se[i][0]-1]==Se[i][2]:
            sum+=Se[i][3]
   # print(sum)
    if sum>max:
        max=sum
print(max)

    

Measured memory_bytes: 9212
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  string a, b, c;
  cin >> a>> b >> c;
  int aa = a.size();
  int bb = b.size();
  if(a[aa - 1] == b[0]){
    if(b[bb - 1] == c[0]){
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
}

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

int main() {
  string S,T;
  char c;
  cin>>c;
  if(c-'a'>=0&&c-'z'<=0){
    cout<<'a'<<endl;
    return 0;
  }
    
  cout<<"A"<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
map < int , int > mp,tmp;
vector < int > vs;
bool check(int x,int y){
	int xy=x^y,i;
	if(n%3==1){
		if(x || y) return 0;
	}
	if(n%3==2){
		if(x || y) return 0;
	}
	--tmp[x];
	--tmp[y];
	for(i=2;i<n;++i){
		int cv=(i%3==0?x:(i%3==1?y:xy));
		--tmp[cv];
		if(tmp[cv]<0) return 0;
	}
	return 1;
}
int main(){
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d",a+i);
		++mp[a[i]];
		vs.push_back(a[i]);
	}
	if((int)mp.size()>4){
		printf("No\n");
		return 0;
	}
	sort(vs.begin(),vs.end());
	vs.erase(unique(vs.begin(),vs.end()),vs.end());
	for(i=0;i<(int)vs.size();++i){
		for(j=0;j<(int)vs.size();++j){
			if(vs[j]<vs[i]) continue;
			if(vs[j]==vs[i] && mp[vs[i]]==1) continue;
			tmp=mp;
			if(check(vs[i],vs[j])){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

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

#define ll long long

using namespace std;

int main(){
	ll n,i;
	char c;
	
	while((c=getchar())!='\n'){
		if(c<='z' && c>='a') c-=32;
			else if(c<='Z' && c>='A') c+=32;
		cout<<c;
	}
	cout<<endl;
}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

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

using namespace std;

#define int long long
#define fi first
#define se second
#define inf 1e9
const int mod=(int)1e9+7;

void test_case(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
	else cout<<"No";
}

signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)test_case();
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var ary = Console
            .ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToArray();
        var a = ary[0];
        var b = ary[1];
        var c = ary[2];

        Console.WriteLine(Math.Min(c, (b / a)));
    }
}

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

int main(){
	int q;
	cin >> q;
	for(int Q=0; Q < q; Q++){
		if(Q != 0) cout << endl;
		int field[9][9];
		for(int i=0; i < 9; i++)for(int j=0; j< 9; j++) cin >> field[i][j];
		bool p[9][9];
		for(int i=0; i < 9; i++)for(int j=0; j< 9; j++) p[i][j] = true;
		for(int i=0; i < 9; i++){
			bool n[10] = {false};
			vector<int> v;
			for(int j=0; j < 9; j++) if(!n[field[i][j]]) n[field[i][j]] = true; else v.push_back(field[i][j]);
			for(int j=0; j< v.size(); j++) for(int k=0; k < 9; k++) if(field[i][k] == v[j]) p[i][k] = false;
		}
		for(int i=0; i < 9; i++){
			bool n[10] = {false};
			vector<int> v;
			for(int j=0; j < 9; j++) if(!n[field[j][i]]) n[field[j][i]] = true; else v.push_back(field[j][i]);
			for(int j=0; j< v.size(); j++) for(int k=0; k < 9; k++) if(field[k][i] == v[j]) p[k][i] = false;
		}
		for(int i=0; i< 3; i++){
			for(int j=0; j< 3; j++){
				bool n[10] = {false};
				vector<int> v;
				for(int k=0; k< 9; k++){
					int x = 3*i+k/3, y = 3*j+k%3;
					if(!n[field[x][y]]) n[field[x][y]] = true; else v.push_back(field[x][y]);
				}
				for(int k=0; k < v.size(); k++){
					for(int l=0; l < 9; l++){
						int x = 3*i+l/3, y = 3*j+l%3;
						if(field[x][y] == v[k]) p[x][y] = false;
					}
				}
			}
		}
		for(int i=0; i< 9; i++){
			for(int j=0; j< 9; j++) cout << (p[i][j] ? " " : "*") << field[i][j];
			cout << endl;
		}
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl

int main() {
  queue<long> que;
  int n; cin >> n;

  que.push(2);
  que.push(1);

  if (n == 1){
    p(1);
    return 0;
  }

  long ans;
  rep(i, n-1) {
    long a = que.front();
    que.pop(); 
    long b = que.front();
    que.push(a+b);
    ans = a+b;
  }

  p(ans);
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int cnt=0;
    char s[7];
    
    scanf("%s", s);

    rep(i, 6){
        if (s[i]=='1') {
            cnt++;
        }
    }
    
    printf("%d", cnt);
    
    return 0;
}



Measured memory_bytes: 1708
/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007  
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    if(!b) return a;
    return gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    ll temp = eulerstotientfunction(m);
    return modpow(x,temp-1,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}
int main()
{
    //fastio();
    ll n,m;
    cin >> n >> m;
    std::vector<pair<ll,ll> > arr;
    for(ll i=0;i<n;i++)
    {
        ll a,b;
        cin >> a >> b;
        if(a>m)
            continue;
        arr.pb(mp(a,b));
    }
    sort(arr.begin(), arr.end());
    priority_queue<ll> pq;
    ll next = 0,ans = 0;
    n = arr.size();
    for(ll i=1;i<=m;i++)
    {
        while(next<n && arr[next].fi==i)
        {
            pq.push(arr[next].se);next++;
        }
        if(!pq.empty())
        {
            ans+=pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
N = int(input())
S = input()


def encrypt(S, N):
    X = ""

    for ch in list(S):
        if 'A' <= ch <= 'Z':
            X += chr((ord(ch) - ord('A') + int(N)) % 26 + ord('A'))
        elif 'a' <= ch <= 'z':
            X += chr((ord(ch) - ord('a') + int(N)) % 26 + ord('a'))
        else:
            X += ch

    return X

# 暗号化
X = encrypt(S, N)
print(X)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
const long double pi = 3.14159265358979323846;

int main()
{
    KAKA
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ld theta = (11 * pi * (60 * h + m))/(ld)(360);
    ld jumbo = cos(theta);
    ld x = (a * a) + (b * b) - (2 * a * b * jumbo);
    ld ans = sqrt(x);
    cout<<fixed<<setprecision(9)<<ans<<"\n";
}

Measured memory_bytes: 4140
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> b=a;
  sort(a.begin(),a.end());
  auto itr=a.end();
  itr--;
  int max=*(itr);
  itr--;
  int second_max=*itr;
  for(int i=0;i<n;i++){
    if(b[i]==max){
      cout<<second_max<<endl;
    }
    else{
      cout<<max<<endl;
    }
  }
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

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

    int sum = 0;
    for (int i = 0; i < s.length(); i++) {
        sum += (int)(s[i] - '0');
        sum %= 9;
    }

    if (sum == 0) {
        cout << "Yes" << endl;
    }  else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
typedef std::pair<int, int> pi;
int n;
int x[2];
int a[100000];
int cnt[2][100002];
std::vector<pi> v;
int main()
{
    int t = 0;
    scanf("%d", &n);
    for(int i=0;i<n;i++)
    {
        scanf("%d", &a[i]);
        cnt[i&1][a[i]]++;
    }
    for(int i=1;i<=100000;i++)
        v.push_back({-cnt[1][i], i});

    std::sort(v.begin(), v.end());
    for(int i=1;i<=100000;i++)
    {
        if(i != v[0].second)
            t = std::max(t, cnt[0][i]-v[0].first);
        else t = std::max(t, cnt[0][i]-v[1].first);
    }

    printf("%d\n", n-t);
}

Measured memory_bytes: 2552
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<VMAX;i++) {
    C[i] =0;
  }

  for(i=0;i<n;i++) {
    scanf("%hd",&A[i+1]);
  }

  for(j=1;j<=n;j++) {
    C[A[j]]++;
  }

  for(i=1;i<VMAX;i++) {
    C[i] = C[i] + C[i-1];
  }

  for(j=n;j>=1;j--) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++) {
    if(i==1) printf("%d",B[i]);
    else printf(" %d",B[i]);
  }
  printf("\n");
  

   return 0;
}



Measured memory_bytes: 9652
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
S = input()

dp = list2d(N+1, 4, 0)
dp[0][0] = 1
msk = (1<<1000) - 1
for i in range(N):
    a = int(S[i])
    for j in range(4):
        dp[i+1][j] |= dp[i][j]
        if j == 0:
            dp[i+1][j+1] |= dp[i][j]<<a*100
            dp[i+1][j+1] &= msk
        if j == 1:
            dp[i+1][j+1] |= dp[i][j]<<a*10
            dp[i+1][j+1] &= msk
        if j == 2:
            dp[i+1][j+1] |= dp[i][j]<<a
            dp[i+1][j+1] &= msk
ans = 0
S = dp[N][3]
for k in range(1000):
    if S & 1<<k:
        ans += 1
print(ans)


Measured memory_bytes: 65096
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, label)
  size = queue.size
  index = queue.index{|entry| entry[0] >= label} || size
  return queue[index][1] if index < size && queue[index][0] == label

  return nil if index > 0 && !label.start_with?(queue[index - 1][0])
  queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(label)

  nodes = {}
  queue.insert(index, [label, nodes])
  nodes
end

def calc(n, arrows, start, goal)
  ins = Array.new(n){[]}
  arrows.each do |arrow|
    ins[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    ins[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end

  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  outs = Array.new(n){[]}
  arrows.each do |arrow|
    outs[arrow.source] << arrow
  end

  limit = n * arrows.map{|arrow| arrow.label.size}.max

  result = ''
  queue = [['', {start => true}]]
  until queue.empty?
    label, nodes = queue.shift
    result << label
    return result if nodes[goal]
    return nil if result.size > limit

    size = label.size
    queue.map!{|key, value| [key[size..-1], value]}

    nodes.each do |node, _|
      outs[node].each do |arrow|
        new_nodes = push(queue, arrow.label)
        new_nodes[arrow.sink] = true if new_nodes
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map do |i|
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  end

  puts calc(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long x,y,total=1;
	cin>>x>>y;
	while (1)
	{
		x*=2;
		if (x<=y)  total++;
		else break;
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,len,kaisuu = 0;
  string mojiretu;
  char moji;
  vector<int> min_cnt(30,10000);
  cin >> n;
  vector<int> moji_cnt(30);
  
  for(int i = 0; i < n ; i++){
    cin >> mojiretu;
    len = mojiretu.size();
    for(int j = 0; j < len; j++){
      moji = mojiretu.at(j);
      moji_cnt.at(moji - 'a')++;
    }
    
    for(int k = 0; k < 26; k++){
      if(min_cnt.at(k) > moji_cnt.at(k))
         min_cnt.at(k) = moji_cnt.at(k);
      moji_cnt.at(k) = 0;
    }
    
  }
  
  for(int k = 0; k < 26; k++){
    while(kaisuu < min_cnt.at(k)){
      cout << char('a' + k);
      kaisuu++;
    }
    kaisuu = 0;
  }
    
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> a;
	for(int i=0; i<N; i++)
	{
		int x;
		cin >> x;
		a.push_back(x);
	}
	map<int,int> m;
	map<int,bool> flag;

	for(int i=0; i<N; i++)
	{
		m[a[i]]=0;
		flag[a[i]]=false;
	}

	for(int i=0; i<N; i++)
	{
		m[a[i]]++;
	}
    
    int num = 0;
    for(int i=0; i<N; i++)
    {
      if(!flag[a[i]]){
    	if(m[a[i]]>=a[i]) num += m[a[i]]-a[i];
    	else num += m[a[i]];
    	flag[a[i]] = true;
        }
    }
    cout << num << endl;
	return 0;
}

Measured memory_bytes: 9592
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			String input = scanner.next();			
			String output = "";
			
			for(int i=0; i<input.length(); i++)
			{
				String str = input.substring(i, i+1);
				if(str.equals("@"))
				{
					int n = Integer.parseInt(input.substring(i+1, i+2));
					for(int j=0; j<n; j++)
					{
						output += input.substring(i+2, i+3);
					}
					
					i+=2;
				}
				else
				{
					output += str;
				}
			}
			System.out.println(output);
		}
	}
}

Measured memory_bytes: 26152
$n=<>;
@a=glob<>;
$r=1e9;
while($r-$l>1){
	@b=0;
	$m=$l+$r>>1;
	$b[$s=$n]=1;
	$N=$c=0;
	for(@a){$c+=$N+=$_>$m?-$b[++$s]:$b[$s--];$b[$s]++;}
	${$c>$n*($n+1)/4?r:l}=$m;
}
print$r

Measured memory_bytes: 27784
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools

N = int(input())
L = list(map(int, input().split()))
ans = 0

for x in itertools.combinations(L, 3):
    if len(set(x)) == 3:
        x = list(x)
        x.sort()
        if x[0] + x[1] > x[2]:
            ans += 1

#
# # print(L)
# L = list(set(L))
# L.sort()

# print(L)
# # for i in range(len(L)):
# for x in itertools.combinations(L, 3):
#     # print(x)
#     # print(x[0] ** 2 + x[1] ** 2)
#     # if x[0] ** 2 + x[1] ** 2 == x[2] ** 2:
#     ans += 1
print(ans)


Measured memory_bytes: 68468
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    int max_value = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        max_value = max(max_value, H[i]);
        if (max_value <= H[i]) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<ll,const char*> parsed;

parsed expr(const char*);
parsed term(const char*);
parsed fact(const char*);

parsed expr(const char* s)
{
	//cout<<"expr(\""<<s<<"\")"<<endl;
	parsed now=term(s);
	while(*now.second=='+' || *now.second=='-'){
		char op=*now.second;
		parsed next=term(now.second+1);
		if(op=='+')
			now=parsed(now.first+next.first,next.second);
		else
			now=parsed(now.first-next.first,next.second);
	}
	//cout<<"expr(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed term(const char* s)
{
	//cout<<"term(\""<<s<<"\")"<<endl;
	parsed now=fact(s);
	while(*now.second=='*' || *now.second=='/'){
		char op=*now.second;
		parsed next=fact(now.second+1);
		if(op=='*')
			now=parsed(now.first*next.first,next.second);
		else
			now=parsed(now.first/next.first,next.second);
	}
	//cout<<"term(\""<<s<<"\")="<<now.first<<endl;
	return now;
}

parsed fact(const char* s)
{
	//cout<<"fact(\""<<s<<"\")"<<endl;
	//if(s[0]=='('){
	//	parsed res=expr(s+1);
	//	res.second++;
	//	return res;
	//}
	//else{
	//	const char* p=s;
	//	if(*p=='-')
	//		p++;
	//	ll n=0;
	//	while(isdigit(*p)){
	//		n=n*10+*p-'0';
	//		p++;
	//	}
	//	return parsed(n,p);
	//}
	
	if(s[0]=='-' || isdigit(s[0])){
		const char* p=s;
		if(*p=='-')
			p++;
		ll n=0;
		while(isdigit(*p)){
			n=n*10+(*p-'0');
			p++;
		}
		return parsed(n,p);
	}
	else if(s[0]=='('){
		parsed res=expr(s+1);
		res.second++;
		return res;
	}
	else
		exit(0);
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		cout<<expr(s.c_str()).first<<endl;
	}
	//string s;
	//getline(cin,s);
	//while(getline(cin,s))
	//	cout<<expr(s.c_str()).first<<endl;
	
	return 0;
}

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

const int N = 2e5 + 100;
vector<int> e[N];
bool vis[N];
int fa[N];

void bfs() {
	queue<int> que;
	que.push(1);
	vis[1] = true;
	while (!que.empty()) {
		int u = que.front();
		que.pop();
		for (auto v : e[u]) {
			if (!vis[v]) {
				fa[v] = u;
				que.push(v);
				vis[v] = true;
			}
		}
	}
}

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	bfs();
	for (int i = 2; i <= n; i++) {
		if (fa[i] == 0) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" << "\n";
	for (int i = 2; i <= n; i++) {
		cout << fa[i] << "\n";
	}
}

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

int n, a, b;
int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n), read(a), read(b);

    if(a + b - 1 > n || 1ll * a * b < n) return !puts("-1");

    for(int i = n - a + 1; i <= n; ++i) { printf("%d ", i); }

    if(b > 1) {
        int all = n - a, t = all / (b - 1);
        int res = all % (b - 1);

        while (all >= 1) {
            int flag = 0;
            if(res > 0 && res --) flag = 1;
            for(int j = std::max(1, all - t -flag + 1); j <= all; ++j) printf("%d ", j);
            all -= t+flag;
        }
    }

    return 0;
}


Measured memory_bytes: 2176
fun main(args:Array<String>):Unit {
    val constant = Regex("""(-?\d+)$""")
    val single = Regex("""(-?\d*)x[-\+$]""")
    val coefficient = listOf(constant, single) + (2..5).map{Regex("""(-?\d*)x\^""" + it.toString())}
    val str = readLine()!!.trim()
    val polynomial = Polynomial(coefficient.map{it.find(str)?.let{when(it.groupValues[1]){
        "", "-" -> it.groupValues[1] + "1"
        else -> it.groupValues[1]
    }.toInt()} ?: 0})
    for (c in -2000 .. 2000){
        if (polynomial[-c] == 0) print(if (c > 0) "(x+$c)" else "(x$c)")
    }
    println()
}
class Polynomial(private val mCoefficient:List<Int>){
    operator fun get(x:Int):Int {
        var variable = 1
        var res = 0
        for (c in mCoefficient){
            res += c * variable
            variable *= x
        }
        return res
    }

    override fun toString(): String {
        return "${mCoefficient[5]}x^5+${mCoefficient[4]}x^4+${mCoefficient[3]}x^3+${mCoefficient[2]}x^2+${mCoefficient[1]}x+${mCoefficient[0]}"
    }
}


Measured memory_bytes: 32656
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  if a <= 9 && b <= 9 then
    print (a * b)
  else
    print (-1)


Measured memory_bytes: 380
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    int ans = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    for (int i = 0; i < N; i++) {
        int xy = V[i] - C[i];
        if (xy > 0) {
            ans = ans + xy;
        }
    }
    
    
    
    
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    mod = 998244353
    dp = [0] * (n + 1)
    dp[1] = 1
    dp[2] = -1
    left = [0] * k
    right = [0] * k
    for i in range(k):
        left[i], right[i] = map(int, input().split())
        right[i] += 1
    for i in range(1, n + 1):
        dp[i] += dp[i - 1]
        for j in range(k):
            if i + left[j] <= n:
                dp[i + left[j]] += dp[i]
            if i + right[j] <= n:
                dp[i + right[j]] -= dp[i]
        dp[i] %= mod
    print(dp[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 19840
use std::io;

fn main() {
    let mut S = String::new();
    io::stdin().read_line(&mut S);
    if (S.find("RRR") >= Some(0)){
        println!("3");
        return;
    }else if(S.find("RR") >= Some(0)){
        println!("2");
        return;
    }else if(S.find("R") >= Some(0)){
        println!("1");
        return;
    }else{
        println!("0");
        return;
    }
}

Measured memory_bytes: 2132
#N個の整数のうち異なる整数は何種類か？
  
n=int(input())
list=[int(input()) for i in range(n)]
sortedlist=sorted(list)
count=n

for i in range(n-1):
	if sortedlist[i]==sortedlist[i + 1]:
		count -= 1

print(count)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[m]={};
    int sum=0;
    for(int i=0;i<n;i++){
        int s=0;
        for(int j=0;j<m;j++){
            int k;
            cin>>k;
            cout<<k<<" ";
            s+=k;
            a[j]+=k;
        }
        sum+=s;
        cout<<s<<endl;
    }
    for(int i=0;i<m;i++){
        cout<<a[i]<<" ";
    }
    cout<<sum<<endl;
}


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

using namespace std;
using ll = long long;
#define MOD 1000000007



#define MOD 1000000007
template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
	friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
		return os<<p.x;
	}
	friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
		long long x;
		is>>x;
		a=ModInt<mod>(x);
		return (is);
	}
};
typedef ModInt<MOD> mint;
 
struct MComb {
	std::vector<mint> fact;
	std::vector<mint> inversed;
	MComb(int n) { // O(n+log(mod))
		fact = std::vector<mint>(n+1,1);
		for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
		inversed = std::vector<mint>(n+1);
		inversed[n] = fact[n] ^ (MOD-2);
		for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
	}
	mint ncr(int n, int r) {
		return (fact[n] * inversed[r] * inversed[n-r]);
	}
	mint npr(int n, int r) {
		return (fact[n] * inversed[n-r]);
	}
	mint nhr(int n, int r) {
		assert(n+r-1 < (int)fact.size());
		return ncr(n+r-1, r);
	}
};
 
mint ncr(int n, int r) {
	mint res = 1;
	for (int i = n - r + 1; i <= n; i++) res *= i;
	for (int i = 1; i <= r; i++) res /= i;
	return res;
}

int main()
{
	mint m, n;
	cin >> m >> n;
	mint res = m^n.x;
	cout << res << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 080 C / Link: http://abc080.contest.atcoder.jp/tasks/abc080_c  ----- */


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

	LL N; 
	cin >> N;
	vector<vector<LL>> a(N, vector<LL>(10));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> a[i][j];
		}
	}
	vector<vector<LL>> P(N, vector<LL>(11));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 11; ++j) {
			cin >> P[i][j];
		}
	}



	LL ans = -LINF;
	FOR(state, 1, 1 << 10) {
		LL ret = 0;

		FOR(i, 0, N) {
			LL cnt = 0;
			FOR(j, 0, 10) {
				if ((state & 1 << j) && (a[i][j])) {
					cnt++;
				}
			}
			ret += P[i][cnt];
		}

		ans = max(ans, ret);
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin>>n;
    cout<<(n+1)/2<<endl;

    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

ans = 0
for a in A:
    if a >= K:
        ans += 1
print(ans)


Measured memory_bytes: 11908
#include <stdio.h>
#include <stdbool.h>

float sign(double x1,double y1,double x2,double y2,double x3,double y3);

int main(void){

	double x1,y1,x2,y2,x3,y3,xp,yp;
	double Area, s, t;

	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) == 8){

		bool b1 = sign(xp,yp,x1,y1,x2,y2) < 0.0f;
  		bool b2 = sign(xp,yp,x2,y2,x3,y3) < 0.0f;
  		bool b3 = sign(xp,yp,x3,y3,x1,y1) < 0.0f;

		if((b1 == b2) && (b2 == b3)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

	}
	return 0;
}

float sign(double x1,double y1,double x2,double y2,double x3,double y3)
{
  return (x1-x3)*(y2-y3) - (x2-x3)*(y1-y3);
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main () {
    int n; cin >> n;
    vector<int> xs(n);
    for (int i = 0; i < n; i++) {
        cin >> xs[i];
    }
    sort(xs.begin(), xs.end());
    int s = xs[0];
    int e = xs[n-1];
    int ans = 10000000;
    for (int p = s; p <= e; p++) {
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp = tmp + ((xs[i] - p) * (xs[i] - p));
        } 
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

// Addition and Subtraction Easy
int main(){
    int A, B, result = 0;
    char op;

    cin >> A >> op >> B;

    if(op == '+'){
        cout << A+B << endl;
    }else{
        cout << A-B << endl;
    }
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = ns()
head = []
tail = []
rev = False
q = ni()
for i in range(q):
    cs = stdin.readline().rstrip().split()
    if cs[0] == "1":
        rev ^= True
        head, tail = tail, head
    else:
        if cs[1] == "1":
            head.append(cs[2])
        else:
            tail.append(cs[2])
print("".join(head[::-1]) + (s[::-1] if rev else s) + "".join(tail))


Measured memory_bytes: 61916
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static int N;
    static int[] A;
    static void input()
    {
        N = int.Parse(ReadLine());
        A = new int[N];
        for (int i = 0; i < N; i++)
            A[i] = int.Parse(ReadLine());
    }
    static void solve()
    {
        input();
        int[] maxs = new int[500];

        for(int i = 0; i < N; i++)
        {
            maxs[i / 500] = Max(maxs[i / 500], A[i]);
        }

        for(int i = 0; i < N; i++)
        {
            int max = 0;
            for(int j = 0; j < 500; j++)
            {
                if (j != i / 500)
                    max = Max(max, maxs[j]);
            }
            for(int j = (i / 500) * 500; j < Min(N, (i / 500 + 1) * 500); j++)
            {
                if(i != j)
                    max = Max(max, A[j]);
            }
            WriteLine(max);
        }

    }}

Measured memory_bytes: 17352
#include <bits/stdc++.h>
#pragma warning (disable : 4996)
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	int a[100007];
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == i+1)
		{
			if (i == n - 1) swap(a[i], a[i - 1]);
			else swap(a[i], a[i + 1]);
			cnt++;
		}
	}
	return !printf("%d", cnt);
}

Measured memory_bytes: 640
#coding:utf-8
#1_3_A
formula = input().split()
stack = []
for char in formula:
    if char.isdigit():
        stack.append(char)
    else:
        ans = str(eval(stack.pop(len(stack)-2) + char + stack.pop()))
        stack.append(ans)
print(stack.pop())

Measured memory_bytes: 7440
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val x = (1..5).map { sc.nextInt() }

  var index = 1
  for (i in x) {
    if (i == 0) {
      println(index)
      return
    }
    index++
  }

}


Measured memory_bytes: 37340
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if (a.back() == b[0] && b.back() == c[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, d, i, j, dif, sum, y;
  int count=0, p, q;
  cin>>n>>d;
  int arr[n][d];
  
  for(i=0; i<n; i++)
    for(j=0; j<d; j++)
      cin>>arr[i][j];
      
  for(i=0; i<n-1; i++)
  {
      p = n-1-i;
      q = 1;
      while(p--)
      {
          sum = 0;
          for(j=0; j<d; j++)
          {
              dif = pow(abs(arr[i][j] - arr[i+q][j]),2);
              sum = sum + dif;
          }
          y = sqrt(sum);
          if(y*y == sum)
          count++;
          q++;
      }
  }
  cout<<count<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a,b,c;
char d,e,f;
int main()
{
	int sum=0;
	cin>>a>>b>>c;
	cin>>d>>e>>f;
	if(a==d) sum++;
	if(b==e) sum++;
	if(f==c) sum++;
	cout<<sum;
	return 0;
	
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string line;
        line = Console.ReadLine();
        int[] tokens = line.Split(' ').Select(int.Parse).ToArray();
        int a = tokens[0];
        int b = tokens[1];
        int c = tokens[2];
        
        if (a == b)
        {
            Console.WriteLine(c);
        }
        else if (b == c)
        {
            Console.WriteLine(a);
        }
        else
        {
            Console.WriteLine(b);
        }
    }
}

Measured memory_bytes: 13652