akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;

public class Main {
    public static void main(String[] args) throws IOException {
	ByteBuffer buf = ByteBuffer.allocate(1000000);
	{
	    buf.clear();
	    Channels.newChannel(System.in).read(buf);
	    buf.flip();
	}
	int n, m, a;
	while ((n = get(buf)) != 0) {
	    m = get(buf);
	    a = get(buf);
	    int max = 0;
	    int[][] amida = new int[1000][n + 1];
	    for (int i = 0; i < m; i++) {
		int h = get(buf) - 1;
		int p = get(buf);
		int q = get(buf);
		amida[h][p] = q;
		amida[h][q] = p;
		max = Math.max(h, max);
	    }
	    for (int h = max; h >= 0; h--) {
		if (amida[h][a] != 0) {
		    a = amida[h][a];
		}
	    }
	    System.out.println(a);
	}
    }

    private static int get(ByteBuffer buf) {
	int i = buf.get();
	while (i < '0' || '9' < i) {
	    i = buf.get();
	}
	int res = 0;
	while ('0' <= i && i <= '9') {
	    res = res * 10 + (i - '0');
	    i = buf.get();
	}
	return res;
    }

}

Measured memory_bytes: 44828
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N, K, Q, val;
    cin >> N >> K >> Q;
    vector<int> arr(N, K-Q);
    for(int i = 0; i < Q; i++) {
        cin >> val;
        arr[val-1] += 1;
    }
    for(int i = 0; i < N; i++) {
        if (arr[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))

total = 0
for a in A:
    total ^= a

ans = []
for a in A:
    ret = total ^ a
    ans.append(ret)
print(*ans)

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

int main() {
    long double a, b;
    cin >> a >> b;
    ll ans = a*b;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3732
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	x=a*p;
	if(p<=c) y=b;
	else y=(p-c)*d+b;
	if(x<y) printf("%d\n",x);
	else printf("%d\n",y);
	return 0;
}

	
		
		


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

const int MOD = 1e9+7;
using namespace std;

char grid[10001][10001];
long long dp[10001][10001];

int main(){
    
    int n, m;
    cin >> n >> m;
    
    char temp;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            cin >> grid[i][j];
        }
    }
    
    dp[0][1] = 1;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if (grid[i][j] == '.')
                dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
            else
                dp[i][j] = 0;
        }
    }
    
    cout << dp[n][m] << endl;

}

Measured memory_bytes: 90624
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 一行読み出し
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 文字列リバース関数
func strReverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

// スペース区切りの文字列から int のスライスを得る
func intSlice(s string) []int {
	ss := strings.Split(s, " ")
	res := make([]int, len(ss))
	for i, v := range ss {
		iv, _ := strconv.Atoi(v)
		res[i] = iv
	}

	return res
}

// * 小さい方の面積が最大となる分割方法は x,y と 長方形の中心を通る直線で分割する
// * その場合の面積は必ず長方形の半分の面積となる
// * x, y が長方形の中心だった場合はどう切っても小さい面積は長方形の半分の面積となるため切り方は無限大
// * 即ち答えは「長方形の面積の半分」と「x,y が長方形の中心か否か」でわかる

func main() {
	var w, h, x, y float64
	fmt.Scan(&w, &h, &x, &y)

	ans1 := w * h / 2
    ans2 := 0
	if x+x == w && y+y == h{
        ans2 = 1
    }

	fmt.Printf("%f %d\n", ans1, ans2)
}


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

int main() {
    int N, a = 0, sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        if (a < b) {
            a = b;
        }
        sum += b;
    }
    cout << sum - a / 2 << endl;
}

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

int main(){
  int A,B;
  cin>>A;
  int N[A-1];
  int M[A+1]={};
  for(int i = 0;i < A-1;i++){
    cin>>N[i];
    M[N[i]]++;
  }
  for(int i  = 1;i < A+1;i++)cout<<M[i]<<endl;
}

Measured memory_bytes: 5164
// AtCoder-Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define FORREV(i,N,_cnt) for(auto i=N-1,cnt=_cnt; cnt > 0; --i, --cnt)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
	ifstream ifs("in.txt");
	cin.rdbuf(ifs.rdbuf());
