akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n;cin >> n;
    ll k = n%10;
    if(k==2 || k==4 || k==5 || k==7 || k==9)
        cout << "hon" << endl;
    else if(k==0 || k==1 || k==6 || k==8)
        cout << "pon" << endl;
    else if(k==3)
        cout << "bon" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#define N 3

using namespace std;

int main(){
  int i, j, k;
  string s;
  char win, c[N][N];

  while(cin >> s){
    k=0;
    for(i=0; i<N; i++){
      for(j=0; j<N; j++){
	c[i][j] = s[k];
	k++;
      }
    }

    win = 'd';

    for(i=0; i<3; i++){
      if(c[i][0] == c[i][1] && c[i][0] == c[i][2] && c[i][0] != 's')
        win = c[i][0];
      if(c[0][i] == c[1][i] && c[0][i] == c[2][i] && c[0][i] != 's')
        win = c[0][i];
    }

    if(c[0][0] == c[1][1] && c[0][0] == c[2][2] && c[0][0] != 's')
      win = c[0][0];
    if(c[0][2] == c[1][1] && c[0][2] == c[2][0] && c[0][2] != 's')
      win = c[0][2];

    cout << win << endl;

  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin>>N;
  int a[N];
  for (int i=0; i<N; i++) {
    cin>>a[i];
  }
  int b[N];
  for (int i=0; i<N; i++) {
    cin>>b[i];
  }
  ll ans=0;
  for (ll bit=0; bit<30; bit++) {
    ll cnt=0;
    ll T=1ll<<bit;
    int A[N],B[N];
    for (int i=0; i<N; i++) {
      A[i]=a[i]%(2*T);
      B[i]=b[i]%(2*T);
    }
    sort(B,B+N);
    for (int i=0; i<N; i++) {
      cnt+=lower_bound(B,B+N,2*T-A[i])-lower_bound(B,B+N,T-A[i]);
      cnt+=lower_bound(B,B+N,4*T-A[i])-lower_bound(B,B+N,3*T-A[i]);
    }
    ans+=(cnt%2)*T;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    long long a,b;
    cin >> a >> b;
    for (long long i = 0; i < b; i++) {
        long long ans = 1;
        for (long long j = 0; j < i; j++) {
            ans *= b-1-j;
            ans %= 1000000007;
        }
        for (long long j = 0; j < i; j++) {
            ans *= modinv(j+1,1000000007);
            ans %= 1000000007;
        }
        for (long long j = 0; j < i+1; j++) {
            ans *= a-b+1-j;
            ans %= 1000000007;
        }
        for (long long j = 0; j < i+1; j++) {
            ans *= modinv(j + 1, 1000000007);
            ans %= 1000000007;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
// HardWork And Faliures will Collide,
// But There is nothing more stronger then You and I.

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define mp make_pair
#define sz(a) ((int)(a).size())
#define mem(x,v) memset((x),(v),sizeof((x)));
#define A(x) (x).begin(),(x).end()
#define re(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define erp(i,k,n) for(int i=n;i>=k;i--)
#define input(v,n) re(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using vvi = vector<vi>;
using tp = tuple<int,int,int>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
// ===================== MANASH =================== //

int n;

void test() {

      string s;
      cin >> s;
      string p = "RRR";
      while(sz(p) and s.find(p) == string :: npos) {
            p.pop_back();
      }
      cout << sz(p);
}

signed main() {

      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
      int T = 1;
      //cin >> T;
      for( int tt = 1; tt <= T; tt++) {
            //cout << "Case #" << tt << " ";
            test();
            cout << "\n";
      }
      return 0;

}

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

typedef long long int ll;

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

    ll N, i, j, inp, price, sold = 0;
    vector<ll> A;

    cin >> N;
    for(i = 0; i < N; i++) {
        cin >> inp;
        A.push_back(inp);
    }

    sold = A[0] - 1;
    A[0] = 1;
    price = 2;

    for (i = 0; i < N; i++) {
        if (A[i] == price) {
            price += 1;
        }
        else if (A[i] > price) {
            sold += (A[i]-1)/price;
            A[i] = price-1;
        }
    }
    cout << sold << '\n' ;
    
    return 0;
}


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

// ----------- define ---------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getbit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(), (x).end()
// ----------------------------------

const int N = 100005;

vector<ii> adj[N];
int color[N];

void dfs(int i, int p, int c) {
  color[i] = c;
  for (auto &j : adj[i]) {
    if (j.fi != p) {
      dfs(j.fi, i, c ^ (j.sc % 2));
    }
  }
}

void MAIN() {
  int n; cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back(ii(v, w));
    adj[v].push_back(ii(u, w));
  }
  dfs(1, 1, 1);
  for (int i = 1; i <= n; i++) {
    cout << color[i] << '\n';
  }
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 13368
from bisect import bisect_left
n, m = map(int, input().split())
import math
import numpy as np
import decimal
import collections
import itertools
import sys
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x, y):
    p = find(x)
    q = find(y)
    if p == q:
        return None
    if p > q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p
def same(x, y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]
par = [-1 for i in range(n)]
def prime_numbers(x):
    if x < 2:
        return []
    prime_numbers = [i for i in range(x)]
    prime_numbers[1] = 0
    for prime_number in prime_numbers:
        if prime_number > math.sqrt(x):
            break
        if prime_number == 0:
            continue
        for composite_number in range(2 * prime_number, x, prime_number):
            prime_numbers[composite_number] = 0
    return [prime_number for prime_number in prime_numbers if prime_number != 0]
def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= math.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
BIT = [0] * (n + 1)
def add(i, x):
    while i <= n:
        BIT[i] += x
        i += i & -i
def query(i):
    s = 0
    while i > 0:
        s += BIT[i]
        i -= i & -i
    return s
a = list(map(int, input().split()))
a.sort(reverse=True)
l, r = 0, 10 ** 6
while r - l > 1:
    m2 = (l + r) // 2
    cnt = 0
    ind = n - 1
    for i in a:
        while ind >= 0 and a[ind] + i < m2:
            ind -= 1
        cnt += ind + 1
    if cnt >= m:
        l = m2
    else:
        r = m2
cum = [0]
for i in a:
    cum.append(cum[-1] + i)
ans = 0
cnt2 = 0
ind2 = n - 1
b = l
for i in a:
    while ind2 >= 0 and a[ind2] + i < b:
        ind2 -= 1
    cnt2 += ind2 + 1
    ans += (ind2 + 1) * i + cum[ind2 + 1]
print(ans - (cnt2 - m) * b)

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

int main() {
  double n, k;
  cin >> n >> k;
  double total = 0;
  for (int i = 1; i <= n; i++) {
    double t = i;
    int cnt = 0;
    while (t < k) {
      t *= 2;
      cnt++;
    }
    double now = (double)(1 / n);
    now *= (double)pow(0.5, cnt);
    total += now;
  }
  printf("%.10f\n", total);
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long n;
    cin>>n;
    
    vector<long> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }
    
    long ans=0;
    for(int i=0;i<n-2;i++){
        vector<long> pre(3);
        for(int j=0;j<3;j++) pre.at(j)=p.at(i+j);
        sort(pre.begin(),pre.end());
        
        if(pre.at(1)==p.at(i+1)) ans++;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if ((x+r)<=W&&(y+r)<=H&&(x-r)>=0&&(y-r)>=0){

		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

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

string s, t;

int main() {
  cin >> s >> t;
  int count;
  vector<int> l;
  for (int i=0;i<t.size();i++) {
    if (s.at(i) != t.at(i)) {
      //cout << s.at(i) << t.at(i) << endl;
      l.push_back(1);
    } 
  }
  cout << l.size() << endl;
}

Measured memory_bytes: 4632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
main()
{
	char s[100] = {0};
	char p[100] = {0};
	char r[200] = {0};
	scanf("%s", s);
	scanf("%s", p);

	strcpy(r, s);
	strcat(r, s);
	puts(strstr(r, p) != NULL ? "Yes" : "No");

	return 0;
}

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

using namespace std;
int main() {
    long long A,B;
    long long tmpA,tmpB;
    cin >> A >> B;
    if(A != 0)
    A--;
    if(A % 2 == 1){
        long long tmp = (A - 1) / 2;
        if(tmp % 2 == 1){
            tmpA  = 1;
        }else{
            tmpA = 0;
        }

    }else{
        long long tmp = A / 2;
        if(tmp % 2 == 1){
            tmpA  = A ^ 0;
        }else{
            tmpA = A ^ 1;
        }
    }
    if(B % 2 == 1){
        long long tmp = (B - 1) / 2;
        if(tmp % 2 == 1){
            tmpB  = 1;
        }else{
            tmpB = 0;
        }

    }else{
        long long tmp = B / 2;
        if(tmp % 2 == 1){
            tmpB  = B ^ 0;
        }else{
            tmpB = B ^ 1;
        }
    }

    cout << (long long)(tmpA ^ tmpB) << endl;

}

Measured memory_bytes: 256
import sys

n, x = map(int, raw_input().split())

if x == 1 or x == 2*n - 1:
    print "No"
else:
    print "Yes"
    if n == 2:
        for i in range(3):
            print i+1
        sys.exit()
    if x > (2*n - 1)/2 + 1:
        core = [x-2, x, x+1, x-1]
    else:
        core = [x+1, x, x-1, x+2]

    lst = [i+1 for i in range(2*n - 1) if i+1 not in core]
    ans = []
    for i in range((2*n - 1)/2 - 2):
        ans.append(lst.pop())
    ans.extend(core)
    ans.extend(lst)
    for a in ans:
        print a


Measured memory_bytes: 17508
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

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

int main() {
    int a, b, c;
    char ch;
    int rect = 0;
    int dia = 0;
    while(cin >> a >> ch >> b >> ch >> c) {
        if (a*a + b*b == c*c) rect++;
        else if (a == b) dia++;
    }
    cout << rect << endl << dia << endl;
    return 0;
}

Measured memory_bytes: 1160
// Copyright 2015 KanatoNagayama
#include <iostream>
using std :: cout;
using std :: cin;
using std :: endl;
int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(x + r > W || x - r < 0 || y + r > H || y - r < 0)
   cout <<  "No" << endl;
  else 
   cout <<  "Yes" << endl;
 return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (long int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

long int ma(long int x,long int y){
    if (x>y) return x;
    else return y;
}

long int mi(long int x,long int y){
    if (x<y) return x;
    else return y;
}


int main(){
    long int N,K;
    cin>>N>>K;
    vector<long int> A(N);
    rep(i,N) cin>>A[i];
    rep(i,mi(K,200)){
        vector<long int> vl(N,0),vr(N,0);
        rep(j,N){
            vl[ma(0,j-A[j])]=vl[ma(0,j-A[j])]+1;
            vr[mi(j+A[j],N-1)]=vr[mi(j+A[j],N-1)]+1;
        }
        A[0]=vl[0];
        for(long int j=1;j<N;j++){
            A[j]=A[j-1]+vl[j]-vr[j-1];
        }
    }
    rep(i,N) cout<<A[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 7920
import java.util.Scanner;
class Main {
  public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int [] a=new int[n];
for(int i=0;i<n;i++) {
	 a[i]=sc.nextInt();
}
for(int o=n-1;o>=0;o--) {
	if(o==0) {
		System.out.println(a[o]);
	}
	else {
		System.out.print(a[o]+" ");
	}
}
sc.close();
  }
}






Measured memory_bytes: 26420
#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>

struct Point
{
    float x;
    float y;
};
struct Line
{
    Line(const Point& a, const Point& b)
    : p1(a), p2(b) {}
    Point p1;
    Point p2;
};
double GetSlope(const Line& line)
{
    return
    (line.p2.y - line.p1.y) /
    (line.p2.x - line.p1.x);
}
bool IsParallel(const Line& l1, const Line&l2)
{
    // std::cerr << std::fixed << std::setprecision(100) << GetSlope(l1) << std::endl;
    // std::cerr << std::fixed << std::setprecision(100) << GetSlope(l2) << std::endl;
    return GetSlope(l1) == GetSlope(l2);
    // const double gosa = 1e-10;
    // double Slope1 = GetSlope(l1);
    // double Slope2 = GetSlope(l2);
    // return std::fabs(Slope1 - Slope2) < gosa;
}
bool IsParallel(const std::vector<Point>& points)
{
    assert(points.size() == 4);
    return IsParallel(Line(points[0], points[1]), Line(points[2], points[3]));
}
std::vector<Point> Input(std::istream& is)
{
    std::vector<Point> points(4);
    for(int i = 0; i < points.size(); ++i){
        is >> points[i].x >> points[i].y;
    }
    return points;
}
int main()
{
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i) {
        std::vector<Point> p = Input(std::cin);
        // std::cout << (IsParallel(p) ? "YES" : "NO") << std::endl; 
        if((p[1].y-p[0].y)/(p[1].x-p[0].x) == (p[3].y-p[2].y)/(p[3].x-p[2].x)){
            std::cout << "YES";
        }else{
            std::cout << "NO";
        }
        std::cout << std::endl;
    }
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>>a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  vector<vector<char>>b(H+2, vector<char>(W+2));
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      b.at(i).at(j) = '#';
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      b.at(i+1).at(j+1) = a.at(i).at(j);
    }
  }
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      cout << b.at(i).at(j);
      if (j == W+1) {
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256
n, t = gets.chomp.split(" ").map(&:to_i)
max = t
keiro = 10001
n.times do |i|
    c, t = gets.chomp.split(" ").map(&:to_i)
    if max >= t
        keiro = [keiro,c].min
    end
end
if keiro == 10001
    puts "TLE"
else
    puts keiro
end

Measured memory_bytes: 14152
<?php
list($N,$H,$W) = explode(" ",trim(fgets(STDIN)));
$ans = 0;
for($i=0;$i<$N;$i++){
list($A,$B) = explode(" ",trim(fgets(STDIN)));
if($A>=$H && $B >= $W){
$ans++;
}
}
echo $ans;


Measured memory_bytes: 3828
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()

    ans_list = deque()

    for i, num in enumerate(num_list):
        if i % 2 == 0:
            ans_list.append(num)
        else:
            ans_list.appendleft(num)

    if n % 2 == 0:
        print(*ans_list)
    else:
        tmp_list = []
        for ans in ans_list:
            tmp_list.append(ans)
        print(*tmp_list[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 124328
n = int(input())
word = []
for i in range(n):
	word.append(input())

if len(word) != len(set(word)):
	print("No")
	exit()

for i in range(1,len(word)):
	if word[i-1][-1] != word[i][0]:
		print("No")
		exit()

print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
using namespace std;

int main(){
	int n,m;
	cin >> n;
	list<int> intlist;
	list<int>::iterator it = intlist.begin();
	string str;
	
	for(int i = 0; i < n; i++){
		cin >> str;
		if(str == "deleteFirst"){
			intlist.pop_front();
			continue;
		}
		if(str == "deleteLast"){
			intlist.pop_back();
			continue;
		}
		cin >> m;
		if(str == "insert"){
			intlist.push_front(m);
		}
		if(str == "delete"){
			it = find(intlist.begin(),intlist.end(),m);
			if( it != intlist.end()) intlist.erase(it);
		}
	}

	it = intlist.begin();
	while(it != intlist.end()){
		if(it != intlist.begin()) cout << " ";
		cout << *it;
		++it;
	}
	cout << endl;
	return 0;
}		

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

#define         ull             unsigned long long
#define         ll              long long
#define         pi              acos(-1.0)
#define         asort(arr,n)    sort(arr,arr+n); ///int arr[100000],n;cin>>n;for(int i=0; i<n; i++){ cin>>arr[i];} asort(arr,n);
#define         dsort(arr,n)    sort(arr, arr+n, greater<int>());   ///int arr[100000],n;cin>>n;for(int i=0; i<n; i++){ cin>>arr[i];} dsort(arr,n);
#define         faster()        ios::sync_with_stdio(false);cin.tie(0);


#define         min3(a,b,c)     min(a,min(b,c))
#define         max3(a,b,c)     max(a,max(b,c))
#define         min4(a,b,c,d)   min(min(a,b),min(c,d))
#define         max4(a,b,c,d)   max(max(a,b),max(c,d))
#define         max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define         min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))


using namespace std;
int main()
{
    faster()
    int n,a,b,c,d;
    cin>>n;
    if(1000 <= n && n<=9999)
    {
        a = n % 10;
        b = n / 10 % 10;
        c = n / 100 % 10;
        d = n / 1000 % 10;
        if((a == b && b == c) || (b == c && c ==d ) || (a == b && b == c && c==d))
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


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

#define N 100005
int n, k;
int a[N], b[N];

int main() {
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	int mask = 0;
	long long best = 0;
	for(int i = 30; i >= 0; i--){
		if(((k + 1) & (1 << i)) == 0){
			mask |= (1 << i);
		} else{
			int cur_mask = mask | (1 << i);
			long long cur_best = 0;
			for(int j = 0; j < n; j++){
				if((a[j] & cur_mask) == 0){
					cur_best += b[j];
				}
			}
			best = max(best, cur_best);
		}
	}
	cout << best << '\n';
	return 0;
}

Measured memory_bytes: 1532
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, D;
  cin >> N >> D;
  
  vector<vector<int>> points(N);
  for (size_t n = 0; n < N; ++n) {
    points[n].reserve(D);
    for (size_t d = 0; d < D; ++d) {
      int num;
      cin >> num;
      points[n].push_back(num);
    }
  }
  int res = 0;
  for (size_t i = 0; i < N - 1; ++i) {
    vector<int>& p1 = points[i];
    long sum = 0;
    for (size_t j = i + 1; j < N; ++j) {
      vector<int>& p2 = points[j];
      int diff = 0;
      for (size_t k = 0; k < D; ++k) {
        int val = p1[k] - p2[k];
        diff += val * val;
      }
      double db = sqrt(static_cast<double>(diff));
      if (floor(db) == db && ceil(db) == db) ++res;
    }
  }
  cout << res << endl;
  
  return 0;
}

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

template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

char f(char c, int n){
	if('a' <= c && c <= 'z'){
		if(c - n < 'a'){
			return f('Z', n - c + 'a' - 1);
		}else{
			return c - n;
		}
	}else{
		if(c - n < 'A'){
			return f('z', n - c + 'A' - 1);
		}else{
			return c - n;
		}
	}
}

void solve(int n){
	vector<int> k;
	readVector(n, k);
	string s;
	cin >> s;
	string t = s;
	for(int i=0; i<t.size(); ++i)
		t[i] = f(s[i], k[i%n]);
	cout << t << "\n";
}

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


Measured memory_bytes: 3092
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <utility>
#include <string>

using namespace std;

int main()
{
  int N; cin >> N;
  if (N == 1) {
    cout << 0;
    return 0;
  }

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

  int count = 0;
  int max_count = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (H[i] >= H[i + 1]) {
      ++count;
      if (count > max_count) {
        max_count = count;
      }
    }
    else {
      count = 0;
    }
  }
  cout << max_count;
}

Measured memory_bytes: 640
L=int(input());S=bin(L);N=len(S)-2;print(N,N+N+S.count("1")-3)
for i in range(1,N):
 for j in[0,1]:print(i,-~i,j<<~-i)
 if int(S[-i]):L^=1<<~-i;print(i,N,L)

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

typedef long long ll;
typedef long double ld;
const ll init = 1e9+7;
const ll N = 1e5+7;

#define mkp make_pair
#define pb push_back
#define pq priority_queue
#define minpq priority_queue <int, vector<int>, greater<int> >
#define vi vector <int> 
#define vll vector <ll>
#define pii pair<int,int>

ll dp[N][3];
ll v[N][3];

ll find_dp(int day, int act){
	if(dp[day][act]==-1){
		for (int i = 0; i < 3; ++i){
			if(i==act) continue;
			dp[day][act] = max(dp[day][act],find_dp(day+1,i)+v[day][act]);
		}
	}
	return dp[day][act];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin>>n;
	for (int i = 1; i <= n; ++i){
		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	for (int i = 0; i < N; ++i){
		dp[i][0]=dp[i][1]=dp[i][2]=-1;
	}
	dp[n][0] = v[n][0]; dp[n][1] = v[n][1]; dp[n][2] = v[n][2];
	ll ans = max(find_dp(1,0),max(find_dp(1,1), find_dp(1,2)));
	cout<<ans<<endl;

    return 0;
} 

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<double> x(n),y(n);
  for(int i=0;i<n;i++) cin >> x[i] >> y[i];
  vector<int> a(n);
  for(int i=0;i<n;i++) a[i]=i;
  double ans=0;
  do{
    for(int i=0;i<n-1;i++){
      ans+=sqrt((x[a[i]]-x[a[i+1]])*(x[a[i]]-x[a[i+1]])+(y[a[i]]-y[a[i+1]])*(y[a[i]]-y[a[i+1]]));
    }
  } while(next_permutation (a.begin(),a.end()));
  for(int i=1;i<=n;i++) ans/=(double)i;
  cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
    int n;
    string S;
    cin >> n;
    cin >> S;
    if(n<3)
    {
        cout << 0 << endl;
        return 0;
    }
    ll r, g, b;
    r = b = g = 0;
    for (int i = 0; i < n; i++)
    {
        if(S[i]=='R')
        {
            r++;    
        }
        else if (S[i]=='G')
        {
            g++;
        }
        else if (S[i]=='B')
        {
            b++;
        }
    }
    ll all = r * g * b;

    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i+1; j < n - 1; j++)
        {
            if (S[i] != S[j])
            {
                int a = j - i;
                int k = i + 2 * a;
                if (k >= n)
                {
                    continue;
                }
                else
                {
                    if (S[j] != S[k] && S[k] != S[i])
                    {
                        all--;
                    }
                }
            }
        }
        
    }
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 3628
n = gets.to_i
l = gets.split.map(&:to_i).sort
ans = 0
(1..n-2).each do |i|
  ((i+1)..n-1).each do |j|
    t = l[j]-l[i]
    z = l.bsearch_index{|x| x > t}
    if z && z < i
      ans += i - z
    end
  end
end
puts ans

Measured memory_bytes: 1912
package main

import "fmt"

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

	b, w := 0, 0
	for _, c := range s {
		if c == '.' {
			w++
		}
	}

	ans := b + w
	for _, c := range s {
		switch c {
		case '#':
			b++
		case '.':
			w--
		}
		ans = min(ans, b+w)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1920
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0
for h_p in range(2 ** h):
    for w_p in range(2 ** w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (h_p >> i) & 1 and (w_p >> j) & 1 and c[i][j] == '#':
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    cin >> n;
    ll R[200000];
    ll mn=INT64_MAX, ans=INT64_MIN;

    for(int i=0;i<n;i++){
        cin >> R[i];
        ans=max(ans, R[i]-mn);
        mn=min(mn,R[i]);
    }

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


Measured memory_bytes: 4664
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	}
}

Measured memory_bytes: 99208
#include<iostream>
using namespace std;
int N = 190;

long long pow5(int x) {
	long long a = (long long)x * x;
	return a * a * x;
}

int main() {
	int x;
	long long p5[N];
	for (int i = 0; i < N; i++) p5[i] = pow5(i);
	cin >> x;
	int ans_a, ans_b;
	int flag = 0;
	for (int a = 0; a < N; a++) {
		for (int b = 0; b < N; b++) {
			if (p5[a] + p5[b] == x) {ans_a=a; ans_b=-b; flag=1;}
			if (p5[a] - p5[b] == x) {ans_a=a; ans_b=b; flag=1;}
			if (flag == 1) break;
		}
		if (flag == 1) break;
	}
	cout << ans_a << " " << ans_b << "\n";
	return 0;
}

Measured memory_bytes: 3628
n = int(input())
l = list(map(int, input().split()))

l.sort()
ans1 = l[-1]
ans2 = -1
diff = 1000000000
for i in range(n-1):
    if diff >= abs(l[i] - ans1//2):
        ans2 = l[i]
        diff = abs(l[i] - ans1//2)
print(ans1, ans2)


Measured memory_bytes: 19908
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
	char s[101];
	cin >> s;

	char p[101];
	cin >> p;

	int flag;
	for (int i = 0; i < strlen(s); i++) {
		flag = 1;
		for (int j = 0; j < strlen(p); j++) {
			if (s[(i + j)%strlen(s)] != p[j]) {
				flag = 0;
				break;
			}
		}
		if (flag) {
			break;
		}
	}
	if (flag) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1100
#include<iostream>
#include<string>
#include<algorithm>
auto main ( ) -> int
{
    const std::string table = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
    std::string input ;
    std::getline ( std::cin , input ) ;
    for ( auto ch : input )
    {
        auto find_iter = std::find ( table.begin ( ) , table.end ( ) , ch ) ;
        std::cout.put ( ( find_iter != table.end ( ) ) ? table [ ( find_iter - table.begin ( ) + 26 ) % 52 ] : ch ) ;
    }
    std::cout << std::endl ;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P; typedef queue<P> Q;
int H, W, cntw, scr[52][52]; char s[52][52]; Q q;
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
int main() {
  scanf("%d %d", &H, &W);
  for(int i = 1; i <= H; ++i) {
    scanf("%s", &s[i][1]);
    for(int j = 1; j <= W; ++j) if(s[i][j] == '.') cntw++;
  }
  q.push(make_pair(1, 1));
  while(!q.empty()) {
    P p = q.front(); q.pop();
    int x = p.first, y = p.second;
    for(int i = 0; i < 4; ++i) {
      int tx = x+dx[i], ty = y+dy[i];
      if(scr[tx][ty] != 0 || s[tx][ty] != '.') continue;
      q.push(make_pair(tx, ty));
      scr[tx][ty] = scr[x][y]+1;
    }
  }
  printf("%d\n", scr[H][W]?cntw-scr[H][W]-1:-1);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>A;
    cout<<(A < 1200 ? "ABC" : "ARC")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    if(a+b>c+d)
    cout<<"Left";
    else if(a+b==c+d)
    cout<<"Balanced";
    else
    cout<<"Right";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (i = 0; i < n; i++)
#define P pair<int, int>

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  vector<int> mx(n);
  mx[0] = h[0];
  for (int i = 1; i < n; i++)
  {
    mx[i] = max(mx[i - 1], h[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    if (h[i] == mx[i])
    {
      ans++;
    }
  }

  cout << ans << endl;
}


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

int N, M;
int INF =  10000;
int ans = 0;

int main(){
    cin >> N >> M;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    vector<vector<int>> edges(M, vector<int>(3));
    rep(i, M){
        int a, b, c;
        cin >> a >> b >> c;
      	a -= 1;
      	b -= 1;
        edges[i][0] = a;
        edges[i][1] = b;
        edges[i][2] = c;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k, N){
        rep(i, N){
            rep(j, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
    }

  	rep(i, N){
   		dist[i][i] = 0;
    }
  
    rep(i, M){
        bool flag = false;
        int a = edges[i][0];
        int b = edges[i][1];
        int c = edges[i][2];
        rep(s, N){
            if (flag == true){
            	break;
            }
            rep(t, N){
                if (dist[s][a] + c + dist[b][t] == dist[s][t]){
                	flag = true;
                  	break;
                }
            }
        }
        if (flag == false) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int a,b,t,i;
  while(scanf("%d %d",&a,&b)!=EOF){
    t=a+b;
    i=1;
    while(1){
      t/=10;
      if(t>0)i++;
      else break;
    }
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	static void solver() {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n = sc.nextInt();
			if (n == 0)
				return;
			String[] s = new String[n];
			for (int i = 0; i < n; i++) {
				s[i] = sc.next();
			}
			int bit = (1 << n) - 1;
			boolean[] unvalid = new boolean[n];
			for (int i = 0; i < n; i++) {
				if (((bit >> i) & 1) == 0)
					continue;
				for (int j = 0; j < n; j++) {
					if (i == j)
						continue;
					if (((bit >> j) & 1) == 0)
						continue;
					out: for (int k = 0; k < s[j].length(); k++) {
						if (s[i].length() > s[j].length())
							continue;
						if (k + s[i].length() > s[j].length())
							continue;
						String sj = s[j].substring(k, k + s[i].length());
						if (sj.equals(s[i])) {
							bit = ~((~(bit)) | (1 << i));
							break out;
						}
					}
				}
			}
			memo = new int[1 << n][n];
			for (int i = 0; i < memo.length; i++) {
				for (int j = 0; j < memo[0].length; j++) {
					memo[i][j] = -1;
				}
			}
			int min = Integer.MAX_VALUE/4;
			for (int i = 0; i < n; i++) {
				if (((bit >> i) & 1) == 1) {
					int d = ~((~bit) | (1 << i));
					min = Math.min(min, dp(d, i, n, unvalid, s));
				}
			}
			System.out.println(min);
		}
	}

	static int[][] memo;

	// state:0 indexed num is used
	// 1 indexed num is unused
	// return min value of the lenght of state + tail 
	static int dp(int state, int tail, int n, boolean[] unvalid, String[] s) {
		if (Integer.bitCount(state) == 0)
			return s[tail].length();
		if (memo[state][tail] != -1) {
			return memo[state][tail];
		}
		int min = Integer.MAX_VALUE/4;
		for (int i = 0; i < n; i++) {
			if ((((state >> i) & 1) == 1) && (!unvalid[i])) {
				int bit = ~((~state) | (1 << i));
				min = Math.min(min, dp(bit, i, n, unvalid, s) - same_length(s[i], s[tail]) + s[tail].length());
			}
		}
		memo[state][tail] = min;
		return min;
	}

	static int same_length(String bottom, String tail) {
		int max = 0;
		for (int i = 0; i < bottom.length(); i++) {
			int add = 0;
			while (bottom.charAt(i + add) == tail.charAt(add)) {
				if (i + add == bottom.length() - 1) {
					max = Math.max(add + 1, max);
					break;
				} else if (add == tail.length() - 1) {
					break;
				} else {
					add++;
				}
			}
		}
		return max;
	}

	static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 68464
while num = gets do
  c1, c2, c3 = num.split.map(&:to_i)
  cnt = 0
  for i in 1..10 do
    unless i == c1 || i == c2 || i == c3 then
  	  if c1 + c2 + i <= 20 then
  	    cnt += 1
      end
    end
  end
  if cnt >= 4 then
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 6096
#include <iostream>
#include <string>
#include <set>
#define llint long long

using namespace std;

llint n, m;
set<string> S;

int main(void)
{
	cin >> n;
	string s;
	for(int i = 1; i <= n; i++){
		cin >> s;
		S.insert(s);
	}
	
	cin >> m;
	
	bool flag = true;
	for(int i = 1; i <= m; i++){
		cin >> s;
		if(S.count(s)){
			if(flag) cout << "Opened by " << s << endl;
			else cout << "Closed by " << s << endl;
			flag = !flag;
		}
		else cout << "Unknown " << s << endl;
	}
	
	return 0;
}


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

const int MAXN = 1.1e3;
char ans[MAXN][MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans[i][j] = '.';
		}
	}
	if (N <= 2) {
		cout << -1 << '\n';
		exit(0);
	}
	if (N == 3) {
		cout << ".aa" << '\n';
		cout << "a.." << '\n';
		cout << "a.." << '\n';
		exit(0);
	}

	int v;
	if (N % 4 == 0) {
		v = 0;
	} else if (N % 4 == 1) {
		ans[0][0] = 'a';
		ans[0][1] = 'a';
		ans[0][2] = 'b';
		ans[0][3] = 'b';
		ans[0][4] = 'a';
		ans[1][4] = 'a';
		ans[2][4] = 'b';
		ans[3][4] = 'b';
		ans[4][4] = 'a';
		ans[4][3] = 'a';
		ans[4][2] = 'b';
		ans[4][1] = 'b';
		ans[4][0] = 'a';
		ans[3][0] = 'a';
		ans[2][0] = 'b';
		ans[1][0] = 'b';

		ans[1][2] = 'c';
		ans[1][3] = 'c';

		ans[2][1] = 'c';
		ans[3][1] = 'c';

		v = 5;
	} else if (N % 4 == 2) {
		ans[0][1] = 'a';
		ans[0][2] = 'a';

		ans[1][0] = 'a';
		ans[2][0] = 'a';

		ans[0][3] = 'b';
		ans[0][4] = 'b';
		ans[0][5] = 'c';
		ans[1][5] = 'c';
		ans[2][5] = 'b';
		ans[2][4] = 'b';
		ans[2][3] = 'c';
		ans[1][3] = 'c';

		ans[3][0] = 'b';
		ans[3][1] = 'b';
		ans[3][2] = 'c';
		ans[4][2] = 'c';
		ans[5][2] = 'b';
		ans[5][1] = 'b';
		ans[5][0] = 'c';
		ans[4][0] = 'c';

		ans[3][4] = 'a';
		ans[3][5] = 'a';

		ans[4][3] = 'a';
		ans[5][3] = 'a';
		v = 6;
	} else if (N % 4 == 3) {
		ans[0][0] = 'a';
		ans[0][1] = 'a';
		ans[0][2] = 'b';
		ans[0][3] = 'b';
		ans[1][0] = 'b';
		ans[1][3] = 'z';
		ans[1][4] = 'z';
		ans[2][0] = 'b';
		ans[2][1] = 'a';
		ans[3][1] = 'a';
		ans[3][4] = 'a';
		ans[3][5] = 'a';
		ans[4][2] = 'a';
		ans[4][5] = 'b';
		ans[5][2] = 'a';
		ans[5][5] = 'b';

		ans[0][6] = 'x';
		ans[1][6] = 'x';
		ans[2][6] = 'y';
		ans[3][6] = 'y';
		ans[4][6] = 'z';
		ans[5][6] = 'z';

		ans[6][0] = 'x';
		ans[6][1] = 'x';
		ans[6][2] = 'y';
		ans[6][3] = 'y';
		ans[6][4] = 'z';
		ans[6][5] = 'z';

		v = 7;
	} else assert(false);
	for (; v < N; v += 4) {
		ans[v+0][v+0] = 'a';
		ans[v+0][v+1] = 'a';
		ans[v+1][v+0] = 'b';
		ans[v+1][v+1] = 'b';

		ans[v+2][v+2] = 'a';
		ans[v+2][v+3] = 'a';
		ans[v+3][v+2] = 'b';
		ans[v+3][v+3] = 'b';

		ans[v+0][v+2] = 'c';
		ans[v+0][v+3] = 'd';
		ans[v+1][v+2] = 'c';
		ans[v+1][v+3] = 'd';

		ans[v+2][v+0] = 'c';
		ans[v+2][v+1] = 'd';
		ans[v+3][v+0] = 'c';
		ans[v+3][v+1] = 'd';
	}
	assert(v == N);

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

	return 0;
}


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

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var n = int.Parse(text);
            text = Console.ReadLine();
            var list = text.Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToList();
            var div = n / 2;

            var left = list[div - 1];
            var right = list[div];

            if (left != right){
                Console.WriteLine((right - left).ToString());
            }
            else{
                Console.WriteLine("0");
            }


        }
    }
}


Measured memory_bytes: 21728
#include <bits/stdc++.h>
using namespace std;
#define REP(name, stop) for (ll(name) = 0; (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;

int main(void) {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    do {
        ans++;
    } while (n /= k);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [True for _ in range(n + 1)]
for _ in range(m):
    a[int(input())] = False

dp = [0] * (n + 1)
dp[0] = 1

for now in range(n):
    for next in range(now + 1, min(n + 1, now + 3)):
        if a[next]:
            dp[next] += dp[now]
            dp[next] %= 1000000007

print(dp[n])

Measured memory_bytes: 7864
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 10, M = 1e4 + 10;

int n, m;
int a[N];
int take[10] = {0, 2 ,5, 5, 4, 5, 6, 3, 7, 6};
pii dp[M], nothing = {-1, -1};
int trans[M];

void test_case();
pii solve(int left);

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + m);
	fill(dp, dp + M, nothing);
	solve(n);
	int left = n, cnt = 10;
	while (trans[left] > 0) {
		cout << trans[left];
		left -= take[trans[left]];
	}
	cout << "\n";
}

pii solve(int left) {
	if (left == 0) {
		return mp(0, 1);
	}
	auto &ans = dp[left];
	if (ans == nothing) {
		ans = {0, 0};
		trans[left] = -1;
		int prev_len = -INF;
		for (int i = 1; i <= m; ++i) {
			if (left - take[a[i]] >= 0) {
				pii next_ans = solve(left - take[a[i]]);
				if (next_ans.second == 1 && next_ans.first >= prev_len) {
					prev_len = next_ans.first;
					ans = {1 + next_ans.first, 1};
					trans[left] = a[i];
				}
			}
		}
	}
	return ans;
}

Measured memory_bytes: 640
w = int(input())
n = int(input())

def swap(nlist,i,j):
    temp = nlist[i-1]
    nlist[i-1] = nlist[j-1]
    nlist[j-1] = temp
    return nlist

nlist = [i+1 for i in range(w)]
for i in range(n):
    i,j = [int(a) for a in input().split(',')]
    swap(nlist,i,j)
for i in nlist:
    print(i)


Measured memory_bytes: 5604
z[75][75];s,d,t,a,*p,j;main(i){for(;scanf("%d%d",&s,&d)*d++;printf("%d\n",s)){for(memset(z,t=9,2e4);s--;)for(j=i=d;--i;a?*p=fmin(*p,a),*z[t]>*p?t=i:0:0)scanf("%d",&a),p=z[i];for(;--j;)for(s=j;--s;a?z[s][j]=z[j][s]=a:0)scanf("%d",&a);for(s=i=0;d+~i++;t=a)for(s+=*z[t],*z[t]=0,a=j=d;--j;*p&&*z[a]>*p?a=j:0)p=z[j],*p=fmin(*p,p[t]);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n,m;
int a[110][110];

int calc(vector<int> &v) {
  int res = 0;
  for (int i = 0; i < v.size(); i++) {
    int add = INF;
    for (int j = 0; j < v.size(); j++) {
      if (j == i) continue;
      CHMIN(add,a[v[i]][v[j]]);
    }
    res += add;
  }
  return res;
}

void dfs(vector<int> &v, int &ans) {
  if (v.size() > 1) CHMAX(ans,calc(v));
  for (int i = v.back()+1; i < n; i++) {
    bool ok = true;
    for (int j = 0; j < v.size(); j++) {
      if (a[v[j]][i] == 0) ok = false;
    }
    if (ok) {
      v.push_back(i);
      dfs(v,ans);
      v.pop_back();
    }
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n >> m;
  REP(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    x--; y--;
    a[x][y] = a[y][x] = z;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    vector<int> v;
    v.push_back(i);
    dfs(v,ans);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3288
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N+10)
	for i := 0; i < N; i++ {
		fmt.Scan(&h[i])
	}

	dp := make([]int, N+10)
	for i := 1; i < N; i++ {
		dp[i] = 99999999999999
	}

	for i := 0; i < N-1; i++ {
		dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
		dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
	}
	fmt.Println(dp[N-1])
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main() {
  int h, w, k;
  cin>>h>>w>>k;
  string s[h];
  for (int i=0; i<h; i++) cin>>s[i];

  int m[h][w];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      m[i][j] = 0;
    }
  }
  int color = 0;
  for (int i=0; i<h; i++) {
    if (s[i].find('#') == string::npos) {
      continue;
    }
    ++color;
    int cnt = 0;
    for (int j=0; j<w; j++) {
      if (s[i][j] == '#') {
        ++cnt;
      }
      if (cnt == 2) {
        ++color;
        cnt = 1;
      }
      m[i][j] = color;
    }
  }
  for (int i=1; i<h; i++) {
    if (m[i][0] != 0) {
      continue;
    }
    for (int j=0; j<w; j++) {
      m[i][j] = m[i-1][j];
    }
  }
  for (int i=h-2; i>=0; i--) {
    if (m[i][0] != 0) {
      continue;
    }
    for (int j=0; j<w; j++) {
      m[i][j] = m[i+1][j];
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cout<<m[i][j];
      if (j != w - 1) {
        cout<<" ";
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1408