akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdint>
#include <array>
#include <vector>
#include <numeric>
#include <algorithm>

class cake {
private:
  std::int_fast64_t beauty;
  std::int_fast64_t tastiness;
  std::int_fast64_t popularity;

public:
  constexpr cake(const std::int_fast64_t beauty, const std::int_fast64_t tastiness, const std::int_fast64_t popularity) :
    beauty(beauty),
    tastiness(tastiness),
    popularity(popularity) {
  }
  constexpr cake() : cake(0, 0, 0) {}

  friend std::istream& operator>>(std::istream& is, cake& self) {
    return is >> self.beauty >> self.tastiness >> self.popularity;
  }

  constexpr std::int_fast64_t value() const {
    return this->beauty + this->tastiness + this->popularity;
  }

  constexpr cake inverse_signs(const std::int_fast64_t sign1, const std::int_fast64_t sign2, const std::int_fast64_t sign3) const {
    return cake(sign1 * this->beauty, sign2 * this->tastiness, sign3 * this->popularity);
  }

  constexpr friend cake operator+(const cake& lhs, const cake& rhs) {
    return cake(lhs.beauty + rhs.beauty, lhs.tastiness + rhs.tastiness, lhs.popularity + rhs.popularity);
  }

  constexpr bool valid() const {
    return this->beauty >= 0 && this->tastiness >= 0 && this->popularity >= 0;
  }
};

int main() {
  std::int_fast64_t n, m;
  std::cin >> n >> m;
  std::vector<cake> cakes(n);
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::cin >> cakes[i];
  }

  std::int_fast64_t result = -1;
  std::array<std::int_fast64_t, 3> signs;
  for (signs[0] = -1; signs[0] <= 1; signs[0] += 2) {
    for (signs[1] = -1; signs[1] <= 1; signs[1] += 2) {
      for (signs[2] = -1; signs[2] <= 1; signs[2] += 2) {
        std::vector<cake> positive_cakes = {};
        for (const cake& cake : cakes) {
          positive_cakes.push_back(cake.inverse_signs(signs[0], signs[1], signs[2]));
        }
        std::sort(positive_cakes.rbegin(), positive_cakes.rend(), [](const cake& lhs, const cake& rhs) {
          return lhs.value() < rhs.value();
        });
        const cake positive_cake_sum = std::accumulate(
          positive_cakes.begin(),
          positive_cakes.begin() + m,
          cake(),
          [](const cake& sum, const cake& positive_cake) { return sum + positive_cake; }
        );
        if (positive_cake_sum.valid()) {
          result = std::max(result, positive_cake_sum.value());
        }
      }
    }
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int a,b;
    cin>>a>>b;
    string s,t;
    rep(i,a)s+=to_string(b);
    rep(i,b)t+=to_string(a);
    if(s<=t)cout<<s;
    else cout<<t;
}

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

using namespace std;


#define M_DEBUG if(0)


/******************************************************************************
	typedef
******************************************************************************/
typedef unsigned long long int ullint;


/*! Main */
int main() {
	ullint n=0, m=0;
	cin >> n >> m;
	assert(n >= 1 && n <= 100000);
	assert(m >= 1 && m <= 100000);

	// 割引券を一枚行使すると、値段が半分になる
	// いちばん有効な使い方は、いちばん額が大きい商品を割ること
	// なので、常に最大の値がどれかわかるヒープでデータをもつ
	priority_queue<double> values; // デフォは降順
	for (ullint i = 1; i <= n; i++) {
		ullint a_i = 0;
		cin >> a_i;
		assert(a_i >= 1 && a_i <= 1000000000);
		values.push(double(a_i));
	}
	while (m > 0) {
		double topval = values.top();
		values.pop();
		M_DEBUG cout << "Discount " << topval << " -> ";
		topval = topval / 2.0;
		M_DEBUG cout << topval << "; " << endl;
		values.push(topval);
		m--;
	}

	ullint sum = 0;
	while (!values.empty()) {
		sum += ullint(values.top()); /// 加算する時点で整数に変換して切り捨てる
		values.pop();
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        boolean isShiritori = A.endsWith(String.valueOf(B.charAt(0)))
                && B.endsWith(String.valueOf(C.charAt(0)));

        System.out.println(isShiritori ? "YES":"NO");
    }
}


