akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, ans[205], l, r, m;
bool lc, mc;
string s;
int main(){
	cin >> n; r = n;
	cout << '?';
	rep(i,n) cout << ' ' << i+1;
	cout << endl;
	cin >> s;
	lc = s == "Red";
	while(l+1 < r){
		m = (l+r) / 2;
		cout << '?';
		rep(i,n) cout << ' ' << i+m+1;
		cout << endl;
		cin >> s;
		mc = s == "Red";
		(lc == mc ? l : r) = m;
	}
	ans[l] = lc;
	ans[l+n] = !lc;
	rep(i,n*2){
		if(i == r-1 || i == r+n-1) continue;
		cout << '?';
		if(i < r || i >= r+n-1){
			rep(j,n-1) cout << ' ' << j+r+1;
			cout << ' ' << i+1 << endl;
		}else{
			rep(j,r-1) cout << ' ' << j+1;
			for(int j=r+n; j<n*2; j++) cout << ' ' << j+1;
			cout << ' ' << i+1 << endl;
		}
		cin >> s;
		ans[i] = s == "Red";
	}
	cout << "! ";
	rep(i,n*2) cout << (ans[i] ? "R" : "B");
	cout << endl;
}

Measured memory_bytes: 724
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#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(c++17)
#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;
typedef long double lb;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep(i,N){
        cin >> P[i];
    }
    ll curmin=LLONG_MAX,ans=0;
    rep(i,N){
        curmin = min(curmin,P[i]);
        if(P[i] == curmin){
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int n,i;
	double a,x;
	
	cin>>n;
	x=0;
	for(i=0;i<n;i++)
	{
		cin>>a;
		x+=1/a;
	}
	
	cout<<1/x;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(b - a) <= d && abs(c - b) <= d || abs(a - c) <= d) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var bg = new BipartiteGraph(N);
        for (int i = 0; i < N - 1; i++)
        {
            var line = ReadLine().Split(' ');
            var u = int.Parse(line[0]) - 1;
            var v = int.Parse(line[1]) - 1;
            var w = int.Parse(line[2]);
            if (w % 2 == 0) bg.UnateSame(u, v);
            else bg.UniteDiff(u, v);
        }

        foreach (var c in bg.Coloring())
        {
            WriteLine(c ? "0" : "1");
        }
    }
}

public class UnionFind
{
    int[] parent;
    int count;
    public int Count => count;
    public int Length => parent.Length;

    public UnionFind(int size)
    {
        parent = new int[size];
        for (int i = 0; i < parent.Length; i++)
        {
            parent[i] = -1;
        }
        count = size;
    }

    public int Root(int x) => parent[x] < 0 ? x : parent[x] = Root(parent[x]);

    public int this[int i]
    {
        get
        {
            return parent[i];
        }
    }

    public bool Same(int x, int y) => Root(x) == Root(y);

    public void Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (x == y) return;
        count--;
        if (parent[x] < parent[y])
        {
            parent[x] += parent[y];
            parent[y] = x;
        }
        else
        {
            parent[y] += parent[x];
            parent[x] = y;
        }
    }

    public int Size(int x) => -parent[Root(x)];
}

class BipartiteGraph : UnionFind//unitesomeができるから二部グラフではないが
{
    public BipartiteGraph(int size) : base(size + size)
    {

    }

    public void UniteDiff(int x, int y)
    {
        base.Unite(x, y + base.Length / 2);
        base.Unite(x + base.Length / 2, y);
    }

    public void UnateSame(int x, int y)
    {
        base.Unite(x, y);
        base.Unite(x + base.Length / 2, y + base.Length / 2);
    }

    public bool IsBipartite()
    {
        for (int i = 0; i < base.Length / 2; i++)
        {
            if (Same(i, i + base.Length / 2)) return false;
        }
        return true;
    }