#endif
	ll N, M; cin >> N >> M; 
	vector< vector<ll> > children(N + 1);
	FOR(i, M) {
		ll a, b;
		cin >> a >> b;
		children[a].push_back(b);
		children[b].push_back(a);
	}
	queue<ll> q;
	for (auto one_child : children[1]) {
		q.push(one_child);
	}
	bool ok = false;
	while (!q.empty()) {
		auto v = q.front(); q.pop();
		for (auto two_child : children[v]) {
			if (two_child == N) {
				ok = true;
				break;
			}
		}
		if (ok) break;
	}
	if (ok) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}


	return 0;
}


Measured memory_bytes: 13544
/* god is with you dont worry */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define input() ios_base::sync_with_stdio(false);cin.tie(0);
const ll mod=1e9+7;
/*ll power(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1){
			res=res*x;
		}
		x=x*x;
		y=y/2;
	}
	return res;
}*/
void solve(){
    ll a,b,n,z;
    cin>>a>>b>>n;
    if(n/b>=1){
    	ll k=n%b;
    	z=n-k-1;
    }
    else
    z=n;
    cout<<(a*z)/b-a*(z/b);
}
int main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3616
package main
import "fmt"
func main() {
  var h,w,n,sr,sc int
  var s,t string
  fmt.Scan(&h,&w,&n,&sr,&sc,&s,&t)
  var l,r,u,d int = 1,w,1,h
  for i:=n-1;i>-1;i-- {
    switch t[i:i+1] {
      case "L": r++
      if r > w { r = w }
      case "R": l--
      if l < 1 { l = 1 }
      case "U": d++
      if d > h { d = h }
      case "D": u--
      if u < 1 { u = 1 }
    }
    switch s[i:i+1] {
      case "L": l++
      case "R": r--
      case "U": u++
      case "D": d--
    }
    if l > r || u > d { break }
  }
  if l <= sc && sc <= r && u <= sr && sr <= d {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   long long n;
  cin>>n;
  cout<<(n*(n+1)/2)-((3*(n/3+1)*(n/3))/2)-((5*(n/5+1)*(n/5))/2)+((15*(n/15+1)*(n/15))/2);
}

Measured memory_bytes: 3588
import sys

S=input().strip()

if S=="" or (len(S)%2 == 1):
  print("No")
  sys.exit()

for i,word in enumerate(S):
  if (i%2==0 and word=="h") or (i%2==1 and word=="i"):
    continue
  else:
    print("No")
    break

else:
  print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int a[200010];
ll sum[200010];

int main(void) {
	cin >> N;
	rep(i, N) cin >> a[i];
	rep(i, N) sum[i + 1] += a[i] + sum[i];
	ll S = sum[N];
	ll ans = INFF;
	rep(i, N - 1) {
		ll d1 = sum[i + 1], d2 = S - d1;
		chmin(ans, abs(d1 - d2));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll MOD = 1000000007;
const int MAX = 200001;
ll inv[MAX];
ll FactorialInv[MAX];
ll Factorial[MAX];

ll powmod(ll a, ll b){
    a %= MOD;
    if(b == 0){
        return 1;
    }
    ll ans = powmod(a, b / 2);
    ans = ans * ans % MOD;
    if(b % 2 == 1){
        ans = ans * a % MOD;
    }
    return ans;
}
void init_combination(){
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % MOD;
    }
    FactorialInv[MAX] = powmod(Factorial[MAX], MOD - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % MOD;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % MOD;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ret = 1;
    for(ll i = 0; i < b; i++) {
        ret *= (a - i);
        ret %= MOD;
        ret *= powmod(i + 1, MOD - 2);
        ret %= MOD;
    }
    return ret;
}

int main() {
    init_combination();
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = powmod(2, n) - 1;
    ans -= combination(n, a);
    ans -= combination(n, b);
    ans += 2 * MOD;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;

int main()
{
	LL h, n;
	cin >> h >> n;

	vector<pair<LL, LL>> ab(n);

	for (auto &e : ab) {
		cin >> e.first >> e.second;
	}

	LL sz = h+10001;
	LL g[sz];

	for (LL i = 0; i < sz; ++i) {
		g[i] = inf;
	}

	g[0] = 0;

	for (LL i = 0; i < h; ++i) {
		if (g[i] != inf) {
			for (LL j = 0; j < n; ++j) {
				g[i+ab[j].first] = min(g[i+ab[j].first], g[i]+ab[j].second);
			}
		}
	}

	LL mn = g[h];
	for (LL i = h; i < sz; ++i) {
		mn = min(mn, g[i]);
	}

	cout << mn << "\n";


	
}

Measured memory_bytes: 384
#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;

int main() {
	int n, a[100];
	bool ans = true;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0&&a[i] % 5 != 0)ans = false;
		}
	}
	if (ans == true)cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

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

using namespace std;

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

    int n, x;
    cin >> n >> x;

    vector<int> v(n, 0);

    for(int i = 0; i < n; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());

    int answer = 0;

    for(int i = 0; i < n - 1; ++i)
    {
        if(x >= v[i])
        {
            ++answer;
            x -= v[i];
        }
        else
            break;
    }

    if(x == v[n - 1])
        ++answer;

    cout << answer << '\n';



}



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

using namespace std;
const int N=200+5;
int isEven(char*);

int main()
{
	char s[N];
	cin>>s;
	int n=strlen(s);
	for(int i=1;i<n-1;i++){
		s[n-i]='\0';
		if(isEven(s)) {
			printf("%d\n",n-i);
			break;
		}
	}
	
	return 0;
}

int isEven(char* ss)
{
	int n=strlen(ss);
	if(n%2==1)	return 0;
	for(int i=0;i<n/2;i++)
		if(ss[i]!=ss[n/2+i])	
			return 0;
	return 1;
}

Measured memory_bytes: 256
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define REP(i,a,n) for(int i = (a); i < (n); i++)
#define ALL(v) v.begin(), v.end()
vector<vector<int>> G;
vector<vector<int>> rG;
vector<int> vs, cmp;
vector<bool> used;
int x[10000], y[10000];
int len, seg_size;
void add_edge(int from, int to) {
	G[from].push_back(to);
	rG[to].push_back(from);
}
void dfs(int v) {
	used[v] = true;
	for (int to : G[v]) {
		if (!used[to]) dfs(to);
	}
	vs.push_back(v);
}
void rdfs(int v, int k) {
	used[v] = true;
	cmp[v] = k;
	for (int to : rG[v]) {
		if (!used[to]) rdfs(to, k);
	}
}
int scc() {
	fill(ALL(used), 0);
	vs.clear();
	rep(i,G.size()) {
		if (!used[i]) dfs(i);
	}
	fill(ALL(used), 0);
	int k = 0;
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
//b[i]→not b[j] | l ≦ j < r
void add(int i, int a, int b, int k, int l, int r) {
	if (a <= l && r <= b) {
		add_edge(i + len - 1, k + seg_size);
		add_edge(k, (i + len - 1) + seg_size);
		return;
	}
	if (b <= l || r <= a) return;
	add(i, a, b, k * 2 + 1, l, (l + r) / 2);
	add(i, a, b, k * 2 + 2, (l + r) / 2, r);
}

int main() {
	int N;
	cin >> N;
	vector<P> v;
	rep(i, N) {
		cin >> x[i] >> y[i];
		v.emplace_back(x[i], i * 2);
		v.emplace_back(y[i], i * 2 + 1);
	}
	sort(ALL(v));
	len = 1;
	while (len < v.size()) len *= 2;
	seg_size = len * 2 - 1;
	G.resize(seg_size * 2);
	rG.resize(seg_size * 2);
	used.resize(seg_size * 2);
	cmp.resize(seg_size * 2);
	int l = 0, r = 1e9;
	while ((r - l) > 1) {
		int m = (l + r) / 2;
		rep(i, G.size()) {
			G[i].clear();
			rG[i].clear();
		}
		rep(i, N) {
			int p = lower_bound(ALL(v), P(x[i], i * 2)) - v.begin();
			int q = lower_bound(ALL(v), P(y[i], i * 2 + 1)) - v.begin();
			add_edge(p + len - 1, (q + len - 1) + seg_size);
			add_edge(q + len - 1, (p + len - 1) + seg_size);
			add_edge((p + len - 1) + seg_size, q + len - 1);
			add_edge((q + len - 1) + seg_size, p + len - 1);
		}
		REP(i, 1, seg_size) {
			int par = (i - 1) / 2;
			add_edge(i, par);
			add_edge(par + seg_size, i + seg_size);
		}
		rep(i, v.size()) {
			int L = upper_bound(ALL(v), P(v[i].first - m, 1 << 30)) - v.begin();
			add(i, L, i, 0, 0, len);
			int R = lower_bound(ALL(v), P(v[i].first + m, -1)) - v.begin();
			add(i, i + 1, R, 0, 0, len);
		}
		int k = scc();
		bool ok = 1;
		rep(i, seg_size) {
			if (cmp[i] == cmp[i + seg_size]) {
				ok = 0;
				break;
			}
		}
		if (ok) l = m;
		else r = m;
	}
	cout << l << endl;
}

Measured memory_bytes: 40056
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = INT()
s = input()

print(s if a >=3200 else "red")

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

#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    int n; cin >> n;
    map<ll, ll> m;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        m[a]++;
    }

    bool ans = true;
    if(m.size() > 3){
        cout << "No" << endl;
        return 0;
    }
    if(m.size() == 3){
        ll x = 0;
        for(auto p : m){
            x ^= p.first;
            if(p.second * 3 != n) ans = false;
        }
        if(x != 0) ans = false;
        ans ? cout << "Yes" << endl : cout << "No" << endl;
        return 0;
    }
    if(m.size() == 2){
        bool z = false;
        for(auto p : m){
            if(p.first == 0){
                z = true;
                if(p.second * 3 != n) ans = false;
            }else{
                if(p.second * 3 != 2 * n) ans = false;
            }
        }
        if(!z) ans = false;
        ans ? cout << "Yes" << endl : cout << "No" << endl;
        return 0;
    }

    for(auto p : m){
        if(p.first != 0) ans = false;
    }
    ans ? cout << "Yes" << endl : cout << "No" << endl;
}