Measured memory_bytes: 21844
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int P;
char S[4];
int res1;
int res2;
int ok[100000];
int ng[100000];
int main(){
  int Lj4PdHRW, i;
  rd(N);
  rd(M);
  for(Lj4PdHRW=(0);Lj4PdHRW<(M);Lj4PdHRW++){
    rd(P);P += (-1);
    rd(S);
    if(ok[P]){
      continue;
    }
    if(S[0]=='A'){
      ok[P]++;
    }
    else{
      ng[P]++;
    }
  }
  for(i=(0);i<(N);i++){
    if(ok[i]){
      res1++;
      res2 += ng[i];
    }
  }
  wt_L(res1);
  wt_L(' ');
  wt_L(res2);
  wt_L('\n');
  return 0;
}
// C


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
long long int order[150007];
int counter[150007];
const int INF=100007;
vector<long long int> v1;

int max3(int a,int b,int c){
	if(a<b)a=b;
	return a>c?a:c;
}

int min3(int a,int b,int c){
	if(a>b)a=b;
	return a<c?a:c;
}

int middle(int a,int b,int c){
	int s=a+b+c;
	s-=max3(a,b,c)+min3(a,b,c);
	return s;
}

int check(long long int x,int n){
	int i,j,k;
	int a,b;
	for(a=n,i=0;i<n+n/2-1;i+=3,a++){
		for(b=0,j=0;j<3;j++){
			if(i+j<n && order[i+j]==0)counter[i+j]++;
			if(order[i+j]!=0 && order[i+j]<x)counter[i+j]=INF;
			b+=counter[i+j];
		}
		b-=max3(counter[i],counter[i+1],counter[i+2]);
		if(b>=INF)counter[a]=INF;
		else counter[a]=b;
	}
	n=n+n/2-1;
	return counter[n];
}
		

int main(){
	int n,m;
	int i,j,k;
	int a,b;
	long long int p[3];
	vector<long long int>::iterator itr;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		b--;
		order[b]=a;
	}
	for(i=m;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	sort(v1.begin(),v1.end());
	for(a=n,i=0;i<n+n/2;i+=3,a++){
		for(j=0,k=0;j<3;j++){
			if(order[i+j]==0)k++;
		}
		if(k!=0)continue;
		order[a]=middle(order[i],order[i+1],order[i+2]);
	}
	
	p[0]=0,p[1]=1000000007;
	while(p[1]-p[0]!=1){
		p[2]=(p[0]+p[1])/2;
		itr=lower_bound(v1.begin(),v1.end(),p[2]);
		a=check(p[2],n);
		b=v1.size()-(int)(itr-v1.begin());
		if(a<=b)p[0]=p[2];
		else p[1]=p[2];
		memset(counter,0,sizeof(counter));
	}
	cout<<p[0]<<endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld; //
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll,ll> pl; //
typedef pair<ld,ld> pd; //
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi;
typedef vector<ll> vl; //
typedef vector<ld> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi; //
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
typedef vector<vi> vvi;
typedef vector<vl> vvll;

//
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back() //
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0}; //