    public bool[] Coloring()
    {
        var ret = new int[base.Length];
        for (int i = 0; i < base.Length / 2; i++)
        {
            var a = base.Root(i);
            var b = base.Root(i + base.Length / 2);
            if (ret[a] == 0)
            {
                ret[a] = 1;
                ret[b] = -1;
            }
        }
        var bret = new bool[base.Length / 2];
        for (int i = 0; i < bret.Length; i++)
        {
            bret[i] = ret[base.Root(i)] == 1;
        }
        return bret;
    }
}


Measured memory_bytes: 17316
package main


import (
  "fmt"
  // "strings"
  "strconv"
  "sort"
)


func sum (n int) int {
  return (n * (n+1)) / 2
}


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


func main () {
  var n int
  fmt.Scanf("%d", &n)

  var s string
  a := make(map[string]int)

  for i := 0; i<n; i++ {
    var keys []string

    fmt.Scanf("%s", &s)
    m := make(map[string]int)

    for k := 0; k<10; k++ {
      keys = append(keys, string(s[k]))

      val, ok := m[string(s[k])]
      if (ok) {
        m[string(s[k])] = val+1
      } else {
        m[string(s[k])] = 1
      }
    }

    sort.Strings(keys)
    var sign string
 
    for _, key := range keys {
      sign += (key + strconv.Itoa(m[key]))
    }

    val, ok := a[sign]
    if (ok) {
      a[sign] = val + 1
    } else {
      a[sign] = 1
    }
  }

  var ans int
  for _, val := range a {
    ans += sum(val-1)
  }

  fmt.Println(ans)
}




Measured memory_bytes: 16516
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=1e9+7;
const int maxn=200+10;
const int N=1e5+10;
const int M=N*20;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}



ll n,m;

int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;
    cin>>n>>m;
    ll x=abs(n-m);
    if(x>1) puts("Alice");
    else puts("Brown");
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (b - a == c - b ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 67388
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n;i>s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

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

	cout << max(max(a + b, a - b), a*b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX_N = 12;
const int MAX_M = 1000;

int N, M;
int a[MAX_M + 5], b, d[MAX_M + 5];
int dp[MAX_M + 5][(1<<MAX_N)];

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; i++)
    {
        scanf("%d%d", &a[i], &b);
        while (b--)
        {
            int c;
            scanf("%d", &c);
            d[i] |= (1<<(c-1));
        }
    }
    dp[0][0] = 0;
    for (int S = 1; S < (1<<N); S++) dp[0][S] = INF;
    for (int i = 1; i <= M; i++)
    {
        for (int S = 0; S < (1<<N); S++)
        {
            dp[i][S] = min(dp[i-1][S], dp[i-1][S&~d[i]]+a[i]);
        }
    }
    if (dp[M][(1<<N)-1] == INF) printf("-1\n");
    else printf("%d\n", dp[M][(1<<N)-1]);
    return 0;
}


Measured memory_bytes: 19640
#include <stdio.h>
int main(void){
    // Here your code !
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b&&b<c){
    printf("Yes\n");    
    }else{
    printf("No\n");
    }
    return 0;
}

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

struct BTree{
    int parent, left, right;
};

BTree tree[25];
int siblings[25];

int depth(int x){
    int res = 0;
    while(tree[x].parent != -1){
        res++;
        x = tree[x].parent;
    }
    return res;
}

int height(int x, int maxn){
    int ln = 0, rn = 0;
    if(tree[x].left == -1 && tree[x].right == -1) return maxn;
    if(tree[x].left != -1) ln = height(tree[x].left, maxn + 1);
    if(tree[x].right != -1) rn = height(tree[x].right, maxn + 1);
    return ln > rn ? ln : rn;
}

