akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

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

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int X;
	cin >> X;
	
	FOR(i, 0, X + 1){
		if ((i*(i + 1)) / 2 >= X) {

			cout << i;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().strip().split()))

# 各数字の個数を記録するリスト alpha
alpha = [0] * 10 ** 5
for a in A:
    alpha[a - 1] += 1

# beta = [i for i in range(1, 10 ** 5 + 1)]

ans = sum(A)
Q = int(input())
for q in range(Q):
    B, C = map(int, sys.stdin.readline().strip().split())
    # beta[B - 1] = C

    # print(f'alpha : {alpha[B - 1]}')
    # print(f'add: {alpha[B - 1] * (C - B)}')

    ans += alpha[B - 1] * (C - B)

    alpha[C - 1] += alpha[B - 1]
    alpha[B - 1] = 0
    # ans = ans + alpha[B - 1] * (C - B)
    print(ans)


Measured memory_bytes: 21232
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   ll a, b, c, k;
   cin >> a >> b >> c >> k;
   if (k < a + b)
   {
      cout << k << endl;
   }
   else
   {
      cout << a + (k - a - b)*-1 << endl;
   }
}

Measured memory_bytes: 3688
d, g = list(map(int, input().split()))
pc = [list(map(int, input().split())) for i in range(d)]
ans = float("INF")

for i in range(2**d):
  num = 0
  score = 0
  for j in range(d):
    if i&(1<<j):
      num += pc[j][0]
      score += (j+1)*100*pc[j][0] + pc[j][1]
  j = d-1
  while score<g and j>=0:
    if i&(1<<j) == 0:
      rem = g-score
      tmax = (j+1)*100*pc[j][0]
      if rem>=tmax:
        num += pc[j][0]
        score += tmax
      else:
        for k in range(1, pc[j][0]):
          num += 1
          score += (j+1)*100
          if score>=g:
            break
    j -= 1
  if score>=g:
    ans = min(ans, num)
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b, c string
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)

	fmt.Printf("%d\n", solve(a, b, c))
}

func solve(a, b, c string) int {
	max := -1
	rets := []int{}
	rets = append(rets, calc(a, b, c))
	rets = append(rets, calc(a, c, b))
	rets = append(rets, calc(b, a, c))
	rets = append(rets, calc(b, c, a))
	rets = append(rets, calc(c, a, b))
	rets = append(rets, calc(c, b, a))
	for _, r := range rets {
		if max < r {
			max = r
		}
	}
	return max
}

func calc(a, b, c string) int {
	//a + bc
	ai, _ := strconv.Atoi(a)
	bci, _ := strconv.Atoi(b + c)
	ans1 := ai + bci
	//ab + c
	abi, _ := strconv.Atoi(a + b)
	bi, _ := strconv.Atoi(c)
	ans2 := abi + bi
	if ans1 < ans2 {
		return ans2
	} else {
		return ans1
	}
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a;
    cin >> b;
    if(a > b){
        cout << "a > b" << endl;
    }else if(a == b){
        cout << "a == b" << endl;
    }else{
        cout << "a < b" << endl;
    }
   
    return 0;    
}

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

using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	H, W := nextInt(), nextInt()
	HW := make([][]string, H)
	isAllWhiteRow := make([]bool, H)
	isAllWhiteCol := make([]bool, W)
	for i := 0; i < H; i++ {
		row := nextLine()
		if !strings.Contains(row, "#") {
			isAllWhiteRow[i] = true
		}
		HW[i] = strings.Split(row, "")
	}
	for i := 0; i < W; i++ {
		isAllWhiteCol[i] = true
		for j := 0; j < H; j++ {
			if HW[j][i] == "#" {
				isAllWhiteCol[i] = false
				break
			}
		}
	}
	for i := 0; i < H; i++ {
		if isAllWhiteRow[i] {
			continue
		}
		for j := 0; j < W; j++ {
			if !isAllWhiteCol[j] {
				fmt.Printf("%s", HW[i][j])
			}
			if j == W-1 {
				fmt.Println()
			}
		}
	}
}

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

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1024
#include <iostream>
#define INF 1e+9
#define MOD (int)1e9+7
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int s = a * x + b * y;
    int t;
    if(x < y){
        t = 2 * c * x + b * (y - x);
    }else{
        t = 2 * c * y + a * (x - y);
    }
    int u = 2 * c * max(x, y);

    cout << min(min(s, t), u) << endl;
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  set<ll> s;
  rep(i,3){
    ll x;
    cin>>x;
    s.insert(x);
  }
  cout << (s.size() == 2 ? "Yes": "No" )<< endl;
  return 0;
}


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