template<class T> bool ckmin(T& a, const T& b) { 
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
    return a < b ? a = b, 1 : 0; }
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

    string S;
    cin >> S;

    int N = S.length();

    int max_prefix = 0;
    int max_suffix = 0;

    int i = 0;
    while (i < N && i < 7 && S[i] == "keyence"[i]) {
        i++;
        max_prefix++;
    }

    i = 0;
    while (i < N && i < 7 && S[N-1-i] == "ecneyek"[i]) {
        i++;
        max_suffix++;
    }

    if (max_prefix + max_suffix >= 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    for(int i = 0; i < n; i++){
      long a = sc.nextLong();
      while(a % 2 == 0){
        a /= 2;
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 34152
while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[0]*(n+10)
        A[0]=1
        A[1]=1
        A[2]=2
        if n==1:
            print(1)
        elif n==2:
            print(1)
        else:
            for i in range(3,(n+1)):
                A[i]=A[i-1]+A[i-2]+A[i-3]
            print((A[n]//3650)+1)


Measured memory_bytes: 5600
n = int(input())
k = int(input())



def choose(n, k):
    if k == 1:
        return n
    if k == 2:
        return n * (n-1) // 2
    if k == 3:
        return n * (n-1) * (n-2) // 6
    #print(f'choosing... k is {k}!')

def nonzerodigs(n):
    ss = list(map(int, list(str(n))))
    ss = [s for s in ss if s != 0]
    return len(ss)


def count(n, k):
    #print(f'count({n}, {k})')
    if k == 0:
        return 1

    if n < 1000:
        cnt = 0
        for i in range(1, n+1):
            if nonzerodigs(i) == k:
                cnt += 1

        return cnt

    ns = list(map(int, list(str(n))))
    d = len(ns)
    top3 = ns[0] * 100 + ns[1] * 10 + ns[2]
    cnt = 0
    for i in range(top3):
        nn = nonzerodigs(i)
        if nn > k:
            continue
        kk = k - nn
        if kk == 0:
            cnt += 1
        else:
            cnt += choose(d-3, kk) * (9**kk)

    nn = nonzerodigs(top3)
    if nn > k:
        return cnt
    elif nn == k:
        cnt += 1
        return cnt
    elif nn < k:
        kk = k - nn
        if kk > 2:
            print("ERROR")
            return -1
        nnn = int("".join(map(str, ns[3:])))
        return cnt + count(nnn, kk)

print(count(n,k))


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

int main()
{
	// 入力
	int n,k; cin>>n>>k;
	string s; cin>>s;
	// 個数カウント
	vector<pair<int,int>> a;
	int c=0;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(i==0){
			c=s[i]-'0';	
			cnt++;
		}
		else if(c==s[i]-'0') cnt++;
		else {
			a.emplace_back(cnt,c);
			cnt=1;
			if(c==0) c=1;
			else c=0;
		}
		if(i==s.size()-1) a.emplace_back(cnt,c);
	}
	//尺取り法
	int left=0;
	int right=0;
	int maxv=0;
	int sum=0;
	int zero=0;
	while(right!=a.size()){
		if(a[right].second==0){
			zero++;
			if(zero>k){
				if(a[left].second==0){
					sum-=a[left].first;
					left++;
					zero--;
				}
				else{
					sum-=a[left].first;
					left++;
					sum-=a[left].first;
					left++;
					zero--;
				}
			}
		}
		sum+=a[right].first;
		maxv=max(maxv,sum);
		right++;
	}
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define mk make_pair
int main(){
	map<int,int>ma;
	int n,m;
	cin>>n;
	r(i,n){
		cin>>m;
		ma[m]++;
	}
	int f=0;
	cin>>m;
	r(i,m){
		cin>>n;
		if(ma[n])ma[n]--;
		else f++;
	}
	if(f)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
	int h,a;
	cin>>h>>a;
	if(h%a==0)
	{
		cout<<h/a;
	}
	else
	{
		cout<<h/a+1;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

const ll INF = 1LL << 60;

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

	ll u_min = INF, u_max = -INF;
	ll v_min = INF, v_max = -INF;

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		ll x, y; cin >> x >> y;
		ll u = x + y, v = x - y;
		chmin(u_min, u);
		chmin(v_min, v);
		chmax(u_max, u);
		chmax(v_max, v);
	}

	cout << max(u_max - u_min, v_max - v_min) << endl;

	return 0;
}

Measured memory_bytes: 3620
d[4],e[9],f,k;
char s[30];
z(){
	int a,b,c;
	a=e[f++];
	a>9?s[k++]=40,
		b=z(),
		s[k++]=a,
		c=z(),
		s[k++]=41,
		a=a-43?a-45?b*c:b-c:b+c:
		(s[k++]=a+48);
	return a;
}
y(o,n,i){
	int j;
	if(i==7){
		f=k=0;
		if(z()==10){
			s[k]=0;
			puts(s);
			return 1;
		}
		return 0;
	}
	if(o){
		for(j=0;j<3;j++){
			e[i] = "+-*"[j];
			if(y(o-1,n+1,i+1))return 1;
		}
	}
	if(n||i==6){
		for(j=0;j<4;j++){
			if(e[i]=d[j]){
				d[j]=0;
				if(y(o,n-1,i+1))return 1;
				d[j]=e[i];
			}
		}
	}
	return 0;
}

int main(void){
	for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)
		y(3,0,0)||puts("0");
}

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

#define MOD 1000000007
#define fastio std::ios_base::sync_with_stdio(false);
#define ll long long
#define matrix vector <vector <ll> >

int main(){

    fastio;
    
    int n;
    cin >> n;
    string s;
    cin >>s;
    int r = 0, b= 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') r++;
        else            b++;
    }
    if(r > b)   cout << "Yes";
    else        cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int N,M,res[100000];
vector<int>v[100000];

int main(){
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=0;i<N;i++){
		res[i]=-1;
	}
	queue<pair<int,int>>q;
	q.push({0,0});
	while(!q.empty()){
		auto p=q.front();
		q.pop();
		if(res[p.first]==-1){
			res[p.first]=p.second;
			for(int i:v[p.first]){
				q.push({i,p.first});
			}
		}
	}
	for(int i=0;i<N;i++){
		if(res[i]==-1){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i=1;i<N;i++){
		cout<<res[i]+1<<endl;
	}
}


Measured memory_bytes: 12232
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int max = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int m = abs(a[i]-a[j]);
            if(max < m) max = m;
        }
    }
    cout << max << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

int main() {
	optimizar_io
	ll N, A, B;

	cin >> N >> A >> B;
	if (N >= A + B) {
		ll div = N / (A + B);
		ll mod = N % (A + B);
		mod = min(mod, A);
		ll ans = (div * A) + mod;
		cout << ans << "\n";
	}
	else {
		cout << min(N, A) << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
As = [nil] + gets.split.map(&:to_i)

b = Array.new(N + 1, 0)
N.downto(1) do |n|
  b[n] = n.step(N, n).inject(0){|s, i| s + b[i]} % 2 == As[n] ? 0 : 1
end
c = b.count(1)
puts c
puts b.map.with_index{|e, i| e == 1 ? i : nil}.compact.join(' ') unless c.zero?

Measured memory_bytes: 26108
#include <bits/stdc++.h>
#define MAX_V 100000
#define MAX_N 1000
using namespace std;

struct edge{int to, cap,cost,rev;};
int V;                         //????????°
vector<edge> G[MAX_V];         //??°???????????£??\???????????¨???
vector<int> dist[MAX_V];               //???????????¢
const vector<int> INF(1<<8,1000);
int prevv[MAX_V],preve[MAX_V]; //??´??????????????¨???

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back((edge){to,cap,cost,G[to].size()});
  G[to].push_back((edge){from,0,-cost,G[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  while(f>0){
    for(int i=0;i<V;i++) dist[i]=INF;
    dist[s]=vector<int>(1<<8,0);

    bool update = true;
    while(update){
      update = false;
      for(int v=0; v<V ;v++){
	if(dist[v]==INF) continue;
	for(int i=0; i<G[v].size(); i++){
	  edge &e = G[v][i];
	  vector<int> ncost=dist[v];
	  if(e.cost!=0)ncost[abs(e.cost)]+=e.cost/abs(e.cost);
	  
	  if(e.cap > 0 && dist[e.to] > ncost){
	    dist[e.to] = ncost;
	    prevv[e.to] = v;
	    preve[e.to] = i;
	    update = true;
	  }
	}
      }
    }
    if(dist[t]==INF) return -1; //????????\??????????????????
    
    //s???t?????????????????£??????????????????
    int d = f;
    for(int v=t; v!=s; v=prevv[v])d=min(d,G[prevv[v]][preve[v]].cap);
    f -= d;
    //res[ += d*dist[t];
    for(int v=t; v!=s; v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return 10;
}


int can[MAX_N][MAX_N];
int Biparite_Matching(int N,int K){
  int s = N+K, t = s+1;
  for(int i=0; i<N; i++) add_edge(s,i,1,0);
  for(int i=0; i<K; i++) add_edge(N+i,t,1,0);

  for(int i=0;i<N;i++)
    for(int j=0;j<K;j++)add_edge(i, N+j,1,can[i][j]);
  V=N+K+2;
  return min_cost_flow(s,t,N);
}



int main(){
  int n;
  cin>>n;
  
  string mp[51];
  for(int i=0;i<n;i++)cin>>mp[i];
  
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)can[i][j] = -mp[i][j];

  Biparite_Matching(n,n);
  string ans;
  for(int i=0;i<n;i++)
    for(int j=0;j<G[i].size();j++)
      if(G[i][j].cap==0) ans+=mp[i][G[i][j].to-n];
  sort(ans.begin(),ans.end());
  cout<<ans<<endl;
  
  return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    int L,R,d;
    cin>>L>>R>>d;
    int ans = R/d - (L-1)/d;
    cout<<ans<<endl;
}

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

using namespace std;

int main(){
	int i,j;
	while (true){
		cin >> i >> j;
		if (i == 0 && j == 0)break;
		(i < j) ? cout << i << " " << j << endl : cout << j << " " << i << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  int A = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x; 
    if (K - x > x) {
      A = A + x * 2;
    }
    else {
      A = A + (K - x) * 2;
    }
  }
  cout << A << endl;
}
      

Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long LL;

const LL N=LL(5e5+5);

struct data {
    LL t1, t2;
    bool operator < (const data &T) const {
        return t2<T.t2;
    }
} A[N];
priority_queue <LL> Q;
LL n, ans, cur;

int main() {
    while(scanf("%lld", &n)!=EOF) {
        for(LL i=0; i<n; i++) scanf("%lld%lld", &A[i].t1, &A[i].t2);
        sort(A, A+n);
        while(!Q.empty()) Q.pop();
        cur=ans=0;
        for(LL i=0; i<n; i++) {
            if(A[i].t1+cur<=A[i].t2) ans++, Q.push(A[i].t1), cur+=A[i].t1;
            else {
                if(Q.empty()) continue;
                LL val=Q.top();
                if(val<=A[i].t1) continue;
                cur-=val-A[i].t1;
                Q.pop();
                Q.push(A[i].t1);
            }
        }
        printf(ans==n?"Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)cout<<(n/x)*t<<endl;
    else cout<<(n/x)*t+t<<endl;
}

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

/*
数列Aを決めて全探索？
M comb N * Q
*/

// combination
// vector<int> comb(vector<int> &A, int r, vector<vector<int>> &res) {
//     if (r == 0) {
//         ;
//     } else {
//         // comb(A, r-1);
//         ;
//     }
// }

bool check_valid(int a, int b, int c, vector<int> &A) {
    a--;
    b--;
    int diff = A[b] - A[a];
    return diff == c;
}

void recursive_comb(vector<int> &index_array, int n, int r, vector<vector<int>> &C) {
    if (r == 0) {
        C.push_back(index_array);
    }
    else {
        if (n < 0)
            return;
        recursive_comb(index_array, n - 1, r, C);
        index_array[r - 1] = n;
        recursive_comb(index_array, n, r - 1, C);
        recursive_comb(index_array, n - 1, r - 1, C);
    }
}

// indexのcombinationが欲しい
vector<vector<int>> index_comb(int n, int r) {
    vector<vector<int>> C;
    vector<int> index_array(r);
    recursive_comb(index_array, n-1, r, C);
    return C;
}

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;

    // vector<vector<int>> C = index_comb(5, 3);
    // for (vector<int> v : C)
    // {
    //     for (int x : v) {
    //         cout << x << " ";
    //     }
    //     cout << endl;
    // }

    vector<vector<int>> I(Q, vector<int>(4));
    for (int i = 0; i < Q; i++)
    {
        cin >> I[i][0] >> I[i][1] >> I[i][2] >> I[i][3];
    }


    vector<vector<int>> index_combs = index_comb(M, N);
    int max_val = 0;
    for (int i = 0; i < index_combs.size(); i++)
    {
        vector<int> A(N);
        for (int k = 0; k < N; k++)
        {
            A[k] = index_combs[i][k] + 1;
        }
        
        // for (int x : A) {
        //     cout << x << " ";
        // }
        // cout << endl;

        int val = 0;
        for (int j = 0; j < Q; j++)
            {
                int a = I[j][0], b=I[j][1], c=I[j][2], d=I[j][3];
                if ( check_valid(a, b, c, A)) {
                    // cout << a << " " << b << " " << c << " " << d << endl;
                    val += d;
                }
            }

        // cout << "score: " << val << endl;
        max_val = max(max_val, val);
    }
    cout << max_val << endl;
}

Measured memory_bytes: 396304
#include <stdio.h>
#include <stdlib.h>

int	main()
{
	int	N, M, X, val;
	int	i, low, high;
	int	*block;

	low = 0;
	high = 0;
	scanf("%d %d %d\n", &N, &M, &X);
	block = (int *)malloc(sizeof(int) * (N + 1));
	i = 0;
	while (i < M)
	{
		scanf("%d ", &val);
		if (val < X)
			low++;
		else
			high++;
		i++;
	}
	if (high < low)
		low = high;
	printf("%d\n", low);
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

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

	int cnt = 0;
	for (int i = 0; i <= (N-3); ++i) {
		string t = s.substr(i, 3);
		if (t == "ABC") cnt += 1;
	}

	cout << cnt << endl;
	return 0;
} 

Measured memory_bytes: 3608
s=io.read()
for i=1, (#s-1)/2 do
    if s:sub(i,i) ~= s:sub(-i,-i) then
        print("No")
        return
    end
end

x = s:sub(1, (#s-1)/2)
y = s:sub((#s+3)/2)

for i=1, #x do
    if x:sub(i,i) ~= x:sub(-i,-i) then
        print("No")
        return
    end
end

for i=1, #y do
    if y:sub(i,i) ~= y:sub(-i,-i) then
        print("No")
        return
    end
end

print("Yes")

Measured memory_bytes: 760
#include<iostream>
#include<cstring>
using namespace std;
char s[101];
int h,n,maxn;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	  cin>>s[i];
	for (int i=1;i<=n;i++)
	{
		if (s[i]=='I') h++;
		else if (s[i]=='D') h--;
		if (h>maxn) maxn=h;
	}
	cout<<maxn<<endl;
	return 0;
}

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

int main() {
  int N, M, k, a1, a2, b1, b2, c1, c2, d1, d2, e1, e2;
  cin >> N;
  vector<string> data(N);
  for ( int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  a1 = 0;
  a2 = 0;
  b1 = 0;
  b2 = 0;
  for ( int i = 0; i < N; i++){
    if ( data.at(i) == "AC" ) {
      a1++;
    }
    if ( data.at(i) == "WA" ) {
      a2++;
    }
    if ( data.at(i) == "TLE" ) {
      b1++;
    }
    if ( data.at(i) == "RE" ) {
      b2++;
    }
  }
    cout << "AC " << "x " << a1 << endl;
    cout << "WA " << "x " << a2 << endl;
    cout << "TLE " << "x " << b1 << endl;
    cout << "RE " << "x " << b2 << endl;
    
    
}

Measured memory_bytes: 6352
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    cin >> a >> b;
    if(a < b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
    }else{
        for(int i = 0; i < a; i++){
            cout << b;
        }
    }
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    d = int(ipt())
    c = [int(i) for i in ipt().split()]
    s = [[int(i) for i in ipt().split()] for _ in range(d)]
    ld = [-1]*26
    edval = [0]*26

    for i in range(d):
        edval = s[i]*1
        for j in range(26):
            dl = i-ld[j]
            edval[j] += c[j]*dl*(dl+1)/20
        v = edval.index(max(edval))
        ld[v] = i
        print(v+1)

    return

if __name__ == '__main__':
    main()


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

int main()
{
	int N,res,ptr;
	cin >> N;

	int A[1000000];

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

	sort(A, A + N);

	while (ptr < N)
	{
		int cc = A[ptr], f = 0;
		while (ptr < N && A[ptr] == cc) f++, ptr++;
		res += f % 2;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 1000000007

vec p(12);
int fun(int h){
    //deb(h);
    if(h==0)
        return 1;
    else
    {
        return 1 + 2*fun(h / 2);
    }
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h;
    cin>>h;

    cout <<  fun(h / 2);

}
  

Measured memory_bytes: 256
#include<iostream>  
using namespace std;  
int main()  
{  
    long long int n,c=1,m,t,temp;  
    cin>>n;  
    for(int i=0;i<n;i++)  
    {  
        cin>>t;  
        if(t>c)  
        {  
            temp=c;  
            c=t;  
            t=temp;  
        }  
        long long int k,l;  
        k=t;  
        l=c;  
        while(t!=0)  
        {  
            temp=c%t;  
            c=t;  
            t=temp;  
        }  
        c=k/c*l;//数据太大，所以先除后乘  
    }     
    cout<<c<<endl;  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, 26) {
        mp['a' + i] = 0;
    }
    rep(i, s.length()) {
        ++mp[s[i]];
    }
    for ( auto tmp_mp : mp ) {
        if ( tmp_mp.second == 0 ) {
            cout << tmp_mp.first << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, A, B, C;
	string S;
	cin >> S;
	if (S[0] == '7')cout << "Yes" << endl;
	else if (S[1] == '7')cout << "Yes" << endl;
	else if (S[2] == '7')cout << "Yes" << endl;
	else cout << "No" << endl;







	return 0;
}



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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;


#define MAX_N 100010
#define MAX_M 100010
int n, m;
vector<int> G[MAX_N];
int color[MAX_N];

bool dfs(int v, int c) {
  color[v] = c;
  for(int i = 0; i < G[v].size(); ++i) {
    if(color[G[v][i]] == c) return false;
    if(color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
  }
  return true;
}

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

  cin >> n >> m;
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    G[--a].push_back(--b);
    G[b].push_back(a);
  }
  rep(i, 0, n) {
    if(color[i] == 0) {
      if(!dfs(i, 1)) {
        cout << 1ll * n * (n - 1) / 2 - m << endl;
        return 0;
      }
    }
  }
  int b = 0, w = 0;
  rep(i, 0, n) {
    if(color[i] == 1) ++b;
    else ++w;
  }

  cout << 1ll * b * w - m << endl;
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(){
	int i,x,y,gcd,lcm;
	
	while(scanf("%d %d", &x, &y) != EOF){
		if(x < y){
			i = x;
			x = y;
			y = i;
		}
		
		i = 1;
		while(1){
			if((y % i) == 0){
				if((x % (y / i)) == 0){
					gcd = y / i;
					break;
				}
			}
			i++;
		}
		
		i = 1;
		while(1){
			if(((x * i) % y) == 0){
				lcm = x * i;
				break;
			}
			i++;
		}
		
		printf("%d %d\n", gcd, lcm);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&k);
  scanf("%s",s);
  n = strlen(s);
  if(n <= k) printf("%s",s);
  else{
    rep(i,k) printf("%c",s[i]);
    printf("...");
  }
  
  return 0;
}



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

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] N = Console.ReadLine().Split(' ');
            int A = int.Parse(N[0]);
            int B = int.Parse(N[1]);
            int C = int.Parse(N[2]);

            if (C >= A && C <= B)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(){
	int n;
	int i;
	int count = 0;
	double x[100],y[100];
	double ans;
	scanf("%d",&n);
	while(n != 0){
		count++;
		for(i = 0; i < n; i++){
			scanf("%lf %lf",&x[i],&y[i]);
		}
		ans = 0;
		for(i = 1; i < n-1; i++){
			ans += ((y[i] - y[0]) * (x[i + 1] - x[0]) - (y[i + 1] - y[0]) * (x[i] - x[0])) / 2;
		}
		printf("%d %.1f\n",count,ans);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1084
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll a,b,c,d;

void solve(){
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	printf("%lld\n",max(max(a*c,a*d),max(b*c,b*d)));
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
int main(){
	int n=0;
	scanf("%d",&n);
	
	int tmp,data[3000]={0};
	for(tmp=0;tmp<n;tmp=tmp++){
		while(scanf("%d %d %d",&data[tmp],&data[tmp+1],&data[tmp+2])!=EOF){
			//sort
			int i,j,longer;
			for(i=0;i<3;i++){
				for(j=i+1;j<3;j++){
					if(data[i]<data[j]){
						longer=data[j];
						data[j]=data[i];
						data[i]=longer;
					}
				}
			}
			//judge
			if(data[tmp]*data[tmp]==data[tmp+1]*data[tmp+1]+data[tmp+2]*data[tmp+2]){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    println!(
        "{}",
        if s.contains(&'a') && s.contains(&'b') && s.contains(&'c') {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
h, w = map(int, input().split())
#行列
s = []
str_changed = []
for i in range(h):#h:高さ
    s.append([str(m) for m in input().split()])

for i in range(h):
    str_changed.append("".join(s[i]))
for i in range(h + 2):
    if i == 0:
        print("#" * (w + 2))
    elif i == h + 1:
        print("#" * (w + 2))
    else:
        print("#" + str_changed[i - 1] + "#")

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };
    let mut ans = false;
    for &a_i in a.iter() {
        if a_i % 2 != 0 {
            ans |= true;
        }
    }
    println!("{}", if ans { "first" } else { "second" });
}


Measured memory_bytes: 3708
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;




long long a[300010];
int tmp[300010];


int main()
{
    int n;scanf("%d",&n);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    long long base=1;long long ans=0;
    long long Mod = 1e9+7;
    for (int iiii=0;iiii<61;++iiii){
        int all1=0,all0=0;
        for (int i=0;i<n;++i){
            tmp[i]=a[i]%2;a[i]/=2;
            if (tmp[i]) ++all1;else ++all0;
        }
        for (int i=0;i<n;++i){
            if (tmp[i]){
                ans+=base*all0;
                ans%=Mod;
                all1--;
            }
            else{
                ans+=base*all1;
                ans%=Mod;
                all0--;
            }
        }

        base*=2;base%=Mod;
    }
    printf("%lld\n",ans);


}









Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin>>N;
    
    bool check=true;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(a%2!=0){check=false;break;}
    }
    
    if(check) cout<<"second"<<endl;
    else cout<<"first"<<endl;
    
}


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


int main() {
    int a, b;
    cin >> a >> b;
    if(a >= 10 || b >= 10) cout << -1 << endl;
    else cout << a*b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  int a;
  int b;
  int r;
  int l;
  cin >> n;
  cin >> a;
  cin >> b;
  l = a * n;
  r = b;
 if (r >= l ) { cout << l << endl;}
  if (r < l ) { cout << r << endl; }

} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = (ll)1e18+1;
int main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll n,m,l;
    cin>>n>>m>>l;

    ll d[n+5][n+5];
    ll x,y,z;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j] = INF;
        }
    }

    for(int i=0;i<m;i++){

            cin>>x>>y>>z;
            x--;
            y--;
            if(z<=l) d[x][y] = d[y][x] = z;

    }

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){

                if(d[i][k]+d[k][j] < d[i][j]){
                    d[i][j] = d[j][i] = d[i][k] + d[k][j];
                }

            }
        }
    }




    ll ans[n+5][n+5];

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){

            if(i==j) ans[i][j] = 0;

            else if(d[i][j]<=l) ans[i][j] = 1;

            else ans[i][j] = INF;


        }
    }

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){


                if(ans[i][k]+ans[k][j] < ans[i][j]){
                    ans[i][j] = ans[j][i] = ans[i][k] + ans[k][j];
                }

            }
        }
    }



    ll q;
    cin>>q;

    while(q--){
        cin>>x>>y;

        x--;
        y--;

        if(ans[x][y] == INF) cout<<"-1\n";
        else cout<< ans[x][y] - 1<<"\n";
    }

}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
 
using namespace std;
 
inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}
 
int main(){
	long long n,d;
	cin>>n;cin>>d;
	if(d==100){
		d=101;
	}
	if(n==0){
		printf("%lld\n",d);
	}
	else if(n==1){
		printf("%lld\n",d*100);
	}
	else printf("%lld\n",d*10000);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
        for(int i = n ; i>=0 ; i--){
            if(Math.sqrt(i) - (int)Math.sqrt(i) == 0 ){
                System.out.println(i);break;
            }
        }
      }
}

Measured memory_bytes: 20820
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 200010
using namespace std;


int main()
{
    string s[12];
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0; i<h; i++)
    {
        cin>>s[i];
    }
    int  ans=inf;
    for(int i=0; i<(1<<h-1); i++)
    {
        int x=__builtin_popcount(i);
        int r[x+1]= {0};
        int flag=1;
        int cnt=x;
        for(int j=0; j<w; j++)
        {
            int c[x+1]= {0};
            int p=0;
            int mx=0;
            for(int t=0; t<h; t++)
            {
                c[p]+=s[t][j]-'0';
                mx=max(mx,c[p]);
                if(i&(1<<t))
                    p++;
            }
            if(mx>k)
            {
                flag=0;
                break;
            }
            mx=0;
            for(int i=0;i<=x;i++)
            {
                mx=max(mx,r[i]+c[i]);
            }
            if(mx>k)
            {
                memset(r,0,sizeof(r));
                cnt++;
            }
            for(int i=0;i<=x;i++) r[i]+=c[i];
        }
        if(flag) ans=min(ans,cnt);
    }

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


Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

char s[8010];
int tx;
int ty;

int cnt_map[16020];
vector<int> v_list;
vector<int> h_list;

bool func(int target, vector<int>& vec, int init)
{
	memset(cnt_map, -1, sizeof(cnt_map));

	queue<int> q;
	q.push(init);
	cnt_map[init] = 0;

	int cnt = 1;
	for (int n : vec)
	{
		int q_cnt = q.size();
		for (int i = 0; i < q_cnt; i++)
		{
			int a = q.front();
			q.pop();

			for (int j = 0; j < 2; j++)
			{
				int d = a;
				d += (j == 0) ? n : -n;

				if (cnt_map[d] < cnt)
				{
					cnt_map[d] = cnt;
					q.push(d);
				}
			}
		}
		cnt++;
	}

	return cnt_map[target] == vec.size();
}

signed main()
{
	cin >> s;
	cin >> tx >> ty;
	int len = strlen(s);

	int counter = 0;
	int offset = 0;
	for (int i = 0; i <= len; i++)
	{
		if (i == len || s[i] != 'F')
		{
			offset = i;
			counter = i;
			break;
		}
	}

	bool is_v = true;
	while (true)
	{
		int f_cnt = 0;
		if (counter >= len) break;
		while (true)
		{
			counter++;
			if (counter >= len) break;
			if (s[counter] != 'F')
			{
				break;
			}
			f_cnt++;
		}

		if (is_v)
		{
			v_list.push_back(f_cnt);
		}
		else
		{
			h_list.push_back(f_cnt);
		}
		is_v = !is_v;
	}

	bool b1 = func(tx + 8010, h_list, 8010 + offset);
	bool b2 = func(ty + 8010, v_list, 8010);

	if (b1 && b2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 512
from itertools import accumulate

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [tuple(map(int, input().split())) for _ in range(M)]

A = sorted(A)
BC = sorted(BC, key = lambda x: x[1], reverse=True)

trade = []
len_ = 0
for b, c in BC:
    if len_ >= N:
        break
    for _ in range(b):
        if len_ >= N:
            break
        trade.append(c)
        len_ += 1

ans = 0
for i in range(N):
    if i >= len_:
        ans += A[i]
    else:
        ans += max(trade[i], A[i])
print(ans)


Measured memory_bytes: 29128
using System;

namespace _96_2
{
    class Program
    {
        static void Main(string[] args)
        {
			string[] acs = Console.ReadLine().Split(' ');
			int A = int.Parse(acs[0]);
			int B = int.Parse(acs[1]);
			int C = int.Parse(acs[2]);
			int K = int.Parse(Console.ReadLine());
			if (B < A && C < A)
			{
				Console.WriteLine(Math.Pow(2, K) * A + B + C);
			}
			else if (A < B && C < B)
			{
				Console.WriteLine(Math.Pow(2, K) * B + A + C);
			}
			else
			{
				Console.WriteLine(Math.Pow(2, K) * C + A + B);
			}
		}
    }
}


Measured memory_bytes: 11092