akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

#define MAX_N 100000
#define MAX_M 100

using namespace std;

int N, M;
int A[MAX_N];

vector<int> solve()
{
    vector<int> B;

    vector<int> idx_odds;
    for ( int i = 0; i < M; i++ )
        if ( A[i] % 2 ) idx_odds.push_back( i );

    switch ( idx_odds.size() )
    {
    case 2:
        swap( A[idx_odds[1]], A[M - 1] );
    case 1:
        swap( A[idx_odds[0]], A[0] );
        break;
    case 0:
        break;
    default:
        return B;
    }

    switch ( M )
    {
    case 1:
        B.push_back( 1 );
        break;
    case 2:
        B.push_back( A[1] + 1 );
        break;
    default:
        for ( int i = 1; i < M - 1; i++ ) B.push_back( A[i] );
        B.push_back( A[M - 1] + 1 );
    }

    if ( A[0] > 1 ) B.insert( B.begin(), A[0] - 1 );

    return B;
}

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

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

    auto ans = solve();

    if ( ans.size() == 0 )
        cout << "Impossible" << endl;
    else
    {
        for ( int i = 0; i < M - 1; i++ ) cout << A[i] << " ";
        cout << A[M - 1] << endl;

        cout << ans.size() << endl;

        for ( int i = 0; i < ans.size() - 1; i++ ) cout << ans[i] << " ";
        cout << ans[ans.size() - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {

	ll n; cin >> n;
	const ll p = 100001;
	vector<ll> aNum(p, 0), bNum(p, 0);
	for (ll i = 0; i < n; i++) {
		ll v; cin >> v;
		if (i % 2 == 0) {
			aNum[v]++;
		}		
		else {
			bNum[v]++;
		}
	}
	ll a_first;
	ll b_first;
	ll tmpA = 0;
	ll tmpB = 0;
	for (ll i = 0; i < p; i++) {
		if (chmax(tmpA, aNum[i])) {
			a_first = i;
		}
		if (chmax(tmpB, bNum[i])) {
			b_first = i;
		}
	}
	sort(aNum.begin(), aNum.end(), greater<ll>());
	sort(bNum.begin(), bNum.end(), greater<ll>());
	ll a_first_cnt = aNum[0];
	ll b_first_cnt = bNum[0];
	ll a_second_cnt = aNum[1];
	ll b_second_cnt = bNum[1];

	if (a_first != b_first) {
		cout << n - a_first_cnt - b_first_cnt << endl;
	}
	else { // a_first == b_first
		cout << min(n - a_first_cnt - b_second_cnt, n - a_second_cnt - b_first_cnt) << endl;
	}
	return 0;
}

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

int n, m, q;
int a[50], b[50], c[50], d[50];
int A[10], ans;

void dfs(int dep, int pre) {
    if (dep == n) {
        int sum = 0;
        for (int i = 0; i < q; i++) if (A[b[i] - 1] - A[a[i] - 1] == c[i]) sum += d[i];
        ans = max(ans, sum);
        return;
    }
    for (int i = pre; i <= m; i++) {
        A[dep] = i;
        dfs(dep + 1, i);
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(0, 1);
    cout << ans << "\n";
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	
	while (1) {
		string s;
		bool flag;
		int count = 0;

		cin >> s;

		if (s[0] == '#') {
			break;
		}
		switch (s[0]) {
		case 'q':
		case 'w':
		case 'e':
		case 'r':
		case 't':
		case 'a':
		case 's':
		case 'd':
		case 'f':
		case 'g':
		case 'z':
		case 'x':
		case 'c':
		case 'v':
		case 'b':
			flag = false;
			break;
		default:
			flag = true;
			break;
		}
		FOR(i, 1, s.size() - 1) {
			switch (s[i]) {
			case 'q':
			case 'w':
			case 'e':
			case 'r':
			case 't':
			case 'a':
			case 's':
			case 'd':
			case 'f':
			case 'g':
			case 'z':
			case 'x':
			case 'c':
			case 'v':
			case 'b':
				if (flag) {
					count++;
				}
				flag = false;
				break;
			default:
				if (!flag) {
					count++;
				}
				flag = true;
				break;
			}
		}
		cout << count << endl;
	}
	
}


Measured memory_bytes: 3120
let bfs g n =
  let d = Array.make n (-1) in
  let q = Queue.create () in
  d.(0) <- 0;
  Queue.add 0 q;
  let rec doit () =
    if not (Queue.is_empty q) then begin
      let i = Queue.take q in
      duduwa (d.(i) + 1) g.(i);
      doit ()
    end
  and duduwa x = function
    | [] -> ()
    | hd :: tl when d.(hd-1) = (-1) -> (d.(hd-1) <- x; Queue.add (hd - 1) q; duduwa x tl)
    | _ :: tl -> duduwa x tl
  in doit ();
  d

let () =
  let n = read_int () in
  let g = Array.make n [] in
  let rec read i =
    if i < n then
      match List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) with
      | u :: _ :: l -> (g.(u-1) <- l; read (i + 1))
      | _ -> exit 1
  in read 0;
  let d = bfs g n in
  let rec print i =
    if i < n then (Printf.printf "%d %d\n" (i + 1) d.(i); print (i + 1))
  in print 0

Measured memory_bytes: 2632
#include <stdio.h>
int a[5];
int main(){
	int n,m,i,s,c;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)a[i]=-1;
	for(i=1;i<=m;i++){
		scanf("%d%d",&s,&c);
		if(a[s]!=-1&&a[s]!=c){//同一位上有不同数值
			printf("-1\n");
			return 0;
		}else{
			a[s]=c;
		}
	}
	if(n>1&&a[1]==0)printf("-1\n");//至少两位数，首位是0
	else if(n==1){//只有一位数
		if(a[1]==-1)printf("0\n");
		else printf("%d\n",a[1]); 
	}
	else{//多位数
		for(i=1;i<=n;i++)
			if(i==1&&a[i]==-1)printf("1");//若对首位没有说明，那么设置为1
			else if(a[i]==-1)printf("0");
			else printf("%d",a[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    vector<int> data(N);
    rep(i,N){
        cin >> data.at(i);
    }
    int flag=1;
    rep(i,N){
        if(data.at(i)%2==0){
            if(data.at(i)%3!=0 && data.at(i)%5!=0){
                flag=0;
                break;
            }
        }
    }

    if(flag==0){
        cout << "DENIED" << endl;
        }
        else{
            cout << "APPROVED" << endl;
        }
 
}

Measured memory_bytes: 256
n = input()
x = map(int, raw_input().split())
x2 = sorted(x)
mid1 = x2[(n/2)-1]
mid2 = x2[n/2]
if mid1 == mid2:
    for i in xrange(n):
        print mid1
else:
    for i in xrange(n):
        if x[i] <= mid1:
            print mid2
        else:
            print mid1


Measured memory_bytes: 19956
def CountingSort(arr_size, in_arr, out_arr, maximum):

    c = [0] * (maximum + 1)
    for j in range(arr_size):
        c[in_arr[j]] += 1
    for i in range(1, maximum + 1):
        c[i] += c[i - 1]
    for j in range(arr_size - 1, -1, -1):
        out_arr[c[in_arr[j]]] = in_arr[j]
        c[in_arr[j]] -= 1

n = int(input())
A = list(map(int, input().split()))
B = [0] * (n + 1)
CountingSort(arr_size=n, in_arr=A, out_arr=B, maximum=max(A))
print(' '.join(map(str, B[1:])))


Measured memory_bytes: 250456
a=gets.chomp.split.map(&:to_i)
b=gets.chomp.split.map(&:to_i)
c=gets.chomp.split("")
t=0
a[0].times do |x|
  i=c[x]
  if x<a[1]||i!=c[x-a[1]]
    if i=="r"
      t+=b[2]
    elsif i=="s"
      t+=b[0]
    else t+=b[1]
    end
  else c[x]=nil
  end
end
puts t

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

static const int MAX=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

void dijkstra(){
  int mincost;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INT_MAX;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  
  while(1){
    int u=-1;  
    mincost=INT_MAX;

    for(int i=0;i<n;i++){
      if(color[i]!=BLACK&&d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost==INT_MAX) break;

    color[u]=BLACK;
  
    for(int i=0;i<n;i++){
      if(color[i]!=BLACK&&M[u][i]!=INT_MAX){
	if(d[u]+M[u][i]<d[i]){
	  d[i]=d[u]+M[u][i];
	  color[i]=GRAY;
	}
      }
    }
  }
  for(int i=0;i<n;i++) cout<<i<<" "<<d[i]<<endl;
}

int main(){
  cin>>n;

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

  int u,k,v,c;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      M[u][v]=c;
    }
  }

  dijkstra();

 return 0;
}

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

using namespace std;

int main(){
	char a; cin >> a;
	if(a == 'A') cout << 'T';
	if(a == 'C') cout << 'G';
	if(a == 'T') cout << 'A';
	if(a == 'G') cout << 'C';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 10000002
#define N 200004
#define K 7


int32_t main()
{
    IOS;

    int a[2];
    cin >> a[0] >> a[1];
    int ans = 0;
    for(int i = 0;i < 2;i++)
    {
        if(a[i] == 3)
            ans += 100000;
        if(a[i] == 2)
            ans += 200000;
        if(a[i] == 1)
            ans += 300000;
    }
    if(a[0] == a[1] and a[0] == 1)
        ans += 400000;
    cout << ans;
    
    return 0;

}
 
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n, m;
int ans = 0;

int field[100][100];

void solve(int now, bool used[]){
	REP(i, n){
		if (!used[i])break;
		if (i == n - 1){
			ans++;
			return;
		}
	}

	REP(i, n){
		if (field[now][i] && !used[i]){
			used[i] = 1;
			solve(i, used);
			used[i] = 0;
		}
	}
}

int main(){
	cin >> n >> m;
	REP(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		field[a][b] = 1;
		field[b][a] = 1;
	}
	bool used[100] = {};
	used[0]=1;
	solve(0,used);
	cout << ans << endl;
}

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

int main(){
    ll A, B, K;
    cin >> A >> B >> K;

    if (A + B < K){
        cout << 0  << " " << 0 << endl;
    } else{
        if (A < K){
            cout << 0 << " " << B - (K - A) << endl;
        } else{
            cout << A - K << " " << B << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    char a, b;
    cin >> a >> b;
    bool h;
    if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
        cout << "H\n";
    } else {
        cout << "D\n";
    }
}

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


int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(w+2,vector<int>(h+2));
    int sum=0;
    rep(i,h){
        rep(j,w) {
            cin >> a.at(j+1).at(i+1);
            sum+=a.at(j+1).at(i+1);
        }
    }
    queue<pair<pair<int,int>,pair<int,int>>> q;
    pair<pair<int,int>,pair<int,int>> v;
    for (int i=1;i<h+1;i++){
        for (int j=1;j<w+1;j++){
            if (a.at(j).at(i)%2==1 && j!=w){
                v.first.first=i;v.first.second=j;
                v.second.first=i;v.second.second=j+1;
                a.at(j+1).at(i)+=1;
                q.push(v);
            }
            if (a.at(j).at(i)%2==1 && j==w && i!=h){
                v.first.first=i;v.first.second=j;
                v.second.first=i+1;v.second.second=j;
                a.at(j).at(i+1)+=1;
                q.push(v);
            }
        }
    }
    cout << q.size() << endl;
    while(!q.empty()){
        v=q.front();
        q.pop();
        cout << v.first.first << " " << v.first.second << " " << v.second.first << " " << v.second.second << endl;
    }
}


Measured memory_bytes: 6656
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in range(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                peaks.append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            elif ices[i] > ices[i+1]:
                peaks.append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        elif i == N-1:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print(max(peaks))

N,L = map(int,input().strip().split())
ices = [int(input().strip()) for _ in range(N)]


orderN(N,L,ices)

Measured memory_bytes: 15560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if(n == 1){
			System.out.println(0);
		}
		int divisor = 2;

		long result = 1;

		while(n > 1){

			int count = 0;

			while(n % divisor == 0){
				count++;
				n /= divisor;
			}

			if(count != 0){
				result *= Math.pow(divisor, count) - Math.pow(divisor, count - 1);
			}

			divisor++;
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 26588
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<int> p;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  p.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  vector<int> sorted = p;
  sort(sorted.begin(), sorted.end());

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (p[i] != sorted[i]) {
      cnt++;
    }
  }

  if (cnt <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

int main(){
    int N,A,i,t;
    int* C;
    cin >> N;
    C = new int[N];
    for(i=0;i<N;i++){
        C[i] = 0;
    }
    t = N-1;
    for (i=0;i<t;i++){
        cin >> A;
        C[A-1] += 1;
    }
    for(i=0;i<N;i++){
        cout << C[i];
        if(i<t)
            cout << '\n';
    }
    delete[] C;
    return 0;
}


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

int main(void){
    int H,W,M;
    cin>>H>>W>>M;
    vector<int> h(M);
    vector<int> w(M);
    rep(i,M)cin>>h[i]>>w[i];
    vector<int> bomb(M,0);
    // 各行・列の爆弾個数を取得
    vector<int> a(H,0);
    vector<int> b(W,0);
    // vector<vector<int>> c(H,vector<int>(W,0));
    rep(i,M){
        a[h[i]-1]++;
        b[w[i]-1]++;
        // c[h[i]-1][w[i]-1]++;
    }

    int am=0,bm=0;
    rep(i,H)am=max(am,a[i]);
    rep(i,W)bm=max(bm,b[i]);
    int acnt=0,bcnt=0;
    rep(i,H)if(a[i]==am)acnt++;
    rep(i,W)if(b[i]==bm)bcnt++;
    ll cnt=0;
    rep(i,M){
        if(a[h[i]-1]==am && b[w[i]-1]==bm)cnt++;
    }
    ll ans;
    if(cnt>=(ll)acnt*bcnt)ans=am+bm-1;
    else ans=am+bm;
    cout<<ans<<endl;
}

Measured memory_bytes: 9064
// B - Bite Eating
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	int n, l;
	cin >> n >> l;

	vector<pair<int, int> > a;
	for (int i = 0; i < n; i++) a.push_back(make_pair(abs(l + i), l + i));
	sort(a.begin(), a.end());

	int ans = 0;
	for (int i = 1; i < n; i++) ans += a[i].second;
	cout << ans << endl;

	return 0;
}


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

int main() {
    int n,w;
    cin >> n >> w;
    vector<long long int> weight(n), value(n);
    for(int i=0; i<n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    vector<long long int> dp(w+1);
    for(int i=0; i<n; i++)
    {
        long long int wt = weight[i];
        for(int j=w; j-wt >= 0; j--)
        {
            dp[j] = max(dp[j],dp[j-wt]+value[i]);
        }
    }
    cout << dp[w];
}


Measured memory_bytes: 1024
def product arr
    a, b, c, d, e, f, g, h = arr
    [a*e - b*f - c*g - d*h,
     a*f + b*e + c*h - d*g,
     a*g - b*h + c*e + d*f,
     a*h + b*g - c*f + d*e]
end

while true
    n = gets.to_i
    break if n == 0
    n.times{
        line = gets.chomp.split.map(&:to_i)
        puts product(line).join(" ")
    }
end


Measured memory_bytes: 6916
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    REP(i, N)cin >> x[i];

    int ans = INF;
    int left = 0;
    int right = K - 1;
    while (right < N) {
        int xl = x[left];
        int xr = x[right];
        int len = min(abs(xl) + abs(xl - xr), abs(xr) + abs(xr - xl));
        ans = min(ans, len);
        left++;
        right++;
    }

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

Measured memory_bytes: 640
#include <stdio.h>

int main() {
	long long Zx, count = 0;
	scanf("%lld", &Zx);
	for (int u = 1; u <= Zx; u++) {
		if (u % 3 != 0 && u % 5 != 0) {
			count += u;
		}
	}
	printf("%lld", count);
	return 0;
}

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

#define pb push_back
#define S second
#define F first
typedef long long ll;

using namespace std;

const ll maxn = 1e5 + 10;
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll n , m , ans;
bool mark[maxn];
vector<int> adj[maxn];

inline void dfs(int u){
	mark[u] = 1;
	for(int i : adj[u]){
		if(!mark[i]){
			dfs(i);
		}
	}
}

int main(){

//	freopen("input.txt", "r", stdin);
	
	cin >> n >> m;
	for(int i=0;i < m;i++){
		int u , v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	for(int i=1;i <= n;i++){
		if(!mark[i]){
			dfs(i);
			ans++;
		}
	}
	cout << ans - 1;

	return 0;
}

Measured memory_bytes: 9668
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int main() {	
	int a, b;
	cin >> a >> b;
	b--;
	cout << a - b << endl;
}


Measured memory_bytes: 256
lunlunnum = []
def lunlun(n):
    if n >= 10000000000:
        return
    lunlunnum.append(n)
    d = n%10
    if d == 0:
        next_d = [0, 1]
    elif d == 9:
        next_d = [8, 9]
    else:
        next_d = [d-1, d, d+1]
    for i in next_d:
        lunlun(n*10 + i)
for i in range(1, 10):
    lunlun(i)
lunlunnum.sort()
k = int(input())
print(lunlunnum[k-1])

Measured memory_bytes: 12296
#include<bits/stdc++.h>
using namespace std;
int main(){
    string N;
    cin>>N;
    if( (N[0]==N[1]&&N[1]==N[2]) || (N[1]==N[2]&&N[2]==N[3]) )
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3608
-- String - Shuffle

import Control.Monad

main :: IO ()
main = do
  cs <- getLine
  when (cs /= "-") $ do
    m <- readLn
    hs <- replicateM m getLine
    putStrLn $ foldl shuffle cs $ map read $ hs
    main

shuffle :: String -> Int -> String
shuffle cs h = bs ++ as
  where (as, bs) = splitAt h cs



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(rall(a));
  cout << a[0] * 10 + a[1] + a[2] << endl;
}


Measured memory_bytes: 256
n, x = gets.chomp.split.map(&:to_i)
m = []
n.times do
  m << gets.chomp.to_i
end
ans = n

sum = m.inject{|i, j| i + j}
x -= sum
m.sort!
m.each do |k|
  break if x < k
  loop do
    if x >= k
      x -= k
      ans += 1
    else
      break
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  REP(i, h) {
    REP(j, w) {

      if (i < b && j < a || i >= b && j >= a) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
//
// Created on 2020/02/22.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int ans;
    int n;
    int r;
    cin>>n>>r;
    if(n>=10){
        ans = r;
    }else{
        ans = 100*(10-n) + r;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main () {
    string up,dow;
    int count=0;
    cin>>up>>dow;
    for(int i=0;i<up.size();i++){
        if(up[i]==dow[up.size()-1-i]){
            count++;
        }
    }
    if(count==up.size()){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
int n,a,b,c,d;
int main(){
	a=read(),b=read(),c=read(),d=read();
	n=read();
	b=min(b,a*2);
	c=min(c,b*2);
	d=min(d,c*2);
	LL ans=(LL)(n>>1)*d+(n&1)*c;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000

int main()
{
  int n, i, a[N];
  long min, max, sum=0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
    sum += a[i];
  }

  min = a[0];
  max = a[0];

  for(i = 1; i < n; i++){
    if(min > a[i]) min = a[i];
    if(max < a[i]) max = a[i];
  }

  printf("%ld %ld %ld\n", min, max, sum);

  return 0;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

int main(){
	fast;
    string s1,s2;
    cin>>s1>>s2;
    int l=s2.length();
    int ans=INT_MAX;
    for(int i=0;i+l<=s1.length();i++)
    {
        int cnt=0;
        for(int j=0;j<l;j++)
            if(s1[i+j]!=s2[j])
                cnt++;
        ans=min(ans,cnt);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

#define PI 3.14159265359


using namespace std;
int main()
{
    int n;
    cin >> n;
    long min = 0;
    long max = 0;
    long sum = 0;
    for(int i=0;i<n;i++){
        long a;
        cin >> a;
        if(min > a || i == 0) min = a;
        if(max < a || i == 0) max = a;
        sum += a;

    }

    cout << min << " " << max << " " <<  sum << endl;

    return 0;
}



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

#define MAX_N 100000
#define MAX_V 100000

int x[MAX_N];
std::map<int, int> eCount, oCount;

int main() {
  int n;

  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    std::cin >> x[i];
    if(i % 2 == 0) {
      ++eCount[x[i]];
    }
    else {
      ++oCount[x[i]];
    }
  }

  int e1 = 0, e2 = 0, o1 = 0, o2 = 0;
  for(auto p : eCount) {
    if(eCount[e1] < p.second) {
      e2 = e1;
      e1 = p.first;
    } else if(eCount[e2] < p.second) {
      e2 = p.first;
    }
  }
  for(auto p : oCount) {
    if(oCount[o1] < p.second) {
      o2 = o1;
      o1 = p.first;
    } else if(oCount[o2] < p.second) {
      o2 = p.first;
    }
  }

  int ans = 0, ans1 = 0, ans2 = 0;
  if(e1 != o1) {
    for(int i = 0; i < n; ++i) {
      if(i % 2 == 0 && x[i] != e1) ++ans;
      if(i % 2 != 0 && x[i] != o1) ++ans;
    }
  } else {
    for(int i = 0; i < n; ++i) {
      if(i % 2 == 0 && x[i] != e1) ++ans1;
      if(i % 2 == 0 && x[i] != e2) ++ans2;
      if(i % 2 != 0 && x[i] != o2) ++ans1;
      if(i % 2 != 0 && x[i] != o1) ++ans2;
    }
    ans = std::min(ans1, ans2);
  }

  std::cout << ans << std::endl;
}

Measured memory_bytes: 5376
#include<algorithm>
#include<iostream>
#include<cstdio>
#define MN 200000
#define N 262144
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,K,T[N*2+5];long long s[MN+5],L[MN+5],ans;
inline void Renew(int x,int k){for(T[x+=N]+=k;x>>=1;)T[x]=T[x<<1]+T[x<<1|1];}
inline int Query(int l,int r)
{
	int res=0;
	for(l+=N-1,r+=N+1;l^r^1;l>>=1,r>>=1)
	{
		if(~l&1) res+=T[l+1];
		if( r&1) res+=T[r-1];	
 	}
 	return res;
}
int main()
{
	n=read();K=read();
	for(int i=1;i<=n;++i) s[i]=s[i-1]+read()-K,L[i]=s[i-1];
	sort(L+1,L+n+1);int num=unique(L+1,L+n+1)-L-1;
	for(int i=1;i<=n;++i)
	{
		Renew(lower_bound(L+1,L+num+1,s[i-1])-L,1);
		int p=upper_bound(L+1,L+num+1,s[i])-L-1;
		if(p) ans+=Query(1,p);
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>sum(n+2);
	sum[0] = 2;
	sum[1] = 1;
	for (int i = 2; i <= n; i++) {
		sum[i] = sum[i - 1] + sum[i - 2];
	}
	cout << sum[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int MOD = 1000000007;

int N;
string S1, S2;

int memo[56][4][4];
int go(int n, int c1, int c2) {
   if (n >= N)
      return 1;
   int& res = memo[n][c1][c2];
   if (res < 0) {
      res = 0;
      if (S1[n] != S2[n]) {
         FOR(nc1, 1, 3) {
            if (nc1 == c1) continue;
            FOR(nc2, 1, 3) {
               if (nc2 == c2) continue;
               if (nc1 == nc2) continue;
               res += go(n+2, nc1, nc2);
               if (res >= MOD)
                  res -= MOD;
            }
         }
      }
      else {
         FOR(nc, 1, 3) {
            if (nc == c1 || nc == c2) continue;
            res += go(n+1, nc, nc);
            if (res >= MOD)
               res -= MOD;
         }
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);

   cin >> N;
   cin >> S1 >> S2;
   memset(memo, -1, sizeof(memo));
   int res = go(0, 0, 0);
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 256
import itertools

n,q=map(int,input().split())
s=input()
lst=[0]*(n-1)

for i in range(n-1):
  if s[i:i+2]=='AC':
    lst[i]+=1
    
lst=list(itertools.accumulate(lst))
lst=[0]+lst

for i in range(q):
  s,t=map(int,input().split())
  print(lst[t-1]-lst[s-1])

Measured memory_bytes: 80884
// inputに入力データ全体が入る
function Main(input) {

  var inp = input.split('\n');
  var N = inp[0];
  var tmp = inp[1].split(' ');
  var tmp2 = inp[2].split(' ');
  var A = new Array;
  A[0] = new Array;
  A[1] = new Array;

  for (var j = 0; j < N; j++) {
    A[0][j] = parseInt(tmp[j]);
    A[1][j] = parseInt(tmp2[j]);
  }


  var maxVal = 0;
  for (var tmp = 0; tmp <= N - 1; tmp++) {
    var sum = 0;
    for (var l = 0; l <= N - 1 - tmp; l++) {
      sum += A[0][l];
    }
    for (var m = N - 1 - tmp; m <= N - 1; m++) {
      sum += A[1][m];
    }
    if (sum > maxVal) maxVal = sum;
  }
  console.log('%d', maxVal);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll N; cin>>N;
  ll a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
    a[i] -= (i+1);
  }
  sort(a,a+N);
  ll m;
  if(N%2==1){
    m = a[N/2];
  }else{
    ll temp = a[N/2-1]+a[N/2];
    if(temp%2==0){ m = temp/2;}
    else{ m = round((ld)temp/2);}
  }
  ll r = 0;
  REP(i,N){
    r += abs(a[i]-m);
  }
  cout << r;
}


Measured memory_bytes: 1792
s = gets.strip.chars
e = ""
for i in 0..s.size-1
  if s[i] == "1"
    e += "1"
  elsif s[i] == "0"
    e += "0"
  else
    if e.size > 1
      e = e[0..e.size-2]
    elsif e.size == 1
      e = ""
    end
  end
end
puts e

Measured memory_bytes: 14332
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int l=s.size();
    if(l==2){
        if(s[0]==s[1]){
            cout<<"1 2"<<endl;
            return 0;
        }
        else{
            cout<<"-1 -1"<<endl;
            return 0;
        }
    }
    for(int i=0;i<l-2;i++){
        string t=s.substr(i,3);
        sort(All(t));
        if(t[0]==t[1]||t[1]==t[2]){
            cout<<i+1<<' '<<i+3<<endl;
            return 0;
        }
    }
    cout<<"-1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
		  while(true)
		  {
		  var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		  if(a[0]==0&&a[1]==0)
		  break;
		  Array.Sort(a);
		  Console.WriteLine("{0} {1}",a[0],a[1]);
	  }
		}
	 }
 }

      
      

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

int main(){
  int i,j,pn,dou;
  char snake[1000];
  fgets(snake,1000,stdin);
  pn=atoi(snake);
   for(i=0;i<pn;i++){
    fgets(snake,1000,stdin);
    if(snake[0]=='>'){
      if(snake[1]=='\''){
	if(snake[2]=='='){
	  j=3;
	  while(snake[j]!='\n'){
	    if(snake[j]=='#') break;
	    if(snake[j]!='=') break;
	    j++;
	  }
	  if(snake[j]=='#'){
	    dou=j-2;
	    j++;
	    if(snake[j]=='='){
	      while(snake[j]!='\n'){
		if(snake[j]=='~') break;
		if(snake[j]!='=') break;
		dou--;
		j++;
	      }
	      if(!dou&&snake[j]=='~'){
		if(snake[j+1]=='\n'){
		  printf("A\n");
		  goto find;
		}
	      }
	    }
	  }	      
	}
      }else if(snake[1]=='^'){
	if(snake[2]=='Q'&&snake[3]=='='){
	  j=4;
	  while(snake[j]!='\n'){
	    if(snake[j]=='~'&&snake[j+1]=='~'&&snake[j+2]=='\n'){
	      printf("B\n");
	      goto find;
	    }
	    if(snake[j]!='Q'||snake[j+1]!='=') break;
	    j+=2;
	  }
	}
      }
    }
    printf("NA\n");
   find:;
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
A, B = [], []
for _ in range(N):
    ai, bi = map(int, input().split())
    A.append(ai)
    B.append(bi)
AB = sorted(list(zip(A, B)))

count = len(AB)

# 先頭
count += AB[0][0] - 1

for i in range(N - 1):
    # i と j の間に何人入れられるか
    if AB[i + 1][0] > AB[i][0] + 1:
        count += AB[i + 1][0] - AB[i][0] - 1

# 末尾 (0点以上なので)
count += AB[-1][1] - 0

print(count)

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

int main(){
    ll a,b,c;
    string ans;
    cin >> a >> b >> c;
    ll x = c-a-b;
    if(x<0){
        ans = "No";
    }
    else{
        if(4*a*b < x*x) ans="Yes";
        else ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ANovember30 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
      if (m1 != m2) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
};

signed main() {
  ANovember30 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main () {
    long n,i,j,max=-10000000,min=10000000,sum=0;
    long k[100000];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>k[i];
        if(max<k[i]){
            max=k[i];
        }
        if(min>k[i]){
            min=k[i];
        }
        sum+=k[i];
    }
    printf("%d %d %ld\n",min,max,sum);
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w; cin >> h >> w;
    map<char,int> mp;
    rep(i,h)rep(j,w) {
        char x; cin >> x;
        mp[x]++;
    }
    bool ok = false;
    if (h&1 && w&1) {
        int ct_4 = 0;
        for (P p : mp) {
            ct_4 += p.second / 4;
            mp[p.first] = p.second % 4;
        }
        int ct_2 = 0;
        for (P p : mp) {
            ct_2 += p.second / 2;
            mp[p.first] = p.second % 2;
        }
        if (ct_4 >= (h/2) * (w/2)) {
            ct_2 += (ct_4 - ((h/2) * (w/2))) * 2;
            if (ct_2 == h/2 + w/2) ok = true;
        }
    } else if (!(h&1) && !(w&1)) {
        int ct_4 = 0;
        for (P p : mp) ct_4 += p.second / 4;
        if (ct_4 == (h/2) * (w/2)) ok = true;
    } else {
        int ct_4 = 0;
        for (P p : mp) {
            ct_4 += p.second / 4;
            mp[p.first] = p.second % 4;
        }
        int ct_2 = 0;
        for (P p : mp) ct_2 += p.second / 2;
        if (ct_4 >= (h/2) * (w/2)) {
            ct_2 += (ct_4 - (h/2) * (w/2)) * 2;
            if (w&1 && ct_2 == h/2) ok = true;
            if (h&1 && ct_2 == w/2) ok = true;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit(0)
arr = list(map(int, input().split()))

diff = 0
while(True):
    if not x - diff in arr:
        print(x - diff)
        exit(0)
    if not x + diff in arr:
        print(x + diff)
        exit(0)
    diff += 1

Measured memory_bytes: 9152
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
		
	int a;
	string s;
	cin >> a >> s;
	cout << ((a < 3200) ? "red" : s);

	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  int no[100];
  int sp;
} ST;

void st(ST *s);
void in(ST *s,int n);
int out(ST *s);

main(){
  int n,i;
  ST s;
  st(&s);

  while(scanf("%d",&n)!=EOF){

    if(n==0 && s.sp>0) printf("%d\n",out(&s));

    else if(n!=0) in(&s,n);
  }

  return 0;
}

void st(ST *s){
  s->sp=0;
}

void in(ST *s,int n){
  s->no[s->sp]=n;
  s->sp++;
}

int out(ST *s){
  s->sp--;
  return(s->no[s->sp]);
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    int a,b,c;
    cin >> a >> b >> c;
    
    
    //処理
    
    //出力
    
    cout << max(max(a,b),c)*9 + a+b+c << ENT;
    return 0;
}

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


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var app bool
	app = true

	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if a % 2 == 0 {
			if !(a % 3 == 0 || a % 5 == 0) {
				app = false
				break
			} 
		}
	}

	if app {
		fmt.Println("APPROVED")
	} else {
		fmt.Println("DENIED")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
int c[101][101];/*???i????????????????????\?????????c[i][j]???;j=0??????i????????????????????°*/

int chain(int e,int l,int done[]){
    int i,j;
    int lmax = l,ltemp;
    if(c[e][0]){
        for(j=1;j<=c[e][0];j++){
            if(done[c[e][j]]){
                done[c[e][j]] = 0;
                ltemp = chain(c[e][j],l+1,done);
                done[c[e][j]] = 1;
                if(ltemp>lmax)lmax = ltemp;
            }
        }
        return lmax;
    }else{
        return l;
    }
}
int main(){
    int n,ans,temp;
    int done[101];/*i???????????¨??? c[i]=1,i=0??????i???max???*/
    int a,b;
    int i,j;
    scanf("%d",&n);
    while(n){
        /*?????????*/
        for(i=0;i<=100;i++){
            done[i] = 0;
            for(j=0;j<=100;j++){
                c[i][j] = 0;
            }
        }
        /*?????????????????????*/
        for(i=0;i<n;i++){
            scanf("%d %d",&a,&b);
            done[a] = done[b] = 1;
            c[a][0]++;
            c[b][0]++;
            c[a][c[a][0]] = b;
            c[b][c[b][0]] = a;
            if(done[0]<a)done[0] = a;
            if(done[0]<b)done[0] = b;
        }
        /*?¢??????¨*/
        /*printf("lim: %d\n",done[0]);
        for(i=1;i<=done[0];i++){
            if(c[i][0]){
                printf("%d is connected with ",i);
                for(j=1;j<=c[i][0];j++)printf("%d,",c[i][j]);
                printf("\n");
            }
        }*/
        ans = 0;
        /*?§????????±???????????????????????±???????*/
        for(i=1;i<=100;i++){
            if(done[i]){
                done[i] = 0;
                temp = chain(i,1,done);
                done[i] = 1;
                if(ans<temp)ans = temp;
            }
        }
        printf("%d\n",ans);
        scanf("%d",&n);
    }
}

Measured memory_bytes: 1068
N = int(input())
X = []
X = list(map(int,input().split()))	
#print(X)
M = max(X)
A = []
ans = 0
for j in reversed(range(1,M+1)):    
    for i in X:
        #print(j,i)
        #print((i-j)*(i-j))
        ans += (i-j)*(i-j)
        #print(ans)
    #print(ans)
    A.append(ans)
    ans = 0
print(min(A))
    

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int num,i,j,in1,in2,mem;
  int g[100][100];
  
  scanf("%d",&num);

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      g[i][j]=0;
    }
  }

  for(i=0;i<num;i++){
    scanf("%d%d",&in1,&in2);
    in1--;
    for(j=0;j<in2;j++){
      scanf("%d",&mem);
      mem--;
      g[in1][mem]=1;
    }
    
  }

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      printf("%d",g[i][j]);
      if(j<num-1)printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2148
#import sys
#input = sys.stdin.readline
M = 10**9+7
n = int(input())
l = list(map(int,input().split()))
o = [0]*61
z = [0]*61
for i in l:
    a = bin(i)[2:]
    j = 0
    while(j < len(a)):
        if a[j] == "1":
            o[len(a)-j-1] += 1

        j += 1

cnt = 0
b = 1
for j in range(len(o)):
    cnt = (cnt+(o[j]*(n-o[j])*b)%M)%M
    b *= 2

print(cnt)


Measured memory_bytes: 115840
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	A.sort()
	l = A[-1]
	p = [1] * l
	for i in range(len(A)):
		a = A[i]
		if p[a-1] == 1:
			p[a-1] = 2
			for j in range(2 * a - 1, l, a):
				p[j] = 0
		elif p[a-1] == 2:
			p[a-1] = 0
	print(len([x for x in A if p[x - 1] in [1, 2]]))

main()

Measured memory_bytes: 32024
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b,c;cin>>a>>b>>c;
  ll k;cin>>k;
  while(a>=b)b*=2,res++;
  while(b>=c)c*=2,res++;
  ans1(res<=k);
  return 0;
}

Measured memory_bytes: 3648