akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct Card { char suit, value; };

void bubble(Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N-1; j > i; j--) {
            if (A[j].value < A[j-1].value) {
                swap(A[j], A[j-1]);
            }
        }
    }
}

void selection(Card A[], int N) {
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;
        }
        swap(A[i], A[minj]);
    }
}

void printCard(Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i == N-1) cout << A[i].suit << A[i].value << endl;
        else cout << A[i].suit << A[i].value << " ";
    }
}

// Stableなバブルソートを基準に選択ソートが安定かを判定
bool isStable(Card C1[], Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main() {
    int N;
    Card C1[100], C2[100];
    char ch;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i = 0; i < N; i++) C2[i] = C1[i]; // C1 を C2にコピー

    bubble(C1, N);
    selection(C2, N);

    printCard(C1, N);
    cout << "Stable" << endl;

    printCard(C2, N);
    if (isStable(C1, C2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
    return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	cout << a + a * a + a * a * a << endl;

	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
int main()
{
	ll n,a,b,c,d;
	RD(n,a,b,c,d);
	--n;
	b = abs(b-a);
	for (ll p = 0; p <= n; ++p)
		if (p*(c+d)-d*n <= b && b <= p*(c+d)-c*n) {
			PL("YES");
			return 0;
		}
	PL("NO");
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

struct UnionFind {
	vector<size_t> parent;
	vector<size_t> rank;
	size_t find_parent(size_t x) {
		if (parent[x] == x) {
			return x;
		} else {
			parent[x] = find_parent(parent[x]);
			return parent[x];
		}
	}
	explicit UnionFind(size_t size) {
		parent.resize(size);
		rank.resize(size);
		for (size_t i = 0; i < size; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	virtual ~UnionFind() {}
	void unite(size_t x, size_t y) {
		size_t px = find_parent(x);
		size_t py = find_parent(y);
		if (px == py) {
			return;
		}
		if (rank[px] < rank[py]) {
			parent[px] = py;
		} else if (rank[px] > rank[py]) {
			parent[py] = px;
		} else {	// rank[px] == rank[py]
			parent[py] = px;
			rank[px]++;
		}
	}
	bool is_same(size_t x, size_t y) {
		return find_parent(x) == find_parent(y);
	}
	unordered_map<size_t, set<size_t>> create_map_parent_to_elements() {
		unordered_map<size_t, set<size_t>> ans;
		for (size_t i = 0; i < parent.size(); i++) {
			ans[find_parent(i)].insert(i);
		}
		return ans;
	}
};

int main() {
     int N, M;
     cin >> N >> M;
     UnionFind uf(N + M);
     for (int i = 0; i < N; i++) {
     	int Ki;
     	cin >> Ki;
     	for (int j = 0; j < Ki; j++) {
     		 int Lj;
     		 cin >> Lj;
     		 Lj--;
     		 uf.unite(i, N + Lj);
     	}
     }
     for (int i = 0; i < N; i++) {
     	if (!uf.is_same(0, i)) {
     		cout << "NO" << endl;
     		return 0;
     	}
     }
     cout << "YES" << endl;
}  


Measured memory_bytes: 3328
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String a=s.next();
		String x=s.next();
		String c=s.next();
		
		System.out.print("A"+x.charAt(0)+"C");

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a;
  cin >> n >> a;
  long long i,j;
  int x[51];
  for(i=0;i<n;i++){
    cin >> x[i];
    x[i]-=a;
  }
  long long dp[51][5001];
  for(i=0;i<n;i++){
    for(j=0;j<5001;j++){
      dp[i][j]=0;
    }
  }
  dp[0][2500]+=1;
  dp[0][2500+x[0]]+=1;
  for(i=0;i<n-1;i++){
    for(j=0;j<5001;j++){
      dp[i+1][j]+=dp[i][j];
      if(j>=x[i+1]){
        dp[i+1][j]+=dp[i][j-x[i+1]];
      }
    }
  }
  cout << dp[n-1][2500]-1 << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
#define re register
#define gc get_char
#define cs const

namespace IO{
	inline char get_char(){
		static cs int Rlen=1<<22|1;
		static char buf[Rlen],*p1,*p2;
		return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,Rlen,stdin),p1==p2)?EOF:*p1++;
	}
	
	template<typename T>
	inline T get(){
		char c;T num;bool f=false;
		while(!isdigit(c=gc()))f=c=='-';num=c^48;
		while(isdigit(c=gc()))num=(num+(num<<2)<<1)+(c^48);
		return f?-num:num;
	}
	inline int gi(){return get<int>();}
}
using namespace IO;

using std::cerr;
using std::cout;

cs int N=1e5+7;

int n;

int col[N],fa[N],rk[N];
inline int gf(int u){
	if(u==fa[u])return u;
	int tp=gf(fa[u]);
	col[u]^=col[fa[u]];
	return fa[u]=tp;
}
inline void mg(int u,int v){
	int fu=gf(u),fv=gf(v);
	if(fu==fv)return ;
	if(rk[fu]<rk[fv])std::swap(fu,fv);
	else if(rk[fu]==rk[fv])++rk[fu];
	col[fv]=col[u]^col[v]^1;
	fa[fv]=fu;
}

struct Tree{
	int last[N],nxt[N],to[N],ecnt;
	int son[N],rt;
	inline void adde(int u,int v){
		++son[u];
		nxt[++ecnt]=last[u],last[u]=ecnt,to[ecnt]=v;
	}
	inline void init(int n){
		for(int re i=1;i<=n;++i){
			int fa=gi();
			if(fa==-1)rt=i;
			else adde(fa,i);
		}
	}
	int dfs(int u){
		std::vector<int> nd;
		if(!(son[u]&1))nd.push_back(u);
		for(int re e=last[u],v=to[e];e;v=to[e=nxt[e]])nd.push_back(dfs(v));
		for(int re i=1;i<nd.size();i+=2)mg(nd[i],nd[i+1]);
		return nd[0];
	}
}t1,t2;

signed main(){
#ifdef zxyoi
	freopen("two_trees.in","r",stdin);
#endif
	n=gi();t1.init(n);t2.init(n);
	for(int re i=1;i<=n;++i)if((t1.son[i]^t2.son[i])&1)puts("IMPOSSIBLE"),exit(0);
	for(int re i=1;i<=n;++i)fa[i]=i;
	t1.dfs(t1.rt);t2.dfs(t2.rt);
	puts("POSSIBLE");
	for(int re i=1;i<=n;++i)
	if(!(t1.son[i]&1))printf("%s ",(gf(i),col[i]?"1":"-1"));
	else printf("0 ");
	return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int N, K; cin >> N >> K;
    int ans = 0;
    rep(i, N) {
        int x; cin >> x;
        ans += min(2 * x, 2 * (K - x));
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    map<string, int> cnt;
    for(int i=0; i<n; i++){
        string s; cin>>s;
        cnt[s]++;
    }

    int ma = 0;
    for(auto i : cnt){
        chmax(ma, i.second);
    }

    for(auto i : cnt){
        if(ma == i.second) cout << i.first << endl;
    }

    return 0;
}

Measured memory_bytes: 23808
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int xa = X*2;
		if(X%Y == 0) {
			System.out.println(-1);
			return;
		}

		while(xa%Y == 0 && xa < Math.pow(10, 18)) {
			xa += X;
		}

		if(xa > Math.pow(10, 18)) {
			System.out.println(-1);
		}else {
			System.out.println(xa);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int prime(int n)
{
	if(n < 2){
		return 0;
	} else if(n == 2){
		return 1;
	}
	
	if(n % 2 == 0){
		return 0;
	}
	
	for(int i = 3; i*i <= n; i+= 2){
		if(n % i == 0){
			return 0;
		}
	}
	
	return 1;
}

int main(int argc, char **argv)
{
	int n, p, q;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		
		for(int i = n; i > 2; i--){
			if(prime(i) == 1){
				p = i;
				break;
			}
		}
		
		for(int i = p-1; i > 2; i--){
			if(prime(i) == 1){
				if((p-i) == 2){
					q = i;
					break;
				}
				p = i;
			}
		}
		
		cout << q << " " << p << endl;
	}
	
	return 0;
}

Measured memory_bytes: 868
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
 
int main()
{
    int i,j,N,v[100],ans;
    long long w[100],W,dp[101][10001];
     
    cin >> N >> W;
     
    for(i=0;i<=N-1;i++) cin >> v[i] >> w[i];
     
    for(i=0;i<=100*N;i++) dp[0][i]=1000000001;
    dp[0][0]=0;
    for(i=1;i<=N;i++)
    {
        for(j=0;j<=N*100;j++)
        {
            if(j-v[i-1]>=0) dp[i][j]=min(dp[i-1][j], dp[i-1][j-v[i-1]]+w[i-1]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    for(i=0;i<=N*100;i++)
    {
        if(dp[N][i]<=W) ans=i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10980
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main(){
	ios::sync_with_stdio(false);
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	for(int i = 0; i < H; i += 1){
		for(int j = 0; j < W; j += 1)
			if(j < 2 * A and i < 2 * B) cout << ((i + j) & 1);
			else if(i < B or j < A) cout << 1;
			else cout << 0;
		cout << "\n";
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
const int inf=0x3f3f3f3f;
int n,m;
char s[max_n];
int dp[max_n];
int Q[max_n],head,tail;
int path[max_n];
int main(){
    scanf("%d%d %s",&n,&m,s);
    dp[n]=0;
    head=1,tail=1;
    Q[head]=n;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='1')dp[i]=inf;
        else{
            int j=Q[head];

            //cout<<i<<' '<<j<<endl;
            if(dp[j]==inf)dp[i]=inf;
            else{
                dp[i]=dp[j]+1;
                path[i]=j;
            }
        }
        while(tail>=head&&dp[Q[tail]]>=dp[i])tail--;
        Q[++tail]=i;
        while(tail>=head&&Q[head]-i+1>m)head++;
    }
    if(dp[0]==inf)printf("-1\n");
    else{
        int x=0;
        vector<int> way;
        while(x!=n){
            int nx=path[x];
            way.push_back(nx-x);
            x=nx;
        }
        //printf("%d\n",way.size());
        for(int i=0;i<way.size();i++)printf("%d%c",way[i],i+1==way.size()?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 2172
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        Scanner sc = new Scanner(System.in);

        // long N = sc.nextLong();
        // long K = sc.nextLong();

        String S = sc.next();

        boolean niceTap = true;
        for (int i = 0; i < S.length(); i++) {
            char tap = S.charAt(i);
            if (i % 2 == 1) {
                if (tap == 'R') niceTap = false;
            } else {
                if (tap == 'L') niceTap = false;
            }
        }

        System.out.println(niceTap ? "Yes" : "No");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
	int M = pow(10,9)+7;
	long long  n,p = 1;
	cin>>n;
	for(int i = 1 ; i <= n ; i ++){
		p = (p * i) % M;
	}
	cout<<p<<endl;

}

Measured memory_bytes: 256
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int n,m;
	read(n);read(m);
	if (n>9||m>9) return puts("-1"),0;
	cout<<n*m;
	return 0;
}









Measured memory_bytes: 2304
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  int a,b= 0;
  
  scanf("%d %d",&a,&b);
  
  if(a < b)
  {
    for(int i = 0;i < b;i++)
    {
      printf("%d",a);
    }
  }
  else
  {
        for(int i = 0;i < a;i++)
    {
      printf("%d",b);
    }
  }
  return 0;
}


Measured memory_bytes: 128
using System;

namespace UOA_PCKWU_1041
{
    class Program
    {
        static void Main(string[] args)
        {
            string total;
            while( (total = Console.ReadLine()) != "0")
            {
                int count = Convert.ToInt32(total) / 4;
                int sum = 0;
                for(var i = 0; i < count; i++)
                {
                    sum += Convert.ToInt32(Console.ReadLine());
                }
                Console.WriteLine(sum);
            }
        }
    }
}



Measured memory_bytes: 15980
import itertools

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

comb = list(itertools.combinations_with_replacement(range(1, M + 1), N))

ma = 0
for c in comb:
    score = 0
    for a in A:
        if (c[a[1] - 1] - c[a[0] - 1] == a[2]):
            score += a[3]
    ma = max(ma, score)
print(ma)


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

int main() { 
    char x, y;
    cin >> x >> y;
    
    if (x > y) {
        cout << ">" << endl;
    } else if (x < y) {
        cout << "<" << endl;
    } else {
        cout << "=" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int judge1(int[]);
void judge2(int[]);
void set(int[], int);
void print(int[]);

int n, Q[8][2];

int main(){
  int i, queen[8];

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d",&Q[i][0],&Q[i][1]);
  }
  
  set(queen, 0);
}

int judge1(int queen[8]){
  int i, j;
    
  for (i = 0; i < 7; i++) {
      for (j = i+1; j < 8; j++) {
	if (queen[i] == queen[j] || abs(queen[i] - queen[j]) == j - i) return 0;
      }
  }
  return 1;
}

void judge2(int queen[8]){
  int i, j, count = 0;  

  for (i = 0; i < 8; i++){
    for(j = 0; j < n; j++){
      if(i == Q[j][0] && queen[i] == Q[j][1])count++;
    }
  }
  if(count == n) print(queen);
}

void set(int queen[], int i){
  int j;
    
  if (i == 8) {
    if (judge1(queen)) judge2(queen);
    return;
  }
    
  for (j = 0; j < 8; j++) {
    queen[i] = j;
	set(queen, i+1);
  }
}

void print(int queen[8]){
  int i, j;
  
  for(i = 0; i < 8; i++){
    for(j = 0; j < 8; j++){
      if(j == queen[i]) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N;
vector<double> v;
const ll INF = 1e12;

int main()
{
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> v[i];
    }

    double result = 0;
    while (v.size() > 1)
    {
        sort(v.begin(), v.end());
        double mean = (v[0] + v[1]) / 2;
        v.erase(v.begin(), v.begin() + 2);
        v.push_back(mean);
    }

    cout << v[0] << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main{

    private static char[][] cmap;
    private static int[] dx = {0,1,0,-1,-1,-1,+1,+1};
    private static int[] dy = {1,0,-1,0,-1,+1,+1,-1};
    private static int n;

    private static int letsGo(int x,int y,int dir)
    {
	if(cmap[y][x] == '0')
	    return 0;

	int nx = x + dx[dir],ny = y + dy[dir];
	if(!(0<=nx && nx < n && 0<=ny && ny < n))
	    return 1;

	return letsGo(nx,ny,dir)+1;
    }

      public static void main(String args[])throws IOException
    {
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	
	while(true)
	    {
		n = Integer.parseInt(in.readLine());
		if(n == 0)
		    break;
		cmap = new char[n+1][n+1];
		for(int i=0;i<n;i++)
		    {
			String line = in.readLine();
			for(int j=0;j<line.length();j++)
			    {
				cmap[i][j] = line.charAt(j);
			    }
		    }

		int mex = 0;
		for(int i=0;i<n;i++)
		    {
			for(int j=0;j<n;j++)
			    {
				if(cmap[i][j] != '1')
				    continue;
				
				for(int k=0;k<8;k++)
				    {
					mex = Math.max(mex,letsGo(j,i,k));
				    }
			    }
		    }

		System.out.println(mex);

	    }
    }
    
}

Measured memory_bytes: 11000
import numpy as np
from numba import njit

@njit('i8(i8,i8,i8[:],i8[:],i8)', cache=True)
def main(N, K, plist, slist, max_score):
    for start in range(N):

        total_score_in_loop = 0
        score_loop = []
        now = start
        while True:
            now = plist[now]
            total_score_in_loop += slist[now]
            score_loop.append(slist[now])
            if now == start:
                break
        
        rem_score, loop_score = 0, 0
        for idx in range(1, len(score_loop)+1):
            rem_score += score_loop[idx-1]
            if total_score_in_loop > 0:
                loop_score = ((K - idx) // len(score_loop)) * total_score_in_loop
            max_score = max(max_score, rem_score + loop_score)
    return max_score


N, K = map(int, input().split())
plist = np.array([i-1 for i in map(int, input().split())], dtype='int64')
slist = np.array([i for i in map(int, input().split())], dtype='int64')
max_score = -10**15
max_score = main(N, K, plist, slist, max_score)
print(max_score)


Measured memory_bytes: 106980
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin>>N>>M;

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

  vector<int> B(N+1);
  for(int i=1;i<=N;i++)
    for(int j=0;j<cnt[i];j++) if(i - j >= 1) B[ i - j ]++;

  int ans = 0;
  for(int i=1;i<=N;i++) ans += B[i] == 0;

  while(M--){
    int X, Y;
    cin>>X>>Y; X--;

    int num = A[X]; A[X] = Y;
    if(num == Y) {cout<<ans<<endl; continue;}
    
    {
      int idx = num - cnt[num] + 1;
      if(idx >= 1) B[ idx ]--;
      if(idx >= 1 && B[ idx ] == 0) ans++;
      cnt[num]--;
    }
    {
      cnt[Y]++;
      int idx = Y - cnt[Y] + 1;
      if(idx >= 1 && B[ idx ] == 0) ans--;
      if(idx >= 1) B[ idx ]++;
    }
    
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int n, s[100005], q, t[50005];
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> s[i];
    cin >> q;
    int count = 0;
    for(int i=0; i<q; i++)
    {
        cin >> t[i];
        if(*lower_bound(s, s+n, t[i])==t[i])
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define int long long

typedef pair<int, int> Pi;
#define fi first
#define se second

const int LLINF = 1LL << 60;

void bfs(int k);

int H, W, K;
char mas[1005][1005];
int mc[1005][1005];

int mx[] = {1, 0, -1, 0};
int my[] = {0, 1, 0, -1};

queue < Pi > que;

main()
{
  cin >> H >> W >> K;

  fill_n(*mc, 1005 * 1005, LLINF);
  
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> mas[i][j];
      if(mas[i][j] == 'S') {
	mc[i][j] = 0; que.push(Pi(i, j));
      }
    }
  }

  bfs(0); //コスト0を作るためのbfs

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(mc[i][j] != LLINF) {
	mc[i][j] = 0; que.push(Pi(i, j));
      }
      mas[i][j] = '.';
    }
  }
  
  bfs(1);

  int minv = LLINF;
  
  for(int i = 0; i < H; i++) minv = min(minv, min((mc[i][0] + K - 1) / K, (mc[i][W - 1] + K - 1) / K));
  for(int j = 0; j < W; j++) minv = min(minv, min((mc[0][j] + K - 1) / K, (mc[H - 1][j] + K - 1) / K));

  cout << minv + 1 << endl;

  return (0);
}

void bfs(int k)
{
  
  while(!que.empty()) {
    Pi d = que.front(); que.pop();
    int y = d.fi, x = d.se;

    for(int i = 0; i < 4; i++) {
      int ny = y + my[i], nx = x + mx[i];

      if(ny < 0 || nx < 0 || ny >= H || nx >= W || mas[ny][nx] == '#' || mc[ny][nx] != LLINF) continue;

      mc[ny][nx] = mc[y][x] + 1;
      if(k || mc[ny][nx] < K) que.push(Pi(ny, nx));
    }
  }
}


Measured memory_bytes: 19216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


		  try{


			  while(true){
				  //????????\???
			     String ab = input.readLine();
		         String []strAry = ab.split(" ");
		         int  a=Integer.parseInt(strAry[0]);
	             int b=Integer.parseInt(strAry[1]);
	             int count=0;
	             int countb=0;
	              if(a==0&&b==0){
	        	      break;
	               }
	                  //a?????°?????????
	                  for(int i=0; i<a; i++){
	                	  //countb????????????????????¨??§else???????????????????????????
	                	  countb=0;
	        	          for(int j=0; j<b; j++){
	        	        	  //count???????????????a???????????????
	        	        	  if(count==a-1||count==0){
	        	        		  //????????????,??????????????¨??????????????????????????????????????????
	        	                 System.out.print('#');
	        	                 //count???????????\????????????????????¨??????????????\?????????
	        	        	  }else{
	        	        		  //countb??????????????¨????????????????????????????????????
	        	        		  countb++;
	        	        		  //countb???????????????????????????
	        	        		  if(countb==1||countb==b){
	        	        			  System.out.print('#');
	        	        			  //countb???????????\???
	        	        		  }else{
                                       System.out.print('.');
	        	        		  }
	        	        	  }


	        	           }
	        	          count++;
	        	          System.out.println("");

	                  }


	                  System.out.println("");
	              }



		    }catch(IOException e) {   System.out.println("Exception : " + e);
		    }

	}
}

Measured memory_bytes: 32240
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll K;
int N=50;
ll ans[50];

int am(){
  int r1=0;
  rep(i,N){
    if(ans[i]>ans[r1]){
      r1=i;
    }
  }
  return r1;
}

int main()
{
  cin>>K;
  rep(i,N) ans[i]=i - K + (N+1)*(K/N) ;
  rep(i,K%N) ans[i]+= N+1;
  cout<<N<<endl;
  rep(i,N-1) cout<<ans[i]<<" ";
  cout<<ans[N-1]<<endl;
  ll cnt=0;
  /*while(ans[am()]>=N){
    rep(i,N) ans[i]+=1;
    ans[am()] -= N+1;
    cnt++;
  }*/
  //cout<<cnt<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
now = A[0]
for i in range(1,N):
  if A[i] <= 2*now:
    now += A[i]
    ans += 1
  else:
    now += A[i]
    ans = 1
print(ans)
         

Measured memory_bytes: 20484
#include <iostream>
#include <string>

using namespace std;

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

	if (b == "A") {
		cout << "T" << endl;
	}
	else if (b == "T") {
		cout << "A" << endl;
	}
	else if (b == "C") {
		cout << "G" << endl;
	}
	else if(b == "G"){
		cout << "C" << endl;
	}
}


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

signed main() {
    int next[] = {0, 10, 7, 4, 1, 11, 8, 5, 2, 12, 9, 6, 3};

    string S;
    cin >> S;

    int N = S.length();

    vector<vector< int >> dp(N+1, vector<int>(13, 0));

    dp[0][0] = 1;

    REPS(i, N) {
        char c = S[i-1];
        vector<int> dp2(13, 0);
        REP(j, 13) {
            dp2[next[j]] = dp[i-1][j];
        }

        if (c == '?') {
            REP(k, 10) {
                REP(j, 13) {
                    (dp[i][(j+k)%13] += dp2[j]) %= MOD;
                }
            }
        } else {
            int a = c - '0';

            REP(j, 13) {
                (dp[i][(j+a)%13] += dp2[j]) %= MOD;
            }
        }
    }

    int ans = 0;

    cout << dp[N][5] << endl;

    return 0;
}

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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    if(s[k - 1] == 'A') s[k - 1] = 'a';
    if(s[k - 1] == 'B') s[k - 1] = 'b';
    if(s[k - 1] == 'C') s[k - 1] = 'c';
    cout << s << '\n';
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string w;
    cin>>w;
    int n = w.length();
    int x[26]={0};
    for(int i=0;i<n;i++)    x[w[i]-'a']++;
    for(int i=0;i<26;i++){
        if(x[i]%2==1){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}



Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    v = list(map(int, input().rstrip('\n').split()))
    v.sort()
    t = v[0]
    for i in range(1, n):
        t = (t + v[i]) / 2
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        private class Data
        {
            public long prime;
            public long cnt;
            public Data(long prime, long cnt)
            {
                this.prime = prime;
                this.cnt = cnt;
            }
        }
        static void Solve()
        {
            var o = Console.ReadLine();
            char a = o[0];
            char b = o[2];
            string ans = (a == 'H' && b == 'H') || (a == 'D' && b == 'D') ? "H" : "D";

            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 100 * 1000 + 123;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
vector<int> g[N];

vector<vector<int>> memo(N, vector<int>(4, -1));

int solve(int v, int color, int par) {
    if (memo[v][color] != -1) return memo[v][color];


    vector<int> children;
    for (int to : g[v]) {
        if (to != par) {
            children.push_back(to);
        }
    }

    if(children.empty()) return 1;

    int res = 1;
    for (int to : children) {
        vector<int> next_colors;
        next_colors.push_back(0);
        if (color != 1) next_colors.push_back(1);
        int cur = 0;
        for (int next_color: next_colors) {
            cur += solve(to, next_color, v);
            cur %= MOD;
        }

        res = (res * 1ll * cur) % MOD;
    }

    memo[v][color] = res;
    return res;
}

int main() {

    cin >> n;
    loop(i, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    int res = 0;
    res += solve(0, 0, -1) ;
    res %= MOD;

    res += solve(0, 1, -1);
    res %= MOD;

    cout << res << endl;
    return 0;
}


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

class Node
{
public:
    int value;
    Node* next;
    Node* prev;
    
    Node(int value, Node* next, Node* prev)
    {
        this->value = value;
        this->next = next;
        this->prev = prev;
    }
};
    
class LinkedList
{
private:
    Node* dummy;
public:
    LinkedList()
    {
        dummy = new Node(0, NULL, NULL);
        dummy->next = dummy;
        dummy->prev = dummy;
    }

    Node* insertFirst(int x)
    {
        Node* n = new Node(x, dummy->next, dummy);
        dummy->next->prev = n;
        dummy->next = n;
        return n;
    }
    Node* deleteNode(Node* n)
    {
        if (n == dummy) { return dummy; }
        n->prev->next = n->next;
        n->next->prev = n->prev;
        return n->next;
    }
    Node* deleteNode(int x)
    {
        for (Node* n = dummy->next; n != dummy; n = n->next)
            if (n != dummy && n->value == x) return deleteNode(n);
        return dummy;
    }
    Node* deleteFirst(void) { return deleteNode(dummy->next); }
    Node* deleteLast(void) { return deleteNode(dummy->prev); }
    void print()
    {
        for (Node* n = dummy->next; n != dummy; n = n->next) {
            cout << n->value;
            if (n->next != dummy) cout << " ";
        }
        cout << endl;
    }
};

int main(void)
{
    int n;
    string command;
    int val;
    LinkedList list;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> val;
            list.insertFirst(val);
        } else if (command == "delete") {
            cin >> val;
            list.deleteNode(val);
        } else if (command == "deleteFirst") {
            list.deleteFirst();
        } else if (command == "deleteLast") {
            list.deleteLast();
        }
    }
    list.print();

    return 0;
}



Measured memory_bytes: 37552
#include <iostream>

using namespace std;

int main() {
	unsigned long long n, m;
	cin >> n >> m;
	
	unsigned long long result = 0;
	if (n * 2 > m) {
		result = m / 2;
	} else {
		result = n;
		if (m - n * 2 != 0) {
			result += (m - n * 2) / 4;
		}
	}
	
	cout << result << endl;
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    string s;
    cin >> s;

    int n = sz(s);
    rep(i,0,n/2){
        if(s[i]!=s[n-1-i]){
            cout << "No\n";
            return;
        }
    }

    int l = (n-1)/2;
    rep(i,0,l/2){
        if(s[i]!=s[l-1-i]){
            cout << "No\n";
            return;
        }
    }

    int f=(n+3)/2-1;
    rep(i,0,(n-f+1)/2){
        if(s[f+i]!=s[n-1-i]){
            cout << "No\n";
            return;
        }
    }

    cout << "Yes\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

# N = 4
# A = [20, 11, 9, 24]

xorAll = 0
for a in A:
    xorAll = xorAll^a
#    print(bin(a))
#    print(bin(xorAll))
#    print(xorAll)
for a in A:
    mem = bin(xorAll)
    ans = xorAll^a
    print(ans, end=' ')

Measured memory_bytes: 105440
#include <iostream>

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;

    bool flag = true;
    for(int i = 0; i < N; i++){
        int a;
        std::cin >> a;
        if(a % 2 == 0){
            if((a % 3 == 0) || (a % 5 == 0)){
                // OK
            }else{
                flag = false;
            }
        }
    }
    if(flag){
        std::cout << "APPROVED" << std::endl;
    }else{
        std::cout << "DENIED" << std::endl;
    }
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

def main():
    X, Y, A, B, C = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))

    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)
    PQ = P[:X] + Q[:Y]
    heapify(PQ)

    while R:
        mpq = heappop(PQ)
        mr = R.pop(0)
        if mpq >= mr:
            heappush(PQ, mpq)
            break
        heappush(PQ, mr)
    
    print(sum(PQ))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 23456
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            if (X < 600)
            {
                Console.WriteLine(8);
            }
            else if (X < 800)
            {
                Console.WriteLine(7);
            }
            else if (X < 1000)
            {
                Console.WriteLine(6);
            }
            else if (X < 1200)
            {
                Console.WriteLine(5);
            }
            else if (X < 1400)
            {
                Console.WriteLine(4);
            }
            else if (X < 1600)
            {
                Console.WriteLine(3);
            }
            else if (X < 1800)
            {
                Console.WriteLine(2);
            }
            else if (X < 2000)
            {
                Console.WriteLine(1);
            }
        }
    }
}

Measured memory_bytes: 27316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
vector<int> arr;
int n, K;
bool dp[100005];
int main() {
    IO;
    cin >> n >> K;
    arr.resize(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    dp[0] = 0;
    for(int i = 1; i <= K; i++){
        dp[i] = 0;
        for(int j = 0; j < n && arr[j] <= i; j++){
            dp[i] = dp[i] | !dp[i-arr[j]];
        }
    }
    cout << ((dp[K]) ? "First" : "Second");

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c;
  
  d = c - a - b;
  
  if (d>0 && d*d>4*a*b){
    cout << "Yes" << endl;  
  }
  else {
    cout << "No" << endl;  
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a1=new int[n];
		int[] a2=new int[n];
		int[] s1=new int[n];
		int[] s2=new int[n];
		int ans=0;
		
		for(int i=0;i<n;i++){
			a1[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++){
			a2[i]=sc.nextInt();
		}
 
		s1[0]=a1[0]; 
		s2[n-1]=a2[n-1];
		for(int i=1;i<n;i++){
			s1[i]=s1[i-1]+a1[i];
		}
		for(int i=n-2;i>=0;i--){
			s2[i]=s2[i+1]+a2[i];
		}
		
		for(int i=0;i<n;i++){
			ans=Math.max(ans, s1[i]+s2[i]);
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23124