Measured memory_bytes: 5120
H,W = map(int, input().split())
s = []
answer = "Yes"

for i in range(H):
    s.append(str(input()))

for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            if j != 0 and s[i][j-1] == ".":
                if j+1 != W and s[i][j+1] == ".":
                    if i != 0 and s[i-1][j] == ".":
                        if i+1 != H and s[i+1][j] == ".":
                            answer ="No"

print(answer)



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

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

	int N; cin >> N;
	long long a[210000];
	long long sum = 0;
	long long b;
	for (int i = 0; i < N; i++) {
		cin >> b;
		sum += b;
		a[i] = sum;
	}
	a[N] = 0;
	a[N + 1] = 1000000000000000;
	sort(a, a + N+2);
	long long cnt = 1;
	long long ans = 0;
	for (int i = 1; i <= N+1; i++) {
		if (a[i - 1] == a[i])cnt++;
		else {
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100, mod = 1000000007, inf = 0x3f3f3f3f;
int n, h[maxn + 10], ans;
int f[maxn + 10][maxn + 10][2][2][2], tmp[2][2][2];
int add(int x, int y) {
	x += y; return x < mod ? x : x - mod;
}
int dec(int x, int y) {
	x -= y; return x < 0 ? x + mod : x;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
int fpow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		y >>= 1; x = mul(x, x);
	}
	return ans;
}

int calcmin(int l, int r) {
	int ans = inf;
	for (int i = l; i <= r; ++i) ans = min(ans, h[i]);
	return ans;
}

void upd(int l, int r, int h) {
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j)
			for (int k = 0; k < 2; ++k)
				tmp[i][j][k] = 0;
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j) {
			if (h) {
				tmp[i][j][0] = add(tmp[i][j][0], mul(f[l][r][i][j][0], fpow(2, h - 1)));
				tmp[j][i][0] = add(tmp[j][i][0], mul(f[l][r][i][j][0], fpow(2, h - 1)));
			} else tmp[i][j][0] = add(tmp[i][j][0], f[l][r][i][j][0]);
			if (h & 1) tmp[j][i][1] = add(tmp[j][i][1], f[l][r][i][j][1]);
			else tmp[i][j][1] = add(tmp[i][j][1], f[l][r][i][j][1]);
		}
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j)
			for (int k = 0; k < 2; ++k)
				f[l][r][i][j][k] = tmp[i][j][k];
}

