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

int main()
{
    int X, Y, Z, K;
    cin>>X>>Y>>Z>>K;
    vector<long long> A(X);
    for (long long &a: A)
        cin>>a;
    vector<long long> B(Y);
    for (long long &b: B)
        cin>>b;
    vector<long long> C(Z);
    for (long long &c: C)
        cin>>c;
    
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());

    priority_queue<pair<long long, pair<int, pair<int,int>>>> Q;
    for (int x=0; x<X; x++)
        for (int y=0; y<Y; y++)
            Q.push(make_pair(A[x]+B[y]+C[0], make_pair(x, make_pair(y, 0))));

    for (int k=0; k<K; k++)
    {
        auto t = Q.top();
        Q.pop();
        cout<<t.first<<endl;

        int x = t.second.first;
        int y = t.second.second.first;
        int z = t.second.second.second;
        if (z<Z-1)
            Q.push(make_pair(A[x]+B[y]+C[z+1], make_pair(x, make_pair(y, z+1))));
    }
}


Measured memory_bytes: 26984
#include <stdio.h>
       
int main(void){
 int a,b,c;
 scanf("%d %d %d",&a,&b,&c);

int n;  
if(a>=b){
n=a;
a=b;
b=n;
}

int m;
if(a>=c){
n=a;
a=c;
c=n;
}

int l;
if(b>=c){
n=b;
b=c;
c=n;
}

printf("%d %d %d\n",a,b,c);

return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class extended_euclidean
{
public:
	value_type gcd;
	value_type lcm;
	value_type x0;
	value_type y0;

public:
	extended_euclidean(value_type a, value_type b)
		: gcd(0), lcm(0), x0(0), y0(0)
	{
		tie(gcd, x0, y0) = process(a, b);
		lcm = a * (b / gcd);
	}

public:
	tuple<value_type, value_type, value_type> process(value_type a, value_type b)
	{
		if (a == 0) return make_tuple(b, 0, 1);

		value_type g, x, y;
		tie(g, x, y) = process(b % a, a);

		return make_tuple(g, y - (b / a) * x, x);
	}
};

//extended_euclidean<long long> ee(a, b);
//long long gcd = ee.gcd;
//long long lcm = ee.lcm;

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

	int N;
	cin >> N;

	vector<unsigned long long> T(N, 0);

	for (int i = 0; i < N; i++)
	{
		cin >> T[i];
	}

	unsigned long long curr = T[0];

	for (int i = 1; i < N; i++)
	{
		extended_euclidean<long long> ee(curr, T[i]);
		curr = ee.lcm;
	}

	cout << curr;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(x,i,e) for(int x=i; x<e; x++)
#define int long long int
 
signed main()
{
	int n,d;
	cin>>n>>d;
	int x[n],y[n];
    int c=0;
	FOR(i,0,n)
	{
		cin>>x[i]>>y[i];
        if ((x[i]*x[i]+y[i]*y[i])<=(d*d)) c++;
	}
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 6644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
        {
            if(s[i]=='9') s[i]='1';
            else if(s[i]=='1') s[i]='9';


        }
     cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define zmrl(x) (int)((x).size())
#define ahen(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;

int Set[100100];

int Find(int x) {
    return Set[x] == x ? x : Set[x] = Find(Set[x]);
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,m; cin>>n>>m;
    for (int i=1; i<=n; i++) Set[i] = i;
    while (m--) {
        int a,b; cin>>a>>b;
        a = Find(a), b = Find(b);
        if (a != b) Set[a] = b;
    }
    vector<bool> flag(n+5, false);
    int cnt = 0;
    for (int i=1; i<=n; i++) {
        int a = Find(i);
        if (!flag[a]) {
            flag[a] = true;
            cnt++;
        }
    }
    cout << cnt-1 << '\n';
    return 0;
}

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

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

        vector<long> lrlr(s.size());
        long cnt = 0, idx = 0;
        char prev = 'R';
        for(long i=0; i<s.size(); i++){
                if(s[i]!=prev){
                        lrlr[idx] = cnt;
                        cnt = 1;
                        idx++;
                        prev = s[i];
                } else cnt++;
        }
        if(prev=='L') lrlr[idx] = cnt++;

        vector<long> ans(s.size());
        bool rNow = true;
        idx = 0;
        for(long i=0; i<lrlr.size(); i++){
                if(rNow){
                        idx += lrlr[i];
                        ans[idx-1] += (lrlr[i]+1)/2;
                        ans[idx] += lrlr[i]/2;
                        rNow = false;
                }else{
                        ans[idx-1] += lrlr[i]/2;
                        ans[idx] += (lrlr[i]+1)/2;
                        idx += lrlr[i];
                        rNow = true;
                }
        }

        for(long i=0; i<ans.size(); i++) cout << ans[i] << endl;

        return 0;
}

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

int main() {
	int bingo[3][3];
	for(int i = 0; i < 3; ++i) 
		for(int j = 0; j < 3; ++j) {
			cin >> bingo[i][j];
		}
	int n;
	cin >> n;
	while(n--) {
		int tmp;
		cin >> tmp;
		for(int i = 0; i < 3; ++i) 
			for(int j = 0; j < 3; ++j)
				if(bingo[i][j] == tmp)
					bingo[i][j] = 0;
			
	}
	bool win = false;
	//if(bingo[0][0] + bingo[0][1] + bingo[0][2] == 0) win = true;
	//if(bingo[1][0] + bingo[1][1] + bingo[1][2] == 0) win = true;
	//if(bingo[2][0] + bingo[2][1] + bingo[2][2] == 0) win = true;
	//if(bingo[0][0] + bingo[1][0] + bingo[2][0] == 0) win = true;
	//if(bingo[0][1] + bingo[1][1] + bingo[2][1] == 0) win = true;
	//if(bingo[0][2] + bingo[1][2] + bingo[2][2] == 0) win = true;
	//if(bingo[0][0] + bingo[1][1] + bingo[2][2] == 0) win = true;
	//if(bingo[0][0] + bingo[1][0] + bingo[2][0] == 0) win = true;
	for(int i = 0; i < 3; ++i) {
		int sumR = 0, sumC = 0, sumD = 0, sumDI = 0;
		for(int j = 0; j < 3; ++j) {
			sumR += bingo[i][j];
			sumC += bingo[j][i];
			sumD += bingo[j][j];
			sumDI += bingo[j][2-j];
		}
		if(sumR == 0 || sumC == 0 || sumD == 0 || sumDI == 0) {
			win = true;
			break;
		} 
	}
	
	cout << ((win)?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	s[5] = ' ';
	s[13] = ' ';

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=201234;

int n,nw,nw2,nx=1,nx2=1;
ll k,res,a[2][51][51],b[2][51][51];

void ksm(ll k)
{
    ll c;
    while(k)
    {
        if(k&1)
        {
            for(int i=1; i<=n; ++i)
            {
                for(int j=1; j<=n; ++j)
                {
                    c=0;
                    for(int k=1; k<=n; ++k)
                    {
                        c=(c+b[nw2][i][k]*a[nx][k][j]%MOD)%MOD;
                    }
                    b[nx2][i][j]=c;
                }
            }
            swap(nw2,nx2);
        }
        k>>=1;
        swap(nw,nx);
        for(int i=1; i<=n; ++i)
        {
            for(int j=1; j<=n; ++j)
            {
                c=0;
                for(int k=1; k<=n; ++k)
                {
                    c=(c+a[nw][i][k]*a[nw][k][j]%MOD)%MOD;
                }
                a[nx][i][j]=c;
            }
        }
    }
}

int main()
{
    scanf("%d %lld",&n,&k);
    for(int i=1; i<=n; ++i)
    {
        for(int j=1; j<=n; ++j)
        {
            scanf("%lld",&a[nx][i][j]);
        }
        b[nw2][i][i]=1;
    }
    ksm(k);
    for(int i=1; i<=n; ++i)
    {
        for(int j=1; j<=n; ++j)
        {
            res=(res+b[nw2][i][j])%MOD;
        }
    }
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define MAX (int)2e5

int main(){
  int n,a[MAX],i,j,xor;
  long long sum;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  
  sum=0;xor=0;j=0;
  for(i=0;i<n;i++){
    for(;j<n;j++){
      if((xor&a[j]) != 0)break;
      xor |= a[j];
    }
    sum += j-i;
    xor ^= a[i];
  }
  
  printf("%lld\n",sum);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A(N);
    for (auto& a : A) {
        std::cin >> a;
    }

    int64_t count = 0;
    for (int64_t i = 0; i < N; i += 2) {
        if (A.at(i)%2 == 1) count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3628
# D
A, B = map(int, input().split())
res_list = [["."]*100 for _ in range(20)] + [["#"]*100 for _ in range(20)]
A -= 1
B -= 1
for i in range(0, 20, 2):
    for j in range(0, 100, 2):
        if B > 0:
            res_list[i][j] = "#"
            B -= 1
for i in range(21, 40, 2):
    for j in range(0, 100, 2):
        if A > 0:
            res_list[i][j] = "."
            A -= 1
print("40 100")
for res in res_list:
    print("".join(res))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MAXN 114514

unsigned long long N;
unsigned long long p[MAXN][3];
unsigned long long dp[MAXN][3];

int main() {
	ios::sync_with_stdio(false);
	memset(p, 0, sizeof(p));
	memset(dp, 0, sizeof(dp));
	cin >> N;
	for(unsigned long long i=0; i<N; i++) {
		for(unsigned long long j=0; j<3; j++) {
			cin >> p[i][j];
		}
	}
	memcpy(dp, p, sizeof(p[0]));
	for(unsigned long long i=1; i<N; i++) {
		for(unsigned long long j=0; j<3; j++) {
			for(unsigned long long k=0; k<3; k++) {
				if(k==j) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k]+p[i][j]);
			}
		}
	}
	unsigned long long ans = 0;
	for(unsigned long long j=0; j<3; j++) {
		ans = max(dp[N-1][j], ans);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 5632
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int n;
	int left, right;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> left;
		right=0;
		int temp;
		bool flag = 1;
		//while(cin >> temp){
		for(int j=1;j<10;j++){
			cin >> temp;
			if(left<right){
				if(right<temp){
					right=temp;
				}else if(left<temp){
					left=temp;
				}else{
					flag=false;
				}
			}else{
				if(left<temp){
					left=temp;
				}else if(right<temp){
					right=temp;
				}else{
					flag=false;
				}
			}
		}
		if(flag){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i,j,l,n,m,k[100],a[100][100],count=0,min=100,mini=100,ans=0;
  	cin>>n>>m;
  	
  	for(i=0;i<n;i++){
		cin>>k[i];
      	if(k[i]<min){
			min=k[i];
          	mini=i;
        }
      for(j=0;j<k[i];j++){
		cin>>a[i][j];
      }
    }

  	for(i=0;i<min;i++){
		for(j=0;j<n;j++){
          	for(l=0;l<k[j];l++){
				if(a[j][l]==a[mini][i]){
					count++;
                }
            }
        }
       if(count==n){
         ans++;
       }
      count=0;
    }
  	
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;
const long long INF = 1000000000000000000;

vector<bool> lis(1000, true);

struct Edge {
    int to;
    long long cost;
};

// trueで閉路
bool bellman_ford(vector<vector<Edge>> &edges, vector<long long> &mini, int src) {
    int n = edges.size();
    mini[src] = 0;
    FOR(i, 0, n) {
        FOR(node, 0, n) {
            for (auto edge : edges[node]) {
                if (mini[node] != INF && mini[node] + edge.cost < mini[edge.to]) {
                    if (i == n - 1) {
                        if (lis[edge.to])
                            return true;
                    }
                    else
                        mini[edge.to] = mini[node] + edge.cost;
                }
            }
        }
    }
    return false;
}


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<Edge>> edges(n);
    vector<vector<Edge>> invedges(n);
    FOR(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        c *= -1;
        edges[a].push_back({ b, c });
        invedges[b].push_back({ a, c });
    }
    vector<long long> mini(n, INF);
    vector<long long> perap(n, INF);
    bool ret = bellman_ford(invedges, perap, n - 1);
    FOR(i, 0, n) {
        if (perap[i] == INF)
            lis[i] = false;
    }
    bool ret1 = bellman_ford(edges, mini, 0);
    if (ret1)
        cout << "inf" << endl;
    else {
        cout << mini[n - 1] * -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a[4],b[4];
    while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
        int h = 0,bs = 0;
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 4; j++){
                if(a[i] == b[j]){
                    if(i == j){
                        h++;
                    }
                    else{
                        bs++;
                    }
                }
            }
        }
    cout << h << " " << bs << endl;
    }
}


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

int a[100010];

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

    int n,k;cin>>n>>k;

    int pos1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==1)pos1=i;
    }

    int ans=0;
    ans+=pos1?(pos1-1)/(k-1)+1:0;
    pos1=max(n-ans*(k-1)-1,0);

    ans+=pos1?(pos1-1)/(k-1)+1:0;

    cout<<ans<<"\n";

    return 0;
}


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

#include<unordered_map>

#include<unordered_set>

#pragma warning(disable:4996)

using namespace std;

using ld = long double;

const ld eps = 1e-9;



//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"





int main() {

	int H,W;cin>>H>>W;

	int h,w;cin>>h>>w;

	bool flag=true;

	if(!(W%w)){

		flag=false;

		swap(H,W);

		swap(h,w);

	}else{



	}

	if(!(W%w)){

		cout<<"No"<<endl;

	}else{

		vector<vector<int> >ans(H,vector<int>(W));

		for(int y=0;y<H;++y){

			for(int x=0;x<W;++x){

				if(x%w==w-1){

					ans[y][x]=-20000*(w-1)-1;

				}else{

					ans[y][x]=20000;

				}

			}

		}

		cout<<"Yes"<<endl;

		if(flag){

			for(int y=0;y<H;++y){

				for(int x=0;x<W;++x){

					cout<<ans[y][x];

					if(x==W-1)cout<<endl;

					else cout<<" ";

				}

			}

		}else{

			for(int x=0;x<W;++x){

				for(int y=0;y<H;++y){

					cout<<ans[y][x];

					if(y==H-1)cout<<endl;

					else cout<<" ";

				}

			}

		}

	}

	return 0;

}

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

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

	int N;
	cin >> N;

	vector<string> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());

	for (int i = 0; i < N; i++) {
		// cout << s[i] << '\n';
	}

	long long ret = 0;
	long long streak = 1;
	for (int i = 1; i < N; i++) {
		if (s[i] == s[i - 1]) {
			streak++;
		} else {
			ret += streak * (streak - 1) / 2;
			streak = 1;
		}
	}
	ret += streak * (streak - 1) / 2;
	cout << ret;
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  double l;
  cin >> l;

  l /= 3.0;
  printf("%.16f\n", l* l * l);


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    char s[200000];
    int b, e;
    cin >> s;
    for (int x=0; x < strlen(s); x++) {
        if (s[x] == 'A') {
            b = x;
            break;
        }
    }
    for (int y=0; y <= strlen(s); y++) {
        if (s[y] == 'Z') {
            e = y;
        }
    }
    cout << e - b + 1 << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n;cin>>n;vll p(n+1);ll i;for(i=1;i<n+1;i++){cin>>p[i];}
  //caricurate
  i=1;ll ans=0;ll cnt;
  while(i<n+1){//1-1 2-1 3-2 4-2 5-3 6-3
    cnt=0;
    if(p[i]==i){
      while((p[i]==i)&&(i<n+1)){cnt++;i++;}
    ans+=(cnt+1)/2;
    }else{i++;}
  }
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}




