akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
v = [0] * n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for i in range(d):
        v[a[i]-1]+=1
ans = 0
for i in range(n):
    if v[i] == 0: ans += 1
print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
ll mod1=1000000007ll;
ll mod2=998244353ll;

bool vis[200002];
ll ma[200002],bit[200005],rank1[200005],parent[200005];
ll c=0,x=0,n,an=0;
ll gcd(ll a, ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
ll power(ll x,ll y)
{   if(y==0) return 1;
    ll p=power(x,y/2);
    p=(p*p)%mod2;
    if(y%2) return  (p*x)%mod2;
    return p;
}
ll sum(ll in)
{   in++;
    ll sum1=0;
    while(in>0)
    {
        sum1+=bit[in];
        in-=in & (-in);
    }
    return sum1;
}
void update(ll in,ll val)
{   in++;
    while(in<=200002)
    {
        bit[in]+=val;
        in+=in & (-in);
    }
}
 struct vec {
    vector<ll> v;
    bool operator<( const  vec& a) const
    { return a.v[0] < v[0]; }
  };

ll find(ll x)
{
    if(x==parent[x])
    return x;
    else
    return find(parent[x]);
}
void merged(ll x, ll y)
{
    x=find(x);
    y=find(y);
    if(rank1[x]>rank1[y])
    {
        parent[y]=x;
        rank1[x]+=rank1[y];
    }
    else
    {
        parent[x]=y;
        rank1[y]+=rank1[x];
    }

}
void solve()
{
   ll n,m;
   cin>>n>>m;
   m--;
   n--;
   ll ans=m/n;
   if(m%n)
     ans++;
   cout<<ans;
}

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


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




int main (){
	
	//Write from here.
	int a,b,c; cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a << " " << b << " " << c << endl;

	
	
		
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

static const int MAXV = 510000;
static const int mod = 1000000007;
long long fac[MAXV], finv[MAXV], inv[MAXV];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAXV; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    int n, k; sc(n), sc(k);
    COMinit();
    ll tmp1, tmp2;
    rep(i, 1, k+1){
        tmp1 = COM(k-1, i - 1);
        tmp2 = COM(n - k + 1, i);
        cout << tmp1 * tmp2 % mod << endl;
    }
    return 0;
}

Measured memory_bytes: 12160
#include<cstdio>
#include<cstdlib>

struct Node{
	int key;
	Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while(x != NIL)
	{
		y = x;
		if(z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}

	z->parent = y;
	if(y == NIL)
		root = z;
	else{
		if(z->key > y->key)
			y->right = z;
		else
			y->left = z;
	}
}

void Inorder(Node *u)
{
	if(u == NIL) return;
	Inorder(u->left);
	printf(" %d", u->key);
	Inorder(u->right);
}

void Preorder(Node *u)
{
	if(u == NIL) return;
	printf(" %d", u->key);
	Preorder(u->left);
	Preorder(u->right);
}

int main()
{
	int n;
	char s[10];
	int x;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		scanf("%s", s);
		if(s[0] == 'i')
		{
			scanf("%d", &x);
			insert(x);
		}
		else
		{
			Inorder(root);
			printf("\n");
			Preorder(root);
			printf("\n");
		}
	}

	return 0;

}


Measured memory_bytes: 26060
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,t;
main()
{
	while(cin>>n>>m>>t,n)
	{
		string s[1001],b[1001];
		s[0]=string(n,'0');
		b[0]=string(m,'0');
		for(int i=0;i++<t;)cin>>s[i]>>b[i];
		string ans(m,'?');
		for(int i=0;i<m;i++)
		{
			bool ok[36]={};
			for(int j=0;j<n;j++)ok[j]=1;
			for(int j=0;j++<t;)
			{
				if(b[j-1][i]!=b[j][i])
				{
					for(int k=0;k<n;k++)ok[k]&=s[j][k]=='1';
				}
				else
				{
					for(int k=0;k<n;k++)ok[k]&=s[j][k]=='0';
				}
			}
			int cnt=0,mi;
			for(int j=0;j<n;j++)if(ok[j])cnt++,mi=j;
			if(cnt==1)
			{
				ans[i]=(char)(mi<10?mi+'0':mi-10+'A');
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 4176
package main

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

func main() {
        scanner := bufio.NewScanner(os.Stdin)
        scanner.Split(bufio.ScanWords)
        writer := bufio.NewWriter(os.Stdout)
        defer writer.Flush()

        scanner.Scan()
        N, _ := strconv.Atoi(scanner.Text())

        numOdds := 0
        for i := 1; i <= N; i++ {
                if i%2 == 1 {
                        numOdds++
                }
        }
        prec := float64(numOdds) / float64(N)
        writer.WriteString(strconv.FormatFloat(prec, 'f', -1, 64))
}


Measured memory_bytes: 640
#include<iostream>

#include<string>
#include <algorithm> 
using namespace std;

int main()
{
    int set[3];
    cin >> set[0] >> set[1] >> set[2];

    for(int i = 0 ; i < 3 ; i ++){
        for(int j = 2 ; j > i ; j--){
            if(set[j] > set[j-1]){
                int temp = set[j];
                set[j] = set[j-1];
                set[j-1] = temp;
            }
        }
    }
    cout << set[1] + set[2] << endl; 
}

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

#define MAX 100000

int N;
int a[MAX];

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

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( a[i] % 2 ) {
			ans = 1;
		}
	}

	if( ans ) {
		cout << "first" << endl;
	}
	else {
		cout << "second" << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to;
};

int main() {
	string str;
	cin >> str;
	int x, y;
	cin >> x >> y;

	vector<int> xm, ym;

	int cc = 0, ct = 0;
	for (auto itr : str) {
		if (itr == 'T') {
			if (ct) ym.push_back(cc); 
			else xm.push_back(cc);
			ct = 1 - ct;
			cc = 0;
		}
		else {
			cc++;
		}
	}
	if (ct) ym.push_back(cc);
	else xm.push_back(cc);

	auto func = [&](vector<int> &siji, int tar, bool ix) {
		int dp[2][17001] = {};
		dp[0][8500] = 1;
		REP(i, siji.size()) {
			REP(j, 17001)
				dp[1 - i % 2][j] = 0;
			REP(j, 17001) {
				if (dp[i%2][j]) {
					dp[1 - i % 2][j + siji[i]] = 1;
					if (ix && i == 0) continue;
					dp[1 - i % 2][j - siji[i]] = 1;
				}
			}
		}
		return dp[siji.size()%2][tar + 8500];
	};

	if (func(xm, x,1) && func(ym, y,0)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int count=0;
    for(int i=1;i<s.size();i++){
        if((s[i-1]=='B'&&s[i]=='W')||(s[i-1]=='W'&&s[i]=='B'))count++;
    }
    
    cout<<count<<endl;    
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int t = sc.nextInt();

		int[] cn = new int[n];
		int[] tn = new int[n];

		int minCost = 1001;

		for (int i=0; i<n; i++) {
			cn[i] = sc.nextInt();
			tn[i] = sc.nextInt();

			if (tn[i] <= t) {
				if (cn[i] < minCost) {
					minCost = cn[i];
				}
			}
		}

		if (minCost == 1001) {
			System.out.println("TLE");
		} else {
			System.out.println(minCost);
		}

		sc.close();
	}

}

Measured memory_bytes: 21972
/*******************************************c#
* 20.04.16 AtCoder Beginner Contest 159. C - Maximum Volume
*
*
*********************************************/
/*********************************************

::test input::

*********************************************/
using System; //Console, IComparable
using System.IO; //StreamWriter 
using System.Linq; //Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; //List<T>
using System.Reflection; //PropertyInfo[], GetProperties[]
using static System.Console; using static IOmacro.CInput;

namespace tempName {
    public class CRun{
        private static class gv{
            public static int N;
            public static int M;
            public static int[] A;
        }
    
        public void build(){            
            var input = _inta;
            gv.N = input[0];
            gv.M = input[1];
            gv.A = _inta;
        }
    
        public void solve(){
            int ans = gv.N;
            
            foreach (int x in gv.A) {
                ans -= x;
            }
            
            ans = (ans >= 0 ? ans : -1);
            WriteLine(ans);
        }
    }

    class Program { 
        static void Main() { 
            var run = new CRun();
            run.build();
            run.solve();
        } 
    }
}

namespace IOmacro {
    public static class CInput {
        public static StreamWriter _writer = new StreamWriter(Console.OpenStandardOutput());
        public static string _string{get{return Console.ReadLine();}}
        public static string[] _stringa{get{return (Console.ReadLine().Split());}}
        public static int _int{get{return int.Parse(Console.ReadLine());}}
        public static int[] _inta{get{return Console.ReadLine().Split().Select(x=>int.Parse(x)).ToArray();}}
        public static long _long{get{return long.Parse(Console.ReadLine());}}
        public static long[] _longa{get{return Console.ReadLine().Split().Select(x=>long.Parse(x)).ToArray();}}    
    }
}


Measured memory_bytes: 29264
import sys
input=sys.stdin.readline
n=int(input())
WSV=[tuple(map(int,input().split())) for i in range(n)]
WSV.sort(key=lambda x:x[0]+x[1])
DP=[0]*(10**4*2+1)
for w,s,v in WSV:
    for i in range(s+1)[::-1]:
        DP[i+w]=max(DP[i+w],DP[i]+v)
print(max(DP))

Measured memory_bytes: 41836
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn main() {
    let s: Vec<u32> = read::<String>()
        .chars()
        .map(|x| x.to_digit(10).unwrap())
        .collect();

    let k: usize = read();
    for i in 0..k {
        if s[i] != 1 {
            println!("{}", s[i]);
            return;
        }
    }
    println!("{}", 1);
}


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

inline int64_t ceiling_div(int64_t a, int64_t b){ // ceiling(a/b)= floor((a+b-1)/b)
  return (a+b-1)/b;
}

int main(){
  int Nlot, Ngoal;
  cin >> Nlot >> Ngoal;

  cout << ceiling_div(Ngoal-1, Nlot-1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
 
int garden[10][10] = {};
int min = 10;
 
int pond_area(int sx,int sy,int width,int height){
  int area = 0;
  for(int i=sx+1;i<width+sx-1;i++){
    for(int j=sy+1;j<height+sy-1;j++){
      int d = garden[j][i];
      area += (min - d);
    }
  }
  return area;
}
     
bool isPond(int sx,int sy,int width,int height){
  //std::cout << "start:(" << sx << ',' << sy << ") width = " << width << " height=" << height << '\n';
  int max = 0;
  min = 10;
  for(int k=sy;k<height+sy;k++){
    int d1 = garden[k][sx];
    int d2 = garden[k][sx+width-1];
    if(d1>d2) d1 = d2;
    if(min>d1) min = d1;
  }
  for(int k=sx;k<width+sx;k++){
    int d1 = garden[sy][k];
    int d2 = garden[sy+height-1][k];
    if(d1>d2) d1=d2;
    if(min>d1) min = d1;
  }
     
  for(int i=sx+1;i<width+sx-1;i++){
    for(int j=sy+1;j<height+sy-1;j++){
      int d = garden[j][i];
      if(max<d) max = d;
    }
  }
     
  //std::cout << "  min=" << min << "  max=" << max << '\n';
     
  if(min>max) return true;
  else return false;
}
 
     
int main(){
  int m,n;
  while(1){
    int max = 0;
    std::cin >> m >> n;
    if(m==0&&n==0) break;
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	std::cin >> garden[i][j];
      }
    }
    /*for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
      std::cout << garden[i][j] << ' ';
      }
      std::cout << '\n';
      }
    */
    for(int height=m;height>2;height--){
      for(int width=n;width>2;width--){
	for(int sy=0;sy<m-height+1;sy++){
	  for(int sx=0;sx<n-width+1;sx++){
	    if(isPond(sx,sy,width,height)){
	      int area = pond_area(sx,sy,width,height);
	      if(area > max) max = area;
	      //std::cout << "area=" << area << '\n';
	    }
	  }
	}
      }
    }
    std::cout << max << '\n';
  }
  return 0;
}



Measured memory_bytes: 2992
#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 = 1000003;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

// 拡張gcd
int ext_gcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1; y = 0; return a;
  }
  int q = a/b;
  int g = ext_gcd(b,a-q*b,x,y);
  int z = x-q*y;
  x = y; y = z;
  return g;
}

// 逆元 | a と m は互いに素
int inv_mod(int a, int m) {
  int x,y;
  ext_gcd(a,m,x,y);
  x %= m;
  if (x < 0) x += m;
  return x;
}

// 逆元(配列) | N! と MOD が互いに素
int fac[1000010], invfac[1000010], inv[1000010];
void init(int n) {
  fac[0] = 1;
  for (int i = 1; i < n; i++) fac[i] = fac[i-1]*i%MOD;
  invfac[n-1] = inv_mod(fac[n-1],MOD);
  for (int i = n-2; i >= 0; i--) invfac[i] = invfac[i+1]*(i+1)%MOD;
  for (int i = 1; i < n; i++) inv[i] = invfac[i]*fac[i-1]%MOD;
}

// 二分塁乗法 | n >= 0
int pow_mod(int x, int n, int m) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = res*x%m;
    x = x*x%m;
    n >>= 1;
  }
  return res;
}