void merge(int l, int r, int ll, int rr) {
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j)
			for (int k = 0; k < 2; ++k)
				tmp[i][j][k] = 0;
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j)
			for (int k = 0; k < 2; ++k)
				for (int s = 0; s < 2; ++s)
					for (int p = 0; p < 2; ++p)
						for (int q = 0; q < 2; ++q) {
							int st = i, ed = p, t = k || q || (j == s);
							tmp[st][ed][t] = add(tmp[st][ed][t], mul(f[l][r][i][j][k], f[ll][rr][s][p][q]));
						}
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j)
			for (int k = 0; k < 2; ++k)
				f[l][r][i][j][k] = tmp[i][j][k];
}

void dp(int l, int r) {
	if (l == r) {
		f[l][r][0][0][0] = f[l][r][1][1][0] = 1;
	} else {
		int minv = calcmin(l, r);
		int lst = l - 1;
		vector<pair<int, int> > vec;
		for (int i = l; i <= r; ++i)
			if (h[i] == minv) {
				if (lst + 1 <= i - 1) vec.push_back(make_pair(lst + 1, i - 1));
				vec.push_back(make_pair(i, i)); lst = i;
			}
		if (lst < r) vec.push_back(make_pair(lst + 1, r));
		for (int i = 0; i < vec.size(); ++i) {
			pair<int, int> e = vec[i];
			dp(e.first, e.second);
			upd(e.first, e.second, calcmin(e.first, e.second) - minv);
			if (i) merge(l, r, e.first, e.second);
			else {
				for (int j = 0; j < 2; ++j)
					for (int k = 0; k < 2; ++k)
						for (int s = 0; s < 2; ++s)
							f[l][r][j][k][s] = f[e.first][e.second][j][k][s];
			}
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &h[i]);
	dp(1, n);
	upd(1, n, calcmin(1, n) - 1);
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 2; ++j)
			for (int k = 0; k < 2; ++k)
				ans = add(ans, f[1][n][i][j][k]);
	printf("%d", ans);
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long

bool field[100][100];

signed main() {
    int n;
    while(cin>>n, n) {
        memset(field, 0, sizeof(field));
        int w, h;
        cin >> w >> h;
        for(int i=0; i<n; ++i) {
            int x, y;
            cin >> x >> y;
            x--;
            y--;
            field[x][y] = true;
        }
        int s, t;
        cin >> s >> t;
        int Max = 0;
        for(int i=0; i<w-s+1; ++i) {
            for(int j=0; j<h-t+1; ++j) {
                int cnt = 0;
                for(int k=0; k<s; ++k)
                    for(int l=0; l<t; ++l) cnt += field[i+k][j+l];
                Max = max(Max, cnt);
            }
        }
        cout << Max << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
package main

import (
	"fmt"
)

func gcd(a, b int) int {
	r := 0
	for(true){
		r = a % b
		a = b
		b = r
		if r == 0 {
			break 
		}
	}
	return a	
}

func lcm(a, b int) int {
	L := 0
	G := gcd(a,b)
	L = a / G * b
	return L
}
func main(){
	var N, Input int
	anslcm := 1
	fmt.Scanf("%d",&N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d",&Input)
		anslcm = lcm(anslcm,Input)
	}
	fmt.Printf("%d\n",anslcm)
}


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

int main()
{
    int x,y;
    cin >> x >> y;
    int ans=0;
    if(x==1)
    ans+=300000;
    else if(x==2)
    ans+=200000;
    else if(x==3)
    ans+=100000;
    if(y==1)
    ans+=300000;
    else if(y==2)
    ans+=200000;
    else if(y==3)
    ans+=100000;
    if(x==1 && y==1)
    ans+=400000;
    cout << ans << endl;
    return 0;
}


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

int main() {
    long N,ans(0);
    cin >> N;
    
    for(long i = 1;i < N+1;i++){
        if(i % 3 == 0 && i % 5 ==0 ){  
        }else if(i % 3 == 0 || i % 5 == 0){
        }else{
            ans += i;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

i64 dp[110][2][110];

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

    int len = N.size();
    vector<int> n(len);
    rep(i, len) n[i] = (N[i] - '0');
    dp[0][0][0] = 1;

    for(int i = 0; i < len; i++){
        for(int smaller = 0; smaller < 2; smaller++){
            for(int j = 0; j < 110; j++){
                for(int x = 0; x <= (smaller ? 9 : n[i]); x++){
                    dp[i + 1][smaller || x < n[i]][j + (x != 0)] += dp[i][smaller][j];
                }
            }
        }
    }

    cout << dp[len][0][K] + dp[len][1][K] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int k;
	cin>>k;
	int cnt=0;
	if(k%2==0)
	{
		cout<<-1;
		return 0;
	}
	long long int val=0;
	for(int i=1;i<=k;i++)
	{
		cnt++;
        val=val*10+7;
        val=val%k;
        if(val==0)
        {
        	cout<<cnt;
        	return 0;
        }
	}
	cout<<"-1";
}

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


int n;
vector<int> a, b, c;
long M = 11234567890L;

// get max happiness on the day
long dfs(int day, char blocked='x'){
    if(day == 0){
        return 0;
    }
    
    long resa = blocked == 'a' ? -M : dfs(day - 1, 'a') + a[day - 1];
    long resb = blocked == 'b' ? -M : dfs(day - 1, 'b') + b[day - 1];
    long resc = blocked == 'c' ? -M : dfs(day - 1, 'c') + c[day - 1];

    return max(resa, max(resb, resc));
}

vector<long> dpa, dpb, dpc;

int main(){ 
    cin >> n;
    REP(i, n){
        int ai, bi, ci;
        cin >> ai >> bi >> ci;
        a.push_back(ai);
        b.push_back(bi);
        c.push_back(ci);
    }

    // dfs
    // long res = dfs(n);

    // DP
    dpa = vector<long>(n);
    dpb = vector<long>(n);
    dpc = vector<long>(n);
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    for(int i=1; i < n; i++){
        dpa[i] = max(dpb[i-1], dpc[i-1]) + a[i];
        dpb[i] = max(dpc[i-1], dpa[i-1]) + b[i];
        dpc[i] = max(dpa[i-1], dpb[i-1]) + c[i];
    }

    auto res = max(dpa[n-1], max(dpb[n-1], dpc[n-1]));


    cout << res << endl;



}

Measured memory_bytes: 4076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] c = S.toCharArray();
		sc.close();
		int aa = 0, bb = 0, cc = 0;
		for (int i = 0; i < 3; i++) {
			if (c[i] == 'a') {
				aa++;
			} else if (c[i] == 'b') {
				bb++;
			} else {
				cc++;
			}
		}
		if (aa == 1 && bb == 1 && cc == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    set<int> se;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        int tmp = 0;
        for (int i = 0; i < n; i++)
        {
            if (bit & (1 << i))
            {
                tmp += a[i];
            }
        }
        se.insert(tmp);
    }

    int q;
    cin >> q;
    for (int test = 0; test < q; test++)
    {
        int m;
        cin >> m;
        bool flg = false;
        if (se.count(m))
        {
            flg = true;
        }
        cout << (flg ? "yes" : "no") << endl;
    }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    string s,subs;
    cin >> s;
    subs = s[0];
    int K = 1;
    for(int i = 1;i < s.size();i ++){
        if(subs.size()==1 && s[i]==subs[0]){
            if(i+1==s.size()) break;
            subs += s[i+1];
            i ++;
        }else{
            subs = s[i];
        }
        K ++;
    }
    cout << K << endl;
    return 0;
}

Measured memory_bytes: 640
def main():
    n, k = map(int, input().split())
    k = min(n, k)
    h = list(map(int, input().split()))
    h += [h[0]] * (k+5)

    dp = [0]*(n+10)
    for i in range(n):
        vals = [dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,k+1)]
        dp[i] = min(vals)
    print(dp[n-1])


if __name__=="__main__":
    main()

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

int main(){
  string S,T;cin>>S>>T;
  bool ans=false;
  for(int i=0;i < S.size();i++){
    if(S==T){
      ans=true;
      break;
    }
    S=S.back()+S.substr(0,S.size()-1);
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 3568
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
#define rrep(i,n) for(ll i=n-1;i>=0;--i)
#define pp pair<ll,ll>
#define ppp pair<ll,pp>
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define fi first
#define se second
const ll MOD=1e9+9,INF=1e16;
ll n,t,ans;
int main(){
	cin>>n>>t;
	int a[200010];
	rep(i,n){
		cin>>a[i];
		if(i==0)continue;
		if(a[i]-a[i-1]>=t)ans+=t;
		else ans+=a[i]-a[i-1];
	}
	cout<<ans+t<<endl;
}

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

using namespace std;

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

typedef long long ll;

int n, s;
ll dp[10][101][1001];

//??????p????????¶ c???????????°??? sum??????????¨?
ll dfs(int p, int c, int sum) {
	if (p < 0 || sum < 0) return 0; 
	if (c < 0) return p == 0 && sum == 0;
	 
	if (dp[p][c][sum] != -1) return dp[p][c][sum];
	
	return dp[p][c][sum] = dfs(p - 1, c - 1, sum - c) + dfs(p, c - 1, sum);
}

int main() {
	fill(dp[0][0], dp[10][0], -1);
	
	while (true) {
		cin >> n >> s;
		if (!n && !s) break;
		
		cout << dfs(n, 100, s) << endl;
	}
	return 0;
}

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
/*-------------------Basis Functions----------------------*/
template<class T> inline void dmin(T& x,T y){ y<x?x=y:0; }
template<class T> inline void dmax(T& x,T y){ y>x?x=y:0; }
template<class T> inline void dmin(T& x,vector<T> y){ 
	for(auto t:y) t<x?x=t:0;
}
template<class T> inline void dmax(T& x,vector<T> y){
	for(auto t:y) t>x?x=t:0;
}
int to_min(pair<int,int> a){
	return a.first*60+a.second;
}
pair<int,int> to_pair(int x){
	return make_pair(x/60,x%60);
}
int main(){
	int h1,m1,h2,m2,k; 
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	int x1=to_min(make_pair(h1,m1));
	int x2=to_min(make_pair(h2,m2));
	int len=x1<x2?x2-x1:to_min(make_pair(24,0))-(x1-x2);
	printf("%d\n",len-k);
	return 0;
}

Measured memory_bytes: 3812
//
// Created by Hideaki Imamura on 2020-03-25.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

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

int N;
vector<ll> A;

int main() {
    cin >> N;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    multiset<ll> m;
    for (int i = 0; i < N; ++i) {
        auto itr = m.lower_bound(A[i]);
        if (itr != m.begin()) m.erase(--itr);
        m.insert(A[i]);
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
#!/usr/bin/env python3
#ABC131 E

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()

if k > (n-1)*(n-2)//2:
    print(-1)
    quit()
print((n-1)*(n-2)//2 + (n-1) - k)
for i in range(n-1):
    print(1,i+2)

a,b = 2,3
for _ in range((n-1)*(n-2)//2 - k):
    print(a,b)
    b += 1
    if b > n:
        a += 1
        b = a+1


Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == a[2]) {
		cout << 1 << endl;
	}
	else if ( a[0]==a[1] || a[1] == a[2]) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int n;
    std::cin >> n;
    std::string str;
    double res = 0;
    double tmp;
    for(int i = 1;i <= n; i++){
        std::cin >> tmp >> str;
        if (str == "JPY") res += tmp;
        else if (str == "BTC") res += tmp * 380000.0;
    }
    std::cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust\n";
    } else {
        cout << "win\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll mx = max(a*c,max(a*d,max(b*c,b*d)));
	cout<<mx<<'\n';
	return 0;
}

Measured memory_bytes: 3624
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    val x1, y1, x2, y2 = scanner.nextDouble
    val xd = x2 - x1
    val yd = y2 - y1
    println(f"${math.sqrt(xd * xd + yd * yd)}%.5f")
  }
}



Measured memory_bytes: 45940
from collections import deque
import sys
H, W = [int(x) for x in input().split()]
s = [list(input()) for _ in range(H)]

white = sum([s[i].count('.') for i in range(H)])
que = deque([(0, 0, 0)])
s[0][0] = '#'
while que:
    y, x, d = que.popleft()
    if (y, x) == (H - 1, W - 1):
        break
    for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        ny = y + dy
        nx = x + dx
        if ny < 0 or ny > H - 1 or nx < 0 or nx > W - 1:
            continue
        if s[ny][nx] == '#':
            continue
        s[ny][nx] = '#'
        que.append((ny, nx, d + 1))
else:
    print(-1)
    sys.exit()

print(white - d - 1)

Measured memory_bytes: 3316
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
H = get_ints

cur = H[0] - 1

ans = true
1.step(N-1) do |i|
  if H[i] >= cur
    cur = [H[i] - 1, cur].max
  else
    ans = false
    break
  end
end

puts ans ? 'Yes' : 'No'


Measured memory_bytes: 21888
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    int cnt[n] = {}, m = 7%n, ans = 1;
    while(cnt[m] == 0)
    {
    	if(m == 0)
    	{
    		cout<<ans<<endl;
    		return;
    	}
    	cnt[m]++;
    	ans++;
    	m = (10*m + 7)%n;
    }
    cout<<"-1";
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 11420
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(string, s);

    rep(i, s.size() - 1) {
        if (s[i] == s[i + 1]) {
            return output("Bad"), 0;
        }
    }

    output("Good");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        String s=scan.next();

        if(a<3200){
            System.out.println("red");
        }else {
            System.out.println(s);
        }
    }
}

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

s = input()[:-1]
t = input()[:-1]
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
track = [[-1]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            dp[i+1][j+1] = dp[i][j]+1
            track[i+1][j+1] = (i, j)
        else:
            if dp[i+1][j]>dp[i][j+1]:
                dp[i+1][j+1] = dp[i+1][j]
                track[i+1][j+1] = (i+1, j)
            else:
                dp[i+1][j+1] = dp[i][j+1]
                track[i+1][j+1] = (i, j+1)

ci, cj = len(s), len(t)
ans = []

while ci!=0 and cj!=0:
    ni, nj = track[ci][cj]
    
    if ci-ni==1 and cj-nj==1:
        ans.append(s[ni])
    
    ci, cj = ni, nj

ans.reverse()
print(''.join(ans))

Measured memory_bytes: 404232
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans2 = (c-a-b);
		BigInteger ba = BigInteger.valueOf(a);
		//ba = ba.multiply(BigInteger.valueOf(a));
		BigInteger bb = BigInteger.valueOf(b);
		//bb = bb.multiply(BigInteger.valueOf(b));
		BigInteger bc = BigInteger.valueOf(c);
		//bc = bc.multiply(BigInteger.valueOf(c));
		String ans = "No";
		BigInteger d =  BigInteger.valueOf(4).multiply(ba).	multiply(bb);
		BigInteger e = bc.subtract(ba).subtract(bb);
		if (d.compareTo(e.multiply(e)) < 0) {
			if ( ans2 > 0) {
				ans = "Yes";
			}
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int dp[1000005];
	for(int i=0;i<a[0];i++)
		dp[i]=0;
	for(int i=a[0];i<1000005;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i<a[j])
				break;
			if(!dp[i-a[j]])
				dp[i]=1;
		}
	}
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	int ans = 0;
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		if(i % 2 == 0)
			continue;

		if(x % 2)
			ans++;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int P, Q, A, N;

int calc(int p, int q, int n, int a, int t) {
	if(p * Q == P * q) return 1;
	if(n == N) return 0;
	if(p * Q > P * q) return 0;
	int ret = 0;
	for(int i = t; i * a <= A; i++) {
		int np = p * i + q, nq = i * q;
		// int g = __gcd(np, nq);
		// np /= g;
		// nq /= g;
		ret += calc(np, nq, n+1, i*a, i);
	}
	return ret;
}


int main(){
	//while(cin >> P >> Q >> A >> N) {
	while(scanf("%d %d %d %d", &P, &Q, &A, &N) != EOF) {
		if(P == 0 && Q == 0 && A == 0 && N == 0) break;
		//cout << calc(0, 1, 0, 1, 1) << endl;
		printf("%d\n", calc(0, 1, 0, 1, 1));
	}
}

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

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

    int n;
    cin >> n;
    map<int, bool> mp;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(mp[a] == true) mp[a] = false;
        else mp[a] = true;
    }

    int ans = 0;
    for(auto x: mp){
        if(x.second) ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl
using namespace std;
int max_int = 2147483647;
int prime = 10e9+7;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    int ans = n;
    REP(i,n+1){
        int tmp = i;
        int cnt = 0;
        while(tmp>0){
            cnt += tmp%6;
            tmp/=6;
        } 
        tmp = n-i;
        while(tmp>0){
            cnt += tmp%9;
            tmp /= 9;
        }
        ans = min(ans,cnt);
    }
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    ll ans = sum;
    ll lsum = 0;
    for (int i = 0; i <= N-2; i++) {
        lsum += A[i];
        ans = min(ans, abs(sum-lsum-lsum));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792