akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N;
  int A = 0;
  M = N;
  
  while(M > 0){
    A = A + M % 10;
    M = M / 10;
  }
 
  if (N % A == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var HWK = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var H = HWK[0];
            var W = HWK[1];
            var K = HWK[2];
            var grid = new bool[H][];
            var all = 0;
            for (var i = 0; i < H; i++)
            {
                var s = Console.ReadLine();
                grid[i] = s.Select(x => x == '#').ToArray();
                all += grid[i].Count(x => x);
            }
            if (all < K)
            {
                Console.WriteLine(0);
                return;
            }

            var answer = 0;

            for (var hb = 0; hb < (1 << H); hb++)
            {
                for (var wb = 0; wb < (1 << W); wb++)
                {
                    var count = 0;
                    for (var i = 0; i < H; i++)
                    {
                        if (((hb >> i) & 1) == 0) continue;
                        for (var j = 0; j < W; j++)
                        {
                            if (((wb >> j) & 1) == 0) continue;
                            if (grid[i][j]) count++;
                        }
                    }
                    if (count == K) answer++;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


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

int top,S[1000];

  
void push(int x){
  top++;
  S[top]=x;
  
}
int pop(){
  top--;
  return S[top+1];
 
}
int main(){

  int a,b;
  top=0;
  char s[100];
  
  while(scanf("%s",s) !=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);
    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(s)); 
    }
  }
  
  printf("%d\n",pop());
 
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int INF = 1000000000;

int main() {
  while(1) {
    int n,m;
    cin>>n>>m;
    if(!n) break;
    int sums = 0;
    vector<int> vs(n);
    REP(i,n) {
      int s;
      cin>>s;
      sums += s;
      vs[i] = s;
    }
    int res = 0;
    vector<int> vd;
    REP(i,m) {
      int d;
      cin>>d;
      if(d < sums) {
        vd.push_back(d);
      } else {
        res += d - sums;
      }
    }
    sort(ALL(vd));
    vector<int> sum(1<<n, 0);
    REP(i,1<<n) {
      REP(j,n) {
        if((i>>j)&1) sum[i] += vs[j];
      }
    }
    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    REP(i,1<<n) {
      REP(j,n) {
        if((i>>j)&1) continue;
        auto first = upper_bound(ALL(vd), sum[i]);
        auto last = lower_bound(ALL(vd), sum[i]+vs[j]);
        int cost = dp[i];
        for(auto itr = first; itr != last; ++itr) {
          cost += min(abs(*itr - sum[i]), abs(*itr - (sum[i] + vs[j])));
        }
        dp[i|(1<<j)] = min(dp[i|(1<<j)], cost);
      }
    }
    cout << dp.back() + res << endl;
  }
  return 0;
}

Measured memory_bytes: 3376
import time
import sys
import io
import re
import math
from Queue import Queue
import collections

start = time.clock();
i = 0
(n, q) = map(int, raw_input().split())

datalist = [raw_input().split() for _ in range(n)]
datalist = collections.deque(datalist)

#print(datalist)
while len(datalist):
    data = datalist.popleft()
    
    data[1] = int(data[1])
    
    if data[1] <= q:
        i += data[1]
        print data[0], i
    else:
        i += q
        data[1] -= q
        datalist.append(data)


Measured memory_bytes: 18688
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long ans = 0;
			for (int i = 0; i < n; i++) {
				int x = a[i];
				while (x % 2 == 0) {
					x /= 2;
					ans++;
				}
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 29564
# C
X, N = map(int, input().split())
A = list(map(int, input().split()))
dct = {i: [] for i in range(101)}
for i in A:
    num = abs(X - i)
    dct[num].append(i)
for k,v in dct.items():
    if (k == 0):
        if (len(v) == 0):
            print(X)
            break
    elif (len(v) == 0):
        if (X >= k):
            print(X - k)
            break
        else:
            print(k - X)
            break
    elif (len(v) == 1):
        if (X - k == v[0]):
            print(X + k)
            break
        else:
            print(X - k)
            break

Measured memory_bytes: 62092
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
t=0
for i in range(n):
    t=t+ab[i][0]
    if t>ab[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 88024
n = int(input())
#a, b = map(int, input().split())
#x, y, z = map(int, input().split())
#a, b, h, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
p = 1
if 0 in arr:
	print(0)
else:
	for i in reversed(arr):
		p *= i
		if p > (10**18):
			print(-1)
			exit()
	print(p)

Measured memory_bytes: 21660
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<=b;i++)
template <typename T>
void read(T &x){
    x=0;
    int flag=1;
    char c=getchar();
    while(c=='-'){
        flag=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    x*=flag;
}

    int n,k;
    char s[100010]={'\0'};
int main()
{
    cin>>s;
    int ans1=0,ans2=1;
    int flag=0;
    for(int i=1;s[i]!='\0';i++){
        if(s[i]==s[i-1])
            flag=1-flag;
        if(flag)ans1++;
        else ans2++;
    }

    cout<<min(ans1,ans2);
    return 0;
}


Measured memory_bytes: 384
// D - String Equivalence
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using VP = vector<pair<char,string>>;

int main(){
	int N; cin>>N;
	VP s(1,{'a',"a"});
	while(--N){
		VP t; swap(s,t);
		rep(i, t.size()){
			char mx; string pre; tie(mx,pre) = t[i];
			for(char c='a'; c<=mx+1; ++c) s.push_back({max(mx, c), pre + c});
		}
	}
	rep(i, s.size()) cout<< s[i].second <<endl;
}

Measured memory_bytes: 10080
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val hwk = inputs.head.split(" ").map(_.toInt)
  val h   = hwk(0)
  val w   = hwk(1)
  val k   = hwk(2)
  val lines = inputs.tail

  println(solve(h, w, k, lines))

  def solve(h: Int, w: Int, k: Int, lines: Seq[String]): Int = {
    var ans = 0
    // bit探索の全組み合わせを作成
    (0 until 1 << h).foreach { condI =>
      (0 until 1 << w).foreach { condJ =>

        var count = 0
        // 削除されてない行列の#を対象に数える
        (0 until h).foreach { i =>
          (0 until w).foreach { j =>
            // 自分の場所が削除されてないとき
            if(
              (condI >> i & 1) != 1 &&
              (condJ >> j & 1) != 1 &&
              lines(i)(j) == '#'
            ) {
              count = count + 1
            }
          }
        }

        if(count == k) {
          ans = ans + 1
        }
      }
    }
    ans
  }
}

Measured memory_bytes: 54984
#include <bits/stdc++.h>
using namespace std;
int n,m,a,b,c,d;
signed main(){
	scanf("%d%d",&n,&m);
	a=1,b=n;
	while(m--){
		scanf("%d%d",&c,&d);
		a=max(a,c),b=min(b,d);
		if(a>b){
			puts("0");
			return 0;
		}
	}
	printf("%d",b-a+1);
}

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

using namespace std;

using ull_t = unsigned long long;

int main()
{
    int N;
    cin >> N;

    vector<int> count(N, 0);
    for (int i = 1; i < N; ++i)
    {
        int a;
        cin >> a;
        ++count[a - 1];
    }

    for (auto c : count)
        cout << c << endl;
}


Measured memory_bytes: 4048
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{

    class Program
    {
        public static IEnumerable<long> PrimeFactors(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }

        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            var factors = PrimeFactors(n);
            Dictionary<long, int> factordict = new Dictionary<long, int> { };

            foreach (long factor in factors)
            {
                if (factordict.ContainsKey(factor))
                    factordict[factor]++;
                else
                    factordict.Add(factor, 1);
            }

            int res = 0;

            foreach (var factor in factordict)
            {
                int cnt = factor.Value;
                int step = 1;
                while (cnt >= step)
                {
                    res++;
                    cnt -= step;
                    step++;
                }
            }

            Console.WriteLine(res);

        }

    }
}



Measured memory_bytes: 27760
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
 
        int[] X = new int[M];
        for(int i = 0; i < M; i++){
            X[i] = sc.nextInt();
        }

        Arrays.sort(X);
        
        int ans = 0;
        Queue<Integer> queue = new PriorityQueue<>( (s1, s2) -> (s2 - s1) );
        for(int i = 1; i < M; i++){
            int diff = X[i] - X[i-1];
            queue.add(diff);
            ans  += diff;
        }
        
        while( !queue.isEmpty() && --N > 0){
            ans -= queue.poll();
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 49820
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

typedef vector<ll>vec;
typedef vector<vec>mat;

mat mul(mat&a, mat&b) {
	mat c(a.size(), vec(b[0].size()));
	rep(i, a.size())rep(j, b[0].size())rep(k, b.size())
		(c[i][j] += a[i][k] * b[k][j]) %= MOD;
	return c;
}
mat ppow(mat&a, ll b) {
	mat res(a.size(), vec(a.size()));
	rep(i, a.size())res[i][i] = 1;
	while (b) {
		if (b & 1)res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}
int main(){
	int n;ll K;cin>>n>>K;
	mat m(n,vec(n));
	rep(i,n){
		rep(j,n)scanf("%lld",&m[i][j]);
	}
	mat res=ppow(m,K);
	ll ans=0;
	rep(i,n)rep(j,n)(ans+=res[i][j])%=MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
struct UnionFind{
    vector<int> r;
 
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
 
    int root(int x){
        if(r[x]<0) 
			return x;
        return r[x]=root(r[x]);
    }
 
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) 
			return false;
        if(r[x]>r[y]) 
			swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
 
 
int main(){
    int N,M;
    cin>>N>>M;
 
    UnionFind UF(N);
    
    for(int i=0;i<M;i++){
        int A,B;
        cin>>A>>B;
        A--;B--;
        UF.unite(A, B);
    }
 
    int ans=0;
    
    for(int i=0;i<N;i++){
        ans=max(ans,UF.size(i));
    }
 
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3948
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(int(input()) for _ in range(n))
    A_s = sorted(A)
    max_A = A_s[n - 1]
    sub_max_A = A_s[n - 2]

    for i in range(n):
        if A[i] == max_A:
            print(sub_max_A)
        else:
            print(max_A)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14120
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val cnt = IntArray(8)
    var overCnt = 0

    readInputLine().split(" ").forEach {
        val rate = it.toInt()
        if (rate >= 3200) {
            overCnt++
        } else {
            cnt[rate / 400]++
        }
    }

    println("${Math.max(1, cnt.count { it != 0 })} ${cnt.count { it != 0 } + overCnt}")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36008
#include<iostream>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int n;cin >> n ;
    int a[100];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    sort(a,a+n,std::greater<>());

    int p_a=0,p_b=0;
    for(int i=0;i<n;i++){
        if(i%2==0) p_a+=a[i];
        else p_b+=a[i];
    }
    p(p_a-p_b)
}

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

typedef long long int ll;
typedef pair<int, int> pii;
bool R(){return true;}
template<typename T, typename ... Args>
bool R(T & x, Args & ... args){return cin >> x && R(args...);}
void init_io(){ios::sync_with_stdio(false);cin.tie(0);}

#define PB push_back
#define MP make_pair
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define SV(vec) do{int __sv;R(__sv);vec.PB(__sv);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 4000000000000000007LL

int k;
string s;

void solve ()
{
  R(k, s);
  printf("%s\n", s.length() <= k ? s.c_str() : (s.substr(0, k) + "...").c_str());
}

int main ()
{
  init_io();
  int t = 1;
  //R(t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>

using namespace std;


int main(int argc, char** argv) {
    long long N, K;

    cin >> N >> K;

	vector<long long> a(N), a_sum(N + 1), sorted, unsorted;
	long long ans = 0;
	int n_th = int(sqrt(N)) + 1;

	for (int i = 0; i < N; i++) 
		cin >> a[i];

	for (int i = 1; i <= N; i++)
		a_sum[i] = a_sum[i - 1] + a[i - 1] - K;


	for (int i = 0; i <= N; i++) {
		// ソート済の部分は2分探索で
		ans += upper_bound(sorted.begin(), sorted.end(), a_sum[i]) - sorted.begin();

		// ソートしていない部分はナイーブに
		for (int j = 0; j < unsorted.size(); j++)
			ans += a_sum[i] >= unsorted[j];

		unsorted.push_back(a_sum[i]);

		if (unsorted.size() >= n_th) {
			sort(unsorted.begin(), unsorted.end());
			auto middle = sorted.insert(sorted.end(), unsorted.begin(), unsorted.end());
			inplace_merge(sorted.begin(), middle, sorted.end());
			unsorted.clear();
		}

	}

	cout << ans << endl;
}

Measured memory_bytes: 6388
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val d = readLine()!!.toInt()
    val e = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    println(if (e - a <= k) "Yay!" else ":(")
}

Measured memory_bytes: 31608
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  string S;
  cin >> N >> S;
  enum RGBtype : int64_t { kR = 0L, kG, kB, kNumber };
  vector<vector<int64_t>> rgb(kNumber, vector<int64_t>());
  for (int64_t i = 0; i < N; ++i) {
    const char ch = S.c_str()[i];
    if (ch == 'R') {
      rgb[kR].push_back(i);
    } else if (ch == 'G') {
      rgb[kG].push_back(i);
    } else if (ch == 'B') {
      rgb[kB].push_back(i);
    }
  }

  vector<int64_t> rgb_index = {0, 1, 2};
  int64_t result = 0;
  do {
    for (auto first : rgb[rgb_index[0]]) {
      const auto second_start = upper_bound(rgb[rgb_index[1]].begin(), rgb[rgb_index[1]].end(), first);
      for (auto second = second_start; second != rgb[rgb_index[1]].end(); ++second) {
        const auto third_start = upper_bound(rgb[rgb_index[2]].begin(), rgb[rgb_index[2]].end(), *second);
        for (auto third = third_start; third != rgb[rgb_index[2]].end(); ++third) {
          const int64_t first_index = first;
          const int64_t second_index = *second;
          const int64_t third_index = *third;
          if (second_index - first_index != third_index - second_index) {
            ++result;
          }
        }
      }
    }
  } while (next_permutation(rgb_index.begin(), rgb_index.end()));
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3668
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(usize);
    let mut m = Vec::new();
    for _ in 0..n {
        m.push(get!(String).split_whitespace().map(|i| i.parse::<i64>().unwrap()).collect::<Vec<_>>());
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                if m[i][j] > m[i][k] + m[k][j] {
                    println!("-1");
                    return;
                }
            }
        }
    }

    let mut r = 0;
    for i in 0..n {
        for j in 0..n {
            let mut f = true;
            for k in 0..n {
                if i != k && j != k && m[i][j] == m[i][k] + m[k][j] {
                    f = false;
                    break;
                }
            }
            if f { r += m[i][j]; }
        }
    }
    println!("{}", r/2);
}

Measured memory_bytes: 3404
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.num = [1] * (n + 1)

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            self.num[x] = self.num[self.parent[x]]
            return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        numx = self.num[x]
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        self.num[x] += self.num[y]
        self.num[y] += numx

    def same_check(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(m)]
inconv = n * (n - 1) // 2
inconv_list = [0] * m
inconv_list[m - 1] = inconv

uf = UnionFind(n)
for i in range(m - 1, 0, -1):
    if inconv == 0:
        break
    a, b = edge[i][0], edge[i][1]
    if not uf.same_check(a, b):
        inconv -= uf.num[a] * uf.num[b]
        uf.union(a, b)
    else:
        inconv = inconv
    inconv_list[i - 1] = inconv
print(*inconv_list, sep="\n")

Measured memory_bytes: 41604
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
	string s;
	int k;
	cin >> s >> k;
	set<string> a;
	for (int i = 1 ; i <= 5 ; i++) for (int j = 0 ; j < s.length() ; j++) {
		if (j + i <= s.length()) a.insert(s.substr(j, i));
	}
	auto j = a.begin();
	for (int i = 0 ; i < k - 1; i++) j++;
	cout << *j;
}
/*
*/


Measured memory_bytes: 4724
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	m := make(map[string]bool)
    N := sc.NextInt()
    w := sc.NextToken()
    m[w] = true
    last := w[len(w)-1:]
    for i := 1; i < N; i++ {
        w = sc.NextToken()
        if m[w] || w[0] != last[0] {
            fmt.Println("No")
            return
        }
        m[w] = true
        last = w[len(w)-1:]
    }
    fmt.Println("Yes")
}

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &Scanner{sc: sc}
}

