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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

#define fi first
#define se second

int n;
int a[125252];
pii p[125252];
pii dp[125252][2];

void pma(pii &a, pii b){
  if(a.first > b.first){
    a = b;
  }else if(a.first == b.first && a.second < b.second){
    a = b;
  }
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n){
    int x = a[i];
    int y=0, z=0;
    if(__builtin_popcount(x)==1){
      y = 1;
    }
    while(x>1){
      z++;
      x = (x+1)/2;
    }
    p[i] = pii(y,z);
  }
  pii PO = pii(1e9, -1e9);
  REP(i,n+1)dp[i][0] = dp[i][1] = PO;
  dp[0][0] = dp[0][1] = pii(0,0);
  REP(i,n){
    if(p[i].first == 1){
      // pow 2
      pii nxt = PO;
      pii x = dp[i][0];
      pma(nxt, pii(x.fi + max(0,p[i].se-x.se), p[i].se));
      x = dp[i][1];
      pma(nxt, pii(x.fi + max(0,p[i].se-x.se), p[i].se));
      dp[i+1][0] = dp[i+1][1] = nxt;
    }else{
      // left connect (0)
      {
        pii nxt = PO;
        pii x = dp[i][0];
        pma(nxt, pii(x.fi + max(0,p[i].se-x.se), max(0,p[i].se-1)));
        x = dp[i][1];
        pma(nxt, pii(x.fi + max(0,p[i].se-x.se), max(0,p[i].se-1)));
        dp[i+1][0] = nxt;
      }
      // right connect (1)
      {
        pii nxt = PO;
        pii x = dp[i][0];
        pma(nxt, pii(x.fi + max(0,(p[i].se-1)-x.se) + 1, p[i].se));
        x = dp[i][1];
        pma(nxt, pii(x.fi + max(0,(p[i].se-1)-x.se) + 1, p[i].se));
        dp[i+1][1] = nxt;
      }
    }
  }
  // REP(i,n+1){
  //   printf("(%4d,%4d) (%4d,%4d)\n", dp[i][0].fi, dp[i][0].se, dp[i][1].fi, dp[i][1].se);
  // }
  int ans = min(dp[n][0].fi, dp[n][1].fi);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>

const int mod = 1000000007;

int N,C,A[404],B[404],D[404][404],S[404][404];

void add(int &a, int b)
{
	a += b;
	if (a >= mod)
		a -= mod;
}

void mul(int &a, int b)
{
	a = (long long)a * b % mod;
}

int main()
{
	scanf ("%d %d",&N,&C);
	for (int i=1;i<=N;i++) scanf ("%d",&A[i]);
	for (int i=1;i<=N;i++) scanf ("%d",&B[i]);

	for (int k=0;k<=C;k++){
		for (int j=1;j<=400;j++){
			int m = 1;
			for (int i=0;i<k;i++) mul(m,j);
			add(S[k][j],m);
			add(S[k][j],S[k][j-1]);
		}
	}

	D[0][0] = 1;
	for (int i=1;i<=N;i++){
		for (int l=0;l<=C;l++) for (int k=0;k<=l;k++){
			int u = (S[k][B[i]] - S[k][A[i]-1] + mod) % mod;
			int v = D[i-1][l-k];
			mul(v,u);
			add(D[i][l],v);
		}
	}

	printf ("%d\n",D[N][C]);

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[100];
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    for(int i = 1;i < m+1;i++){
        for(int j = 0;j < n-1;j++){
            //cout << "*" << i << "*" << j << endl;
                int p = a[j];
                int q = a[j+1];
                p = p % i;
                q = q % i;
            
             if(p > q){
                int s = a[j];
                a[j] = a[j+1];
                a[j+1] = s;
            } 
        }
    }
    for(int i = 0;i < n;i++){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int a[200005],n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	int now=0;
	a[0]=-1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>a[i-1]+1)
		{
			puts("-1");
			return 0;
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i+1]<=a[i]) ans+=a[i];
	}
	cout<<ans;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    int x, y;
    if (a < b)
    {
        x = a;
        y = b;
    }
    else
    {
        x = b;
        y = a;
    }

    for (int i = 0; i < y; i++)
    {
        cout << x;
    }
    cout << endl;

    return 0;
}


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

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = int.Parse(spl[1]);

        var sum = 0L;

        for(int i=k; i<=n; i++) {
            var y = calc(n - (i - 1), n)+1;
            //Debug.Write(y.ToString());

            var y2 = calc(0, (i-1));
            //Debug.Write("-" + y2);

            y -= y2;
            //Debug.Write("=" + y);
            //Debug.WriteLine("");

            if (y < 0) y += Mod;

            sum += y % Mod;
            sum %= Mod;
        }

        return sum+1;
    }

    static long calc(long n, long m) {
        //Debug.WriteLine("n:" + n + " m:" + m);
        var y = (n + m) % Mod;
        y = (y * (m - n + 1)) % Mod;
        y = ModSq(y, 2);
        return y % Mod;
    }

    static long ModSq(long x1, long x2) {
        long bb = ModPow(x2, Mod - 2);
        return (x1 * bb) % Mod;
    }

    static long ModPow(long x1, long x2) {
        long ans = 1;
        while (x2 > 0) {
            if (x2 % 2 == 1) {
                ans = (ans * x1) % Mod;
            }
            x1 = (x1 * x1) % Mod;
            x2 /= 2;
        }
        return ans % Mod;
    }

}