int main() {
   int h,w,k;
   cin >> h >> w >> k;
   vector<string> a(h);
   int ans=0;
   rep(i,h) cin >> a[i];
   for (int bit = 0; bit < (1<<h); ++bit) {
        vector<string> s=a;
        for (int i = 0; i < h; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                rep(j,w) s[i][j]='.';
            }
        }
        for (int bits = 0; bits < (1<<w); ++bits) {
        vector<string> b=s;
        for (int i = 0; i < w; ++i) {
            if (bits & (1<<i)) { // 列挙に i が含まれるか
                rep(j,h) b[j][i]='.';
            }
        }
        int c=0;
        rep(i,h) {
          rep(j,w) {
            if(b[i][j]=='#') c++;
          }
        }
         if(c==k) ans++;
        
        }
    }
    pt(ans);

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

using Graph = vector<vector<int>>;

int N, A, B, C;
int W[10];
int ans;
int dfs(int n, int a, int b, int c){
  if(n == N){
    if(a == 0 || b == 0 || c == 0) return INF;
    return abs(A-a) + abs(B-b) + abs(C-c);
  }
  int ans = dfs(n+1, a, b, c);
  ans = min(ans, dfs(n+1, a+W[n], b, c) + 10);
  ans = min(ans, dfs(n+1, a, b+W[n], c) + 10);
  ans = min(ans, dfs(n+1, a, b, c+W[n]) + 10);
  return ans;
}

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

  cin >> N >> A >> B >> C;
  rep(i,N) cin >> W[i];
  cout << dfs(0, 0, 0, 0) - 30 << endl;

}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n;cin>>n;
	vl a(n);
	ll cnt=0;
	rep(i,n){
		cin>>a[i];
		ll m=a[i];
		while(m%2==0){
			m/=2;
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        int forward = 0;
        int backward = 0;

        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == (48 + i % 2 )) {
                forward++;
            }
            if (S.charAt(i) != (48 + i % 2)) {
                backward++;
            }
        }

        System.out.println(Math.min(forward, backward));
    }
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