func (r *Scanner) SetBufferSize(size int) {
	buf := make([]byte, size)
	r.sc.Buffer(buf, size)
}

func (r *Scanner) NextToken() string {
	r.sc.Scan()
	return r.sc.Text()
}

func (r *Scanner) NextInt64() int64 {
	n, e := strconv.ParseInt(r.NextToken(), 10, 64)
	if e != nil {
		panic(e)
	}
	return n
}

func (r *Scanner) NextInt() int {
	n, e := strconv.ParseInt(r.NextToken(), 10, 32)
	if e != nil {
		panic(e)
	}
	return int(n)
}

func (r *Scanner) NextInt64Array(size int) []int64 {
	a := make([]int64, size)
	for i := 0; i < size; i++ {
		a[i] = r.NextInt64()
	}
	return a
}

func (r *Scanner) NextIntArray(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = r.NextInt()
	}
	return a
}


Measured memory_bytes: 640
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100010;

char str[MAXN];

int main ()
{
    scanf ("%s", &str);
    int len = strlen (str);
    bool flag = false;
    int x, y;
    for (int i = 1; i < len; i ++)
    {
        if (str[i - 1] == str[i])
        {
            flag = true;
            x = i - 1;
            y = i;
            break;
        }
        if (i > 1)
        {
            if (str[i - 2] == str[i])
            {
                flag = true;
                x = i - 2;
                y = i;
                break;
            }
        }
    }
    if (flag)
    {
        x ++;
        y ++;
        printf ("%d %d\n", x, y);
    }
    else
    {
        printf ("-1 -1\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string> S(3);
  REP(i, 3){
    cin >> S[i];
  }
  REP(i, 3){
    cout << S[i][i];
  }
  cout << endl;
}

Measured memory_bytes: 3632
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }

    let mut ans0 = 0;
    for (i, &c) in s.iter().enumerate() {
        if i % 2 == 0 && c != '0' {
            ans0 += 1;
        }
        if i % 2 == 1 && c != '1' {
            ans0 += 1;
        }
    }

    let mut ans1 = 0;
    for (i, &c) in s.iter().enumerate() {
        if i % 2 == 1 && c != '0' {
            ans1 += 1;
        }
        if i % 2 == 0 && c != '1' {
            ans1 += 1;
        }
    }

    println!("{}", std::cmp::min(ans0, ans1));
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

void solve(long long a, long long b) {
    stringstream ss1, ss2;


    for (int i = 0; i < b; i++)
        ss1 << a;

    for (int i = 0; i < a; i++)
        ss2 << b;

    cout << min(ss1.str(), ss2.str()) << endl;


}

int main() {
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

struct Edge{
    int to,id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1){ //c,pの-1はデフォルト値、何ももらえなかったときになるよ。まあ最初だけだけどね
    int k = 1; //使う色の最大値
    rep(i, g[v].size()){//頂点vを受け、そこに隣接する辺について処理
        int u = g[v][i].to; //行き先を見る
        int ei = g[v][i].id; //辺番号を見る
        if(u == p) continue; //行き先が元いた頂点になっているのでこの辺は考えない というか考えると逆走する
        if(k == c) ++k; //その辺の色がcと同じになっているのでkをインクリメント
        ans[ei] = k; //ei番目の辺の色はk！やったね！
        ++k; //kをインクリメントしておく
        dfs(u,ans[ei],v); //行き先の頂点uを与え再帰、あと辺の色も与える、元いた頂点vも与えるよ
    }
}

int main(){
    int n;
    cin >> n;
    ans = vector<int>(n-1);
    g.resize(n);
    rep(i,n-1) {
        int a,b;
        
        cin >> a >> b; //辺の一端ともう一端の番号 1 2みたいな
        a--;b--; //インデックスにするためのデクリメント
        Edge e = {b,i};
        Edge e2 = {a,i};
        g[a].push_back(e); //辺の行き先と辺のID
        g[b].push_back(e2); //双方向なのでこうする
    }
    dfs(0);
    int mx = 0;
    rep(i, n){
        mx = max(mx,int(g[i].size())); // i番目の頂点につながっている辺の本数　何番目が最大かをだす
    }
    cout << mx << endl;
    rep(i,n-1){
        cout << ans[i] << endl;
    }
	return 0;
}



Measured memory_bytes: 8320
a = input()
A = []
for i in range(len(a)-2):
    if(int(a[i:i+3]) <= 753):
        A.append(-1*(int(a[i:i+3]) - 753))
    else:
        A.append(int(a[i:i+3]) - 753)
print(min(A))

Measured memory_bytes: 3060
using System;
using static System.Console;
using System.Collections.Generic;

namespace abc179
{
    class Program
    {
        static int keyNum = 998244353;
        static void Main()
        {
            var nk = ReadNumList();
            var n = nk[0];
            var k = nk[1];
            var aList = new int[k][];
            for (var i = 0; i < k; ++i)
            {
                aList[i] = ReadNumList();
            }

            WriteLine(LeapingTak(n, aList));
        }
        static long LeapingTak(int n, int[][] aList)
        {
            var dp = new long[n + 1];
            var diff = new long[n + 1];
            dp[0] = 1;
            diff[2] = -1;
            for (var i = 1; i <= n; ++i)
            {
                dp[i] = (dp[i - 1] + diff[i]) % keyNum;
                // distribute to diff (imos)
                foreach (var a in aList)
                {
                    if (i + a[0] < diff.Length)
                    {
                        diff[i + a[0]] = (diff[i + a[0]] + dp[i]) % keyNum;
                    }
                    if (i + a[1] + 1 < diff.Length)
                    {
                        diff[i + a[1] + 1] = (diff[i + a[1] + 1] + keyNum - dp[i]) % keyNum;
                    }
                }
            }
            return dp[n];
        }
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            if (line.Length == 1 && string.IsNullOrEmpty(line[0]))
            {
                return new int[0];
            }
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
    }
}


Measured memory_bytes: 30324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Elm {
  int pos, len;
  string s;
};
bool operator< (const Elm &e1, const Elm &e2) {
  if(e1.len == e2.len) {
    return e1.s > e2.s;
  } else {
    return e1.len > e2.len;
  }
}
bool solve() {
  int n, a, s, g; cin >> n >> a >> s >> g;
  if(n == 0) return false;
  vector<vector<pair<int, string>>> v(n);
  for(int i=0;i<a;++i) {
    int x, y; cin >> x >> y;
    string lab; cin >> lab;
    v[x].emplace_back(y, lab);
  }
  vector<vector<string>> dp(n, vector<string>(400, "{"));
  priority_queue<Elm> pq;
  pq.push({s, 0, ""});
  dp[s][0] = "";
  while(!pq.empty()) {
    auto now = pq.top(); pq.pop();
    int pos = now.pos, len = now.len;
    string tmp = now.s;
    if(dp[pos][len] < tmp) continue;
    for(int i=0;i<(int)(v[pos].size());++i) {
      int nxt = v[pos][i].first;
      string add = v[pos][i].second;
      if((int)(tmp.size()) + (int)(add.size()) >= 400) continue;
      if(dp[nxt][(int)(tmp.size()) + (int)(add.size())] > tmp + add) {
        dp[nxt][(int)(tmp.size()) + (int)(add.size())] = tmp + add;
        pq.push({nxt, (int)(tmp.size()) + (int)(add.size()), tmp + add});
      }
    }
  }
  string ans = "{";
  for(int i=0;i<300;++i) {
    ans = min(ans, dp[g][i]);
  }
  for(int i=300;i<400;++i) {
    if(ans > dp[g][i]) ans = "{";
  }
  cout << (ans == "{" ? "NO" : ans) << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    if(!solve()) break;
  }
}



Measured memory_bytes: 9980
<?php
  $s = trim(fgets(STDIN));
  $li = [];
  for($i=0; $i<strlen($s); $i++){
    $li[$s[$i]]=1;
  }
  $moji = 'a';

  while(1){
    if($moji == "aa"){
      break;
    }
    if(!isset($li[$moji])){
      echo $moji."\n";
      exit;
    }
    $moji++;
  }
  echo "None\n";

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

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

  if (2 * max(a, b) - 1 <= 16) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a * a * 3 << endl;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1;i++) {
		cout << i << ' ';
	}
}

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