int main() {
	int  N, M, p, E, a, b, c, H, L, V, w, x, y, z, K, T;
	E = 0;
	cin >> N >> M >> p;
	int*d = new int[M];
	int*f = new int[M];
	int*g = new int[M];
	for (a = 0; a < M; a++) {
		cin >> d[a];
	}
	x = N % 2;
	y = (N - x) / 2;
	if (p > 0) {
		for (a = 0; a < M; a++) {
			d[a] = d[a] - p;
			if (d[a] < 0) {
				d[a] = N + d[a];
			}
		}
	}
	for (a = 0; a < M; a++) {
		for (b = a + 1; b < M; b++) {
			if (d[a] > d[b]) {
				z = d[a];
				d[a] = d[b];
				d[b] = z;
			}
		}
	}
	H = d[M - 1];
	L = d[0];
	c = 0;
	for (a = 0; a < M - 1; a++) {
		f[a] = d[a] * 2 + N - d[a + 1];
	}
	for (a = 0; a < M - 1; a++) {
		for (b = a + 1; b < M - 1; b++) {
			if (f[a] > f[b]) {
				z = f[a];
				f[a] = f[b];
				f[b] = z;
			}
		}
	}
	for (a = 0; a < M - 1; a++) {
		g[a] = (N - d[a + 1]) * 2 + d[a];
	}
	for (a = 0; a < M - 1; a++) {
		for (b = a + 1; b < M - 1; b++) {
			if (g[a] > g[b]) {
				z = g[a];
				g[a] = g[b];
				g[b] = z;
			}
		}
	}
	if (M == 1) {
		if (H > N - L) {
			E = (N - L) * 100;
		}
		else {
			E = (H)* 100;
		}
	}
	else {
		if (H > N - L) {
			if (f[0] > g[0]) {
				if (N - L > g[0]) {
					E = g[0] * 100;
				}
				else {
					E = (N - L) * 100;
				}
			}
			else {
				if (N - L > f[0]) {
					E = f[0] * 100;
				}
				else {
					E = (N - L) * 100;
				}
			}
		}
		else {
			if (f[0] > g[0]) {
				if (H > g[0]) {
					E = g[0] * 100;
				}
				else {
					E = (H)* 100;
				}
			}
			else {
				if (H > f[0]) {
					E = f[0] * 100;
				}
				else {
					E = (H)* 100;
				}
			}
		}
	}
	cout << E << endl;

	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, l[50], u[50], r[50], d[50];
ll s[222][222];
bool v[222][222];

void rec(int x, int y) {
	v[x][y] = true;
	rep(i,4) {
		int xx = x + dx[i], yy = y + dy[i];
		if (xx<0 || 222<=xx || yy<0 || 222<=yy || v[xx][yy] || s[xx][yy]!=s[x][y]) continue;
		rec(xx,yy);
	}
}

signed main() {
	while (1) {
		cin >> n;
		if (n==0) break;
		vi xs, ys;
		rep(i,n) {
			cin >> l[i] >> u[i] >> r[i] >> d[i];
			xs.pb(u[i]), xs.pb(d[i]), ys.pb(l[i]), ys.pb(r[i]);
		}
		sort(all(xs)), sort(all(ys));
		xs.erase(unique(all(xs)),xs.end()), ys.erase(unique(all(ys)),ys.end());
		int h = 2, w = 2;
		map<int,int> x, y;
		rep(i,xs.size()) x[xs[i]] = h, h += 2;
		rep(i,ys.size()) y[ys[i]] = w, w += 2;
		memset(s,0,sizeof(s));
		rep(k,n) reps(i,x[d[k]]+1,x[u[k]]) reps(j,y[l[k]]+1,y[r[k]]) s[i][j] |= 1ll<<k;
		int res = 0;
		memset(v,0,sizeof(v));
		rep(i,222) rep(j,222) if (!v[i][j]) res++, rec(i,j);
		cout << res << ln;
	}
}


Measured memory_bytes: 6620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 998244353;

struct Combi
{
	vector<ll> fact;
	vector<ll> ifact;
	vector<ll> inv;
	vector<ll> pow2;
	const ll MOD = (998244353);
	ll add(ll a, ll b)
	{
		a+=b;
		while(a>=MOD) a-=MOD;
		return a;
	}
	void radd(ll &a, ll b)
	{
		a=add(a,b); 
	}
	ll mult(ll a, ll b)
	{
		return (a*1LL*b)%MOD;
	}
	void rmult(ll &a, ll b)
	{
		a=mult(a,b);
	}
	ll modpow(ll a, ll b)
	{
		ll r=1;
		while(b)
		{
			if(b&1) r=mult(r,a);
			a=mult(a,a);
			b>>=1;
		}
		return r;
	}
	ll choose(ll a, ll b)
	{
		if(a<b) return 0;
		if(b==0) return 1;
		if(a==b) return 1;
		return mult(fact[a],mult(ifact[b],ifact[a-b]));
	}
	ll inverse(ll a)
	{
		return modpow(a,MOD-2);
	}
	void init(ll _n)
	{
		fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
		fact.resize(_n+1);
		ifact.resize(_n+1);
		inv.resize(_n+1);
		pow2.resize(_n+1);
		pow2[0]=1;
		ifact[0]=1;
		fact[0]=1;
		for(ll i=1;i<=_n;i++)
		{
			pow2[i]=add(pow2[i-1],pow2[i-1]);
			fact[i]=mult(fact[i-1],i);
			//ifact[i]=mult(ifact[i-1],inv[i]);
		}
		ifact[_n] = inverse(fact[_n]);
		for(ll i=_n-1;i>=1;i--)
		{
		    ifact[i] = mult(ifact[i + 1], i + 1);
		}
		for(ll i=1;i<=_n;i++)
		{
		    inv[i] = mult(fact[i-1],ifact[i]);
		}
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k,m;
    cin >> n >> m >> k;
    Combi comb;
    comb.init(n+10);
    ll ans = 0;
    for (ll z=0;z<=k;z++){
        ans += (((comb.choose(n-1,z)*comb.modpow(m-1,n-z-1))%mod) * m)%mod;
        ans %= mod;
    }
    if (ans < 0) ans += mod;
    cout << ans << endl;
} 

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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void init(){
}

void solve(){
    int x;
    for (int i = 0; i < 5; i++){
        cin >> x;
        if (x == 0){
            cout << i+1 << '\n';
        }
    }
    
}


int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>

int main(void){
	int N,i,j,k,l=0;
	scanf("%d",&N);
	int a[N];
	for (i = 0; i < N; i++){
		scanf("%d",&a[i]);
		k = 0;
		if(i != 0){
			for (j = 0;j < i;j++){
			if(a[i] > a[j] || a[i] == a[j]){
		k = k+1;}}}
		if (k == i){
		l = l+1;}}
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int, int> ii;
typedef long long LL;
typedef pair <LL, int> li;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int tab[N], nextt[N], prevv[N], head, tail, i, v, n;
LL res[N], c, T[N];
set<li> Q;
li top;

void add(int v1, int v2) {
	int dh = tab[v2] - tab[v1];
	LL r1 = dh * 1LL * dh + res[v1];
	LL r2 = res[v2];
	LL cc;
	if (r2 <= r1) cc = 0; else {
		cc = (r2 - r1) / (2 * dh);
		if ((r2 - r1) % (2 * dh) > 0) cc++;
	}
	T[v1] = tab[v2] + cc;
	Q.insert(li(T[v1], -v1));
	//printf("insert for %d = %lld\n", v1, T[v1]);
}

void rem(int v) {
	if (nextt[v] != -1) {
		prevv[nextt[v]] = prevv[v];
		Q.erase(li(T[v], -v));
	}
	if (prevv[v] != -1) {
		nextt[prevv[v]] = nextt[v];
		Q.erase(li(T[prevv[v]], -prevv[v]));
	}
	if (prevv[v] != -1 && nextt[v] != -1) add(prevv[v], nextt[v]);
	if (head == v) head = nextt[v];
	if (tail == v) tail = prevv[v];
	nextt[v] = prevv[v] = -1;
}

int main() {
scanf("%d %lld", &n, &c);
for (i=1;i<=n;i++) scanf("%d", &tab[i]);
res[1] = 0;
nextt[1] = prevv[1] = -1;
head = 1;
tail = 1;
for (i=2;i<=n;i++) Q.insert(li(tab[i], i));
while (!Q.empty()) {
	top = *Q.begin();
    Q.erase(Q.begin());
    v = top.second;
	//cout << v << endl;
    if (v > 0) {
		res[v] = res[head] + (tab[v] - tab[head]) * 1LL * (tab[v] - tab[head]) + c;
		//printf("res[%d] = %lld\n", v, res[v]);
		nextt[tail] = v;
		nextt[v] = -1;
		prevv[v] = tail;
		tail = v;
		add(prevv[v], v);
	} else {
		rem(-v);
	}
}
printf("%lld\n", res[n]);
}

Measured memory_bytes: 18176
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, P;
  cin >> N >> P;
  vector<int> A(N);
  bool all_even = true;
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
    if (A[i] % 2 != 0)
      all_even = false;
  }
  long ans = 1;
  if (all_even)
  {
    if (P == 0)
    {
      for (int i = 0; i < N; i++)
        ans *= 2;
    }
    else
      ans = 0;
  }
  else
  {
    for (int i = 0; i < N - 1; i++)
      ans *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int a, b;
int main() {
	cin >> a >> b;
	puts(a > b ? "safe" : "unsafe");
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main(){
	int a,b;
	cin >> a>>b;
	for (int i = b - a + 1; i < b + a; i++) {
		cout << i;
		if (i == b + a - 1)cout << endl;
		else cout << " ";
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	static BufferedReader br;

	public static void main(String[] args) {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			System.out.println((Integer.parseInt(br.readLine())
					+ Integer.parseInt(br.readLine()))
					* Integer.parseInt(br.readLine()) / 2);
		} catch (Exception e) {
			System.err.println("Error : " + e.getMessage());
		}
	}
	
}


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

int main(){
  string s;
  cin>>s;
  s.erase(s.size()-1);
  while(s.size()>0){
    if(s.size()%2==0){
      if(s.substr(0,s.size()/2)==s.substr(s.size()/2,s.size()/2)){
        cout<<s.size()<<endl;
        return 0;
      }
    }
    s.erase(s.size()-1);
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

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

   int res = 111;
   FOR(i,0,9)
   {
      if(res>=n)
      {
         cout << res << endl;
         return 0;
      }
      res += 111;
   }
   return 0;
}


Measured memory_bytes: 256
import math

N ,D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        x_sq = 0
        for k in range(D):
            x_sq += (X[i][k] - X[j][k])**2
        x_sq = math.sqrt(x_sq)
        if x_sq.is_integer():ans += 1
          
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    stack<char> st1;
    string str;
    cin>>str;
    ll ans=0;
    ll len=str.size();
    for(ll i=0;i<len;i++)
    {
        if(st1.empty()|| st1.top()==str[i])
        {
            st1.push(str[i]);
            continue;
        }
        st1.pop();
        ans+=2;
    }
    cout<<ans;
    return 0;
}
    

Measured memory_bytes: 512
def main():
    n=int(input())
    s=list(input())
    ans=0
    how_r=[0 for i in range(n+1)]
    how_g=[0 for i in range(n+1)]
    how_b=[0 for i in range(n+1)]
    for i in range(n):
        string=s[i]
        if string=="R":
            how_r[i+1]+=1
        elif string=="G":
            how_g[i+1]+=1
        elif string=="B":
            how_b[i+1]+=1
    for i in range(n):
        how_r[i+1]+=how_r[i]
        how_g[i+1]+=how_g[i]
        how_b[i+1]+=how_b[i]


    for  i in range(n):
        for j in range(i+1,n):
            x=s[i]
            y=s[j]
            if x!=y:
                if "R" not in [x,y]:
                    ans+=how_r[j+1]-how_r[i]
                    if (i+j)%2==0:
                        if s[(i+j)//2]=="R":
                            ans-=1

                elif "G" not in [x,y]:
                    ans+=how_g[j+1]-how_g[i]
                    if (i+j)%2==0:
                        if s[(i+j)//2]=="G":
                            ans-=1

                elif "B" not in [x,y]:
                    ans+=how_b[j+1]-how_b[i]
                    if (i+j)%2==0:
                        if s[(i+j)//2]=="B":
                            ans-=1  
    print(ans)
if __name__=="__main__":
    main()









Measured memory_bytes: 74452
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
int main() {
    FIO;
    //test
    {
        ll n;
        cin>>n;
        ll a[n],b[n],i,u,v;
        for(i=0;i<n;i++){
            cin>>a[i];
            cin>>b[i];
        }
        sort(a,a+n);
        sort(b,b+n);
        if(n%2==1){
            u=a[n/2];
            v=b[n/2];
        }
        else{
            u=a[n/2]+a[n/2-1];
            v=b[n/2]+b[n/2-1];
        }
        cout<<v-u+1<<endl;
    }
	return 0;
}


Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int main(void){
	int h, n;
	cin >> h >> n;
	int mp[h + 1];
	fill(mp, mp + h + 1, 0);
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		mp[y] =  (mp[y] | (1 << x));
	}
	int mask[5] = {0, 3, 6, 12, 15};
	int dp[h][16];
	fill(dp[0], dp[h], 0);
	for(int i = 1; i < 5; i++){
		if(!((mp[0] | mp[1]) & mask[i])){
			if(mask[i] == 15) dp[1][mask[i]] = 2;
			else dp[1][mask[i]] = 1;
		}
	}
	for(int i = 1; i < h - 1; i++){
		for(int j = 0; j < 5; j++){
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][mask[j]]);
			for(int k = 1; k < 5; k++){
				if(((mp[i] | mask[j]) & mask[k]) == 0 && (mp[i + 1] & mask[k]) == 0){
					if(mask[k] == 15) dp[i + 1][mask[k]] = max(dp[i + 1][mask[k]], dp[i][mask[j]] + 2);
					else dp[i + 1][mask[k]] = max(dp[i + 1][mask[k]], dp[i][mask[j]] + 1);
				}
			}
		}
	}
	int mx = -1;
	for(int i = 0; i < 16; i++) mx = max(mx, dp[h - 1][i]);
	cout << mx << endl;
	return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>


#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

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;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;


int main() {
    int N; cin >> N;
    vector<int> x(N);
    rep (i, N) {
        cin >> x[i];
    }
    int res = 0;
    rep(i, N-2) {
        if(x[i] < x[i+1] && x[i+1] < x[i+2]) res++;
        else if(x[i] > x[i+1] && x[i+1] > x[i+2]) res++;
    }
    
    cout << res << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>

#define p(x) cout << "(" << x.first << "," << x.second << ")" << endl;

using namespace std;
const int MAX_H = 1005;
const int MAX_W = 1005;

char D[MAX_H][MAX_W];
bool visited[MAX_H][MAX_W];

int H, W, N;

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

typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef vector<PII> VII;

int bfs(PII from, PII to) {
  queue<PIII> que;
  memset(visited, false, sizeof(visited[0][0]) * MAX_H * MAX_W);

  que.push(make_pair(from, 0));
  while (!que.empty()) {
    PIII p = que.front(); que.pop();
    int d = p.second;
    if (p.first == to) {
      return d;
    }
    for (int k = 0; k < 4; k++) {
      int i2 = p.first.first + dx[k];
      int j2 = p.first.second + dy[k];
      if (0 <= i2 && i2 < H && 0 <= j2 && j2 < W && D[i2][j2] != 'X' && !visited[i2][j2]) {
        visited[i2][j2] = true;
        que.push(make_pair(make_pair(i2, j2), d+1));
      }
    }
  }
  return -1;
}

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

  VII pos(N+1);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      D[i][j] = c;
      if (c == 'S') {
        pos[0] = make_pair(i, j);
      } else if (c > '0') {
        pos[c - '0'] = make_pair(i, j);
      }
    }
  }

  int res = 0;
  for (int i = 0; i < N; i++) {
    res += bfs(pos[i], pos[i+1]);
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 5084
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

int Q;

int mx = 0;

void score(vector<int> seq) {
  int s = 0;

  rep(j, Q) {
    if (seq[b[j]] - seq[a[j]] == c[j]) s += d[j];
  }

  if (mx < s) mx = s;
}

void calc(vector<int> seq, int N, int M, int before) {
  if (seq.size() == N) {
    score(seq);
    return;
  } else {
    for (int i = before; i <= M; i++) {
      auto tmp = seq;
      tmp.push_back(i);
      calc(tmp, N, M, i);
    }
  }
}

int main() {
  int N, M;
  cin >> N >> M >> Q;

  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  rep(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }

  vector<int> seq;
  calc(seq, N, M, 1);

  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 3636
def main(n,a_list):

    i = 0
    list = [0] * n
    while i < n:
        list[a_list[i] - 1] = i + 1
        i += 1

    i = 0
    while i < n:
        print(list[i], end="")
        if not i == n - 1:
            print(' ', end="")
        i += 1


if __name__ == '__main__':
    n = int(input())
    a_list = list(map(int, input().split()))
    main(n, a_list)


Measured memory_bytes: 63724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    
    string s;
    string t[]={"dream","dreamer","erase","eraser"};
    cin >> s;
    reverse(s.begin(),s.end());
    for(int i=0;i<4;i++)
    reverse(t[i].begin(),t[i].end());
    
    bool can = true;
    
    for(int i=0;i<s.size();){
        bool can2 = false;
        for(int j=0;j<4;j++){
            if(s.substr(i,t[j].size())==t[j]){
                can2=true;
                i+=t[j].size();
            }
        }
        if(!can2){
            can=false;
            break;
        }
    }
    
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 512
A,B,C,X,Y=map(int,input().split())
cost=A*X+B*Y
Z=max(X,Y)
for i in range(0,2*Z+1,2):
    x=max(0,X-(i//2))
    y=max(0,Y-(i//2))
    cost=min(cost,C*i+A*x+B*y)
print(cost)

Measured memory_bytes: 9180
import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    val s = sc.next()
    s match {
      case "SUN" => pw.println(7)
      case "MON" => pw.println(6)
      case "TUE" => pw.println(5)
      case "WED" => pw.println(4)
      case "THU" => pw.println(3)
      case "FRI" => pw.println(2)
      case "SAT" => pw.println(1)
    }


    pw.flush()
  }
}

Measured memory_bytes: 25888
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int be,en;
  be = 0;
  en = 0;
  int count = 0;
  while(en < n){
    if(s[en] == '1'){
      en++;
      continue;
    }else{
      if(k == count){
        break;
      }
      while(en < n && s[en]=='0'){
        en++;
      }
      count++;
    }
  }

  int ans = en-be;
  while(en<n){
    be++;
    if(s[be-1] == '0' && s[be] == '1'){
      while(en < n && s[en] == '0'){
        en++;
      }
      while(en < n && s[en] == '1'){
        en++;
      }
    }
    chmax(ans,en-be);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<math.h>

int main(){
    int N , M , C;
    scanf("%d %d %d" , &N , &M , &C);
    int a[N][M];
    int b[M];
    for(int i = 0 ; i<M;i++){
        scanf("%d" , &b[i]);
    }

    for(int t=0 ; t < N ; t++ ){
        for(int s = 0 ; s< M ; s++){
            scanf("%d" , &a[t][s]);
        }
    }
    int counter = 0;
    for(int t= 0 ; t< N ; t++){
        int c = 0;
        for(int u = 0 ; u < M ; u++){
            c += a[t][u]*b[u];
        }
        c +=C;
        if(c>0)counter+=1;
    }
    printf("%d\n" , counter);
    return 0;
}

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

   void solve() {
      ll n, a, b;
      cin >> n >> a >> b;
      ll ans = (n / (a + b)) * a;
      n -= (n / (a + b)) * (a + b);
      ans += min(n, a);
      cout << ans << endl;
   }

   int main() {
      cin.tie(0);
      cin.sync_with_stdio(0);
      int testcase = 1;
      // cin >> testcase;
   
      for(int i = 0; i < testcase; i++) {
         solve();
      } 
      return 0;
   }


Measured memory_bytes: 3640
N = int(input())
A = list(map(int,input().split()))
         
if(0 in A):
  ans = 0 
else:
  ans = 1       
  for a in A:
    ans *= a
    if(ans > 10**18):
      ans = -1
      break
    if(len(str(ans))>=2):
     if(str(ans)[1] == 'e'):
      ans = -1
      break
         
print(ans)  

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    char a;
    cin >> a;
    cout << char(int(a - 'a') + 1 + 'a') << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=sorted(int(input())for _ in[0]*N)
n=N//2-1
print(2*sum(A[n+2:])-2*sum(A[:n])+A[n+1]-A[n]-(min(A[n]+A[n+2],2*A[n+1])if N%2>0 else 0))

Measured memory_bytes: 7948
#include <stdio.h>
 
int main(void)
{
    int H, W, i, j;
     
    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) {
            break;
        }
         
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                if ((i + j) % 2 == 0) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
     
    return 0;
}

Measured memory_bytes: 572
def isPalindrome(string): return True if string == string[::-1] else False


s = input()
n = len(s)

a = isPalindrome(s)
b = isPalindrome(s[:((n - 1) // 2)])
c = isPalindrome(s[(n + 3) // 2:n - 1])

ans = 'Yes' if (a == b == c) else 'No'
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{

    int n,a,b;
    scanf("%d",&n);
    a = (int)sqrt((double)n);
    b = a * a;
    printf("%d\n",b);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in) ;
		int n = sc.nextInt();
		int m = sc.nextInt();
		
	
		int[][] a = new int[n][m];
		int[]   b = new int[m];
		int[]   c = new int[n];
	//a[n][m] ?????????????????\????????????????????????
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0; j < m ; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		
	//b[m] ?????????????????\?????????
		for(int j = 0 ; j < m ; j++) {
			b[j] = sc.nextInt();
		}
	
	//????????????????????????????????????
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0; j < m ; j++) {
				int A = a[i][j] ;   //A???A????????¨????????????
				int B = b[j] ;      //??????b????????¨????????????
				c[i] += A*B;        //??????c??????????¨???????????????§???
			}
			System.out.println(c[i]);
		}
		
		sc.close();

	}
	
}

Measured memory_bytes: 40456
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

template <typename T>
void print(T pBegin, T pEnd)
{
  for(T p = pBegin; p != pEnd; p++)
	std::cout << *p << " ";
  std::cout << '\n';
}

int main(int argc, const char * argv[])
{
  unsigned int n;
  std::cin >> n;
  std::vector<int> vec(n*2);
  for (int i = 0; i < n*2; i++) {
	std::cin >> vec[i];
  }

  std::sort(vec.rbegin(), vec.rend());
  //  print(vec.begin(), vec.end());
  int sum = 0;
  for (int i = 0; i < n*2; i+=2) {
	sum += vec[i+1];
  }
  std::cout << sum << "\n";

  return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll mod = 1e9 + 7;
ll dp[200005];
vll divs[200005];
ll binpow(ll a, ll b){
	if (b == 0) return 1;
	ll x = binpow(a, b / 2);
	x *= x; x %= mod;
	if (b % 2) return (x * a) % mod;
	else return x;
}
int main(){
	for (ll i = 1; i < 200005; i++){
		for (ll j = i; j < 200005; j += i) divs[j].pb(i);
	}
	ll n, k; cin >> n >> k;
	dp[1] = 1; dp[0] = 0;
	for (ll i = 2; i <= k; i++){
		ll rem = binpow(i - 1, n); rem -= dp[i - 1]; 
		for (ll j = 1; j < divs[i].size(); j++) rem += (dp[i / divs[i][j]] - dp[i / divs[i][j] - 1]); 
		rem %= mod; dp[i] = (binpow(i, n) - rem + mod) % mod;
	}
	ll ans = 0;
	for (ll i = 1; i <= k; i++) (ans += (dp[k / i] * i)) %= mod;
	cout << ans << endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int a, v;
	long long int b, w;
	long long int t;

	cin >> a >> v >> b >> w >> t;

	if(a == b) cout << "YES";

	if(v == 0) cout << "NO";
	
	if(a <= b){
		long long int astep = a + v * t;
		long long int bstep = b + w * t;

		if(bstep <= astep) cout << "YES";
		else cout << "NO";
	}
	else{
		long long int astep = a - v * t;
		long long int bstep = b - w * t;

		if(astep <= bstep) cout << "YES";
		else cout << "NO";
	}

	return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Set<String> st = new HashSet<>();
    int n = sc.nextInt();
    for(int i =0 ; i<n; i++){
      String keihin = sc.next();
      st.add(keihin);
    }
    System.out.println(st.size());
  }
}

Measured memory_bytes: 76872
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = 0

n.times do
  a = gets.split.map(&:to_i)

  sum = 0
  m.times do |j|
    sum += a[j] * b[j]
  end
  ans += 1 if sum + c > 0
end

puts ans


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void solve(){
    stack<int> s1;
    stack<pii> s2;
    string input;
    cin >> input;
    
    int s=0;
    for(int i=0; i<input.size(); ++i){
        if(input[i]=='\\') s1.push(i);
        else if(input[i]=='/' and s1.size()>0){
            int j=s1.top(); s1.pop();
            s+=i-j;
            int a=i-j;
            while(s2.size()>0 and s2.top().first>j){
                a+=s2.top().second; s2.pop();
            }
            s2.push(make_pair(j,a));
        }
    }
    
    vector<int> ans;
    while(!s2.empty()){
        ans.push_back(s2.top().second);
        s2.pop();
    }
    
    reverse(ans.begin(),ans.end());
    cout << s << endl;
    cout << ans.size();
    for(auto i:ans){
        cout << " " << i;
    }
    cout << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1324
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
ll x, y, A, B, C, a[N], b[N], c[N];
ll res[N];
bool cmp(ll x, ll y){
        return x > y;
};
int main() {
    scanf("%lld%lld%lld%lld%lld", &x, &y, &A, &B, &C);
    for (int i = 1; i <= A; i++)
        scanf("%lld", &a[i]);
    for (int i = 1; i <= B; i++)
        scanf("%lld", &b[i]);
    for (int i = 1; i <= C; i++)
        scanf("%lld", &c[i]);
    sort(a + 1, a + A + 1, cmp);
    sort(b + 1, b + B + 1, cmp);
    sort(c + 1, c + C + 1, cmp);
    int k = 0;
    for (int i = 1; i <= x; i++)
        res[++k] = a[i];
    for (int i = 1; i <= y; i++)
        res[++k] = b[i];
    sort(res + 1, res + k + 1, cmp);

    int index = 1;
    for (int i = k; i >= 1; i--) {
        if(res[i] < c[index]) {
            res[i] = c[index];
            index++;
        }
        if(index > C)
            break;
    }
    ll sum = 0;
    for (int i = 1; i <= k; i++)
        sum += res[i];
    printf("%lld\n", sum);
        return 0;
}



Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

VI v;

void solve(ll n, ll syu) {
    if (syu == 1) {
        char e = 'a' + (int)(n - 1);
        cout << e << endl;
        return;
    }
    char c = 'a';
    while (n > syu) {
        n -= syu;
        c += 1;
    }
    cout << c;
    solve(n, syu / 26);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n;
    cin >> n;
    ll len = 0;
    v.pb(1);
    ll syu = 1;
    while (n > syu * 26) {
        len++;
        syu *= 26;
        v.pb(syu);
        n -= syu;
    }
    solve(n, syu);
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, d;
	
	cin>>n>>d;
	
	vector<int> p(n);
	for(int i=0;i<n;++i){
		cin>>p[i];
		--p[i];
	}
	
	vector<int> c(n);
	for(auto &_ : c) cin>>_;
	
	ll ans = -1e18;
	for(int i=0;i<n;++i){
		vector<bool> u(n);
		ll sum = 0;
		int len = 0;
		for(int k=i;!u[k];k=p[k]){
			u[k] = 1;
			++len;
			sum+=c[k];
		}
		
		
		ll pref = 0;
		for(int h=1,k=i; h<=len; ++h,k=p[k]){
			pref+=c[k];
			if(h>d) break;
			
			int x = (d - h) / len;
			
			ans = max(ans, sum * x + pref);
			ans = max(ans, pref);
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3628
from collections import Counter

n = int(input())
a = tuple(map(int, input().split(" ")))
# n = 10000
# a = tuple(sum([[i, i] for i in range(1, n+1, 2)], [])[:n])

a_counter = Counter(a)
a_counter[int(n%2==0)] = 2

if set(a_counter.values()) == {2}:
    print((2 ** (n//2)) % (10**9+7))
else:
    print(0)

Measured memory_bytes: 14824
#include<stdio.h>
int main(){
    int x,y,i,gcd;
    scanf("%d %d",&x,&y);
    if(x < y){
        i = x;
        x = y;
        y = i;
    }
    gcd = x % y;
    while(gcd != 0){
        x = y;
        y = gcd;
        gcd = x % y;
    }
    printf("%d\n",y);
    return 0;
}


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

int main() {
  string a;
  int a_1,a_2,a_3;
  cin >> a;
  a_1 = atoi(a.substr(0,1).c_str());
  a_2 = atoi(a.substr(1,1).c_str());
  a_3 = atoi(a.substr(2,1).c_str());
  cout <<a_1+a_2+a_3<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int f(int n)
{
    if(n % 2 == 0)
    {
        return n / 2;
    }
    else
    {
        return 3 * n + 1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s;
    cin >> s;
    vector<int> a;
    a.push_back(s);
    int i = 0;
    while(1)
    {
        a.push_back(f(a[i]));
        for(int j = 0; j < a.size() - 1; j++)
        {
            if(a[j] == a[i + 1])
            {
                cout << i + 2;
                return 0;
            }
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P,int>PP;

signed main() {
	int a, b; cin >> a >> b;
	cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,[1,n]);print['Snuke','Fennec'][sum(g[i]>h[i]for i in range(n+1))*2<n]

Measured memory_bytes: 37724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second

vector<pll> v;
int pref[100005];
void solve(){  
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int rl=1;
	v.pb(mp(0,0));
	rep(i,1,n){
		if(s[i]!=s[i-1]){
			v.pb(mp(rl,s[i-1]-'0'));
			rl=1;
		}
		else{
			++rl;
		}
	}  
	v.pb(mp(rl,s[sz(s)-1]-'0'));
	rep(i,1,sz(v)){
		pref[i]=v[i].F+pref[i-1];
	}
	int ans=0;
	rep(i,1,sz(v)){
		int prev;
		if(v[i].S==0)
		prev=max(0,i-2*k);
		else prev=max(0,i-2*k-1);
		ans=max(ans,pref[i]-pref[prev]);

	}
	cout<<ans<<endl;
}

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


Measured memory_bytes: 1652
#include<bits/stdc++.h>
int main(){
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    while(true){
        c-=b;
        if(c <= 0){
            puts("Yes");
            return 0;
        }
        a-=d;
        if(a <= 0){
            puts("No");
            return 0;
        }
    }
}

Measured memory_bytes: 3692