int main(){
    int n, id, l, r, deg;
    cin >> n;
    for(int i = 0; i < 25; i++){
        tree[i].parent = -1;
        tree[i].left = -1;
        tree[i].right = -1;
        siblings[i] = -1;
    }
    for(int i = 0; i < n; i++){
        cin >> id >> l >> r;
        tree[id].left = l;
        tree[id].right = r;
        if(l != -1) tree[l].parent = id;
        if(r != -1) tree[r].parent = id;
        if(l != -1 && r != -1){
            siblings[l] = r;
            siblings[r] = l;
        }
    }
    for(int i = 0; i < n; i++){
        deg = 0;
        cout << "node " << i << ": parent = " << tree[i].parent << ", sibling = " << siblings[i];
        if(tree[i].left != -1) deg++;
        if(tree[i].right != -1) deg++;
        cout << ", degree = " << deg << ", depth = " << depth(i) << ", height = " << height(i, 0) << ", ";
        if(tree[i].parent == -1) cout << "root";
        else if(tree[i].left == -1 && tree[i].right == -1) cout << "leaf";
        else cout << "internal node";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

const LL MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<string> ss(2);
    cin >> ss[0] >> ss[1];

    LL ans = 1;
    int x = 0;
    int pre = -1;

    while (x < n) {
        if (ss[0][x] == ss[1][x]) {
            if (pre == -1) ans = 3;
            else if (pre == 0) ans *=2, ans = ans % MOD;
            ++x; pre = 0;
        } else {
            if (pre == -1) ans = 6;
            else if (pre == 0) ans *= 2, ans = ans % MOD;
            else ans *= 3, ans = ans % MOD;
            x += 2; pre = 1;
        }
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int d0=j%10;
            int d1=j/10;
            
            if (d0>1&&d1>1&&d0*d1==i){
                ans++;
                // cout<<d0<<" "<<d1<<endl;
            }
        }
    }
    fin(ans);


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	string s;
	int K;
	cin>>s>>K;
	int N=s.size();
	rep(i,N){
		int need=('z'-s[i]+1)%26;
		if(need<=K){
			s[i]='a';
			K-=need;
		}
	}
	s[N-1]='a'+(s[N-1]-'a'+K%26);
	cout<<s<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // exit()
#include <string.h>         // strcmp()

#define N_LIST 1000020

typedef struct list_tbl
{
	int key;
	int prev;
	int next;
} list_t;

int lineno;
list_t list[N_LIST];
int ix;
int head;
int tail;
int room;

void
cleanup(int ecode)
{
	exit(ecode);
}

void
insert(int key)
{
	int l;

	if (ix >= N_LIST)
	{
		fprintf(stderr, "line %d: List overflow. size%d\n", lineno, N_LIST);
		cleanup(1);
	}

	if (room == 0)
		l = ix++;
	else
	{
		l = room;
		room = list[l].next;
	}

	list[l].key = key;
	list[l].next = head;
	int next = head;
	head = l;

	if (next == -1)
	{
		list[l].prev = tail;
		tail = l;
	}
	else
	{
		list[l].prev = list[next].prev;
		list[next].prev = l;
	}
}

void
delete(int key)
{
	int next;
	int* pnext;
	int l;

	pnext = &head;
	for (l = head; l != -1 && list[l].key != key; l = list[l].next)
		pnext = &list[l].next;

	if (l == -1)
		return;

	next = list[l].next;
	*pnext = next;

	if (next == -1)
		tail = list[l].prev;
	else
		list[next].prev = list[l].prev;

	list[l].next = room;
	room = l;
}

void
delete_first()
{
	int t = head;
	head = list[head].next;
	if (head == -1)
		tail = -1;
	else
		list[head].prev = -1;

	list[t].next = room;
	room = t;
}

void
delete_last()
{
	int t = tail;
	tail = list[tail].prev;
	if (tail == -1)
		head = -1;
	else
		list[tail].next = -1;

	list[t].next = room;
	room = t;
}

int
main(int argc, char** argv)
{
	char command[15];
	int x = 0;
	int n = 0;
	int l;
	int i;

	head = -1;
	tail = -1;
	room = 0;
	ix = 0;

	scanf("%d", &n);
	lineno = 0;
	for (i = 0; i < n; ++i)
	{
		lineno++;
		scanf("%s", command);
		if (strcmp(command, "insert") == 0)
		{
			scanf("%d", &x);
			insert(x);
		}
		else if (strcmp(command, "delete") == 0)
		{
			scanf("%d", &x);
			delete(x);
		}
		else if (strcmp(command, "deleteFirst") == 0)
			delete_first();

		else if (strcmp(command, "deleteLast") == 0)
			delete_last();
	}

	const char* sep = "";
	for (l = head; l != -1; l = list[l].next)
	{
		printf("%s%d", sep, list[l].key);
		sep = " ";
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 12320
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntIntMap() map[int]int {
  var s []string = strings.Split(NextLine()," ")
  var n,a int
  n = len(s)
  m := map[int]int{}
  for i:=0;i<n;i++ {
    a,_ = strconv.Atoi(s[i])
    if v,ok := m[a];ok {
      m[a] = v + 1
    } else {
      m[a] = 1
    }
  }
  return m
}

func main() {
  _ = NextInt()
  a := NextIntIntMap()
  b := Entries{}
  for key,val := range a {
    e := Entry{key,val}
    b = append(b,e)
  }
  sort.Sort(sort.Reverse(b))
  var x,y int = 0,0
  for i:=0;i<b.Len();i++ {
    if b[i].val >= 4 && x == 0 {
      x = b[i].key
      y = x
      break
    } else if b[i].val >= 2 {
      if x == 0 {
        x = b[i].key
        continue
      } else if y == 0 {
        y = b[i].key
        break
      }
    }
  }
  fmt.Println(x*y)
}
type Entry struct {
  key int
  val int
}
type Entries []Entry
func(entries Entries) Len() int {
  return len(entries)
}
func(entries Entries) Swap(i,j int) {
  entries[i],entries[j] = entries[j],entries[i]
}
func(entries Entries) Less(i,j int) bool {
  if entries[i].key == entries[j].key {
    return entries[i].val < entries[j].val
  } else {
    return entries[i].key < entries[j].key
  }
}

Measured memory_bytes: 11904
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n;
int x[400], y[400], b[400], p[400];


int main(){

	cin >> n;
	rep(i, n){
		cin >> x[i] >> y[i] >> b[i] >> p[i];
	}

	rep(i, n){
		int total = 0;
		int tmp1 = b[i], tmp2 = p[i], tmp3 = 0;

		total += x[i] * b[i] + y[i] * p[i];

		if (b[i] >= 5 && p[i] >= 2)total -= total / 5;
		else {
			if (b[i] < 5)tmp1 = 5;
			if (p[i] < 2)tmp2 = 2;
			tmp3 = x[i] * tmp1 + y[i] * tmp2;
			tmp3 -= tmp3 / 5;
			if (tmp3 < total)total = tmp3;
		}
		cout << total << endl;
	}

	return 0;
}



Measured memory_bytes: 3120
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 k = sc.nextInt();
        int i,j;
        for(i = 0; i < k;i++){
          if(a + i <= b){
          System.out.println(a + i);
          }else{
           break; 
          }
        }
      	for(j = k-1; j >= 0;j--){
          if(b - j > a + i - 1){          
          System.out.println(b - j);
          }
        }
    }
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int M, D;
    cin >> M >> D;

    int ans = 0;

    repd(i, 1, M + 1) {
        repd(j, 1, D + 1) {
            int d1, d10;
            d1 = j % 10;
            d10 = j / 10;
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
import math

def isprime(n):

    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            return False

    return True


if __name__ == '__main__':

    n = int(input())
    nums = []
    for _ in range(n):
        nums.append(int(input()))

    count = 0
    for n in nums:
        if isprime(n):
            count += 1

    print(count)


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N;
    cin>>N;
    vector<int> A(N),ans(0);
    rep(i,N){
        cin>>A.at(i);
    }
    rep(i,N){
        if(i==0){ans.pb(A.at(i));}
        else{
            int l=-1,r=sz(ans);
            while(r-l>1){
                int m=(r+l)/2;
                if(ans.at(m)>=A.at(i))l=m;
                else{r=m;}
            }
            if(r==sz(ans)){ans.pb(A.at(i));}
            else{ans.at(r)=A.at(i);}
        }
    }
    cout<<sz(ans)<<endl;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vec vector <ll>
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll k,n;
	cin>>k>>n;
	ll arr[200456];
	ll i;
	ll sum1=0;
	ll sum2=0;
	for(i=0;i<n;i++)
		{
			cin>>arr[i];
		}
	sort(arr,arr+n);
	ll maxi=0;
	for(i=0;i<n;i++)
	{
					if(i>0)
			sum1+=arr[i]-arr[i-1];
		if((arr[i]-arr[i-1])>maxi && i>0)
			maxi=arr[i]-arr[i-1];
	}
	sum2=sum1-maxi+k-arr[n-1]+arr[0];
	if(sum1<sum2)
		cout<<sum1;
	else
		cout<<sum2;

	return 0;
}


Measured memory_bytes: 1792
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def calc(x,y):
    z = -(2*x - y)
    if z%2 != 0:
        print('No')
        return
    else:
        a = z//2

    if a < 0:
        print('No')
        return
    
    b = x - a
    if b < 0:
        print('No')
        return
    
    print('Yes')
    return

x,y = mi()

calc(x,y)

Measured memory_bytes: 9200
#!/usr/bin/env python3
import re

n = int(input())
s = input()
k = int(input())

save = []

for i in range(n):
    if(s[i] != s[k-1]):
        save.append('*')
    else:
        save.append(s[i])

for i in range(len(save)):
    print(save[i], end = '')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

// 長さN,値域1-Mの広義単調増加列を生成（O(N+M-1 C N）
vector<vector<int>> U;
void dfs(vector<int> &vec, int N, int M){
  if (vec.size()==N){
    U.push_back(vec);
    return;
  }

  int l = vec.size()? vec.back() : 1;  
  for (int v=l;v<=M;v++){ // 狭義の場合はv=l+1とする
    vec.push_back(v);
    dfs(vec,N,M);
    vec.pop_back();
  }
}


int main(){
  int N, M, Q; cin >> N >> M >> Q;
  int a[Q], b[Q], c[Q], d[Q];
  rep(i,Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i], --b[i];
  }

  vector<int> init;
  dfs(init,N,M);

  ll ans = 0;
  for (auto vec : U){
    ll tmp = 0;
    rep(i,Q){
      if (vec[b[i]] - vec[a[i]]==c[i]) tmp += d[i];
    }
    chmax(ans, tmp);
  }
  cout << ans << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}

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

int main(void){
    int d;

    while(cin >> d){
        int COUNT = 0;

        for (int i = d; 600 > i; i = i + d){
        	int j = i * i * d;
        	COUNT = COUNT + j;
         }

         cout << COUNT << endl;
    }

    return 0;
}


Measured memory_bytes: 3048
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int x =s.nextInt();
        int t = s.nextInt();
        int q;
        if(n%x==0)
            q = n/x;
        else
            q = n/x+1;
        System.out.println(q*t);
    }
}