Measured memory_bytes: 27304
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(short i = 0; i < n; i++)



int main() {
    int sx, sy, tx, ty;
    
    cin >> sx >> sy >> tx >> ty;
    
    string ans;
    REP(i, tx - sx){
        ans += 'R';
    }
    REP(i, ty - sy){
        ans += 'U';
    }
    REP(i, tx - sx){
        ans += 'L';
    }
    REP(i, ty - sy){
        ans += 'D';
    }
    
    ans += 'D';
    REP(i, tx - sx + 1){
        ans += 'R';
    }
    REP(i, ty - sy + 1){
        ans += 'U';
    }
    ans += "LU";
    REP(i, tx - sx + 1){
        ans += 'L';
    }
    REP(i, ty - sy + 1){
        ans += 'D';
    }
    ans += 'R';
    
    cout << ans << endl;
}


Measured memory_bytes: 384
def sol(h, w):
    if h == 1 or w == 1:
        return 1
    a = (w+1) // 2
    b = w // 2
    res = (a+b) * (h//2)
    if h & 1:
        res += a
    return res

def main():
    h, w = map(int, input().split())
    print(sol(h, w))

if __name__ == '__main__':
    main()



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

int main() {
    int n, s[100010], q;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> s[i];

    cin >> q;
    int ans = 0;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        int l = 0, r = n - 1;
        while (l <= r) {
            int m = (l + r) / 2;
            if (s[m] == t) {
                ++ans;
                break;
            }
            if (s[m] > t)
                r = m - 1;
            else
                l = m + 1;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3360
def examB():
    K, S = LI()
    ans = 0
    for x in range(K + 1):
        if 0 <= S - x <= K:
            ans += S - x  + 1
        elif K < S - x <= 2 * K:
            ans += K - (S - x - K) + 1
    print(ans)

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3316
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

//
// セグメント木
//
type segTree []int

const segTreeDefault = 0

// マージ関数
func (s *segTree) segMerge(a, b int) int {
	if a > b {
		return a
	}
	return b
}

/*
func (s *segTree) segMerge(a,b, int) int {
	return a+b
}
*/

func segTreeInit(N int) segTree {
	size := 1
	for N > size {
		size <<= 1
	}
	s := make(segTree, size*2)
	for i := 0; i < size*2; i++ {
		s[i] = segTreeDefault
	}
	s[0] = 0
	return s
}

func (s *segTree) set(i, pos int) {
	N := len(*s)/2 + pos
	(*s)[N] = i
	for N > 1 {
		N /= 2
		(*s)[N] = s.segMerge((*s)[2*N], (*s)[2*N+1])
	}
}

func (s *segTree) setAll(a []int, n int) {
	N := len(*s) / 2
	for i := 0; i < n; i++ {
		(*s)[N+i] = a[i]
	}
	for N > 1 {
		N >>= 1
		for i := 0; i < N; i++ {
			pos := N + i
			(*s)[pos] = s.segMerge((*s)[2*pos], (*s)[2*pos+1])
		}
	}
}

func (s *segTree) querySub(l, r, index, L, R int) int {
	if R <= l || r <= L {
		return segTreeDefault
	}
	if l <= L && R <= r {
		return (*s)[index]
	}
	med := (L + R) / 2
	lval := s.querySub(l, r, index*2, L, med)
	rval := s.querySub(l, r, index*2+1, med, R)
	return s.segMerge(lval, rval)
}

// queryの区間は[l, r)です
func (s *segTree) query(l, r int) int {
	return (*s).querySub(l, r, 1, 0, len(*s)/2)
}

/*
	seg := segTreeInit(N)

	seg.setAll(a, N)
	seg.set(val, pos)
	seg.query(l, r) // [L, R)
*/

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// Data :
type Data struct {
	X int
}

type flower struct {
	h, a int
}

// Datas :
type Datas []flower

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	return p[i].h < p[j].h
}

func solve(N int, d Datas) int {
	seg := segTreeInit(N)

	for i := 0; i < N; i++ {
		v := seg.query(0, d[i].h)
		v += d[i].a
		seg.set(v, d[i].h)
	}

	return seg.query(0, N)
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	d := make(Datas, N)
	for i := 0; i < N; i++ {
		d[i].h = getInt() - 1
	}
	for i := 0; i < N; i++ {
		d[i].a = getInt()
	}
	out(solve(N, d))
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int P[20];
	rep(i, N) cin >> P[i];

	int kotae = 0;
	rep(i, N - 2) {
		if (P[i] < P[i + 1] && P[i + 1] < P[i + 2]) kotae++;
		else if (P[i] > P[i + 1] && P[i + 1] > P[i + 2]) kotae++;
	}

	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 256
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()

    let rec func c mxcount count =
        function
        | [] -> max mxcount count
        | x::xs when x = c -> func c (max mxcount count) 0 xs
        | _::xs -> func c mxcount (count+1) xs

    let arr = scanner.Next() |> Seq.toList
    let f = fun x -> func x 0 0 arr

    [|'a'..'z'|]
    |> Array.map f
    |> Array.min
    |> printfn "%i"

    0


Measured memory_bytes: 14940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll n;
    cin >> n;
    ll num = 1;
    ll z = 26;
    while (1) {
        if (n-z>0) {
            n -= z;
            z *= 26;
            num++;
        }
        else break;
    }
    string ans = string(num, 'a');
    n--;
    rrep(i, num) {
        ans[i] = 'a' + n%26;
        n /= 26;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> a(n+2,0),d(n+2,0);
    for(int i=0;i<n;i++){
        cin>>a[i+1];
        d[i+1]=abs(a[i+1]-a[i]);
    }
    d[n+1]=abs(a[n]);
    partial_sum(d.begin(),d.end(),d.begin());
    for(int i=1;i<=n;i++){
        cout<<d[i-1]+d[n+1]-d[i+1]+abs(a[i-1]-a[i+1])<<endl;
    }
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <utility>

#define MAX_V 100010
using namespace std;
vector<int> G[MAX_V];
vector<pair<int,int>> toi;
stack<int> st;
bool used[MAX_V];
int d[MAX_V],a[MAX_V],V;

void dfs(int s){
	used[s] = true;
	st.push(s);
	while(!st.empty()){
		int e = st.top();
		st.pop();
		for(int i=0;i<G[e].size();i++){
			if(!used[G[e][i]]){
				used[G[e][i]] = true;
				d[G[e][i]] = d[e]+1;
				st.push(G[e][i]);
			}
		}
		
	}
}

void dfs1(int s){
	used[s] =false;
	st.push(s);
	while(!st.empty()){
		int e = st.top();
		st.pop();
		for(int i=0;i<G[e].size();i++){
			if(used[G[e][i]]){
				used[G[e][i]] = false;
				st.push(G[e][i]);
			}
		}
	}
}
	
int main(){
	int i,j,k,ans=0,cnt,x,y;
	cin >> V >> k;
	cin >> i;
	if(i!=1){
		ans++;
	}
	for(i=1;i<V;i++){
		cin >> a[i];
		a[i]--;
		G[a[i]].push_back(i);
	}

	for(i=0;i<V;i++){
		G[i].push_back(-1);
		used[i] = false;
		d[i] = 0;
	}
	dfs(0);

	for(i=0;i<V;i++){
		if(d[i]>k){
			toi.push_back(make_pair(d[i],i));
		}
	}
	sort(toi.begin(),toi.end());

	for(i=toi.size()-1;i>=0;i--){
		if(used[toi[i].second]){
			ans ++;
			cnt = 0;
			x = toi[i].second;
			while(cnt<k-1){
				cnt++;
				y = a[x];
				x = y;
			}
			dfs1(x);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8440
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long
#define Graph vector<vector<int> >
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    // A, B バラ買いパターン
    int n = a * x + b * y;

    // A, B のどちらか必要な量を超えるパターン
    int m = 2 * c * max(x, y);

    // 必要最小限の Cセットを買い、足りない分はバラ買いパターン
    int p = x < y ? b : a;
    int l = 2 * c * min(x, y) + p * abs(x - y);

    // 上記のうちでいっちゃん安いの
    int ans = min(n, min(m, l));
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int h, w;
    cin >> h >> w;
    int n; cin >> n;
    vector<int> c(n);
    REP(i,n) cin >> c[i];

    vector<vector<int>> ans(h,vector<int>(w));
    int x = 0, y = 0;
    const int R=0,D=1,L=2,U=3;
    int dir=0;

    REP(i,n) {
        int a = i+1;
        int b = c[i];
        REP(j,b) {
            ans[y][x] = a;
            switch (dir)
            {
            case R:
                if (x == w-1 || ans[y][x+1] !=0 ) dir++;
                break;
            case D:
                if (y == h-1 || ans[y+1][x] !=0 ) dir++;
                break;
            case L:
                if (x == 0 || ans[y][x-1] !=0 ) dir++;
                break;
            case U:
                if (y == 0 || ans[y-1][x] !=0 ) dir=0;
                break;
            default:
                break;
            }

            switch (dir)
            {
            case R:
                x++;
                break;
            case D:
                y++;
                break;
            case L:
                x--;
                break;
            case U:
                y--;
                break;
            default:
                break;
            }
        }
    }

    for(auto v:ans) {
        REP(i,v.size()-1) cout << v[i] << " ";
        cout << v.back() << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a;
	cout<<800*a-200*(a/15);



	cout<<endl;
} 


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=200003;

map<ll,ll> primefactor(ll n){
  map<ll,ll> res;
  for( ll i=2LL ;i*i<=n;i++){
    while(n%i==0){
      ++res[i];
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}


int main(){
  ll n;
  cin>>n;
  ll res=0;
  int now=0;
  res+=n/11LL;
  res*=2LL;
  ll rest=n%11LL;
  if(rest!=0 and rest<=6LL)res++;
  else if (rest!=0 and rest>6LL)res+=2;
  cout<<res<<endl;
  return 0;
}


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

 using namespace std;

 int main() {
   int N, i;
   string ans;

   cin >> N;

   vector<char> S(N);

   for (i = 0; i < N; i++) cin >> S.at(i);

   ans = "Three";
   for (i = 0; i < N; i++) {
     if (S.at(i) == 'Y') {
       ans = "Four";
       break;
     }
   }

   cout << ans << endl;
}


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

int main() {
  int n, m, sum=0;
  cin >> n >> m;
  vector<int> A(n);
  rep(i,n) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  int cnt=0;
  double b = sum/(4.0*m);
  rep(i,n) {
    if(b <= A.at(i)) cnt++;
  }
  string ans = "No";
  if (cnt>=m) ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  
  int n;
  cin >> n;
  string s[n];
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  int m;
  cin >> m;
  string t[m];
  for(int i = 0; i < m; i++){
    cin >> t[i];
  }
  
  int max = 0;
  for(int i = 0; i < n; i++){
    int count = 0;
    for(int j = 0; j < n; j++){
      if(s[i] == s[j]){
        count++;
      }
    }
    for(int j = 0; j < m; j++){
      if(s[i] == t[j]){
        count--;
      }
    }
    if(count > max){
      max = count;
    }
  }
  
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  int l, r;
  int S = 0; 
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    S += r - l + 1;
  }
  cout << S << endl;
}

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

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int);
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fastpow(ll, ll, ll);
ll slowpow(ll, ll, ll);
ll _gcd(ll, ll);
ll _lcm(ll, ll);
ll extgcd(ll, ll, ll&, ll&);
ll _inv(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

const int N = 50;
int D[N];

int main()
{
    int n = si();

    int res = 0;
    for (int i = 0; i < n; ++i)
    {
        int d = si();
        D[i] = d;
        for (int j = 0; j < i; ++j)
            res += D[j] * d;
    }

    pi(res);

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fastpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slowpow(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll _gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

ll _lcm(ll a, ll b)
{
    return a / _gcd(a, b) * b;
}

ll extgcd(ll a, ll b, ll& k, ll& l)
{
    if (b == 0)
    {
        k = 1; l = 0;
        return a;
    }
    ll res = extgcd(b, a % b, l, k);
    l -= a / b * k;
    return res;
}

ll _inv(ll a, ll p)
{
    return fastpow(a, p - 2, p);
}


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


map <string , int > m ;

bool fun( pair < int , string > a , pair < int , string > b ){
	if( a.first > b.first ) return true ;
	else if( a.first == b.first ) return a.second < b.second ;
	else return false ;
}

int main(){
	int N ;
	string s ;
	cin >> N ;
	for( int i = 0 ; i < N ; i++ ){
		cin >> s ;
		if(m.find(s) != m.end() )m[s]++ ;
		else m[s] = 1 ;
	}
	vector < pair < int , string > > p ;
	for( auto  x : m ){
		p.push_back({x.second,x.first});
	}
	sort(p.begin(),p.end(),fun) ;
	cout << p[0].second << endl ;
	for( int i = 1 ; i < p.size() ; i++ ){
		if( p[0].first == p[i].first ) cout << p[i].second << endl ;
		else break ;
	}




	return 0 ;
}

Measured memory_bytes: 29556
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>

int main(void) {
	int N, K, V;
	std::cin >> N >> K;

	std::unordered_map<int, int> mymap;

	for (int i = 0; i < N; i++) {
		std::cin >> V;
		if (mymap.find(V) == mymap.end()) {
			mymap[V] = 1;
		} else {
			int v = mymap[V];
			mymap[V] = v + 1;
		}
	}

	std::vector<int> count;
	for (std::unordered_map<int, int>::iterator it = mymap.begin();
			it != mymap.end(); ++it) {
		count.push_back(it->second);
	}
	std::sort(count.begin(), count.end());
	int res = 0;
	if (count.size() > K) {
		for (int i = 0; i < count.size() - K; i++) {
			res += count[i];
		}
	}
	std::cout << res;
	return 0;
}

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

#define int long long
typedef pair<int, int> P;
//#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream & operator>>(istream & is, vector<T> & vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {

	int r;
	cin >> r;
	cout << r * r << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	ll k, a, b;
	cin >> k >> a >> b;
	if (b / k - (a - 1) / k > 0)
		cout << "OK\n";
	else
		cout << "NG\n";
}


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

template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }

  Int H(Int n,Int k){
    return C(n+k-1,n);
  }

  Int S(Int n,Int k){
    Int res=0;
    for(Int i=1;i<=k;i++){
      Int tmp=C(k,i)*pow(i,n)%MOD;
      if((k-i)&1) res+=MOD-tmp;
      else res+=tmp;
      res%=MOD;
    }
    res=res*finv[k]%MOD;
    return res;
  }
  
  Int B(Int n,Int k){
    Int res=0;
    for(Int j=1;j<=k;j++){
      res+=S(n,j);
      res%=MOD;
    }
    return res;
  }

  
  vector<vector<Int> > D(Int n,Int m){
    vector<vector<Int> > dp(n+1,vector<Int>(m+1,0));
    dp[0][0]=1;
    for(Int i=0;i<=n;i++){
      for(Int j=1;j<=m;j++){
	if(i-j>=0) dp[i][j]=(dp[i][j-1]+dp[i-j][j])%MOD;
	else dp[i][j]=dp[i][j-1];
      }
    }
    return dp;
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      rinv=rinv*inverse(k)%MOD;
      if(k%2) res+MOD-rinv;
      else res+=rinv;
      res%=MOD;
    }
    for(Int i=1;i<=n;i++) res=res*i%MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(2e5);
  Int n,k;
  cin>>n>>k;
  cout<<(n>=k?mod.D(n,k)[n-k][k]:0)<<endl;
  return 0;
}



Measured memory_bytes: 15552
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[8]={-1,-1,-1,0,0,1,1,1};
int dy[8]={-1,0,1,-1,1,-1,0,1};
int main(void){
    
    int h,w;
    cin>>h>>w;
    char s[51][51];
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int ans=0;
            if(s[i][j]=='.'){
                for(int k=0;k<8;k++){
                    if(i+dx[k]<0||i+dx[k]>=h||j+dy[k]<0||j+dy[k]>=w)continue;
                    if(s[i+dx[k]][j+dy[k]]=='#')ans++;
                }
                
                s[i][j]=ans+'0';
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<s[i][j];
        }
        cout<<endl;
    }
    return 0;
}


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

int main() {
  int l, r, ans = 2018;
  cin >> l >> r;
  if(l/2019 < r/2019) ans = 0;
  else{
    for(int i = l%2019; i < r%2019; i++){
      for(int j = i+1; j <= r%2019; j++){
        int k = i*j%2019;
        if(ans > k) ans = k;
      }
    }
  }
  cout << ans << endl;
}


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

vector<vector<int> > g;
int dp[110000];

int dfs(int v){
//  cout << "dfs: " << v << endl;
  if(dp[v] != -1) return dp[v];
  
  int res = 0;
  for(auto j: g[v]){
    res = max(res, dfs(j) + 1);
  }
  return dp[v] = res;
}

int main(void){
  int N, M;
  cin >> N >> M;
  g.assign(N, vector<int>());
  for(int i=0; i<M; i++){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--; tmp2--;
    g[tmp1].push_back(tmp2);    
  }
  for(int i=0; i<N; i++) dp[i] = -1;
  int ans = -1;
  for(int i=0; i<N; i++) ans = max(ans, dfs(i));
  cout << ans << endl;  
  return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=100000;
int n,len;
long long zu[20];
string s;
long long ans=0;
long long get_num(int a,int b){
	long long num=0;
	for(int j=0;j<b;j++)num=(num<<3)+(num<<1)+s[a+j]-'0';
	return num;
}
void  dfs(int x,int ste){
	if(x==len){
		for(int i=1;i<=ste;i++)ans+=zu[i];
		return ;
	}
	for(int i=1;i<=len;i++)
	  if(x+i<=len){
	  	zu[ste+1]=get_num(x,i);
	  	dfs(x+i,ste+1);	  	
	  }
}
int main(){
	cin>>s;
	len=s.length();
	dfs(0,0);
	cout<<ans<<endl;
	return 0;
}

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

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

vector<int> sticks(n,0);
for(int i=0;i<n;i++)
cin>>sticks[i];

sort(sticks.begin(), sticks.end());
int count=0;
for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++)
    for(int k=j+1;k<n;k++){
        if(sticks[i]!=sticks[j] && sticks[i]!=sticks[k] && sticks[j]!=sticks[k])
        if((sticks[i]+sticks[j])>sticks[k])
            count++;
        // cout<<sticks[i]<<sticks[j]<<sticks[k]<<endl;
    }
        
}
cout<<count;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int maxr = 96;
const int maxc = 100;

char a[maxr][maxc];
int main()
{
    int A, B;
    scanf("%d%d", &A, &B);

    int mx = min(16, min(A, B)), tempA = A, tempB = B, cnt = 0;
    for(int i = 0; i < maxr; i ++) {
        if(i % 6 == 0)
            tempA --;
        if(i % 6 == 3)
            tempB --;
        if(i % 6 == 2) {
            cnt ++;
            if(cnt == mx) {
                if(A < B) {
                    for(int k = i; k < maxr; k ++)
                        for(int j = 0; j < maxc; j ++)
                            a[k][j] = '.';
                } else {
                    tempB --;
                    for(int k = i; k < maxr; k ++)
                        for(int j = 0; j < maxc; j ++)
                            a[k][j] = '#';
                }
                break;
            }
        }
        for(int j = 0; j < 100; j ++) {
            if((i % 6 ) <= 2)
                a[i][j] = '.';
            if((i % 6) > 2)
                a[i][j] = '#';
        }
    }

    int resW = tempA, resB = tempB;
    for(int i = 1; i < maxr; ) {
        if((i % 6) == 1) {
            for(int j = 0; j < maxc; j += 2)
                if(resB)
                    resB --, a[i][j] = '#';
        } else {
            for(int j = 0; j < maxc; j += 2)
                if(resW)
                    resW --, a[i][j] = '.';
        }
        i += 3;
    }
    int row = maxr;
    printf("%d %d\n", row, 100);
    for(int i = 0; i < row; i ++) {
        for(int j = 0; j < maxc; j ++)
            printf("%c", a[i][j]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next(),b=sc.next(),c=sc.next();
		System.out.println((a.charAt(a.length()-1)==b.charAt(0)&&b.charAt(b.length()-1)==c.charAt(0))?"YES":"NO");
		sc.close();
	}
}

Measured memory_bytes: 21332
package main

import (
	"fmt"
	"math"
)

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

	sqrt := int(math.Sqrt(float64(x)))

	ans := 1
	for i := 2; i <= sqrt; i++ {
		for j := 1; j < 10; j++ {
			tmp := pow(i, j)
			if tmp > x {
				break
			}
			ans = max(ans, tmp)
		}
	}

	fmt.Println(ans)
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,i,a;
	t = 1;
	while(t--) {
     a = 0;
	 cin >> n;
	 int arr[n];
     for(i = 0; i < n; i++)
      cin >> arr[i];
     for(i = 1; i < n - 1; i++) {
      if((arr[i - 1] < arr[i] && arr[i] < arr[i + 1]) || (arr[i - 1] > arr[i] && arr[i] > arr[i + 1]))
	   a++;
     }
     cout << a << endl;
	}
	return 0;
}



Measured memory_bytes: 256
nums = input().split()
width = int(nums[0])
height = int(nums[1])
x = int(nums[2])
y = int(nums[3])
r = int(nums[4])

if x - r >= 0 and x + r <= width:
    ans_x = True
else:
    ans_x = False
    
if y - r >= 0 and y + r <= height:
    ans_y = True
else:
    ans_y = False
    
if ans_x and ans_y:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ff first
#define ss second
 
#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif
 
const int inf = 2e18;
const int ninf = -2e18-5;
const int mod = 1e9 + 7;
int n, k, cnt;

int arr[101];
int dp[101][100010];
int pre[101][100010];

signed main(){
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
 
	cin>>n>>k;
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<=k; j++){
			dp[i][j] = -1;
		}
	}

	for(int i=n-1; i>=0; --i){
		int now = 0;
		for(int j=0; j<=k; j++){
			if(i==n-1){
				if(j<=arr[i]) dp[i][j] = 1;
				else dp[i][j] = 0;
			}
			else{
				int l = min(arr[i], j);
				dp[i][j] = (pre[i+1][j] - pre[i+1][j-l] + dp[i+1][j-l] + mod)%mod;
			}
			now = (now + dp[i][j])%mod;
			pre[i][j] = now%mod;
		}
	}
	cout<<dp[0][k]%mod<<endl;
	return 0;
}

Measured memory_bytes: 159884
#include<iostream>
#include<numeric>

using namespace std;

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

int hlen[1500];
int wlen[1500];
int hcount[1500*1000+1];
int wcount[1500*1000+1];

void lencount(int n, int count[], int len[]){
    REP(i, n){
        for(int j=1; j<=n-i; j++){
            count[accumulate(len+i, len+i+j, 0)] += 1;
        }
    }
}

int main(){
    while(1){
        int n, m;
        cin >> n >> m;
        if(n==0) break;

        REP(i, n){
            int h;
            cin >> h;
            hlen[i] = h;
        }
        REP(j, m){
            int w;
            cin >> w;
            wlen[j] = w;
        }

        REP(i, 1500*1000+1){
            hcount[i] = 0;
            wcount[i] = 0;
        }
        lencount(n, hcount, hlen);
        lencount(m, wcount, wlen);

        int sum = 0;
        REP(i, 1500*1000+1){
            sum += hcount[i] * wcount[i];
        }
        cout << sum << endl;
    }
}

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


int main() {
  ll N;cin>>N;
  vector<ll> A(N+1);rep(i,N) cin>>A[i];
  
  A[N]=1000000003;
  sort(A.begin(),A.end());
  
  ll count=1,ans=0;
  for(int i=0;i<N;i++){
	if(A[i]==A[i+1]) count++;
    else{
      if(count%2==0){
        count=1;
        continue;
      }
      else{
        count=1;
        ans++;
        continue;
      }
    }
  }
  
  cout << ans << endl;
}
 

Measured memory_bytes: 4040
#include <set>
#include <cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(auto s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)printf("%d\n",v[++i]);}}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  int mx = 0;
  int sum = 0;
  int t;
  rep(i, n) {
    cin >> t;
    sum += t;
    mx = max(mx, t);
  }
  sum -= mx / 2;
  cout << sum;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, count, minj, A[100];
    count = 0;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    for(int i = 0; i < n; i++){
        int flag = 0;
        minj = i;
        for(int j = i; j < n; j++){
            if(A[j] < A[minj]){
                minj = j;
                flag = 1;
            }
        }
        if(flag){
            int temp;
            temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
            count++;
        }
        
    }
    
    cout << A[0];
    for(int i = 1; i < n; i++){
        cout << " " << A[i];
    }
    cout << endl << count << endl;
    
    return 0;
    
}



Measured memory_bytes: 3112
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    count=0
    flag = True
    while(flag):
        flag = False
        for i in range(N-1):
            if A[i] > A[i+1]:
                A[i], A[i+1] = A[i+1], A[i]
                count += 1
                flag = True
    print(*A)
    print(count)


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

using namespace std;
#define int long long
string s[1000050];
int arr[1005000];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		std::sort(str.begin(),str.end());
		s[i]=str;
	}
	sort(s,s+n);
	int ans=0;
	int sum=1;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(s[i]!=s[i-1]){
			arr[cnt++]=sum;
			sum=1;
		}else{
			sum++;
		}
	}
	for(int i=0;i<cnt;i++){
		if(arr[i]==1){
			continue;
		}else{
			ans+=(arr[i]-1)*arr[i]/2;
		}
		
	}
	cout<<ans;
	return 0;
} 
/*
3 4 5
1 3 6 10
*/

Measured memory_bytes: 15232