int main(){
    ll x;
    cin>>x;
    for(ll i=1;i<=1000;i++){
        for(ll j=0;j<i;j++){
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(a-b==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    for(ll i=0;i<=1000;i++){
        for(ll j=0;j<=1000;j++){
            ll a= i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(a+b==x){
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3596
package main

import (
  "fmt"
  "sort"
  "strings"
)

func main() {
  var N,L int
  fmt.Scan(&N,&L)
  S := make([]string, N)
  for i := range S {
    fmt.Scan(&S[i])
  }
  sort.Strings(S)
  fmt.Println(strings.Join(S,""))
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<map>

using namespace std;

int main(){
	int c1,c5,c10,c50,c100,c500;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	int ans=c1+(c5*5)+(c10*10)+(c50*50)+(c100*100)+(c500*500);
	if(ans>=1000) printf("1\n");
	else printf("0\n");
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define  f first 
#define  s second 
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int w,h,c=1,sx,sy,gx,gy;
char mp[101][101];
int bt[101][101];
int cs[101][101];
int nn[5][5]=
  {{2,2,2,2,2},
   {2,3,3,3,2},
   {2,3,1e8,3,2},
   {2,3,3,3,2},
   {2,2,2,2,2}
  };
int used[100][101][101];

void nu(int x,int y){
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++){
      int nx=x+j-2,ny=y+i-2;
      if(nx<0||w<=nx||ny<0||h<=ny)continue;
      cs[ny][nx]=max(nn[i][j],cs[ny][nx]);
    }
}

int cal(){
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(P(0,0),P(sx,sy)));
  int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
  while(!Q.empty()){
    PP p=Q.top();
    Q.pop();
    if(p.s.f==gx&&p.s.s==gy&&p.f.s==c-1)return p.f.f;
    if(used[p.f.s][p.s.s][p.s.f]==1)continue;
    used[p.f.s][p.s.s][p.s.f]=1;
    for(int i=0;i<4;i++){
      int nx=p.s.f+dx[i],ny=p.s.s+dy[i];
      int ncs=p.f.f+cs[p.s.s][p.s.f],nbt=p.f.s|bt[p.s.s][p.s.f];
      if(nx<0||w<=nx||ny<0||h<=ny)continue;
      Q.push(PP(P(ncs,nbt),P(nx,ny)));
    }
  }
}


int main(){
  cin>>w>>h;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
      cs[i][j]=max(1,cs[i][j]);
      if(mp[i][j]=='M')bt[i][j]=c,c*=2;
      if(mp[i][j]=='#')nu(j,i);
      if(mp[i][j]=='S')sx=j,sy=i;
      if(mp[i][j]=='G')gx=j,gy=i;
    }
  cout<<cal()<<endl; 
  return 0;
}

Measured memory_bytes: 8312
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int k = sc.nextInt();
		
		char replaceTo = '*';
		char replaceFrom = s.charAt(k - 1);
		
		
		String reString = s.replaceAll("[^" + replaceFrom+"]", "" + replaceTo);
		System.out.println(reString);
	}
}

Measured memory_bytes: 21972
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t D[13];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; i++)
	{
		int a;
		in >> a;
		if (a == 0) {
			out << 0 << endl; return 0;
		}
		D[a]++;
		if (D[a] >= 3) {
			out << 0 << endl; return 0;
		}
	}

	int32_t ok = 0;
	for (int32_t mid = 1; mid <= 12; mid++)
	{
		bool is_ok = true;
		int32_t last = 0;
		int32_t last_2 = -1;
		int32_t last_3 = -1;
		for (int32_t i = 1; i <= 12; i++)
		{
			if (D[i] == 0) { continue; }
			if (D[i] == 2) {
				if (i - std::max(last_2,last) < mid) { is_ok = false; break; }
				last_2 = -1; last = i;
				continue;
			}

			if (last_2 == -1) {
				if (i - last < mid) { is_ok = false; break; }
				last_2 = i;
			}
			else {
				//2-2
				if (i - last_2 >= mid) { last_2 = i; continue; }
				if (last_3 != -1) {
					if (i - last_3 < mid) { is_ok = false; break; }
				}
				last_3 = last_2;
				last_2 = i;
			}
		}

		if (D[12] != 0) {
			for (int32_t i = 0; i < 12; i++)
			{
				if (D[i] != 0 && 12 - i < mid) { is_ok = false; break; }
			}
		}
		else {
			int32_t last = -1;
			for (int32_t i = 1; i < mid; i++)
			{
				auto j = 12 - i;
				if (last == -1)
				{
					if (D[j] == 2) {
						if ((12 - j) * 2 < mid) { is_ok = false; }
						break;
					}
					if (D[j] == 1) {
						last = j;
					}
				}
				else {
					if (D[j] != 0) {
						if ((12 - j) +(12-last) < mid) { is_ok = false; }
						break;
					}
				}
			}
		}

		if (is_ok) { ok = mid; }
		else { break; }
	}

	out << ok << endl;
	return 0;
}
#endif


Measured memory_bytes: 888
n=int(input())
a=list(map(int,input().split()))
L=[0]
R=[0]
def gcd(x,y):
    if x==0:return y
    else:return gcd(y%x,x)
for i in range(n-1):
    L.append(gcd(L[i],a[i]))
    R.append(gcd(R[i],a[-1-i]))
MAX=0
for i in range(n):
    MAX=max(MAX,gcd(L[i],R[-1-i]))
print(MAX)


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int l = a+b;
  int r = c+d;
  if(l > r){
    cout << "Left" << endl;
  }
  else if(l == r){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : ARPIT *
* NICK : arpitfalcon *
* INSTITUTION : BIT MESRA *
* Ab m game m hu. *
******************************************/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 -
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vin                    \
    ll n;                      \
    cin >> n;                  \
    vector<ll> x(n);           \
    for (ll i = 0; i < n; i++) \
    cin >> x[i]
#define vout                   \
    for (ll i = 0; i < n; i++) \
    cout << x[i] << " "
#define T     \
    ll t = 1; \
    cin >> t; \
    while (t--)
#define ain                    \
    ll n, k;                   \
    cin >> n >> k;             \
    ll a[n];                   \
    for (ll z = 0; z < n; z++) \
    cin >> a[z]
#define aout                   \
    for (ll i = 0; i < n; i++) \
    cout << a[i] << " "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define max4(a, b, c, d) max(a, max3(b, c, d))
#define min4(a, b, c, d) min(a, min3(b, c, d))
#define blink                \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double PI = 3.141592653589793238463;

#define forn(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define for1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define forr(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))

/*
__builtin_ffs(x)
  Number of set bits: __builtin_popcount(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
*/

double bin_search(vector<double> &lanterns, double len, int n)
{
    double low = 0.0, high = len + 1;
    double ans = len;
    bool flag = true;
    double mid;

    while (high - low > 1e-9)
    {
        mid = low + (high - low) / 2;
        double dist = 0.0;
        for (int i = 0; i < (n - 1); i++)
        {
            dist = (lanterns[i + 1] - lanterns[i]) / 2;
            if (dist >= mid)
            {
                flag = false;
                break;
            }
        }

        if (flag)
            high = mid;
        else
            low = mid;

        ans = mid;
        flag = true;
    }

    if (lanterns[0] - 0 > ans)
        ans = lanterns[0] - 0;
    if (len - lanterns[n - 1] > ans)
        ans = len - lanterns[n - 1];

    return ans;
}

int main()
{
    blink
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    // your code goes here
    int a, b;
    cin >> a >> b;

    if (a > 8 || b > 8)
        cout << ":(" << endl;
    else
        cout << "Yay!";

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a == b || a < b)
    {
        cout << a;
    }
    else
    {
        cout << a - 1;
    }

    return 0;
}

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

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

    int a = 0, b = 0, c = 0;
    for (auto ch : s) {
        a += ch == 'a';
        b += ch == 'b';
        c += ch == 'c';
    }

    cout << (abs(a - b) <= 1 && abs(b - c) <= 1 && abs(a - c) <= 1 ? "YES" : "NO") << endl;
}



Measured memory_bytes: 3700
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back
#define SZ(x) ll(x.size())

using namespace std;
const int maxn = 1000*100+5 ;

int main()
{
	migmig ;int a , b ; 
	cin>>a>>b ;
	
	if(b != 100) 
	cout<<b ;
	
	else cout<<101 ; 
	for(int i = 0 ;  i < a ; i ++) cout<<"00" ;  
}
//////
////////
///////////



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = Integer.parseInt(sc.next());
		sc.close();
		long g = a[0];
		long aa , ab , am;
		for(int i = 1 ; i < n ; i++){
			aa = g;
			ab = a[i];
			am = aa % ab;
			while(ab != 0){
				am = aa % ab;
				aa = ab;
				ab = am;
			}
			g = aa;
		}
		ou.println(g);
		ou.flush();
	}
}