int Q;

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

  init(1000003);
  cin >> Q;
  REP(i,Q) {
    int x,d,n;
    cin >> x >> d >> n;
    if (d == 0) {
      cout << pow_mod(x,n,MOD) << endl;
      continue;
    }
    int y = x*inv_mod(d,MOD)%MOD;
    if (y == 0 || y+n-1 >= MOD) {
      cout << 0 << endl;
      continue;
    }
    cout << fac[y+n-1]*invfac[y-1]%MOD*pow_mod(d,n,MOD)%MOD << endl;
  }

  return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

long long n[100001];

int main(){
	int N,M;
	scanf("%d %d", &N, &M);

	n[0] = 1;
	for(int i=1;i<=100000;i++){
		n[i] = n[i-1]*(long long)i;
		n[i] %= 1000000007;
	}

	long long ans;

	if(abs(N-M)>1){
		ans = 0;
	}else if(N!=M){
		ans = n[N] * n[M];
	}else{
		ans = n[N] * n[M];
		ans *= 2;
	}
	ans %= 1000000007;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi" ){
        dunk("Yes");
    }

    else{
        dunk("No");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
	int N, M;
	cin >> N >> M;
	vint l(M+1), r(M+1), sum(N+1, 0);
	for(int i = 0;i < M;i++){
		int li, ri;
		cin >> li >> ri;
		l[i] = li-1;
		r[i] = ri-1;
	}
	for(int i = 0;i < M;i++){
		sum[l[i]]++;
		sum[r[i]+1]--;
	}
	int ans = 0;
	int s = 0;
	for(int i = 0;i < N;i++){
		s += sum[i];
		if(s == M)	ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#s = gets.chomp
n = gets.chomp.to_i
#a,b = gets.chomp.split(" ").map{|i|i = i.to_i}
if n==1 then
  puts 1.0
#elsif n%2==1 then
elsif n%2==0 then
  puts (n/2)/(n.to_f)
else 
  puts ((n/2)+1)/(n.to_f)
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <unordered_set>
#include <set>
typedef long long LL;
using namespace std;
LL n, wei;
const LL INT_MIN = -0x7fffffff - 1;
int main() {
    scanf("%lld %lld", &n, &wei);
    vector<LL> w(n);
    vector<LL> v(n);
    vector<vector<LL>> dp(n + 1, vector<LL>(n * 3 + 1, INT_MIN));
    for(int i = 0; i < n; i++) {
        scanf("%lld %lld", &w[i], &v[i]);
    }
dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int a = n - 1; a >= 0; a--) {
            for(int b = 0; b<= 3 *n; b++) {
                if(dp[a][b] >= 0) {
                    LL b2 = b + w[i] - w[0];
                    dp[a + 1][b2] = max(dp[a + 1][b2], dp[a][b] + v[i]);
                }
            }
        }
    }
    LL ans = INT_MIN;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= 3 * n; j++) {
            if (i * w[0] + j <= wei) {
                ans = max(ans, dp[i][j]);
            }
        }
    }
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,t;
  cin>>n>>t;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  int mn=a[0];
  a.pb(-1);
  vector<int> v;
  map<int,int> re;
  for(int x:a){
    if(x<mn){
      //cout<<x<<v;
      int mx=*max_element(all(v));
      int m=v.size();
      vector<int> l(m+1),r(m+1);
      rep(i,m){
	if(v[i]==mn) l[i+1]=1;
	if(v[i]==mx) r[i]=1;
      }
      rep(i,m) l[i+1]+=l[i];
      rrep(i,m) r[i]+=r[i+1];
      int t=m;
      rep(i,m+1) MN(t,l[i]+r[i]);
      re[mx-mn]+=t;
      v.clear();
      mn=x;
    }
    v.pb(x);
  }
  cout<<re.rbegin()->Y<<endl;
  return 0;
}



Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  map<string, int> mp;
  int n;
  char e;
  string s;
  cin >> n;
  cin >> s;
  mp[s]++;
  e = s[s.size() - 1];
  rep(i,n-1)
  {
    cin >> s;
    if (e != s[0] || mp[s]) {
      cout << "No";
      return 0;
    }
    e = s[s.size() - 1];
    mp[s]++;
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<lli,lli> pll;
typedef std::vector<lli> vll;
typedef std::vector<pll> vpll;
typedef std::vector<bool> vbb;
typedef map<lli,lli>mll;
typedef map<lli,lli,greater<lli>>mllg;
lli MOD=1e9 +7;
const lli INF=1e18;
#define forr(i,p,n) for(i=p; i<n; i++)
#define be(a) a.begin(),a.end()
#define mp make_pair
#define um unordered_map
#define eb emplace_back 
#define pb push_back 
#define F first
#define S second
lli sub(lli a,lli b,lli p=MOD){return ((a%p)-(b%p)+p)%p;}
lli mult(lli a,lli b, lli p=MOD) {return ((a%p)*(b%p))%p;}
lli add(lli a, lli b, lli p=MOD) {return (a%p + b%p)%p;}
lli fpow(lli n, lli k, lli p = MOD) {lli r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
lli inv(lli a, lli p = MOD) {return fpow(a, p - 2, p);}
lli fdiv(lli a,lli b,lli p=MOD){
	lli yinv=inv(b);
	lli ans=(a*yinv)%p;
	return ans;
}
ull I1018=1000000000000000000;const ull I10e5=100000;const lli I10e6=1e6;
lli ZERO=0;ull I10e9=1000000000;lli ONE=1;
void printVecpll(std::vector<pll> v){
	for(auto p:v){
		cout<<(char)p.first<<" "<<p.second<<endl;
	}
}
void printVec(std::vector<lli> v){
	for(lli i=0;i<v.size();i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}
vll read_vec(lli n){
	lli i;
	vll v(n);
	forr(i,0,n){
		cin>>v[i];
	}
	return v;
}
void print_um(unordered_map<lli,lli>m){
	for(pair<lli,lli>p:m){cout<<p.first<<" "<<p.second<<endl;   }
}
std::vector<bool> is_prime;
std::vector<lli> primes;
void sieve(lli n){
	is_prime.resize(n+2,true);
	primes.clear();
	lli p;
	for(p=2;p*p<=n;p++){
		if(is_prime[p]){
			lli i;
			for(i=p*p;i<=n;i+=p){
				is_prime[i]=false;
			}
		}
	}
	is_prime[0]=is_prime[1]=false;
	lli i;
	for(i=2;i<=n;i++){
		if(is_prime[i]){
			primes.eb(i);
		}
	}
}

//     //FACTORIAL
// std::vector<lli> fact_vec(10004);
// void fact_fun(lli n){
// 	lli i;
// 	fact_vec[0]=1;
// 	for(i=1;i<=n+2;i++){
// 		fact_vec[i]=(fact_vec[i-1]*i)%MOD;
// 	}
// }

    //declare

// class Sol{      	
// public: 
// 	Sol(){			
// 	}
// };
int main(){	
	ios::sync_with_stdio(false);
	cin.tie(0);
 //    #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
 //    #endif
	lli a,b;
	cin>>a>>b;
	if(a<=9 && b<=9){
		lli ans=a*b;
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}   




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

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int sum = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i=1;i<=k;i++){
			for(int j=1;j<=k;j++){
				if (i < j){
					list.add(gcd(j,i));
				}
				else{
					list.add(gcd(i,j));
				}
			}
		}
		for(int i=1;i<=k;i++){
			for(int j=0;j<list.size();j++){
				if (i < list.get(j)){
					sum += gcd(list.get(j), i);
				}
				else{
					sum += gcd(i, list.get(j));
				}
			}
		}
		System.out.println(sum);
	}

	public static int gcd(int x, int y){
		int z = x%y;
		if(z!=0){
			return gcd(y, z);
		}
		return y;
	}
}

Measured memory_bytes: 36972
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    long long ans = 0;
    for(int i = 0; i < 60; i++){
        long long x = 0;
        for(int j = 0; j < n; j++){
            if((A[j] >> i) & 1) x++;
        }
        long long now = x * (n - x) % MOD;
        for(int j = 0; j < i; j++){
            now = (now * 2) % MOD;
        }
        ans = (ans + now) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n;
int w[120];
int qzh[120];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>w[i];
	for(int i=1;i<=n;i++)
		qzh[i]=qzh[i-1]+w[i];
	int res=qzh[n];
	for(int i=1;i<=n;i++){
		res=min(res,abs(qzh[i]-(qzh[n]-qzh[i])));
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum = 0;

    for(int i = 0;i < 2;i++) {
      if(a >= b) {
        sum += a;
        a--;
      } else {
        sum += b;
        b--;
      }
    }

    System.out.println(sum);

  }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define mii map<int,int>
#define ff first
#define ss second
#define mll map<long long,long long>
#define ull unordered_map<long long,long long>
#define pb push_back
#define si set<int>
#define mp make_pair
#define sll set<long long>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define test(t) ll t;cin>>t;while(t--)
#define mod 1000000007
#define SIZE 1000001
#define rep(a,b) for(int a=0;a<b;a++)
#define reps(a,b,c) for(int a=b;a<c;a++)
#define I INT_MAX
#define Im INT_MIN
using namespace std;

int main()
{
    ll n,w,ans=0;
    cin>>n>>w;
    ll a[n][2];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
    }
    map<ll,ll> m;
    m[w]=0;
    for(int i=0;i<n;i++)
    {
        for(auto p:m)
        {
            if((p.ff-a[i][0])>=0)
                m[p.ff-a[i][0]]=max(m[p.ff-a[i][0]],p.ss+a[i][1]);
        }
    }
    for(auto p:m)
        ans=max(ans,p.ss);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9744
n=int(input())
A=list(map(int,input().split()))
A=list(map(lambda x:x//400 if x<3200 else 8,A))
n_red=A.count(8)
red_exist=1 if n_red else 0
n_min=len(set(A)) if not red_exist else len(set(A))-1
print(1 if not n_min else n_min,n_min+n_red)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;

#define MAXN 100000
int N,K;
int A[MAXN+5];
long long SumP[MAXN+5],Sum[MAXN+5];

int main(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++){
        scanf("%d",&A[i]);
        Sum[i]=Sum[i-1]+A[i];
        SumP[i]=SumP[i-1]+(A[i]>0)*A[i];
    }
    long long Ans=0;
    for(int i=K;i<=N;i++){
        long long tmp=Sum[i]-Sum[i-K];
        tmp=(tmp>0)*tmp+SumP[i-K]+SumP[N]-SumP[i];
        Ans=max(Ans,tmp);
    }
    printf("%lld",Ans);
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <unordered_map>

using namespace std;

static array<int, 2> bases{6, 9};

// n円引き出すには何回操作が必要か
int solve(int n, unordered_map<int, int> &memo) {
  if (memo.count(n) > 0) {
    return memo[n];
  }

  if (n == 0) {
    return 0;
  }

  int min_op = n + 1;
  for (auto base : bases) {
    int exp = 1;
    while(n >= exp) {
      min_op = min(solve(n - exp, memo) + 1, min_op);
      exp *= base;
    }
  }

  return memo[n] = min_op;
}

int main(int argc, const char *argv[])
{
  int n;
  cin >> n;

  unordered_map<int, int> memo;
  cout << solve(n, memo) << "\n";
  return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

// 考察
// 対称性は斜めに遷移させても変わらない
// -> (A,B) == (A+x,B+x)
// 調べるべきもの
// -> if n=3: (1,0) == (2,1) == (0,2) == stop!! (1,0)
// -> A,Bのdiffが異なるものだけ調べて対象の場合は、ans += n

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string board[n];
  rep(i,n) cin >> board[i];

  ll ans = 0;

  rep(diff,n){ // a,b の組み合わせループ(aを固定)
    int b = (diff) % n;
    bool flag = true;
    rep(_i,n)rep(_j,n){
      int i = _i;
      int j = (_j + b) % n;
      int ri = _j;
      int rj = (_i+b) % n;
      if(board[i][j] != board[ri][rj]) flag = false;
    }
    if(flag) ans += n;
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 384
def BubbleSort(C,N):
    for a in range(0,N-1):
        for b in range(N-1,a,-1):
            if int(C[b][1]) < int(C[b-1][1]):
                C[b],C[b-1] = C[b-1],C[b]

def SelectionSort(C,N):
    for a in range(0,N-1):
        index_min = [x[1] for x in C[(a+1):]].index(min([x[1] for x in C[(a+1):]]))+a+1
        # print(f'{min(A[a+1:])} {index_min}')
        if C[a][1] > C[index_min][1]:
            C[a],C[index_min] = C[index_min],C[a]


N = int(input())
A = input().split()
B = A.copy()

BubbleSort(A,N)
print(*A)
print('Stable')

SelectionSort(B,N)
print(*B)
if A == B:
    print('Stable')
else:
    print('Not stable')




Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int n=s.size();
string s1=s.substr(0,(n-1)/2);
string s2=s.substr((n-1)/2+1,n-(n-1)/2+1);
string _s=s;
string _s1=s1;
string _s2=s2;
reverse(_s.begin(),_s.end());
reverse(_s1.begin(),_s1.end());
reverse(_s2.begin(),_s2.end());
if(s==_s&&s1==_s1&&s2==_s2){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
//system("pause");
return 0;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
vi arr;
void in(){
    cin >> n;
    rep(i,0,n) arr.push_back(input());
    sort(all(arr));

}

int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
void solve(){

    int g = arr[0];

    rep(i,1,n){
        g = gcd(g, arr[i]);
    }

    print(g);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 1400
using System;


namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string s2 = s + s;
            string p = Console.ReadLine();
            if (s2.Contains(p))
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 9792
#include <stdio.h>

int main(){
    long int i=1, ans;
    int N;

    scanf("%d", &N);

    while(1){
        if(i*i <= N){
            ans = i*i;
            i++;
        }
        else{
            printf("%d\n", ans);
            return 0;
        }
    }
}

Measured memory_bytes: 128
a,b,c=map(int,input().split())
lst=[a,b,c]
lst.sort()
x=lst[0]
y=lst[1]
z=lst[2]

if (z-x)%2==(z-y)%2==1:
    print(1+int((2*z-x-y-2)/2))
elif (z-x)%2==(z-y)%2==0:
    print(int((2*z-x-y)/2))
elif z%2==x%2:
    z+=1
    x+=1
    print(1+int((2*z-x-y)/2))
else:
    z+=1
    y+=1
    print(1+int((2*z-x-y)/2))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
using VP = vector<P>;
using VVI = vector<VI>;

int main() {
    long a, b;
    cin >> a >> b;
    cout << a + (a <= b) - 1 << endl;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    int[][] red = new int[n][2];
    int[][] blue = new int[n][2];

    for (int i = 0; i < n; ++i) {
      red[i][0] = sc.nextInt();
      red[i][1] = sc.nextInt();
    }

    for (int i = 0; i < n; ++i) {
      blue[i][0] = sc.nextInt();
      blue[i][1] = sc.nextInt();
    }

    ArrayList<int[]> redL = new ArrayList<>();
    Collections.addAll(redL, mergeSort(red));

    ArrayList<int[]> blueL = new ArrayList<>();
    Collections.addAll(blueL, mergeSort2(blue));

    /*
    for (int[] i : redL) {
      System.out.print("(" + i[0] + ", " + i[1] + ")  ");
    }
    System.out.println();

    for (int[] i : blueL) {
      System.out.print("(" + i[0] + ", " + i[1] + ")  ");
    }
    System.out.println();
    */

    int res = 0;

    for (int j = 0; j < blueL.size(); ++j) {
      int[] bPoint = blueL.get(j);
      for (int i = redL.size() - 1; i >= 0; --i) {
        int[] rPoint = redL.get(i);
        if (rPoint[0] < bPoint[0] && rPoint[1] < bPoint[1]) {
          ++res;
          redL.remove(i);
          break;
        }
      }
    }


    System.out.println(res);
  }

  public static int[][] mergeSort(int[][] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[][] left = new int[mid][2];
    int[][] right = new int[a.length - mid][2];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge(mergeSort(left), mergeSort(right));
  }

  public static int[][] merge(int[][] l, int[][] r) {
    int[][] merged = new int[l.length + r.length][2];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i][0] < r[j][0] || (l[i][0] == r[j][0] && l[i][1] <= r[i][1]))
      //if (l[i][0] + l[i][1] <= r[i][0] + r[i][1])
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }

  public static int[][] mergeSort2(int[][] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    int[][] left = new int[mid][2];
    int[][] right = new int[a.length - mid][2];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge2(mergeSort2(left), mergeSort2(right));
  }

  public static int[][] merge2(int[][] l, int[][] r) {
    int[][] merged = new int[l.length + r.length][2];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      //if (l[i][0] < r[j][0] || (l[i][0] == r[j][0] && l[i][1] <= r[i][1]))
      if (l[i][1] < r[j][1] || (l[i][1] == r[j][1] && l[i][0] <= r[i][0]))
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }
}

Measured memory_bytes: 22996
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int a, b;
		int sum = 0, g = 1;
		
		cin >> a;
		if( cin.eof() )	{ break; }
		
		cin >> b;
		sum += a + b;
		
		while(sum >= 10) {
			g++;
			sum /= 10;
		}
		cout << g << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{
    static readonly int[] diffs = { 1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049 };
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Enumerable.Repeat(int.MaxValue, n + 1).ToArray();
        a[0] = 0;
        for (int i = 0; i < a.Length; i++)
        {
            foreach (var diff in diffs)
            {
                if (diff + i >= a.Length) continue;
                a[diff + i] = Min(a[diff + i], a[i] + 1);
            }
        }
        Console.WriteLine(a.Last());
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef vector<ll> vec;

int main(int argc, char const *argv[])
{
    ll N,H,W;
    cin >> N;
    cin >> H;
    cin >> W;
    ll cnt = 0;
    
    for(ll i = 0; i <= N-H; i++){
        for(ll k = 0; k <= N-W; k++){
            cnt++;
        }
    }

    cout << cnt << endl;
}

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

#define ll long long
#define ld long double
using namespace std;

int main() {
    char a,b;
    cin >> a >> b;
    if (a == b && a == 'H')
        cout << "H" << endl;
    else if (a == 'D' && b == 'H')
        cout << "D" << endl;
    else if (a == b && a == 'D')
        cout << "H" << endl;
    else if (a == 'H' && b == 'D')
        cout << "D" << 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;
int64_t getpower(int64_t a,int64_t p) {
	int64_t waru = (int64_t)((1e9) + 7);
	int64_t result = 1;  //d = (int64_t)log2(p);
	vector<int64_t> L;
	for (int64_t i = 1; i < p*2; i*=2)
	{
		int64_t ap = ((p / i) % 2 == 1) ? a : 1;
		result = result * ap % waru;
		a = (a * a) % waru;
	}


	return result;

}
int main()
{
	int64_t n, a, b;
	int64_t waru = (int64_t)1e9 + 7;
	cin >> n >> a >> b;

	int64_t maxpattern = 1,ans,nca=1,ncb=1;

	maxpattern = getpower(2, n);
	maxpattern--;
	//ans = maxpattern;

	for (int i = 0; i < a; i++)
	{
		nca = nca * (n - i) % waru;
		nca = nca * getpower(i + 1,waru-2) % waru;
	}
	for (int i = 0; i < b; i++)
	{
		ncb = ncb * (n - i) % waru;
		ncb = ncb * getpower(i + 1,(waru-2)) % waru;
	}
	//n = 256 * 256;
	//n = n * n;
	//n = n * (n-1);
	//cout <<n <<endl;
	cout << (maxpattern+waru-nca+waru-ncb)%waru;
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func nextChar(c rune) rune {
	if c == '0' {
		return c + 1
	}
	return c - 1
}

func main() {
	var s string
	fmt.Scanln(&s)
	ans := len(s)
	for _, c := range "01" {
		sum := 0
		for _, d := range s {
			if c != d {
				sum++
			}
			c = nextChar(c)
		}
		if sum < ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include "iostream"
using namespace std;

char problem[100011];
int far;

int main() {
	cin >> problem;
	for (int i = 0; problem[i] != NULL; i++) {
		far = i;
	}
	for (int i = 0; i <= far;) {
		//cout << i << "\n";
		if (problem[i] == 'd') {
			if (problem[i + 1] == 'r'&&problem[i + 2] == 'e'&&problem[i + 3] == 'a'&&problem[i + 4] == 'm') {
				if (problem[i + 5] == 'e'&&problem[i + 6]=='r') {
					if(problem[i+7]=='a')i += 5;
					else i += 7;
				}
				else i += 5;
			}
			else {
				cout << "NO\n";
				return 0;
			}
		}
		else if (problem[i] == 'e') {
			if (problem[i + 1] == 'r'&&problem[i + 2] == 'a'&&problem[i + 3] == 's'&&problem[i + 4] == 'e') {
				if (problem[i+5] == 'r')i += 6;
				else i += 5;
			}
			else {
				cout << "NO\n";
				return 0;
			}
		}
		else {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  while(1){
    long long n,a[70000],b[70000],max,nagasa=0,m;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      scanf("%lld",&a[i]);
      nagasa+=a[i];
    }
    for(int i=0;i<n-1;i++)scanf("%lld",&b[i]);
    m=n-1;
    sort(b,b+m);
    max=nagasa*n;
    for(int i=n-1;i>0;i--){
      nagasa+=b[i-1];
      if(max<nagasa*i)max=nagasa*i;
    }
    printf("%lld\n",max);
  }
  return 0;
}

Measured memory_bytes: 4196
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

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

  ll ans = 0;
  if (n * 2 <= m) {
    m -= n * 2;
    ans += n;
    ans += m / 4;
    cout << ans << endl;
  } else
    cout << m / 2 << endl;
}


Measured memory_bytes: 256
S = input()

for i in range(len(S)):
  if i % 2 == 0 and S[i] != "R" and S[i] != "U" and S[i] != "D":
    print("No")
    exit()
  if i % 2 == 1 and S[i] != "L" and S[i] != "U" and S[i] != "D":
    print("No")
    exit()
  
print("Yes")


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,m;
    cin >>n >>m;
    vector<int> a(n+1);
    rep(i,n) cin >>a[i+1];

    for(int k=1; k<=m; ++k)
    {
        int b=1;
        while(1)
        {
            if(b==n) break;

            if(a[b]%k > a[b+1]%k) swap(a[b],a[b+1]);
            ++b;
        }
    }

    rep(i,n) printf("%d\n", a[i+1]);
    return 0;
}

Measured memory_bytes: 3220
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

int main() {
	for (int N, M; N = in(), M = in();) {
		vector<int> t(N), u;
		for (int &p: t)
			p = in();
		t.push_back(0);
		sort(t.rbegin(), t.rend());
		for (auto i = t.begin(); i != t.end(); i++)
			for (auto j = i; j != t.end(); j++)
				if (*i + *j <= M)
					u.push_back(*i + *j);
		sort(u.rbegin(), u.rend());
		u.erase(unique(u.begin(), u.end()), u.end());
		int r = 0;
		for (auto i = u.begin(), e = u.end(); i != e; i++) {
			e = lower_bound(i + 1, e, M - *i, greater<int>());
			r = max(r, *i + *e);
		}
		outl(r);
	}
}


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


void solve(long long N, std::vector<float> H){
    vector<float> dH(N-1, 0);
    for(int i = 0; i < N-1; ++i){
        if(H[i+1] - H[i] <= 0) dH[i] += 1;
    }
    //for(int i = 0; i < N; ++i) cout << dH[i] << endl;
    //cout << endl;
    vector<float> ans(N, 0);
    for(int i = 0; i < N-1; ++i){
        if(dH[i] > 0) ans[i+1] = ans[i] + dH[i];
        else ans[i+1] = 0;
    }
    //for(int i = 0; i < N; ++i) cout << ans[i] << endl;
    sort(ans.begin(), ans.end(), greater<float>());
    cout << ans[0] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<float> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%fd",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 4672
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a + b + c == max({a, b, c}) * 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256