bool v[100005];
ll d[100005];
vector<P> G[100005];
bool ok = true;

void dfs(int tmp, int dis){
    for(auto i : G[tmp]){
        if(!v[i.first]){
            v[i.first] = true;
            d[i.first] = d[tmp] + i.second;
            dfs(i.first,d[tmp] + i.second);
        }else{
            if(d[i.first] != d[tmp] + i.second) ok = false;
        }
    }
}

int main()
{
    int n,m; cin >> n >> m;
    rep(i,m){
        int l,r,d; cin >> l >> r >> d;
        l--; r--;
        G[l].push_back(make_pair(r,d));
        G[r].push_back(make_pair(l,-d));
    }
    for(int i = 0; i < n; i++){
        if(!v[i]){
            d[i] = 0;
            v[i] = true;
            dfs(i,0);
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int64_t answer = A[0] - 1;
  int offset = 2;
  for (int i = 1; i < N; ++i) {
    // cout << i << ": " << answer << " offset=" << offset << endl;
    if (A[i] <= offset) {
      offset = max(offset, A[i] + 1);
      continue;
    }
    answer += (int64_t)((A[i] - 1) / offset);
  }
  cout << answer << endl;
  return 0;
}


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

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

using namespace std;

// data
int n;
const int MAX_N = 5e5;
int a[MAX_N];
int aux[MAX_N];
// int cmp_cnt = 0;

int merge_sort(int a[], int il, int ir);
int main(){
    cin >> n;
    rep(i, n) cin >> a[i];

    int cmp_cnt = merge_sort(a, 0, n);
    rep(i, n) cout << a[i] << (i<n-1?" ":"\n");
    cout << cmp_cnt << endl;
}

int merge(int *a, int l, int m, int r){
    int il = l, ir = m, cnt = 0;
    REP(i, l, r){

        if(il < m && a[il] < a[ir] || ir >= r) 
            aux[i] = a[il++];
        else
            aux[i] = a[ir++];
        
        cnt ++;
    }

    REP(i, l, r) a[i] = aux[i];
    return cnt;
}


int merge_sort(int a[], int il, int ir){
    if(ir - il<= 1) return 0;

    int mid = (il + ir) / 2;

    int cmp_cnt = 0;
    cmp_cnt += merge_sort(a, il, mid);
    cmp_cnt += merge_sort(a, mid, ir);
    cmp_cnt += merge(a, il, mid, ir);

    return cmp_cnt;
}



Measured memory_bytes: 6980
####################
####################
####################
####################
from heapq import*
i=input
for s in[0]*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>=r:x+=[[k,l,r]]
  else:y+=[[n-k,r,l]]
 for x in x,y:
  x.sort();h=[]
  for k,l,r in x:
   if k:s+=l;heappush(h,l-r)
   else:s+=r
   if len(h)>k:s-=heappop(h)
 print(s)

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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

    int h, w, n;
    cin >> h >> w >> n;

    vector<int> score(h + 1, (1 << 28));
    vector<int> bound(h + 1, -1);

    using P = pair<int, int>;
    map<P, int> recorder;
    vector<int> x(n), y(n);

    int ans = h;
    repeat (i, n) {
        cin >> x[i] >> y[i];
        if (y[i] == 1) {
            ans = min(ans, x[i] - 1);
        }
        recorder[{x[i], y[i]}] = i;
    }

    // simulate
    int cx = 1, cy = 1, turn = 0;
    while (cx <= h) {
        bound[cx] = max(bound[cx], cy);
        if (turn == 0) {
            if (recorder.count({cx + 1, cy})) {
                bound[cx + 1] = max(bound[cx + 1], cy);

                for (int nx = cx + 1; nx <= h; nx++) {
                    bound[nx] = max(bound[nx], cy);
                }
                break;
            } else if (cx + 1 > h) break;
            cx++;
        } else {
            if (recorder.count({cx, cy + 1}) or cy + 1 > w) {
                ;
            } else {
                cy++;
            }
        }
        turn ^= 1;
    }


    repeat (i, n) {
        if (1 <= x[i] - y[i] and x[i] - y[i] <= w and y[i] <= bound[x[i]]) {
            score[x[i] - y[i]] = min(score[x[i] - y[i]], x[i] - 1);
        }
    }

    for (int x = 1; x <= h; x++) {
        // cerr << x << ": " << bound[x] << " score " << score[x] << endl;
        ans = min(ans, score[x]);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int sub(int a, int b){
  if(a >= b)return a-b;
  return a - b + mod;
}
int power(int a, int b){
	int re = 1;
	while(b){
		if(b&1)re= mul(re, a);
		a = mul(a, a);
		b>>=1;
	}
	return re;
}
int const N = 100 *1001;

/********************i**********************************/
vector<int> vec[10];
void dfs(int a, int p){
  cout << a << " ";
  for(int b : vec[a]){
    if(b == p)continue;
    dfs(b, a);
  }
  cout << a << " ";
}
void solve(){
  ll a;
  cin >> a;
  ll b = __lg(a);
  ll ans = (1LL<<b) + (1LL<<b) - 1;
  cout << ans;
}
/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    int n,T; std::cin >> n>>T;
    int c;
    int ans=1001;
    rep(i,n){
        int t;std::cin >> c>>t;
        if(t<=T)ans=min(ans,c);
    }
    if(ans==1001)std::cout << "TLE" << std::endl;
    else std::cout << ans << std::endl;
    /*std::vector<pair> ct;
    rep(i,n){
        int c,t;std::cin >> c>>t;
        if(t<=T){
            ct.push_back(make_pair(c, t));
        }
    }
    */
    
}

Measured memory_bytes: 384
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let t : String = get_vec::<String>().iter().map(|s| s.to_uppercase().chars().nth(0).unwrap()).collect::<String>();

    println!("{}", t);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll h, w;
  cin >> h >> w;
  vector<string> pic(0);
  for (ll i = 0; i < h; i++) {
    string s;
    cin >> s;
    pic.push_back(s);
    pic.push_back(s);
  }
  for (ll i = 0; i < 2 * h; i++) cout << pic[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%lf",&n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%lf ",n)
#define dprin(n) printf("%lf\n",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

int main()
{
    int t;
    cin>>t;
    if(t>=30)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
return 0;
}

Measured memory_bytes: 3600
from bisect import bisect_left

n = int(input())
a = list( map(int, input().split()))

a.sort()
half = a[-1]/2

index = bisect_left(a,half)
candi1 = a[index]
if index > 0: candi0 = a[index-1]
else: candi0 = -1

if abs(half-candi0) > abs(half-candi1): ans = candi1
else: ans = candi0

print(a[-1], ans, sep=' ')


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

int main(){
    string s;
    cin>>s;
   
    string ans;
    for(int i=0; i<s.size();i+=2){
        ans += s[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 512
use std::io;
use std::cmp;

fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {

    let a = read_one::<isize>();
    let b = read_one::<isize>();
    let c = read_one::<isize>();
    let d = read_one::<isize>();

    println!("{}", cmp::min(a, b) + cmp::min(c, d));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){

    ll n,d;
    cin>>n>>d;

    ll answer=0;

    rep(i,n){
        ll x,y;
        cin>>x>>y;

        if (x*x+y*y<=d*d){
            answer++;
        }

        
    }

    cout<<answer<<endl;
    


}








            






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

int main() {
	int n,k,mx = 0,a[100010],b[100010];
	long long ans = 0,ret = 0;
	bool f = false;
	cin >> n >> k;
	for (int i = 0;i < n;++i) scanf("%d %d", &a[i], &b[i]);
	for (int i = 31;i >= 0;--i) {
		if (k & 1 << i) {
			mx = i+1;
			break;
		}
	}
	
	for (int i = 0;i < n;++i) {
		f = true;
		for (int j = 0;j < 31;++j) {
			if (a[i] & (1 << j) && !(k & (1 << j))) {
				f = false;
				break;
			}
		}
		if (f) ret += b[i];
	}
	
	ans = ret;
	for (int i = 0;i < mx;++i) {
		if (k & 1 << i) {
			ret = 0;
			k ^= 1 << i;
			for (int j = 0;j < n;++j) {
				f = true;
				for (int l = 0;l < 31;++l) {
					if (a[j] & 1 << l && !(k & (1 << l))) {
						f = false;
						break;
					}
				}
				if (f) ret += b[j];
			}
			k |= 1 << i;
			ans = max(ans,ret);
		}
		else k |= 1 << i;
	}
		
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int n;
	cin>>n;
	string arr[n];
	set<string>s;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		s.insert(arr[i]);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;int n=s.size(),w=0;
  for(int i=0;i<n;i++){if(s.at(i)=='o')w++;}
  if(w+15-n<8)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define f(i, n) for (int i = 0; i < n; ++i)

using namespace std;
void solve() {
    string s, t;
    cin >> s >> t;
    if (s.size() != t.size()) {
        cout << "No" << nl;
        return;
    }
    vector<int> one(26, 0);
    vector<int> two(26, 0);
    vector<int> three(26, 0);
    for (char e : s) {
        one[e - 'a']++;
        three[e - 'a']++;
    }
    for (char e : t) {
        two[e - 'a']++;
    }
    sort(one.begin(), one.end());
    sort(two.begin(), two.end());
    bool okay = true;
    for (int i = 0; i < 26; ++i) {
        if (one[i] != two[i]) {
            okay = false;
            break;
        }
    }

    cout << (okay ? "Yes" : "No") << nl;
}

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

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}
*/

#define	MOD 1000000007

int	main() {
	char C;
	cin >>C;
	int c=C-'a';
	c++;
	cout <<char(c+'a') <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, answer = 0;
	cin >> N;
	vector<string> S(N);
	for (int count = 0; count < N; count++)
	{
		cin >> S.at(count);
	}
	sort(S.begin(), S.end());
	int index = 0;
	while (index < N)
	{
		if (index < N - 1 && S.at(index) != S.at(index + 1))
		{
			answer++;
			index++;
		}
		else if (index == N - 1)
		{
			answer++;
			index++;
		}
		else
		{
			int diff = 2;
			while (index + diff < N && S.at(index) == S.at(index + diff))
			{
				diff++;
			}
			answer++;
			index += diff;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 9548
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    int count = 0;
    for(int i =1;i<=n;i++)
    {
        cin>>arr[i];
    }
    if(n%2==0)
    {
        for(int i = 1;i<n;i+=2)
        {
            if(arr[i]%2)
            {
                count++;
            }
        }
    }
    else
    {
        for(int i = 1;i<=n;i+=2)
        {
            if(arr[i]%2)
            {
                count++;
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	map<int,int> mp;
	int a;
	while(cin >> a){
		mp[a]++;
	}
	int ma=0;
	for(auto p:mp){
		ma=max(p.second,ma);
	}
	for(auto p:mp){
		if(ma==p.second){
			cout << p.first << endl;
		}
	}
}


Measured memory_bytes: 3088
s = input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            a = int(s[0])
            if i == 0:
                a += int(s[1])
            else:
                a -= int(s[1])
            if j == 0:
                a += int(s[2])
            else:
                a -= int(s[2])
            if k == 0:
                a += int(s[3])
            else:
                a -= int(s[3])
            if a == 7:
                print("{0}{4}{1}{5}{2}{6}{3}=7".format(s[0],s[1],s[2],s[3],"-" if i else "+","-" if j else "+","-" if k else "+"))
                exit()


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

int main(){
    double t;
    int n,h;
    vector<int> f(6,0);
    cin>>n;
    for(;n--;){
        cin>>t;
        if(t<165.0) h = 0;
        else h = ((int)t-160)/5;
        if(h>5)h=5;
        f[h]++;
    }
    for(n=0;n<6;n++){
        cout<<n+1<<":";
        while(f[n]--) cout<<"*";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <atcoder/all>

// g++-10 b.cpp -std=c++17 -I .

using ll = long long int;
using P = std::pair<int, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,m,dist[55][55];
std::string s[55];
std::queue<P> que;

bool check(int i, int j){
	return (0<=i && i<n && 0<=j && j<m && (s[i][j]!='#'));
}

int main(void){
	int i,j,x,y;
	ll w = 0ll;
	std::cin >> n >> m;
	atcoder::mcf_graph<ll, ll> g(n*m+2);
	for(i=0; i<n; ++i){
		std::cin >> s[i];
		for(j=0; j<m; ++j){
			if(s[i][j]=='o'){
				++w;
				g.add_edge(n*m,i*m+j,1ll,0ll);
				g.add_edge(i*m+j,n*m+1,1ll,n+m);
			}else if(s[i][j]=='.'){
				g.add_edge(i*m+j,n*m+1,1ll,0ll);
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<m; ++j){
			if(s[i][j]!='o'){
				continue;
			}
			std::fill(dist[0],dist[55],INF);
			dist[i][j] = 0;
			que.push(P(i,j));
			while(!que.empty()){
				x = que.front().first;
				y = que.front().second;
				if(dist[x][y]){
					g.add_edge(i*m+j,x*m+y,1ll,n+m-dist[x][y]);
				}
				que.pop();
				if(check(x+1,y) && dist[x+1][y] > dist[x][y]+1){
					dist[x+1][y] = dist[x][y]+1;
					que.push(P(x+1,y));
				}
				if(check(x,y+1) && dist[x][y+1] > dist[x][y]+1){
					dist[x][y+1] = dist[x][y]+1;
					que.push(P(x,y+1));
				}
			}
		}
	}
	auto ans = g.flow(n*m,n*m+1,w);
	std::cout << (w*(n+m)-ans.second) << std::endl;
	return 0;
}


Measured memory_bytes: 8844
module DLinkedList = struct
  type 'a element =
    { value : 'a;
      mutable next : int;
      mutable prev : int
    }
  type 'a t = {
    mutable first : int;
    mutable last  : int;
    mutable index : int;
    elts : 'a element array
  }

  let create n = {first = -1; last = -1; index = 0;
                  elts = Array.make n {value=0;next=0;prev=0}}
                 
  let insert_first t value =
    let new_elt = {prev = -1; next = t.first; value} in
    let i = t.index in
    begin match t.first with
      | -1 -> ()
      |  old_first -> t.elts.(old_first).prev <- i
    end;
    t.first <- i; t.elts.(i) <- new_elt; t.index <- i + 1;
    begin match t.last with
      | -1 -> t.last <- t.first
      | _ -> ()
    end

  let remove t elt =
    let {prev; next; _} = elt in
    begin match prev with
      | -1 -> t.first <- next
      | pi -> t.elts.(pi).next <- next
    end;
    begin match next with
      | -1 -> t.last <- prev
      | ni -> t.elts.(ni).prev <- prev
    end
      
  let find t v =
    let rec loop = function
      | -1 -> ()
      |  i ->
        let elt = t.elts.(i) in
        if v = elt.value then remove t elt
        else loop elt.next
    in
    loop t.first

  let remove_first t =
    begin match t.first with
      | -1 -> ()
      |  i ->
        let first = t.elts.(i) in
        begin match first.next with
          | -1 -> t.first <- -1; t.last <- -1
          | j -> t.elts.(j).prev <- -1; t.first <- j
        end
    end

  let remove_last t =
    begin match t.last with
      | -1 -> ()
      | i ->
        let last = t.elts.(i) in
        begin match last.prev with
          | -1 -> t.first <- -1; t.last <- -1
          |  j -> t.elts.(j).next <- -1; t.last <- j
        end
    end

  let print t =
    let rec loop e = match e.next with
      | -1 -> Printf.printf "%d\n" e.value
      |  i -> Printf.printf "%d " e.value; loop t.elts.(i)
    in
    loop t.elts.(t.first)
end

let () =
  let open DLinkedList in
  let (n: int) = read_int () in
  let (dll: int t) = create n in
  for i=1 to n do
    begin match read_line () with
      | "deleteFirst" -> remove_first dll
      | "deleteLast" -> remove_last dll
      | s ->
        begin match String.sub s 0 6,
                    (String.sub s 7 (String.length s - 7)
                    |> int_of_string) with
        | "insert", n -> insert_first dll n
        | "delete", n -> find dll n
        | _ -> ()
        end
    end
  done;
  print dll

Measured memory_bytes: 59152
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n,t;
  cin >> n >> t;
  
  vector<vector<int>>cost_time(n,vector<int>(2));
  
  for(int i=0;i<n;i++){
    cin >> cost_time[i][0];
    cin >> cost_time[i][1];
  }
 
  int ans = 9999;
  
  for(int i=0;i<n;i++){
    if(cost_time[i][1] <= t){
      if(ans > cost_time[i][0])
        ans = cost_time[i][0];
    }
  }
  
  if(ans == 9999)
    cout << "TLE" << endl;
  else
  	cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int n,m,root[100010],lc[20000010],rc[20000010],now,sum[20000010];
vector <int> V[100010];

void pushup(int o)
{
    sum[o] = sum[lc[o]] + sum[rc[o]];
}

void insert(int o1,int &o2,int l,int r,int pos)
{
    if (!o2 || o1 == o2)
        o2 = ++now;
    lc[o2] = lc[o1];
    rc[o2] = rc[o1];
    sum[o2] = sum[o1];
    if (l == r)
    {
        sum[o2]++;
        return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid)
        insert(lc[o1],lc[o2],l,mid,pos);
    else
        insert(rc[o1],rc[o2],mid + 1,r,pos);
    pushup(o2);
}

int query(int o,int l,int r,int x,int y)
{
    if (!o)
        return 0;
    if (x > y)
        return 0;
    if (x <= l && r <= y)
        return sum[o];
    int mid = (l + r) >> 1,res = 0;
    if (x <= mid)
        res += query(lc[o],l,mid,x,y);
    if (y > mid)
        res += query(rc[o],mid + 1,r,x,y);
    return res;
}

int main()
{
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= n; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        V[y].push_back(x);
    }
    for (int i = 1; i <= m; i++)
    {
        root[i] = root[i - 1];
        for (int j = 0; j < V[i].size(); j++)
            insert(root[i],root[i],1,m,V[i][j]);
    }
    for (int i = 1; i <= m; i++)
    {
        int temp = 0,ans = 0;
        for (int j = i; j <= m; j += i)
        {
            ans += query(root[j - 1],1,m,temp + 1,j - 1);
            temp = j;
        }
        ans += query(root[m],1,m,temp + 1,m);
        printf("%d\n",n - ans);
    }

    return 0;
}


Measured memory_bytes: 74112
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		int W = Integer.parseInt(str[0]);
		int H = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);
		int y = Integer.parseInt(str[3]);
		int r = Integer.parseInt(str[4]);
		if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }

  else if(A+B > C+D){
    cout << "Left" << endl;
  }
  
  else{
    cout << "Right" << endl;
  }
  
}


Measured memory_bytes: 256
from sys import stdin

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

if A <= K:
    K_ = K-A
    A = 0
    if B <= K_:
        print("0 0")
    else:
        print("0 {}".format(B-K_))

else:
    print("{} {}".format(A-K, B))


Measured memory_bytes: 2940
//問題URL
    //

    //解き方メモ
    //
    
    #include<iostream>
    using namespace std;

    int main(){
        int n,k;
        int result;

        //R,G入力
        cin >> n >> k;

        //N回計算
        result = 1;
        for(int i=0;i<n;i++){
            //２倍とK加算の小さい方を判定
            if(result > k)
                result += k;
            else
                result *= 2;
        }

        //出力
        cout << result << endl;

        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int
main ()
{
  string str;
  string table[2] =
    { "abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
  getline (cin, str);
for (auto & e:str)
    {
      int buf =
	find (table[0].begin (), table[0].end (), e) - table[0].begin ();
      if (buf != table[0].size ())
	e = table[1][buf];
    }
  cout << str << endl;
}

Measured memory_bytes: 1188
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	print(eval(S()))


if __name__ == '__main__':
    main()

Measured memory_bytes: 27096