Measured memory_bytes: 35844
n,k = map(int,input().split())
sl = list(input())

l = []
l.append(0)
ans = 0
before = ""
count = 0
if sl[0] == "0":
   l.append(0)
for idx,s in enumerate(sl):
   if s != before:
      before = s
      if idx > 0:
         l.append(idx)
         if len(l) == 2*k + 2:
            ans = max(l[-1] - l[0], ans)
            l.pop(0)
            l.pop(0)
l.append(n)
ans = max(l[-1] - l[0], ans)
print(ans)

Measured memory_bytes: 49648
object Main extends App {

  import scala.io.StdIn._
  val n = readLine.trim.toInt
  val points = Array.tabulate(n){_ ⇒ 0}
  for (_ ← 0 until (n * (n - 1) / 2)) {
    val Array(a, b, c, d) = readLine.trim.split(' ').map(_.toInt)
    if (c > d){
      points(a - 1) += 3
    }else if (c < d){
      points(b - 1) += 3
    }else {
      points(a - 1) += 1
      points(b - 1) += 1
    }
  }
  val scores = Array.tabulate(n * 3 + 1){_ ⇒ 0}
  points.foreach(scores(_) += 1)
  for (i ← (1 to 3 * n).reverse){
    scores(i - 1) += scores(i)
  }
  points.foreach{score ⇒
    println(scores(score + 1) + 1)
  }
}