Measured memory_bytes: 58400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0;i < N;i++){
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }
    sort(S.begin(), S.end());
    int cnt = 0;
    unsigned long ans = 0;
    for(int i = 0;i < N - 1;i++){
        if(S[i] == S[i+1]){
            cnt++;
        }
        else cnt = 0;
        ans += cnt;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7296
def mergecount(A):
    cnt = 0
    n = len(A)
    if n>1:
        A1 = A[:n>>1]
        A2 = A[n>>1:]
        cnt += mergecount(A1)
        cnt += mergecount(A2)
        i1=0
        i2=0
        for i in range(n):
            if i2 == len(A2):
                A[i] = A1[i1]
                i1 += 1
            elif i1 == len(A1):
                A[i] = A2[i2]
                i2 += 1
            elif A1[i1] <= A2[i2]:
                A[i] = A1[i1]
                i1 += 1
            else:
                A[i] = A2[i2]
                i2 += 1
                cnt += n//2 - i1
    return cnt

N, K = map(int, input().split())
A = [int(input()) for i in range(N)]
Ak = [a-K for a in A]
Aks = [0]
t = 0
for ak in Ak:
    t += ak
    Aks.append(t)
print(N*(N+1)//2 - mergecount(Aks))


Measured memory_bytes: 31984
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<pair<int,int>> A(N);
  for(pair<int,int> &p:A){
    int a,b;
    cin>>a>>b;
    p.first=a+b;
    p.second=a-b;
  }
  sort(A.begin(),A.end());
  int ans=0,n=-10000000000;
  for(int i=0;i<N;i++){
    if(A[i].second>=n){
      ans++;
      n=A[i].first;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4744
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

x,y = map(int,input().split())
for turu in range(x+1):
  kame = x-turu
  if kame * 4 + turu * 2 == y:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 65468