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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 200'000
#define LOG_N 60
i64 C[LOG_N + 1][MAX_N];

int main() {
    i64 N, K; cin >> N >> K;
    vector<i64> A(N);
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }

    REP(i, N) {
        C[0][i] = A[i];
    }

    REP(k, LOG_N) {
        REP(i, N) {
            C[k + 1][i] = C[k][C[k][i]];
        }
    }

    i64 cur = 0;
    REP(k, LOG_N) {
        if (K >> k & 1) {
            cur = C[k][cur];
        }
    }
    cout << (cur + 1) << endl;

    return 0;
}

Measured memory_bytes: 100084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,k,q;
	cin>>n>>k>>q;
	vector<ll> a(n,k);
	for(int i=0;i<q;i++)
	{
		ll t;
		cin>>t;
		a[t-1]++;
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]-q>0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}

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

int main(){
    int n, i;
    cin >> n;
    vector<int> v(n);
    for(i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double a = v[0];
    for(i = 0; i < n - 1; i++){
        a = (a + v[i+1]) / 2;
    }
    printf("%.8f\n", a);

}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); 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--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

// kmjpさんブログ参考
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 1;
    vector<ll> C(100010, 0);
    C[0] = 3;
    rep(i, N) {
      // rep(i, 5) cout << C[i] << ' ';
      // cout << ' ' << A[i] + 1;
      // cout << endl;
      ans *= C[A[i]];
      ans %= mod;
      C[A[i]]--;
      C[A[i]+1]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
s = input()
t = input()
len_s = len(s)
len_t = len(t)
ans = float("inf")
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1
    ans = min(cnt, ans)
print(ans)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

vector<ll> lucmemo(87, 0);
ll luc(int n) {
  if (n == 0) return 2;
  if (n == 1) return 1;
  if (lucmemo.at(n) != 0) return lucmemo.at(n);
  lucmemo.at(n) = luc(n - 1) + luc(n - 2);
  return lucmemo.at(n);
}

int main() {
  int n;
  cin >> n;
  cout << luc(n) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main(void){
    int n,k,ans=1;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ans+=min(ans,k);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
// Here your code !

$input = trim(file_get_contents('php://stdin'));

list($a, $b) = explode(" ", $input);

if ($a > $b) {
    echo "a > b", PHP_EOL;
} elseif($a < $b) {
    echo "a < b", PHP_EOL;
} else {
    echo "a == b", PHP_EOL;
}

Measured memory_bytes: 15260
//from 2145~

#include <stdio.h>
int main(void){
    // Your code here!
    
    int x;
    scanf("%d",&x);
    
    if( 400<=x && x<=599 ) printf("8\n"); //if( x <= 400 && x<=599 ) printf("8\n");
    else if( 600<=x && x<=799 ) printf("7\n");
    else if(  800<=x && x<=999 ) printf("6\n");
    else if( 1000<=x && x<=1199 ) printf("5\n");
    else if( 1200<=x && x<=1399 ) printf("4\n");
    else if( 1400<=x && x<=1599 ) printf("3\n");
    else if( 1600<=x && x<=1799 ) printf("2\n");
    else if( 1800<=x && x<=1999 ) printf("1\n");
    
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    vector<int> A(3);
    for(int i=0;i<3;i++) cin >> A.at(i);
    sort(A.begin(),A.end());
    if(A.at(0)==5&&A.at(1)==5&&A.at(2)==7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main() {
  int N, P=0, W=0, G=0, Y=0;
  string color;
  cin >> N;
  
  for(int i = 0 ; i < N ; i++){
    cin >> color;
    if(color == "P"){
      P++;
    }    
    if(color == "W"){
      W++;
    }    
    if(color == "G"){
      G++;
    }
    if(color == "Y"){
      Y++;
    }
  }
  
  if(P != 0 && W != 0 && G != 0 && Y != 0){
    cout << "Four" << endl;
  }
  if(!(P != 0 && W != 0 && G != 0 && Y != 0)){
    cout << "Three" << endl;
  }
  
}

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

#define N 10001
vector<int> prime(N);

int main(){
  int n;
  prime[0] = 1;
  prime[1] = 1;
  vector<int> prm;

  for(int i=2; i<N; i++){
    if(prime[i]==0){
      prm.push_back(i);
      for(int j=i*i; j<N; j+=i)
	prime[j]=1;
    }
  }

  while(cin >> n && n!=0){
    for(int i=prm.size()-1; i>0; i--){
      if(prm[i] <= n && prm[i] == prm[i-1]+2){
	cout << prm[i-1] << " " << prm[i] << endl;
	break;
      }	
    }
  }

  return 0;
}

Measured memory_bytes: 1272
ai = lambda: list(map(int, input().split()))

n, m = ai()

from collections import defaultdict as dd

edge = dd(list)
for _ in range(m):
    a, b, c = ai()
    edge[a - 1].append([b - 1, -c])


dist = [float('inf')] * n
dist[0] = 0
vs = {0}
i = 0
while vs:
    cur_v = vs.pop()
    for v, c in edge[cur_v]:
        if dist[v] > dist[cur_v] + c:
            dist[v] = dist[cur_v] + c
            vs.add(v)
            if i >= n-1 and v == n-1:
                print('inf')
                exit()
    i += 1
    if i > n*2:
        break
print(-dist[-1])


Measured memory_bytes: 3948
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const 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;}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    if(a<b){
        int num=0;
        while(c<=b){
            num++;
            c*=2;
        }
        if(num<=k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        int num=0;
        while(b<=a){
            num++;
            b*=2;
        }
        while(c<=b){
            num++;
            c*=2;
        }
        if(num<=k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define fst first
#define snd second

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);
  
  int a, b;
  cin >> a >> b;
  cout << (a-1) * (b-1) << "\n";
  
  return 0;
}



Measured memory_bytes: 256
class DisjointSet:
    def __init__(self, size):
        self.rank = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]
        
def kruskal(V, e):
    # V=ノードの数，e=(s, t, w)のエッジのリスト
    e = sorted(e, key=lambda x: x[2])
    S = DisjointSet(V)
    K = []
    for s, t, w in e:
        # if S.findSet(s) != S.findSet(t):
        if not S.same(s, t):
            S.unite(s, t)
            K.append((s, t, w))
    return K

if __name__ == '__main__':
    V, E = map(int, input().split())
    # s, t, w
    e = [tuple(map(int, input().split())) for i in range(E)]
    K = kruskal(V, e)
    ans = 0
    for s, t, w in K:
        ans += w
    print(ans)
    


Measured memory_bytes: 25016
N,K = map(int,input().split())
S = list(input())
happy = 0
for i in range(N-1):
  if S[i] == S[i+1]:
    happy += 1
for i in range(K):
  if happy == N-1:
    break
  elif happy == N-2:
    happy += 1
    break
  else:
    happy += 2
print(happy)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m, q;
	int a2[50], b[50], c[50], d[50], a[11];
	int c1, c2 = 0;
	cin >> n >> m >> q;
	for(int i = 0;i < q;i++){
		cin >> a2[i] >> b[i] >> c[i] >> d[i];
	}
	for(a[1] = 1;a[1] <= m;a[1]++){
		for(a[2] = a[1];a[2] <= m;a[2]++){
			if(n >= 3){
				for(a[3] = a[2];a[3] <= m;a[3]++){
					if(n >= 4){
						for(a[4] = a[3];a[4] <= m;a[4]++){
							if(n >= 5){
								for(a[5] = a[4];a[5] <= m;a[5]++){
									if(n >= 6){
										for(a[6] = a[5];a[6] <= m;a[6]++){
											if(n >= 7){
												for(a[7] = a[6];a[7] <= m;a[7]++){
													if(n >= 8){
														for(a[8] = a[7];a[8] <= m;a[8]++){
															if(n >= 9){
																for(a[9] = a[8];a[9] <= m;a[9]++){
																	if(n == 10){
																		for(a[10] = a[9];a[10] <= m;a[10]++){
																			c1 = 0;
																			for(int i = 0;i < q;i++){
																				if(a[b[i]] - a[a2[i]] == c[i]){
																					c1 += d[i];
																				}
																			}
																			c2 = max(c2, c1);
																		}
																	}else{
																		c1 = 0;
																		for(int i = 0;i < q;i++){
																			if(a[b[i]] - a[a2[i]] == c[i]){
																				c1 += d[i];
																			}
																		}
																		c2 = max(c2, c1);
																	}
																}
															}else{
																c1 = 0;
																for(int i = 0;i < q;i++){
																	if(a[b[i]] - a[a2[i]] == c[i]){
																		c1 += d[i];
																	}
																}
																c2 = max(c2, c1);
															}
														}
													}else{
														c1 = 0;
														for(int i = 0;i < q;i++){
															if(a[b[i]] - a[a2[i]] == c[i]){
																c1 += d[i];
															}
														}
														c2 = max(c2, c1);
													}
												}
											}else{
												c1 = 0;
												for(int i = 0;i < q;i++){
													if(a[b[i]] - a[a2[i]] == c[i]){
														c1 += d[i];
													}
												}
												c2 = max(c2, c1);
											}
										}
									}else{
										c1 = 0;
										for(int i = 0;i < q;i++){
											if(a[b[i]] - a[a2[i]] == c[i]){
												c1 += d[i];
											}
										}
										c2 = max(c2, c1);
									}
								}
							}else{
								c1 = 0;
								for(int i = 0;i < q;i++){
									if(a[b[i]] - a[a2[i]] == c[i]){
										c1 += d[i];
									}
								}
								c2 = max(c2, c1);
							}
						}
					}else{
						c1 = 0;
						for(int i = 0;i < q;i++){
							if(a[b[i]] - a[a2[i]] == c[i]){
								c1 += d[i];
							}
						}
						c2 = max(c2, c1);
					}
				}
			}else{
				c1 = 0;
				for(int i = 0;i < q;i++){
					if(a[b[i]] - a[a2[i]] == c[i]){
						c1 += d[i];
					}
				}
				c2 = max(c2, c1);
			}
		}
	}
	cout << c2 << endl;
}

Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
int H,W;
int sx,sy,gx,gy;

struct edge{lint to,cost;};
lint V;
vector<edge> G[1000000]; // MAX_V
lint d[1000000]; // MAX_V
void dijkstra(lint S){
  priority_queue<plint,vector<plint>,greater<plint>> que;
  fill(d,d+V,LINF);
  d[S]=0;
  que.push(plint(0,S));
  while(!que.empty()){
    plint p=que.top();
    que.pop();
    lint v=p.second;
    if(d[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(plint(d[e.to],e.to));
      }
    }
  }
}
 
int main(void){
    cin >> H >> W;
    cin >> sx >> sy >> gx >> gy;
    sx--,sy--,gx--,gy--;
    V=H*W;
    char S[H][W];
    rep(i,H) cin >> S[i];
    rep(i,H) rep(j,W){
        int now=i*W+j;
        if(S[i][j]=='#') continue;
        if(i!=0) if(S[i-1][j]!='#') G[now].push_back({now-W,0});
        if(i!=H-1) if(S[i+1][j]!='#') G[now].push_back({now+W,0});
        if(j!=0) if(S[i][j-1]!='#') G[now].push_back({now-1,0});
        if(j!=W-1) if(S[i][j+1]!='#') G[now].push_back({now+1,0});
        for(int k=i-2;k<=i+2;k++) for(int l=j-2;l<=j+2;l++){
            if(k<0 || k>=H || l<0 || l>=W) continue;
            if(S[k][l]=='#') continue;
            G[now].push_back({k*W+l,1});
        }
    }
    dijkstra(sx*W+sy);
    if(d[gx*W+gy]==LINF) cout << -1 << endl;
    else cout << d[gx*W+gy] << endl;
}

Measured memory_bytes: 206028
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    char op;
    for(int i = 0; i < 10000; i++){
        cin >> a >> op >> b;
        if(op == '+'){
            c =a + b;
        } else if (op == '-'){
            c = a - b;
        } else if (op == '*'){
            c = a * b;
        } else if (op == '/'){
            c = a / b;
        }else{
            break;
        }
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
class Dice
  attr_accessor :face

  def rotate_n
    @face[0],@face[1],@face[5],@face[4] = @face[1],@face[5],@face[4],@face[0]
  end
  def rotate_e
    @face[0],@face[2],@face[5],@face[3] = @face[3],@face[0],@face[2],@face[5]
  end
  def rotate_s
    @face[0],@face[1],@face[5],@face[4] = @face[4],@face[0],@face[1],@face[5]
  end
  def rotate_w
    @face[0],@face[2],@face[5],@face[3] = @face[2],@face[5],@face[3],@face[0]
  end
end

dice = Dice.new
dice.face = gets.chomp.split.map(&:to_i)
c = gets.chomp.split("")
c.each do |item|
  case item
  when "N"
    dice.rotate_n
  when "E"
    dice.rotate_e
  when "S"
    dice.rotate_s
  when "W"
    dice.rotate_w
  end
end
puts dice.face[0]

Measured memory_bytes: 6120
#include<iostream>
#include<string>
#include<set>

using namespace std;
int main()
{
    int n;
    cin>>n;
    set<string>s ;


   for(int i =1 ; i<=n ; i++)
   {
      string k;
      cin>>k;
      s.insert(k);
   }
   cout<<s.size();



}



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

int main() {
    int N;
    cin >> N;
    vector<int> S(N + 1, 0);
    for(int i=0; i<N; ++i) {
        cin >> S[i + 1];
        S[i + 1] += S[i];
    }
    int res = 1001001001;
    for(int t=1; t<N; ++t) {
        res = min(res, abs(S[N] - S[t] - S[t]));
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,l,ans=1E12;
	cin>>n;
	if(n<10)
		cout<<1;
	else{l=sqrt(n+1);
	for(int i=1;i<=l;++i){
		if(!(n%i)){
			long long m=n/i;
			string s=to_string(i),t=to_string(m);
			ans=max(s.size(),t.size());
		}
	}
	cout<<ans;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3010;
ll f[N],g[N][N],pw[N];
ll n,mo,C[N][N];
void move(ll &a,ll b){a=(a+b)%mo;}
ll power(ll a,ll b){
	ll ans=1;
	while (b){
		if (b&1)ans=ans*a%mo;
		a=a*a%mo;
		b>>=1;
	}return ans;
}
int main(){
	cin>>n>>mo;
	g[0][0]=1;
	pw[0]=2;C[0][0]=1;
	for (int i=1;i<=n;i++){
		pw[i]=pw[i-1]*pw[i-1]%mo;
		g[i][0]=1;
		C[i][0]=C[i][i]=1;
		for (int j=1;j<=i;j++)
			move(g[i][j],g[i-1][j]*(j+1)+g[i-1][j-1]),
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
	}
	ll ans=0;
	for (int i=0;i<=n;i++){
		for (int j=0;j<=i;j++)
			move(f[i],g[i][j]*power(2,(n-i)*j));
		f[i]=f[i]*pw[n-i]%mo;
		move(ans,f[i]*C[n][i]*power(-1,i));
	}
	cout<<(ans%mo+mo)%mo<<endl;
}

Measured memory_bytes: 140032
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            int H = scan.nextInt();
            int W = scan.nextInt();
            if (H == 0 || W == 0) {
                break;
            }
            for (int i = 0;i < H; i++) {
                for (int j = 0;j < W; j++) {
                    sb.append("#");
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }

}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[101010], b[101010], c[101010];
i64 bb[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) cin >> c[i];
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	
	i64 ans = 0;
	for(int i = 0; i < n; i++){
		bb[i] = lower_bound(a,a+n,b[i])-a;
	}
	for(int i = 0; i < n; i++){
		bb[i+1] += bb[i];
	}
	for(int i = 0; i < n; i++){
		int pos = lower_bound(b,b+n,c[i])-b-1;
		if(pos < 0) continue;
		ans += bb[pos];
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

#define MAX INT_MAX
#define ll long long int

void solve(){
    char a[3];
    int s=0,r=0; 
    for(int i=0;i<3;i++){
        cin>>a[i];
        if(a[i]=='S'){
            s++;
        }
        else r++;
    }
    if(s==3) cout<<0;
    else if(s==2) cout<<1;
    else if(s==1){
        if(a[1]=='S') cout<<1;
        else cout<<2;
    }
    else cout<<3;
}

int main(){
    // ll t;
    // cin>>t;
    // while(t--) 
    solve();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	uint N, K;
	cin >> N >> K;
	
	vector<uint> H(N);
	
	for(uint i=0; i<N; i++) {
		cin >> H[i];
	}
	
	if(K >= N) {
		cout << 0;
		return 0;
	}

	sort(H.begin(), H.end(), greater<uint>());
	
	ull ans = accumulate(H.begin() + K, H.end(), (ull)0);
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int X = sc.nextInt();
      int T = sc.nextInt();
      
      // 計算
      int total = 0;
      int count = 0;
      if(N % X == 0){
        count = N / X;
      }else{
        count = N / X + 1;
      }
      
      total = count * T;
      
      // 出力
      System.out.println(total);
    }

}

Measured memory_bytes: 35624
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;
#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
vector<long long> divisor(long long n) {
vector<long long> ret;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end()); // 昇順に並べる
return ret;
}
inline ll check(ll N, ll K){
    while(N>=K){
        if(N%K==0)N/=K;
        else N%=K;
    }
    return N;
}
signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vl A=divisor(N);
    //debug(A)
    vl B=divisor(N-1);
    unordered_set<ll> ans;
    for(auto p: A){
        if(p==1)continue;
        if(check(N,p)==1)ans.insert(p);
    }
    for(auto p: B){
        if(p==1)continue;
        if(check(N,p)==1)ans.insert(p);
    }
    prt(ans.size());


    return 0;
}



Measured memory_bytes: 3676
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


a, b, c, d = [II() for _ in range(4)]

print(min(a, b) + min(c, d))


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

int main()
{
	int n;int s=0;
	cin>>n;
	int s1,s2;
	cin>>s1>>s2;
	for(int i=s1;i<=s2;i++)
	{
		if(i%n==0)
		s++;
		
	}
	if(s>0)
	cout<<"OK";
	else
	cout<<"NG";
	return 0;
 } 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  int n,k;
  cin>>n>>k;
  ll ans = pow(n/k,3);
  if(k%2==0){
    ans+=pow((n/(k/2)-n/k),3);
  }
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

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

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] A;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        A = new int[N + 2];
        for (int i = 1; i < N + 1; i++)
            A[i] = cin.nextInt();
    }
    static void solve()
    {
        input();
        long sum = Abs(A[0]);
        int[] skip = new int[N];
        for(int i = 1; i < N + 2; i++)
        {
            sum += Abs(A[i] - A[i - 1]);
        }
        for(int i = 1; i < N + 1; i++)
        {
            WriteLine(sum - Abs(A[i] - A[i - 1]) - Abs(A[i + 1] - A[i]) + Abs(A[i + 1] - A[i - 1]));
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	std::string str;
	int m = 0;
	int h = 0;

	for(;;){
#if INPUT_FROM_FILE
		ifs >> str;
#else
		std::cin >> str;
#endif
		if(str == "-"){ break;}
		
#if INPUT_FROM_FILE
		ifs >> m;
#else
		std::cin >> m;
#endif
		for(int i = 0; i < m; i++){
#if INPUT_FROM_FILE
			ifs >> h;
#else
			std::cin >> h;
#endif
			str = str.substr(h, std::string::npos) + str.substr(0, h);
		}
		std::cout << str << std::endl;
	}
	return 0;
}

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

using namespace std;
constexpr long long int mod = 1000000007;

int main() {
    int a, b, c,k;
    cin >> a >> b >> c >> k;
    if (a >= k)cout << k;
    else if (a + b >= k)cout << a;
    else cout << (a + (a + b) - k);
}

Measured memory_bytes: 3624
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include <iostream>
using namespace std;

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

  int n, y; cin >> n >> y;
  for (int i = 0; i <= y / 10000; ++i){
    if (i > n) break;
    if (i * 10000 > y) break;
    for (int j = 0; j <= y / 5000; ++j){
      if (i + j > n) break;
      if (i * 10000 + j * 5000 > y) break;
      for (int k = 0; k <= y / 1000; ++k){
        if (i + j + k > n) break;
        if (i + j + k == n && 10000 * i + 5000 * j + 1000 * k == y){
          cout << i << " " << j << " " << k << '\n'; return 0;
        }
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif

const ll oo = 1e16;
const int maxn = 1e5 + 10;

vector<vector<int>> adj(maxn);
vector<bool> used(maxn,false);

vector<int> sorted;
ll dp[maxn];

void dfs(int node){
	used[node] = true;
	for(int el : adj[node])
		if(!used[el]){
			dfs(el);
		}
	
	sorted.push_back(node);
}

int N,M;
void test_case(){
	cin >> N >> M;
	memset(dp,0,sizeof(dp));
	for(int i = 0;i<M;++i){
		int a,b;
		cin >> a >> b;
		--a,--b;
		adj[a].push_back(b);
	}
	for(int i = 0;i<N;++i){
		if(!used[i])
			dfs(i);
	}
	reverse(all(sorted));
	ll ans = 0;
	for(int i : sorted){
		for(int j : adj[i])
			dp[j] = max(dp[j],dp[i] + 1);
	}
	for(int i = 0;i<N;++i)
		ans = max(ans,dp[i]);
	
	cout << ans << endl;
}

	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 12064
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    money = 1000
    stock = 0
    buy_flag = True
    sale_flag = False

    for day in range(n):
        today_info = num_list[day]
        if buy_flag:
            buy_flag = False
            for feature in range(day+1,n):
                feature_info = num_list[feature]
                if today_info < feature_info:
                    for min_day in range(day+1, feature):
                        if today_info > num_list[min_day]:
                            break
                    else:
                        buy_flag = True
                    break
            if buy_flag:
                buy_num = money // today_info
                money -= buy_num * today_info
                stock += buy_num
                buy_flag = False
                sale_flag = True
            else:
                buy_flag = True
        elif sale_flag:
            for feature in range(day+1,n):
                feature_info = num_list[feature]
                if feature_info > today_info:
                    for min_day in range(day+1, feature):
                        if today_info > num_list[min_day]:
                            break
                    else:
                        sale_flag = False
                    break
            if sale_flag:
                money += today_info * stock
                stock = 0
                buy_flag = True
                sale_flag = False
            else:
                sale_flag = True

        # print(day+1, money, stock)

    print(money)

if __name__ == '__main__':
    main()


Measured memory_bytes: 72628
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

map<int, int> cnt;
int n ,k, ans, a[200005];
int norm(int x) {
	x %= k;
	x += k;
	x %= k;
	return x;
}

signed main()
{
	IO_OP;
	
	cin >> n >> k;
	for(int i=1;i<=n;i++) {
		cin >> a[i];
		a[i] %= k;
		a[i] += a[i-1];
	}
	for(int i=n;i>=1;i--) {
		if(i+k-1<=n) cnt[norm(a[i+k-1]-(i+k-1)-1)]--;
		cnt[norm(a[i]-i-1)]++;
		ans += cnt[norm(a[i-1]-i)];
	}
	cout << ans << endl;
	
}





Measured memory_bytes: 14336
#include <iostream>
using namespace std;
 
int H, W;
string A[100];
 
bool check() {
  for (int i = 0; i < H; i++) {
    bool ok = true;
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        ok = false;
      }
    }
    if (ok) {
      for (int k = i; k < H-1; k++) {
        swap(A[k],A[k+1]);
      }
      H--;
      return true;
    }
  }
  for (int j = 0; j < W; j++) {
    bool ok = true;
    for (int i = 0; i < H; i++) {
      if (A[i][j] == '#') {
        ok = false;
      }
    }
    if (ok) {
      for (int k = 0; k < H; k++) {
        A[k] = A[k].substr(0,j)+A[k].substr(j+1);
      }
      W--;
      return true;
    }
  }
  return false;
}
int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> A[i];
  }
  while (check());
  for (int i = 0; i < H; i++) {
    cout << A[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<ll>a(x);
    vector<ll>b(y);
    vector<ll>c(z);
    for(int i=0;i<x;i++)
        cin>>a[i];
    for(int i=0;i<y;i++)
        cin>>b[i];
    for(int i=0;i<z;i++)
        cin>>c[i];
    vector<ll>ans(k);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
   
    for(int i=0;i<x;i++)
        for(int j=0;j<y;j++)
            for(int m=0;m<z;m++)
            {
                if((i+1)*(j+1)*(m+1)<=k)
                    ans.push_back(a[i]+b[j]+c[m]);
            }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    for(int i=0;i<k;i++)
        cout<<ans[i]<<endl;
    return 0;
}


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

struct Ca{char suit,value;};

void BubbleSort(struct Ca C[],int N){
	
   for(int i = 0 ;i< N;i++){
     for(int j = N-1;j>=i;j--){
		 if( C[j].value< C[j-1].value){
			Ca tmp=C[j];C[j]=C[j-1];C[j-1]=tmp;}
}
   }
}
        

void SelectionSort(struct Ca C[],int N)
{  
 for(int i = 0 ;i< N;i++){
    int minj = i;
    for(int j = i ;j< N;j++){
      if (C[j].value< C[minj].value)
		  minj = j;}
Ca tmp=C[i];C[i]=C[minj];C[minj]=tmp;}
}
    
bool isStable(struct Ca c1[],struct Ca c2[],int N){
for(int i=0;i<N;i++){
if(c1[i].suit!=c2[i].suit)return false;
}return true;
}
int main(){
Ca c1[100],c2[100];
int N;
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];

BubbleSort(c1,N);

SelectionSort(c2,N);

for(int i=0;i<N;i++){
if(i>0)cout<<" ";
cout<<c1[i].suit<<c1[i].value;
}
cout<<endl;
cout<<"Stable"<<endl;

for(int i=0;i<N;i++){
if(i>0)cout<<" ";
cout<<c2[i].suit<<c2[i].value;
}
cout<<endl;
if(isStable(c1,c2,N)){
cout<<"Stable"<<endl;
}else{
cout<<"Not stable"<<endl;
}

return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll a, b, c, d, N;
    cin >> a >> b >> c >> d >> N;
    N *= 4;
    ll ans = 0;
    ll m = a*4;
    m = min(m, b*2);
    m = min(m, c);
    if(N%8 == 4) ans += m;
    m = min(2*m, d);
    ans += m*(N/8);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	for(int i=0;i<a.length();i++)putchar('x');
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string s,ans="No";

    cin >> s;
    rep(i,0,1){
        if(s[i]!=s[i+1])ans = "Yes";
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	ll a,b,c;cin>>a>>b>>c;
	if(a==b and a!=c or a==c and a!=b or b==c and b!=a){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
N, *A = map(int, open(0).read().split())
A = list(zip(*[iter(A)] * N))

M = 2 ** N

S = [0] * M
for state in range(M):
    for i, ai in enumerate(A):
        for j in range(i + 1, N):
            if (state >> i) & 1 and (state >> j) & 1:
                S[state] += ai[j]

dp = [0] * M
for state in range(M):
    mask = state
    while mask:
        dp[state] = max(
            dp[state],
            dp[state - mask] + S[mask]
        )
        mask = (mask - 1) & state

print(dp[-1])

Measured memory_bytes: 74572
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <map>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

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

    vector<ll> a(n,0), b(n,0);

    rep(i,0,n) cin>>a[i]>>b[i];

    multimap<ll, ll> s;
    rep(i,0,n) s.emplace(a[i],b[i]);

    ll sum(0), unit(0);
    for (auto i: s)
    {
        if (unit >= m) break;

        if (unit + i.second <= m)
        {
                sum += i.first * i.second;
                unit += i.second;
                //cout << unit << ' ' << sum <<  endl;
        }
        else if (i.second > (m - unit))
        {
                sum += (m-unit) * i.first;
                unit += (m - unit);
        } 
            
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

int main(){
    vector<int> v;
    int i,x;
    while(1){
        cin>>x;
        if(x!=0){
            v.push_back(x);
        }
        else{
            break;
        }
    }
    for(i=0; i<v.size(); i++){
        cout<<"Case "<<i+1<<": "<<v[i]<<endl;
    }
    return 0;
}



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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll x,y;
    
    cin>>x>>y;
    
    ll ans = x*500;
    
    if(ans >= y)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a * b == 15) {
		cout << "*" << endl;
	}
	else if (a + b == 15) {
		cout << "+" << endl;
	}
	else {
		cout << "x" << endl;
	}
}

Measured memory_bytes: 256