akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main(){

    vector<bool> nums(3);

    for (int i = 0; i < 2; i++) {
        int num;
        cin >> num;
        nums[num-1] = true;
    }
        

    for (int i = 0; i < 3; i++)
        if (!nums[i])
            cout << i+1 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<N; i++) {
			int a=sc.nextInt();
			m.put(a, m.containsKey(a) ? m.get(a)+1 : 1);
		}
		long sum = 0;
		for(Entry<Integer,Integer> e : m.entrySet()) {
			int a = e.getKey();
			int cnt = e.getValue();

			if(a<cnt) {
				sum += cnt-a;
			}else if(a>cnt){
				sum += cnt;
			}
		}
		System.out.println(sum);
		sc.close();
	}
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n,c = 0,d;
int main() {
    cin >> n;
    int a[n];
    rep(i,0,n){
        cin >> a[i];
    }
    rep(i,0,n-1){
        int b = a[i];
        rep(j,i,n){
            if(b > a[j]){
                b = a[j];
                d = j;
            }
        }
        if(a[i] != b){
            swap(a[i],a[d]);
            c++;
        }
    }

    rep(i,0,n){
        printf("%d",a[i]);
        if(i != n-1) printf(" ");
    }
    printf("\n");
    pout(c);
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define REP(i,e,s) for(register int i=e; i<=s; i++)

int read() {
    int ch=getchar(),x=0,f=1;
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

#define MAXN 200000+10
#define INF 0x3f3f3f3f
int a[MAXN];

int main() {
    int n=read();
    REP(i,1,n) a[i]=read();
    int maxx=-INF,minn=a[1];

    REP(i,2,n) {
        maxx=max(maxx,a[i]-minn);
        minn=min(minn,a[i]);
    }

    printf("%d\n",maxx);
    return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <map>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    map<int,int> mp;
    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto it = mp.begin(); it != mp.end(); ++it){
        if(it->first - it->second < 0) ans += it->second - it->first;
        else if(it->first - it->second > 0) ans += it->second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8060
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int main(){
    string s;
    cin >> s;
    int acn = 0; int zcn = 0;
    rep(i, s.size()){
        if(s[i] == 'A'){
            acn = i;
            break;
        }
    }
    for(int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            zcn = i;
            break;
        }
    }
    cout << zcn - acn + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
struct UnionFind{
    vector<int> par;
    vector<long long> rank;
    void init(int n){
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 1;
        }
    }
    int root(int x){
        if(par[x] == x) return x;
        return root(par[x]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    long long size(int x){
        return rank[(root(x))];
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(size(y) > size(x)) swap(x, y);
        rank[x] += rank[y];
        par[y] = par[x]; 
    }
};
int main(){
    long long N, M;
    cin >> N >> M;
    long long m = N * (N - 1) /2;
    vector<int> A(M), B(M);
    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    UnionFind U;
    vector<long long> sum(M, m);
    U.init(N);
    for(int i = 0; i < M - 1; i++){
        int a = A[M - 1 - i], b = B[M - 1 - i];
        if(U.same(a, b)) {
            sum[M - 2 - i] = m;
            continue;
        }
        long long t = U.size(b) * U.size(a);
        U.unite(a, b);
        m -= t;
        sum[M - 2 - i] = m;
    }
    for(int i = 0; i < M; i++) cout << sum[i] << endl;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int H, W;cin>>H>>W;
    //vector<vector<int>> s(H, vector<int>(W,0));
    vector<string> s(H);
    int tot_white=0;
    rep(i,H){
        cin>>s.at(i);
        rep(j,W){
            if(s.at(i).at(j)=='.')tot_white++;
        }
        /*
        rep(j,W){
            cin>>s.at(i).at(j);
            if(s.at(i).at(j)=='.')tot_white++;
        }
        */
    }

    // ダイクストラ法でゴールまでの最短経路を求める

    priority_queue<T, vector<T>,greater<T>> pq;
    pq.push(make_tuple(0, 0, 0));

    vector<vector<int>> min_distance(H, vector<int>(W,-1));

    while(pq.size()>0){
        int cost, h, w;
        tie(cost, h, w) = pq.top();pq.pop();
        if(h==H-1 && w==W-1){
            cout<<tot_white-cost-1<<endl;
            return 0;
        }
        if(min_distance.at(h).at(w)>=0)continue;
        min_distance.at(h).at(w) = cost;

        for(int i=-1;i<2;i++){
        for(int j=-1;j<2;j++){
            if(abs(i)+abs(j)!=1)continue;
            if(h+i<0||h+i>H-1)continue;
            if(w+j<0||w+j>W-1)continue;
            if(min_distance.at(h+i).at(w+j)>=0)continue;
            if(s.at(h+i).at(w+j)=='#')continue;
            pq.push(make_tuple(cost+1, h+i, w+j));
        }
        }


    }

    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

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

#define M 1000000

int memo[M];

vector<int> getvect(int n,int L){
    vector<int> ret;

    rep(i,L){
        ret.push_back(n%10);
        n/=10;
    }

    return ret;
}

int getnum(vector<int>& a){
    int ret = 0;
    int range = 1;
    rep(i,a.size()){
        ret += range*a[a.size()-1-i];
        range*=10;
    }
    return ret;
}

int main(){
    FRONT:;

    int n,L;
    cin>>n>>L;
    if(n==0 && L==0)return 0;


    rep(i,M)memo[i]=-1;

    int ansi=-1;
    int ansj=-1;
    int counter = 0;

    while(1){

        if(memo[n]!=-1){
            printf("%d %d %d\n",memo[n],n,counter-memo[n]);
            break;
        }
        memo[n] = counter;
        counter++;

        vector<int> a = getvect(n,L);
        vector<int> b = getvect(n,L);


        sort(a.begin(),a.end());
        sort(b.begin(),b.end()); reverse(b.begin(),b.end());


        int anum = getnum(a);
        int bnum = getnum(b);

        n = bnum - anum;
    }

    goto FRONT;
}

Measured memory_bytes: 5100
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

X,Y = list(map(int, input().split()))

# X = 2n+m, Y = n+2mとして
n = (2*X-Y)//3
m = (Y-n)//2

mod = 10**9+7 #出力の制限
N = n+m
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


if (X + Y) % 3 != 0:
    print(0)
elif n < 0 or m < 0:
    print(0)
else:
    print(cmb(n+m, n, mod))

Measured memory_bytes: 82440
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;*/
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
typedef long long ll;
typedef pair<ll, ll> Pa;

/*
template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

typedef modint<MOD> m;
m func[400001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}*/

string s;
list<char> lst;
int main() {
	cin >> s;
	rep(i, s.size()) {
		lst.push_back(s[i]);
	}
	cin >> N;
	int revcount = 0;
	rep(i, N) {
		cin >> A;
		if (A == 1) {
			revcount++;
		}
		else {
			char c;
			cin >> B >> c;
			if (B == 1) {
				if (revcount % 2 == 0) lst.push_front(c);
				else lst.push_back(c);
			}
			else {
				if (revcount % 2 == 0) lst.push_back(c);
				else lst.push_front(c);
			}
		}
	}
	if (revcount % 2 == 1) {
		lst.reverse();
	}
	
		for (auto itr = lst.begin(); itr != lst.end(); ++itr) {
			std::cout << *itr;
		}
	
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;


ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}
 vil v[200005];
 vil a(200005),p(200005);
 bool vis[200005]={false};
 ll maxi=INT_MIN;
void dfs(int s,ll atil,ll ptil){
    vis[s]=true;
    for(auto x: v[s]){
        if(!vis[x]){
            
       ll sm=(atil+a[x-1])/(ptil+p[x-1]);
       if(sm>maxi){
           maxi=sm;
          // vis[x]=true;
           dfs(x,atil+a[x-1],ptil+p[x-1]);
       }
       else if(sm==maxi){
         //  vis[x]=true;
           dfs(x,atil+a[x-1],ptil+p[x-1]);
       }
        }
    }
     
}
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n;cin>>n;
  vil v(n);
  unordered_map<ll,ll> m;
  ll sum=0;
  for(int i=0;i<n;i++)cin>>v[i],m[v[i]]++,sum+=v[i];
  ll q;cin>>q;
  while(q--){
      ll p,r;
      cin>>p>>r;
      ll x=m[p];
     ll tt=sum+((r-p)*x);
     sum=tt;
      m[p]=0;m[r]+=x;
      cout<<tt<<endl;
  }
}





  

Measured memory_bytes: 15728
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  str s,t;
  cin>>s>>t;
  int cnt=0;
  rep(i,s.size()){
    cnt+=(bool)(s[i]-t[i]);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3916
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class D {
        static final int mod = 1000000007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Long.parseLong(in.next());
            long k = Long.parseLong(in.next());
            long ans = 0;

            for (long i = k; i <= n + 1; i++)
                ans = (ans + (n + 1 - i) * i + 1) % mod;

            // 出力
            out.println(ans);

        }

    }
}



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

using namespace std;

struct Data
{
    int node;
    long long le;
};

struct cmp
{
    bool operator()(const Data &l, const Data &r)
    {
        return l.le > r.le;
    }
};

int n, m;
long long k, oo = 1e15, a[1010][1010];

void Process()
{
    for (int k=0; k<=n-1; k++)
        for (int i=0; i<=n-1; i++)
            for (int j=0; j<=n-1; j++)
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
}

void Input()
{
    ios_base::sync_with_stdio(0);       cin.tie(0);

    cin >> n >> m >> k;
    for (int i=0; i<=n-1; i++)
        for (int j=0; j<=n-1; j++)
            a[i][j] = oo;

    for (int i=1; i<=m; i++)
    {
        int x, y;   long long le;       cin >> x >> y >> le;
        x--;        y--;

        if (le > k) a[x][y] = a[y][x] = oo;
            else a[x][y] = a[y][x] = le;
    }

    Process();

    for (int i=0; i<=n-1; i++)
        for (int j=0; j<=n-1; j++)
            if (a[i][j] <= k) a[i][j] = 1;
                else a[i][j] = oo;

    Process();

    int test;       cin >> test;

    while (test--)
    {
        int x, y;       cin >> x >> y;
        x--;      y--;

        if (a[x][y] == oo) cout << -1 << endl;
            else cout << a[x][y] - 1 << endl;
    }
}

int main()
{
    Input();
    return 0;
}


Measured memory_bytes: 4224
import java.io.IOException;
import java.util.*;

public class Main {


	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int sizeOfList = sc.nextInt();
		List<Long> values = new ArrayList<Long>();

		long biggest = -(2000000000-1);
		for (int i = 0; i < sizeOfList; i++) {
			values.add(sc.nextLong());
		}
		long min = values.get(0);
		for (int i = 1; i < values.size(); i++) {
			long diff = values.get(i) - min;
			if (biggest < diff) {
				biggest = diff;
			}
			if (values.get(i) < min) {
				min = values.get(i);
			}
		}

		System.out.println(biggest);
	}
}

Measured memory_bytes: 101680
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

int main() {
  int N, K;

  cin >> N >> K;
  
  vector<int> h(N);
  
  fill(h);
  
  int r = 0;
  for (auto i : h) {
    if (i >= K)
      r++;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000 + 7;

long long modpow(long long a, long long n, long long mod)
{
	long long res = 1;
	while ( n>0 )
	{
		if ( n & 1 ) res = res * a % mod;
		a = (a * a) % mod;
		n >>= 1;
	}
	return res;
}

long long modcomb(long long m, long long n, long long mod)
{
	if (m < n) return -1;
	if (n > m/2) n = m-n;
	long long x=1;
	long long y=1;
	for (long long i=m; i>m-n; i--)
	{
		x = x * i % mod;
	}
	for (long long i=2; i<n+1; i++)
	{
		y = y * i % mod;
	}
	long long inverseY = modpow(y, mod-2, mod);
	return x * inverseY % mod;
}

int main()
{
	long long n, a, b;
	cin >> n >> a >> b;
	long long sum=0;

	sum = modpow(2,n, MOD);
	sum--;

	long long nca = modcomb(n,a,MOD);
	long long ncb = modcomb(n, b, MOD);

	sum -= nca;
	if ( sum<0 ) sum += MOD;
	sum -= ncb;
	if ( sum<0 ) sum += MOD;

	cout << sum << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int dp1[3030][3030];
int dp2[3030][3030];
bool color[3030];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n,t;cin>>n>>t;
    V<Pin>food(n+1);
    for(int i=1;i<=n;i++){
        cin>>food[i].fi>>food[i].se;
    }
    int ans=0;
    sort(all(food));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=t-1;j++){
            if(j>=food[i].fi){
                dp1[i][j]=mmax(dp1[i-1][j],dp1[i-1][j-food[i].fi]+food[i].se);
            }
            else{
                dp1[i][j]=dp1[i-1][j];
            }
        }
    }
    for(int i=n;i>=1;i--){
        for(int j=1;j<=t-1;j++){
            if(j>=food[i].fi){
                dp2[i][j]=mmax(dp2[i+1][j],dp2[i+1][j-food[i].fi]+food[i].se);
            }
            else{
                dp2[i][j]=dp2[i+1][j];
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=t-1;j++){
            chmax(ans,dp1[i-1][j]+dp2[i+1][t-1-j]+food[i].se);
        }
    }
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------














































Measured memory_bytes: 71936
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if((S.charAt(2)==S.charAt(3))&&(S.charAt(4)==S.charAt(5))) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

#define int long long
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; }
template<class T> struct BinaryIndexTree{
    int n;
    vector<T> bit; 
    vector<T> org;

    BinaryIndexTree(int si): bit(si+1), org(si+1) { n = si; }; 

    void add(int idx, T v){
        org[++idx] += v;
        for(int i = idx;i <= n;i+=i&-i) bit[i] += v;
    }

    void update(int idx, T v){
        T vv = v - org[++idx];
        org[idx] = v;
        for(int i = idx;i <= n;i+=i&-i) bit[i] += vv;
    }

    T sum(int a){
        T ret = 0;
        for(int i = a;i > 0;i-=i&-i) ret += bit[i];
        return ret;
    }

    T sum(int l, int r) { return sum(r)-sum(l); }; 
};

int a[500010];
int r[500010] = {};
int ans[500010];
signed main(){
	int n, q;
	cin >> n >> q;

	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	memset(r, -1, sizeof(r));

	vector<vector<pair<pair<int, int>, int>>> vec(n);
	for(int i = 0;i < q;i++){
		int l, r;
		cin >> l >> r;
		l--; r--;
		vec[r].push_back({{l, r}, i});
	}

	BinaryIndexTree<int> bit(n);
	for(int i = 0;i < n;i++){
		if(r[a[i]] != -1) bit.add(r[a[i]], -1);
		r[a[i]] = i;
		bit.add(r[a[i]], 1);
		for(int j = 0;j < vec[i].size();j++){
			ans[vec[i][j].second] = bit.sum(vec[i][j].first.first, i+1);
		}
	}

	for(int i = 0;i < q;i++){
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 51216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
typedef long long LL;

using namespace std;

//「ある場合A」の事象数は余事象1-A^c

int main(void) {
	int n;
	cin >> n;
	vector<int>A(n);
	int all = 1, bad = 1;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		all *= 3;
		if (A[i] % 2 == 0) {
			bad *= 2;
		}
	}
	cout << all - bad;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	int a=read(),b=read(),c=read();
	cout<<(a-b)%c;
	return 0;
}



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

int main(){
	int h, a;
  	cin >> h >> a;
  
  	int ans = (h+a-1) / a;
  
  	cout << ans << endl;
}

Measured memory_bytes: 3528
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main (){
  
  int n;
  
  while(1){
    cin >>n;
    if (n==0)break;
    
    vector<int> posx,posy;
    posx.push_back(0);
    posy.push_back(0);
    
    int i,posn,dir,x,y;
    
    for(i=0;i<n-1;i++){
      cin >> posn >> dir;
      if(dir==0){
	//左
	posx.push_back(posx[posn]-1);
	posy.push_back(posy[posn]);
      }else if(dir==1){
	//下
	posx.push_back(posx[posn]);
	posy.push_back(posy[posn]-1);
      }else if(dir==2){
	//右
	posx.push_back(posx[posn]+1);
	posy.push_back(posy[posn]);
      }else if(dir==3){
	//上
	posx.push_back(posx[posn]);
	posy.push_back(posy[posn]+1);
      }
      //cout << posx[i+1] <<endl;
      //cout << posy[i+1] <<endl;
    }
    
    sort(posx.begin(),posx.end());
    sort(posy.begin(),posy.end());
    
    x = (posx[posx.size()-1]+1) - posx[0];
    y = (posy[posy.size()-1]+1) - posy[0];
    
    cout << x << " " << y <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;


int main() {
	ll numV, numE;
	cin >> numV >> numE;
	vector<set<ll>> adjacents;
	adjacents.resize(numV + 1);
	for (ll i = 0; i < numE; i++) {
		ll a, b;
		cin >> a >> b;
		adjacents[a].insert(b);
		adjacents[b].insert(a);
	}
	vector<ll> v;
	for (ll i = 2; i <= numV; i++) {
		v.push_back(i);
	}
	ll ans = 0;
	do {
		bool success = true;
		vector<ll> order;
		order.push_back(1);
		for (ll i = 0; i < v.size(); i++) {
			order.push_back(v[i]);
		}
		for (ll i = 0; i < v.size(); i++) {
			if (adjacents[order[i]].find(order[i + 1]) == adjacents[order[i]].end()) {
				success = false;
				break;
			}
		}
		if (success) {
			ans++;
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << ans << endl;
}


Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    private enum State
    {
        None,
        A,
        AB,
    }

    public static void Main()
    {
        var s = Console.ReadLine().ToArray();

        var state = State.None;
        ulong count = 0;
        ulong prevA = 0;

        for (int i = 0; i < s.Length; ++i)
        {
            switch (s[i])
            {
                case 'A':
                    if (state == State.A)
                    {
                        ++prevA;
                    }
                    else
                    {
                        state = State.A;
                        prevA = 0;
                    }
                    break;
                case 'B':
                    state = state == State.A ? State.AB : State.None;
                    break;
                case 'C':
                    if (state == State.AB)
                    {
                        ++count;
                        count += prevA;
                        state = State.A;
                    }
                    else
                    {
                        state = State.None;
                    }
                    break;
            }
        }

        Console.WriteLine(count);
    }

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 13196
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, colorX, colorY, D; vll path;
//***********//
void dfs(ll now, ll C) {
	stack<ll> S;
	S.push(now);
	flag[now] = C;
	if (now < 100000) colorX[C-1] ++;
	else colorY[C-1]++;
	while (!S.empty()) {
		ll u = S.top();
		S.pop();
		for (ll i = 0; i < path[u].size(); i++) {
			ll v = path[u][i];
			if (flag[v] == 0) {
				dfs(v, C);
			}
		}
	}
}
int main() {
	cin >> N;
	flag.resize(200000);
	path.resize(200000);
	for (i = 0; i < N; i++) {
		ll x, y;
		cin >> x >> y;
		x--; y--;
		path[x].push_back(100000 + y);
		path[100000+y].push_back(x);
	}
	ll C = 1;
	for (i = 0; i < 200000; i++) {
		if (flag[i]==0 && path[i].size() > 0) {
			colorX.push_back(0);
			colorY.push_back(0);
			dfs(i, C);
			C++;
		}
	}
	debug(colorX, colorY);
	for (i = 0; i < colorX.size(); i++) {
		ans += colorX[i]*colorY[i];
	}
	cout << ans-N;
}

Measured memory_bytes: 59520
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = (int)1e9 + 7;
int INF = (int)2e18;


signed main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        char temp = S[i];
        int count = 0;
        for (int j = 0; j < S.length(); j++) {
            if (temp == S[j]) ++count;
        }
        if (count != 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
n = int(input())
t_score = 0
h_score = 0

for i in range(n):
    cards = list(input().split())
    t_card, h_card = cards[0], cards[1]
    if t_card == h_card:
        t_score += 1
        h_score += 1
    else:
        cards.sort(reverse=True)
        if cards[0] == t_card:
            t_score += 3
        else:
            h_score += 3

print(t_score, h_score)



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

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		int n = int.Parse(Console.ReadLine());
		var d = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int sum = 0;
		
		for(int a=0;a!=n-1;a++){
			
			for(int b=a+1;b!=n;b++){
				
				sum += d[a] * d[b];
				
			}
			
			
		}
		
		Console.WriteLine(sum);
		
	}
}

Measured memory_bytes: 13268
from decimal import Decimal

def main():

    # 引数を受け取る
    args = input().split(' ')

    # リストの中身をint型に変換
    args = [float(i) for i in args]

    ans1 = int(args[0] / args[1])
    ans2 = int(args[0] % args[1])
    ans3 = args[0] / args[1]

    print('{0} {1} {2:.8f}'.format(ans1, ans2, ans3))



if __name__ == "__main__":
    main()


Measured memory_bytes: 6324
N = gets.to_i
Ary = gets.split.map(&:to_i).sort

count = 0
Ary.each.with_index do |a, i|
  break if i == Ary.size - 1
  Ary[(i+1)..-1].each.with_index do |b, j|
    c = (Ary[(i+j+2)..-1].bsearch_index { |c| a + b <= c } )
    if c
      count += c
    else
      count += Ary[(i+j+2)..-1].size
    end
  end
end

puts count


Measured memory_bytes: 1916
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		long N = sc.nextLong();

		int result = String.valueOf(N).length();

		for (long f = 2; f * f <= N; f++) {
			if (N % f != 0) continue;
			result = Math.min(result, String.valueOf(N / f).length());
		}
		System.out.println(result);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    V<> a(n);
    cin >> a;
    sort(rall(a));
    int ans = accumulate(a.begin(), a.begin() + k, 0);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int rec(int a){
      return a/100*60+a%100;
}
int main(){
      int n,p,q,k,a,b;
      while(cin>>n>>p>>q&&(n||p||q)){
            p=rec(p);
            q=rec(q);
            int cnt[24*60+2];
            memset(cnt,0,sizeof(cnt));
            REP(times,n){
                  cin>>k;
                  while(k--){
                        cin>>a>>b;
                        a=rec(a);b=rec(b);
                        cnt[a]++;
                        cnt[b]--;
                  }
            }
            int ans=0,sum=0;
            REP(i,24*60+1)cnt[i+1]+=cnt[i];
            for(int i=p;i<q;i++){
                  if(cnt[i]<n){
                        sum++;
                        ans=max(ans,sum);
                  }else{
                        sum=0;
                  }
            }
            cout<<ans<<endl;
      }
}

Measured memory_bytes: 1164
import sys
import gc
import numpy as np
import string

N = int(input())
S = [input() for i in range(N)]

dict = string.ascii_lowercase#abc...xyz

data_list = np.zeros((N,26))

for i in range(0,N):
	list = []
	for j in range(0,26):
		list.append(S[i].count(str(dict[j])))
	data_list[i] = np.array(list)
data_min = data_list.min(axis = 0)

del list
gc.collect()

a = np.nonzero(data_min)
size = np.nonzero(data_min)[0].size
b = a[0]
kotae = ""
for i in range(size):
	Moji = dict[b[i]]*int(data_min[b[i]])
	kotae = kotae + Moji
	pass
del data_min
gc.collect()

print(kotae)



Measured memory_bytes: 12268
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int N;
vi findAns(vi bits,int A,int B) {
    if (bits.size() == 1) {
        vi r;
        r.pb(A),r.pb(B);
        return r;
    }

    int i;
    for (i = 0; i < bits.size(); i++) {
        if ((A^B) & (1 << bits[i])) break;
    }
    int p = i;
    vi bits2;
    for (i = 0; i < bits.size(); i++) {
        if (i != p) bits2.pb(bits[i]);
    }
    vi f,s;
    if ((A^(1 << bits2[0])) == B) {
        f = findAns(bits2,A,A^(1 << bits2[1]));
        s = findAns(bits2,A^(1 << bits2[1]),B);
    }
    else {
        f = findAns(bits2,A,A^(1 << bits2[0]));
        s = findAns(bits2,A^(1 << bits2[0]),B);
    }
    vi ans;
    for (i = 0; i < f.size(); i++) {
        if ((A^f[i]) & (1 << bits[p])) f[i] ^= (1 << bits[p]);
        ans.pb(f[i]);
    }
    for (i = 0; i < s.size(); i++) {
        if ((B^s[i]) & (1 << bits[p])) s[i] ^= (1 << bits[p]);
        ans.pb(s[i]);
    }
    return ans;
}
int main() {
    int A,B;
    cin >> N >> A >> B;

    int i,a = 0,b = 0;
    for (i = 0; i < N; i++) {
        if (A & (1 << i)) a++;
        if (B & (1 << i)) b++;
    }
    if ((a+b) & 1) {
        vi v;
        for (i = 0; i < N; i++) v.pb(i);
        v = findAns(v,A,B);
        printf("YES\n");
        for (i = 0; i < (1 << N); i++) printf("%d ",v[i]);
        printf("\n");
    }
    else printf("NO\n");

    return 0;
}



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

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int N, A, B, C;
vector<int> l;
int dfs(const vector<int> a, const vector<int>& b, const vector<int>& c, int i) {
  if (i == N) {
    if (a.size() == 0 || b.size() == 0 || c.size() == 0) return kInf;
    int sumA = accumulate(a.begin(), a.end(), 0);
    int sumB = accumulate(b.begin(), b.end(), 0);
    int sumC = accumulate(c.begin(), c.end(), 0);
    int costA = abs(A - sumA) + 10 * (a.size() - 1);
    int costB = abs(B - sumB) + 10 * (b.size() - 1);
    int costC = abs(C - sumC) + 10 * (c.size() - 1);
    return costA + costB + costC;
  }

  vector<int> a2 = a; a2.push_back(l[i]);
  vector<int> b2 = b; b2.push_back(l[i]);
  vector<int> c2 = c; c2.push_back(l[i]);
  int minMP = kInf;
  minMP = min(minMP, dfs(a, b, c, i + 1));
  minMP = min(minMP, dfs(a2, b, c, i + 1));
  minMP = min(minMP, dfs(a, b2, c, i + 1));
  minMP = min(minMP, dfs(a, b, c2, i + 1));
  return minMP;
}

int main() {
  cin >> N >> A >> B >> C;
  l.resize(N); cin >> l;

  cout << dfs({}, {}, {}, 0) << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    int n, d, x[15][15];
    cin >> n >> d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            long long ans=0;
            long long root;
            for(int k=0;k<d;k++){
                ans += pow(x[i][k] - x[j][k], 2);
            }
            root = int(sqrt(ans));
            if(pow(root, 2)==ans){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<regex>
#include<set>
#include<initializer_list>
#include<tuple>
#include<queue>
#include<functional>
#include<random>
#include<cstdlib>
#include<fstream>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()

const int INFTY = 100000000;
const long long LINFTY = 1e20;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> boxes(N, 1);
    vector<bool> isRed(N, false);
    isRed[0] = true;
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        x--; y--;
        boxes[x]--;
        boxes[y]++;
        if (isRed[x]) isRed[y] = true;
        if (boxes[x] == 0) isRed[x] = false;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) if (isRed[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int
	var factor []int
	var front, back int

	fmt.Scanf("%d", &x)

	factor = makeDivisors(x)
	// fmt.Print(factor)

	for i := 0; i < len(factor); i++ {
		front = factor[i]
		back = x / factor[i]
		if check(front, back) == true {
			return
		}
	}

}

func makeDivisors(n int) []int {
	divisors := make([]int, 0)
	for i := 1; i < int(math.Sqrt(float64(n))+1); i++ {
		if n%i == 0 {
			divisors = append(divisors, i)
			if i != n/i {
				divisors = append(divisors, n/i)
			}
		}
	}

	return divisors
}

func check(front int, back int) bool {
	for i := 0; i < 500; i++ {
		a := float64(i)
		b := a - float64(front)
		if float64(back) == (math.Pow(a, 4) + math.Pow(a, 3)*b + math.Pow(a, 2)*math.Pow(b, 2) + a*math.Pow(b, 3) + math.Pow(b, 4)) {
			fmt.Println(int(a), int(b))
			return true
		}
	}
	return false
}

func PrimeFactors(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	if n > 2 {
		pfs = append(pfs, n)
		pfs = append(pfs, 1)
	}

	if n == 1 {
		pfs = append(pfs, 1)
	}

	return
}


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

using namespace std;

int main(void)
{
    int x,n;
    cin>>x>>n;
    unordered_set<int> ps;
    int p;
    for(int i=0;i<n;++i)
    {
        cin>>p;
        ps.insert(p);
    }
    int l = x,r=x;
    while(1)
    {
        if(ps.count(l) ==0 ){
            cout<<l<<endl;
            break;
        }
        else if(ps.count(r)==0){
            cout<<r<<endl;
            break;
        }
        --l;
        ++r;
    }
    
    
}


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

const string day[7]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

int mtod(int m){
	if (m==0)return 0;
	int re=0;
	if(m==2)re=29;
	else if(m==4 || m==6||m==9||m==11)re=30;
	else re=31;
	return mtod(m-1)+re;
}
int main(){
	int m,d;
	while(cin>>m>>d && m+d){
		int now=mtod(m-1)+d;
		cout<<day[(now-1)%7]<<endl;
	}
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
char a[100005];
int main()
{
    ios::sync_with_stdio(false);
    double c;
    cin>>c;
    printf("%.20f",6.28318530717958623200*c);

}



Measured memory_bytes: 3808