Measured memory_bytes: 51888
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B&lang=jp

"""
import sys
from sys import stdin
from itertools import combinations
input = stdin.readline


def main(args):
    while True:
        n, x = map(int, input().split())
        if n == 0 and x == 0:
            break

        ans = 0
        for c in combinations(range(1, n+1), 3):
            if sum(c) == x:
                ans += 1

        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7708
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll p;
	cin >>p;
	
	
	rep2(h,1,3501) rep2(n, 1,3501){
		//rep2(w,1,3501){
		
		ll w1= (ll)4*h*n - p*n - p*h;
		if( p*h*n >= w1 && w1 >0 &&   p*h*n % w1 ==0 ){
			cout << h <<" "<<n <<" "<<p*h*n/w1 <<"\n";
			return 0;
		}
		
	}
	return 0;

}


Measured memory_bytes: 256
N = int(input())

restaurants = {}
for i in range(1, N+1):
    s, p = input().split()
    restaurants[i] = (s, int(p))

key = lambda x: x[1]
restaurants_sorted = sorted(restaurants.items(), key=key)

city_restraurant = []
city = ""
for restaurant in restaurants_sorted:
    if not city:
        city = restaurant[1][0]
        city_restraurant.append((restaurant[0], restaurant[1][1]))
    elif city == restaurant[1][0]:
        city_restraurant.append((restaurant[0], restaurant[1][1]))
    else:
        city_restraurant.sort(key=lambda x: x[1], reverse=True)
        for c in city_restraurant:
            print(c[0])
        city_restraurant = [(restaurant[0], restaurant[1][1])]
        city = restaurant[1][0]
city_restraurant.sort(key=lambda x: x[1], reverse=True)
for c in city_restraurant:
    print(c[0])

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

using namespace std;

namespace {
    int N, K, L;

    /** output whole vector. ex) vector<int>{1, 2, 3} -> '1 2 3'. */
    template<typename T>
    ostream& operator<<(ostream& os, const vector<T>& xs) {
       if (xs.empty()) return os;
       os << xs[0];
       for (auto i = 1; i < xs.size(); i++) os << ' ' << xs[i];
       return os;
    }

    struct UnionFind {
        int N;
        vector<int> P;
        UnionFind(int N) : N(N) {
            P.clear();
            P.resize(N, -1);
        }
        int root(int x) {
            if (P[x] == -1) return x;
            return P[x] = root(P[x]);
        }
        int query(int x, int y) { return root(x) == root(y); }
        void merge(int x, int y) {
            x = root(x);
            y = root(y);
            if (x == y) return;
            P[x] = y;
        }
    };

    void solve() {
        cin >> N >> K >> L;
        UnionFind a(N), b(N);
        for (int i = 0; i < K; i++) {
            int p, q; cin >> p >> q;
            p--; q--;
            a.merge(p, q);
        }
        for (int i = 0; i < L; i++) {
            int r, s; cin >> r >> s;
            r--; s--;
            b.merge(r, s);
        }
        map<pair<int, int>, int> C;
        for (int i = 0; i < N; i++) {
            C[make_pair(
                a.root(i),
                b.root(i)
            )] += 1;
        }
        vector<int> ans;
        for (int i = 0; i < N; i++) {
            ans.push_back(C[make_pair(a.root(i), b.root(i))]);
        }
        cout << ans << endl;
    }
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 14452
#include<stdio.h>

int main(void)
{
  int num;
  int length[200] = {};
  int i, j;
  int temp;
  int sum=0;

  scanf("%d", &num);

  for (i=0;i<num*2;i++){
    scanf("%d", &length[i]);
  }

  for(i=0;i<num*2;i++){
    for(j=i+1;j<num*2;j++){
      if(length[i] < length[j]){
	temp = length[i];
	length[i] = length[j];
	length[j] = temp;
      }
    }
  }
  
  sum = length[1];
  for(i=1;i<num*2;i+=2){
    sum += length[i+2];
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
/*#include "unp.h"
int main()
{
    int listenfd,connfd;
    pid_t childpid;
    socklen_t chilen;
    struct sockaddr_in chiaddr,servaddr;
    listenfd=Socket(AF_INET,SOCK_STREAM,0);
    bzero(&servaddr,sizeof(servaddr));
    servaddr.sin_family=AF_INET;
    servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
    servaddr.sin_port=htons(SERV_PORT);
    Bind(listenfd,(SA*)&servaddr,sizeof(servaddr));
    Listen(listenfd,LISTENQ);
    for(;;)
    {
        chilen=sizeof(chiaddr);
        connfd=Accept(listenfd,(SA*)&chiaddr,&chilen);
        if((childpid=Fork())==0)
        {
            Close(listenfd);
            str_echo(connfd);
            exit(0);
        }
        Close(connfd);
    }
}*/
#include <bits/stdc++.h>
using namespace std;
#define maxn 22222
int a[maxn],b[maxn],pos[maxn];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0; i<n; i++)
        {
            scanf("%d",&pos[i]);
            a[i]=(i+1)*n;
            b[i]=(n-i)*n;
        }
        for(int i=0; i<n; i++)
        {
            a[pos[i]-1]-=(n-i-1);
        }
        for(int i=0; i<n; i++)
        {
            if(i==0)
                printf("%d",a[i]);
            else
                printf(" %d",a[i]);
        }
        printf("\n");
        for(int i=0; i<n; i++)
        {
            if(i==0)
                printf("%d",b[i]);
            else
                printf(" %d",b[i]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=1;i<=N;i++){
    int cnt=0;
    for(int j=1;j<=sqrt(i);j++){
      if(i%j==0)cnt++;
    }
    if(cnt*2==8&&i%2!=0){
      ans++;
      //cout<<i<<endl;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;

int main()
{
    si(n);
    ll a[n+1];
    fr(i,1,n+1)   cin>>a[i];
    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    
    cout<<dp[n];
}

Measured memory_bytes: 5248
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, m, k, x;
    cin >> n >> m;
    ll mpp[m+1] = {0};
    rep(i, n){
        cin >> k;
        while(k--){
            cin >> x;
            mpp[x]++;
        }
    }
    ll c = 0;
    rep(i, m+1){
        if(mpp[i] == n){
            c++;
        }
    }
    cout << c << endl;
    return 0;
}




Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

int main(){
  ll N,M;
  string s;
  ll p,q,r;
  cin >> p >> q>>r ;
  cout << min(p+q,min(q+r,p+r)) << endl;

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  ll n;
  cin >> n;
  string str;
  cin >> str;
  if (n < 3200){
    cout << "red\n";
  }
  else {
    cout << str << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var str=input.trim();
var a=false;
var ans="";
for(var i=0;i<str.length;i++){
   if(str[i]=="A")a=true;
   if(str[i]=="Z" && a==true){a=false;ans+="AZ";}
}
if(ans=="")ans=-1;
console.log(ans);

Measured memory_bytes: 7384
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
S = input()

min1 = 0 # 01010101
min2 = 0 # 10101010


for i in range(len(S)):
    if i%2==0:
        if S[i]=="0":
            min2 += 1
        else:
            min1 += 1
    else:
        if S[i]=="1":
            min2 += 1
        else:
            min1 += 1

print(min(min1,min2))

Measured memory_bytes: 66156
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string N;
    cin >> N;
    int len = N.length();
    if (N[len - 1] == '3') cout << "bon" << endl;
    else if (N[len - 1] == '0' || N[len - 1] == '1' || N[len - 1] == '6' || N[len - 1] == '8') cout << "pon" << endl;
    else cout << "hon" << endl;
}


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

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

  for(int i =0 ; i < N ; i++){
      string color ;
      cin >> color ;
    
    if(color == "Y"){
      cout << "Four" << endl;
    return 0;
    }
  }
  cout << "Three" << endl;
  
  
  // ここにプログラムを追記
}

Measured memory_bytes: 256
X, N = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)

array = [0..101].map(&:to_a).flatten

p.each do |i|
  array.delete i
end
compare = 10000
answer = nil

array.each do |j|
  result = X - j
  if compare > result.abs
    answer = j
    compare = result.abs
  end
end
puts answer


Measured memory_bytes: 14244
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main(){
  int n;
  cin >> n;
  set<int> s;
  int a;
  for(int i=0;i<n;i++) {
    cin >> a;
    s.insert(a);
  }
  cout << s.size() << endl;
  return 0;
 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

int main() {
	optimizar_io
	int n, a[110];

	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (((i + 1) & 1) and a[i] & 1)
			cnt++;
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int a, b, c;

int main() {
	cin >> a >> b >> c;
	for (int i = 1; i <= b; ++i) {
		if (a * i % b == c) return cout << "YES" << endl, 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    // 1'000'000'000'000'001
    ll n;
    cin >> n;
    string ans = "";

    // 1-26
    // 26+1 - 26+26*26
    // 26+26*26+1 - 26+26*26+26^3
    while (n > 0) {
        ll a = (n - 1) % 26;
        n = (n - a) / 26;
        ans = string(1, a + 'a') + ans;
    }

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


Measured memory_bytes: 3152
n, m = map(int, input().split())
lst = [[] for _ in range(n + 1)]
py = [None] * m
for i in range(m):
    p, y = map(int, input().split())
    py[i] = [p, y]
    lst[p].append(y)

for i in range(n + 1):
    lst[i] = {v: i for i, v in enumerate(sorted(lst[i]))}

for i, j in py:
    print(str(i).zfill(6) + str(lst[i][j]+1).zfill(6))

Measured memory_bytes: 63808
pub mod contest {
    pub mod input {
        use std::io;
        use std::str::FromStr;
        use std::fmt::Debug;

        pub fn read_line<F>() -> F
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input.trim().parse().unwrap()
        }

        pub fn read_words<F>() -> Vec<F>
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input
                .split_whitespace()
                .map(|i| i.parse().unwrap())
                .collect()
        }

        pub fn read_matrix<F>(num_lines: usize) -> Vec<Vec<F>>
        where F: FromStr, <F as FromStr>::Err: Debug {
            (0..num_lines).map(|_| read_words()).collect()
        }

        // 所有権的な問題で SplitWhitespace を直接持てないので妥協
        pub struct WordsReader {
            words: Vec<String>,
            cur: usize,
        }

        impl WordsReader {
            pub fn new() -> Self {
                let mut input = String::new();
                io::stdin().read_line(&mut input).unwrap();
                WordsReader {
                    words: input.split_whitespace().map(|i| i.to_owned()).collect(),
                    cur: 0,
                }
            }

            pub fn next<F>(&mut self) -> F
            where F: FromStr, <F as FromStr>::Err: Debug {
                let v: F = self.words[self.cur].parse().unwrap();
                self.cur += 1;
                v
            }
        }
    }
}

use std::cmp;

fn max_span(k: i32, a: &Vec<i32>) -> i32 {
    let mut min_a = k + 9999; // a[i] としてはありえない値をてきとうに
    let mut max_a = -9999;
    let mut max_span = -9999;
    for i in 0..(a.len() - 1) {
        min_a = cmp::min(min_a, a[i]);
        max_a = cmp::max(max_a, a[i]);
        max_span = cmp::max(max_span, a[i + 1] - a[i]);
    }
    let last_span = (k - a.last().unwrap()) + a[0];
    cmp::max(max_span, last_span)
}

fn solve(k: i32, a: &mut Vec<i32>) -> i32 {
    a.sort();
    k - max_span(k, a)
}

#[test]
fn test_solve() {
    assert_eq!(solve(20, &mut vec![5, 10, 15]), 10);
    assert_eq!(solve(20, &mut vec![0, 5, 15]), 10);
}

fn main() {
    let mut wr = contest::input::WordsReader::new();
    let k: i32 = wr.next();
    let _: usize = wr.next();
    let mut a: Vec<i32> = contest::input::read_words();
    println!("{}", solve(k, &mut a));
}


Measured memory_bytes: 8444