akhauriyash/Code-Regression huggingface dataset:
# d
N, K = map(int, input().split())
S = input()

# ランレングス ex:00010 => ["03", "11", "01"]
run_length_S = []
count = 1
for i in range(len(S)):
    try:
        if S[i] == S[i+1]:
            count += 1
        else:
            run_length_S.append([S[i], count])
            count = 1
    except:
        run_length_S.append([S[i], count])

# しゃくとり法
right = 0
total = 0
max_total = 0

for left in range(len(run_length_S)):
    # Kより下なら右に移動
    while right < len(run_length_S) and K >= 0:
        # 1なら移動
        if run_length_S[right][0] == "1":
            total += int(run_length_S[right][1])
            right += 1
        # 0ならKより下で移動
        elif K == 0 and run_length_S[right][0] == "0":
            break
        else:
            total += int(run_length_S[right][1])
            right += 1
            K -= 1
    
    # 最大合計の更新
    max_total = max(total, max_total)
    
    # leftをインクリメントする準備
    if right == left:
        right += 1
    else:
        total -= int(run_length_S[left][1])
    
    # 外されるleftが0だった場合、反転回数を増やす
    if run_length_S[left][0] == "0":
        K += 1

print(max_total)

Measured memory_bytes: 13300
t[9999][999],j;main(p,W,a,b,c){for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);j=c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]:fmax(t[c][j],(t[c][j-a]+b));for(;t[0][++j]!=t[0][W];);}} 

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

int main(void){
    int a, n, min=10000000;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a;
        int cnt=0;
        while(a%2==0){
            ++cnt;
            a /= 2;
        }
        if(min>cnt) min = cnt;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,i,j,swap,arr[100];

    for(i=0;i<5;i++)
    {
        cin>>arr[i];
    }
    for(i=0;i<4;i++)
        for(j=0;j<5-i-1;j++)
    {
        if(arr[j]<arr[j+1])
            {
                swap=arr[j];
        arr[j]=arr[j+1];
        arr[j+1]=swap;

            }

    }
    for(i=0;i<4;i++)
        {
            cout<<arr[i]<<" ";
        }
        if(i<5)
            cout<<arr[i]<<endl;

    return 0;
    }

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
char s[N]; int dp[N][2];
int main() {
	int n; scanf("%s", s + 1), n = strlen(s + 1);
	dp[1][0] = 1;
	for (int i = 2; i <= n; i++) {
		dp[i][0] = max(dp[i][0], dp[i - 1][1] + 1);
		if (s[i] != s[i - 1]) dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
		dp[i][1] = max(dp[i][1], dp[i - 2][0] + 1);
		if (i >= 4 && !(s[i - 3] == s[i - 1] && s[i - 2] == s[i]))
			dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
	}
	printf("%d\n", max(dp[n][0], dp[n][1]));
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define ll long long
#define INF (int)(1e9+5)
#define MOD (int)(1e9 + 7) 
#define pi 3.14159265

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x -= (x / 500) * 500;
    ans += (x / 5) * 5;
    cout << ans << '\n';
    return 0;
}



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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	vector<int> W(10); rep(i, 0, 10) { cin >> W[i]; }
	vector<int> K(10); rep(i, 0, 10) { cin >> K[i]; }
	sort(W.begin(), W.end(), greater<int>());
	sort(K.begin(), K.end(), greater<int>());
	int w = accumulate(W.begin(), W.begin() + 3, 0);
	int k = accumulate(K.begin(), K.begin() + 3, 0);
	cout << w << " " << k << endl;
	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    vll a(n);
    ll s = 0;
    rep(i, n){
        cin >> a[i];
        s += a[i];
    }

    ll sub = 0;
    for(ll i=1;i<n;i+=2){
        sub += a[i];
    }

    vll x(n);
    x[0] = s-2*sub;
    rep2(i, 1, n){
        x[i] = 2*a[i-1]-x[i-1];
    }

    rep(i, n) cout << x[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 4844
package main

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


func solveFromFile() int{
    var nu int
    scanner := bufio.NewScanner(os.Stdin)
    file, err := os.Open(os.Args[1])
    if err != nil {
      log.Fatalf("failed opening file: %s", err)
    }
    scanner = bufio.NewScanner(file)
    scanner.Scan()
    tempstr := scanner.Text()
	  n, err2 := strconv.Atoi("123")
    nu = n
    nu = nu +321
    if err2 != nil {
      log.Fatalf("failed opening file: %s", err2)
      
    }

    defer file.Close()
    scanner.Scan()
    return solution(tempstr, scanner.Text())
}

//========== Implement Algorithm =======================
func solution(num1 string, num2 string) int{
  if num1 == string(num2[:len(num2)-1]){
    return 1
  }
  return 0
}

func main() {

//================== Variables used ====================
  var num1,num2 string 
  var ret int
//======================================================

  if len(os.Args) >=2{
//============== Get return value from File ============
    ret = solveFromFile()


  }else{
//============== Get return value from STDIN ===========
    //scanner := bufio.NewScanner(os.Stdin)

    //scanner.Scan()
    size,_ := fmt.Fscan(os.Stdin, &num1, &num2)
    size++
    //fmt.Sscanf(scanner.Text(), "%s %s", &num1, &num2)
    //fmt.Scanln(&num1)
    //fmt.Scanln(&num2)
    ret = solution(num1,num2)
  }

//================== OUTPUT ============================
  if ret==1 {
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
  
}

Measured memory_bytes: 1884
'use strict'

function main(s) {

  const n = Number(s);

  let i = 0;
  while (Math.pow(2, i) <= n) {
    i += 1;
  }

  const ans = Math.pow(2, i - 1);
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		n= sc.nextInt();
		int max = 1;
		Map<String,Integer> map = new HashMap<String,Integer>();
		for (int i=0;i<n;i++) {
			String s = sc.next();
			if (map.containsKey(s)==false) {
				map.put(s, 1);
			} else {
				Integer in = map.get(s);
				in = in+1;
				if (in>max) {
					max = in;
				}
				map.put(s, in);
			}
		}
		Object[] array = map.keySet().toArray();
		Arrays.sort(array);
		for (int i=0;i<array.length;i++) {
			if (map.get(array[i])== max) {
				System.out.println(array[i]);
			}
		}
	}


}

Measured memory_bytes: 88872
from collections import defaultdict


N, K = map(int, input().split())
p = list(map(int, input().split()))
pd = defaultdict(int)

kitai = []
for i in p:
    if not pd[i]:
        ex = (1 + i) / 2
        kitai.append(ex)
    else:
        kitai.append(pd[i])

# 累積和
rui = []
for i, j in enumerate(kitai):
    if i == 0:
        rui.append(j)
    else:
        rui.append(rui[i-1] + j)

ans = 0
for i, j in enumerate(rui):
    if i + (K-1) >= N:
        continue
    else:
        if i == 0:
            ans = rui[i+K-1]
        else:
            ans = max(ans, rui[i+K-1] - rui[i-1])

print(ans)

Measured memory_bytes: 25572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    
    int N;
    cin >> N;
    vi h(N);
    in(N,h);
    vi dp(N,infi);
    dp[0] = 0;
    
    rep(i,N){
        if(i-1 >= 0) chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i-2 >= 0) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    
    cout << dp[N-1] << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main(){
	int q,a,b;
	string s;
	cin>>q;
	set<string>m;
	for(;q--;){
		cin>>a;
		if(a==0)cin>>s,m.insert(s),cout<<m.size()<<endl;
		if(a==1)cin>>s,cout<<m.count(s)<<endl;
	}
}



Measured memory_bytes: 21892
<?php
fscanf(STDIN, "%d", $count);
$cityPoints = array();

for ($i = 1; $i <= $count; $i++) {
    fscanf(STDIN, "%s %d", $cityNames, $points);
    $cityPoints[$i] = $cityNames . ":" . sprintf('%03d', 100 - intval($points));
}

asort($cityPoints);

foreach (array_keys($cityPoints) as $key) {
    echo $key . "\n";
}


Measured memory_bytes: 4212
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        HashSet<Integer> set = new HashSet<Integer>();
        for (int i=0;i<N;i++) {
            int p = sc.nextInt();
            set.add(p);
        }

        int ans = X;
        if (set.contains(X)) {
            for (int i=1;i<200;i++) {
                if (!set.contains(X-i)) {
                    ans = X-i;
                    break;
                }
                if (!set.contains(X+i)) {
                    ans = X+i;
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35800
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);

        while(true){
        int n= scan.nextInt();
        if(n==0)break;
       
        int max =0;
        int min =501;
        while(n!=0){
        	int sum =0;
        	for(int i=0;i<5;i++)
        		sum+=scan.nextInt();
        	max=Math.max(max,sum);
        	min = Math.min(min, sum);
        	n--;
        }
        System.out.println(max+" "+min);
        }
    }
}

Measured memory_bytes: 12000
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,Q=LI()
HQ=[]
EVS=[]
for i in range(N):
    S,T,X=LI()
    EVS.append((S-0.5-X, 1, X))
    EVS.append((T-0.5-X, 0, X))
for i in range(Q):
    D=II()
    EVS.append((D, 2, D))
EVS.sort()

st=set()
PQ=[]
for time, ev, loc in EVS:
    if ev == 1:
        heapq.heappush(PQ, loc)
        st.add(loc)
    elif ev == 0:
        st.remove(loc)
    else:
        while PQ and PQ[0] not in st:
            heapq.heappop(PQ)
        if PQ:
            print(PQ[0])
        else:
            print(-1)


Measured memory_bytes: 86556
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>>a;
  vector<pair<int,int>>b;
  for(int i=0;i<n;i++){
  	int x,y;
  	cin>>x>>y;
  	a.push_back(make_pair(x,y));
  }
  for(int i=0;i<m;i++){
  	int x,y;
  	cin>>x>>y;
  	b.push_back(make_pair(x,y));
  }
  for(int i=0;i<n;i++){
  	int best=INT_MAX,ind;
  	for(int j=0;j<m;j++){
  		int dist = abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second);
  		if(dist<best){
  			best=dist;
  			ind=j+1;
  		}
  	}
  	cout<<ind<<endl;
  }
}  


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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    s = "@" + s;
    vector<vector<int>> pre(n + 2, vector<int> (10, 0));
    for (int i = 1; i <= n; i++) {
        s[i] -= '0';
        pre[i] = pre[i - 1];
        pre[i][s[i]]++;
    }
    bool is[10][10][10];
    memset(is, 0, sizeof is);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 10; j++) {
            if (pre[i - 1][j] == 0) continue;
            for (int k = 0; k < 10; k++) {
                if (pre[n][k] == pre[i][k]) continue;
                is[j][s[i]][k] = 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                ans += is[i][j][k];
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
std::vector<int> v[L];
ll a[L], spf[L], ans[L];
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<L; i++) 
        spf[i] = i; 
    for (int i=4; i<L; i+=2) 
        spf[i] = 2; 
    for (int i=3; i*i<L; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<L; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
int go(ll x)
{
	ll tx = x, f = 0, cur;
	while (x != 1) 
    { 
    	if(sz(v[spf[x]]))f = 1;
        v[spf[x]].pb(x);
        cur = spf[x];
        while(x%cur == 0)x/=cur;
    } 
    return f;
}
void fff()
{
	sieve();
	int n;
	cin >> n;
	ll g = 0;
	int co = 0;
	FOR(i,0,n)
	{
		cin >> a[i];
		ans[i] = go(a[i]);
		co += ans[i];
		g = __gcd(g, a[i]);
	}
	if(co == 0)cout <<"pairwise coprime\n";
	else if(g == 1) cout << "setwise coprime\n";
	else cout <<"not coprime\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K<A) cout << K << endl;
  else if (K >= A && K <= A+B) cout << A << endl;
  else cout << A-(K-A-B) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);

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

    sort(a.begin(),a.end());
    cout << a[n-1] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define mod 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
ll a,b,n;

void solve(){
 cin>>a>>b>>n;
  ll ans=0;
  if(b==1 || b-1>n){
    cout<<(a*n)/b-a*(n/b);
    return ;
  }
  for(ll i=b-1;i<=n;i+=b){
    ans=max(ans,(a*i)/b-a*(i/b));
  }
  cout<<ans;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

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

int main(int argc, char *argv[]) {

    int A, B, C, D; //salud y  fuerza respectivamente, primeros dos takahashi, luego aoki

    //condicion de corte, cuando A o C sean = 0 o inferior. 


    cin>>A>>B>>C>>D;
    bool attack = true;

    while (A > 0 && C > 0){

        if (attack){ //es lo mismo que poner ==true

            C = C - B;
            attack = false;
        }
        else{
            A = A - D;
            attack = true;
        }

    }

    if ( A > 0){
        cout<<"Yes"<<endl;

    }
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3556
N = int(input())
p = list(map(int,input().split()))
num = list(range(1,N+1))
ans = 0
for i in range(N):
    if p[i] != num[i]:
        ans += 1
if ans == 2:
    print('YES')
elif p == num:
    print('YES')
else:
    print('NO')

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

 int  main() 
    {
    	int n;
    	cin>>n; 
    	int arr[n][3];
    	for(int i=0;i<n;i++)
    	  {
    	      for(int j=0;j<3;j++)
    	        cin>>arr[i][j];
    	  }
    	
    	  int max_prev[3];
    	  memset(max_prev,0,sizeof(max_prev));
    	  max_prev[0]=arr[0][0];
    	  max_prev[1]=arr[0][1];
    	  max_prev[2]=arr[0][2];
    	  
    	  int dp[3];
    	  int temp[3];
    	  for(int i=1;i<n;i++)
    	    {
    	        for(int j=0;j<3;j++)
    	          {   int res=INT_MIN;
    	              for(int k=0;k<3;k++)
    	               {
    	                   if(j!=k)
    	                     {
    	                         res=max(res,max_prev[k]+arr[i][j]);
    	                         
    	                         
    	                     }
    	                   
    	               }
    	              temp[j]=res;
    	              
    	          }
    	          max_prev[0]=temp[0];max_prev[1]=temp[1];max_prev[2]=temp[2];
    	          
    	    }
    	  
    	  
    	   cout<<max(max_prev[0],max(max_prev[1],max_prev[2]));
    	
    	
    	
    	 
    	 return 0;
    	
    }

Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
vector <int> v[100005];
llint mod=1e9+7,dp[100005][2],bio[100005];
llint sum(llint a,llint b) {
	return ((a%mod)+(b%mod))%mod;
}
llint mul(llint a,llint b) {
	return ((a%mod)*(b%mod))%mod;
}
llint dfs(int x,int c) {
	bio[x]=1;
	if(dp[x][c]!=-1) return dp[x][c];
	llint ret=1;
	for(int i=0;i<v[x].size();i++) {
		if(bio[v[x][i]]) continue;
		if(c==1) {
			ret=mul(ret,dfs(v[x][i],0));
			//if(x==1) cout << dfs(v[x][i],0) << " " << ret << endl;
		}
		else ret=mul(ret,sum(dfs(v[x][i],1),dfs(v[x][i],0)));
	}
	//cout << x << " " << c << " " << ret << endl;
	dp[x][c]=ret;
	bio[x]=0;
	return ret;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n-1;i++) {
		int a,b;
		cin >> a >> b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
	}
	memset(dp,-1,sizeof(dp));
	llint sol=0;
	sol=sum(sol,dfs(0,0));
	memset(bio,0,sizeof(bio));
	sol=sum(sol,dfs(0,1));
	cout << sol;
	return 0;
}


Measured memory_bytes: 14976
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
	int A, B;
	cin >> A >> B;

	int cnt = 0;
	for (int i = A; i <= B; i++) {
		string s = to_string(i);
		if ((s[0] == s[4]) && (s[1] == s[3])) {
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
def z_algo(s):
    ret = [0]*(len(s))
    ret[0] = len(s)
    i = 1
    j = 0
    while i<len(s):
        while i+j<len(s)  and s[i+j]==s[j]:
            j+=1
        ret[i] = j
        if j==0:
            i+=1
            continue
        k=1
        while i+k<len(s) and k+ret[k] <j:
            ret[i+k] = ret[k]
            k+=1
        i+=k
        j=min(ret[k],j-k) ## j= j-kでもよい
    return ret

n = ni()
s = input()
ans = 0
for i in range(n):
    z = z_algo(s[i:])
    for j in range(len(z)):
        if j>=z[j]:
            ans = max(ans,z[j])
print(ans)


Measured memory_bytes: 79724
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x0123456789) cerr<<#x0123456789<<':'<<x0123456789<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x0123456789:v)cerr<<x0123456789<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;
typedef long double ld;

signed main(){
    ll X;
    cin >> X;
    if(X==7 || X==5 || X==3){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>

using namespace std;
#define ll long long

int main() {
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    ll ans = 0;
    vector<vector<bool>> f(N, vector<bool>(N, false));
    for(int k = 0; k < N; k++) {
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                if(i == j || j == k || k == i) continue;
                if(A[i][j] == A[i][k] + A[k][j]) {
                    f[i][j] = true;
                } else if(A[i][j] > A[i][k] + A[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= i; j++) {
            if(!f[i][j]) {
                ans += A[i][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4340
solve :: [Int] -> Int -> Int -> Int
solve [] passed minNumber = passed
solve (x:xs) passed minNumber =
  solve
    xs
    (if minNumber >= x then passed + 1 else passed)
    (min x minNumber)


main = do
  _ <- getLine
  numbers <- (map read . words) <$> getLine
  putStrLn $ show $ solve numbers 0 200001

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]++;
    }
    int s = 0, mx = 0;
    queue<int> q;
    rep(i, n) {
        q.push(p[i]);
        s += p[i];
        if (q.size() > k) {
            s -= q.front(); q.pop();
        }
        if (q.size() == k) {
            mx = max(mx, s);
        }
    }
    double ans = mx/2.0;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 1792
import numpy as np
from collections import defaultdict
from functools import reduce

n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(n-2):
    if ((p[i+1] < p[i]) and (p[i+1] > p[i+2])) or ((p[i+1] > p[i]) and (p[i+1] < p[i+2])):
        cnt += 1

print(cnt)


Measured memory_bytes: 21404
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int h, w; cin >> h >> w;
	rep(i, h) {
		string s;
		cin >> s;
		cout << s << endl;
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;
typedef unsigned long long ll;

int main(void) {
  ll i, j, k, t, n, a, b, c, d, ans, x, y, z;
  scanf("%lld", &t);
  for(k = 0; k < t; ++k) {
    scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
    priority_queue< pair<ll, ll> > q;
    pair<ll, ll> p;
    ans = 18 * 1e18;
    q.push(make_pair(n, 0));
    while(q.size()) {
      p = q.top(), q.pop();
      if(q.size() && p.first == (q.top()).first) continue;
      if(p.first == 1) {
        if(ans > p.second + d) ans = p.second + d;
        break;
      }
      if(p.first < 1e10 && ans > p.second + d * p.first) ans = p.second + d * p.first;
      q.push(make_pair(p.first >> 1, p.second + (p.first & 1) * d + a));
      if(p.first != 2) q.push(make_pair((p.first >> 1) + 1, p.second + (2 - (p.first & 1)) * d + a));
      q.push(make_pair(p.first / 3, p.second + (p.first % 3) * d + b));
      q.push(make_pair(p.first / 3 + 1, p.second + (3 - p.first % 3) * d + b));
      q.push(make_pair(p.first / 5, p.second + (p.first % 5) * d + c));
      q.push(make_pair(p.first / 5 + 1, p.second + (5 - p.first % 5) * d + c));
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3332
module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";var n=e(1);e(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,e){"use strict";var n=e(3),i=e(5);t.exports=function(t){var r=new n(t);i(r)}},function(t,r,e){"use strict";var n=e(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,e){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,e){"use strict";function n(t,r){var e=Math.max(t,r),n=Math.min(t,r);if(e==n)return e;for(;0!=n;){var i=n;n=e%n,e=i}return e}t.exports=function(t){for(var r=t.in(),e=new Array(r),i=0;i<r;i++)e[i]=t.in();var o=new Array(r+1);o[0]=0;var s=new Array(r+1);s[r]=0;for(var u=0;u<r;u++)o[u+1]=n(o[u],e[u]),s[r-1-u]=n(s[r-u],e[r-1-u]);for(var a=1,c=0;c<r;c++){var f=n(o[c],s[c+1]);a=Math.max(a,f)}console.log(a)}}]);

Measured memory_bytes: 30332
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n,m;
      cin >> n >> m;
      vector<int> ans(n);
      for (int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        ans.at(a-1)++;
        ans.at(b-1)++;
      }
      for(int i=0; i<n; i++)
        cout << ans.at(i) <<endl;
    }

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/07/07  Problem: soundhound2018_master_qual E / Link: __CONTEST_URL__  ----- */
/* ------問題------

kenkooooさんは n 頂点 m 辺の単純連結グラフを拾いました。 グラフの頂点には 1 から n の番号が付けられていて、 i 番目の辺は頂点 ui と vi をつないでいます。 また、i 番目の辺には整数 si が定められています。
kenkooooさんは次の条件を満たすようにそれぞれの頂点に 正の整数 を書き込もうとしています。
どの辺 i についても、頂点 ui と vi に書かれた正の整数の和は si に等しい
条件を満たすような正の整数の書き方が何通りあるか求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

VL A, B, C;
void dfs(int v, VL&cost, VI&visit, VI&color, const vector<vector<PLL>>&G) {
	for (auto ed : G[v]) {
		int nx = ed.first;
		if (visit[nx]) {
			if (color[v] == color[nx]) {
				A.push_back(v);
				B.push_back(nx);
				C.push_back(ed.second);
			}
			continue;
		}
		visit[nx] = 1;
		color[nx] = 1 ^ color[v];
		cost[nx] = ed.second - cost[v];
		dfs(nx, cost, visit, color, G);
	}
}

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

	int N, M;
	cin >> N >> M;
	vector<vector<PLL>>G(N);
	using tp = tuple<int, int, int>;
	vector<tp>edge;
	FOR(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		G[a].push_back(PLL(b, c));
		G[b].push_back(PLL(a, c));
		edge.push_back(tp(a, b, c));
	}

	VL cost(N, 0);
	VI visit(N, 0);
	VI color(N, 0);
	cost[0] = 1;
	visit[0] = 1;
	dfs(0, cost, visit, color, G);
	auto check = [&]() {
		FOR(i, 0, N)if (cost[i] < 1)return false;
		FOR(i, 0, SZ(edge)) {
			int a, b, c; tie(a, b, c) = edge[i];
			if (cost[a] + cost[b] != c)return false;
		}
		return true;
	};
	if (SZ(A)) {// 矛盾しうる -> 二部グラフでない
		LL dist0 = C[0] - (cost[A[0]] + cost[B[0]]);
		if (abs(dist0) % 2) {
			cout << 0 << endl;
		}
		else {
			dist0 /= 2;
			FOR(i, 0, N) {
				if (color[i] == color[A[0]])cost[i] += dist0;
				else cost[i] -= dist0;
			}
			cout << check() << endl; // 調整してあり得る場合
		}
	}
	else { // 0 or R-L+1
		LL L = LINF, R = LINF;
		FOR(i, 0, N) {
			if (color[i]) {
				R = min(R, cost[i]);
			}
			else {
				L = min(L, cost[i]);
			}
		}
		if (L < 1) {
			
			FOR(i, 0, N) {
				if (color[i]) {
					cost[i] -= 1 - L;
				}
				else {
					cost[i] += 1 - L;
				}
			}
		}
		debug(R);
		debug(L);
		LL ans = max(0LL, L + R - 1);
		if (!check())ans = 0;
		cout << ans << endl;

	}


	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int imax = INT_MAX;
int imin = INT_MIN;
ll llmax = LLONG_MAX;
ll llmin = LLONG_MIN;

int main()
{
	ll x, sum(0);
	cin >> x;
	for (int i = 1; i < 10000000; i++){
		sum += i;
		if (sum >= x){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	ll A[N];
	rep(i, 0, N) {
		cin >> A[i];
		if(A[i] > N) {
			cout << 0 << endl;
			return 0;
		}
	}

	ll B[N];
	ll tmp_a[N], tmp_b[N];
	memset(tmp_a, 0, sizeof(tmp_a));
	memset(tmp_b, 0, sizeof(tmp_b));
	if(N % 2 == 0) {
		rep(i, 0, N / 2) {
			B[i] = N - 2 * i - 1;
			B[N - i - 1] = N - 2 * i - 1;
		}
		rep(i, 0, N) {
			tmp_a[A[i]]++;
			tmp_b[B[i]]++;
		}
		rep(i, 0, N) {
			if(tmp_a[i] != tmp_b[i]) {
				cout << 0 << endl;
				return 0;
			}
		}

		ll ans = 1;
		rep(i, 0, N / 2) ans = ans * 2 % mod;
		cout << ans << endl;
		return 0;
	}

	int zero_num = 0;
	rep(i, 0, N) {
		if(A[i] == 0) zero_num++;
	}
	if(zero_num != 1) {
		cout << 0 << endl;
		return 0;
	}
	
	rep(i, 0, N / 2) {
		B[i] = N - 2 * i - 1;
		B[N - i - 1] = N - 2 * i - 1;
	}
	B[N / 2] = 0;

	rep(i, 0, N) {
		tmp_a[A[i]]++;
		tmp_b[B[i]]++;
	}
	rep(i, 0, N) {
		if(tmp_a[i] != tmp_b[i]) {
			cout << 0 << endl;
			return 0;
		}
	}

	ll ans = 1;
	rep(i, 0, N / 2) ans = ans * 2 % mod;
	cout << ans << endl;
	return 0;
		
}


Measured memory_bytes: 3328
class UnionFind:
  def __init__(self, n):
    self.par = [-1 for _ in range(n)]
  def root(self, x):
    return x if self.par[x] < 0 else self.root(self.par[x])
  def unite(self, x, y):
    x, y = self.root(x), self.root(y)
    if x != y:
      if self.par[y] < self.par[x]:
        x, y = y, x
      self.par[x] += self.par[y]
      self.par[y] = x
    return x != y
  def find(self, x, y):
    return self.root(x) == self.root(y)
  def size(self, x):
    return -self.par[self.root(x)]

n, m = map(int, input().split())
tree = UnionFind(n)
b = []
for _ in range(m):
  a, c = map(int, input().split())
  b.append([a - 1, c - 1])
b.reverse()
ans = [sum(range(n))]
for i, p in enumerate(b):
  tmp = ans[-1]
  if not tree.find(p[0], p[1]):
    tmp -= tree.size(p[0])*tree.size(p[1])
    tree.unite(p[0], p[1])
  ans.append(tmp)
for i in reversed(ans[:-1]):
  print(i)

Measured memory_bytes: 26412
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

string s;
ll ans = 1, n;
int main() {
	cin >> n;
	cin >> s;
	REP(i, s.size() - 1) {
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
A = list(input().split())

op = ['+', '-', '*']

stack = []

for v in A:
	if v not in op:
		stack.append(v)
	elif v in op:
		tmp1 = int(stack.pop())
		tmp2 = int(stack.pop())
		if v == '+':
			stack.append(tmp2 + tmp1)
		elif v == '-':
			stack.append(tmp2 - tmp1)
		elif v == '*':
			stack.append(tmp2 * tmp1)

print(stack[0])


Measured memory_bytes: 5600
s=input()
n=len(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    break
  elif i<n-2 and s[i]==s[i+2]:
    print(i+1,i+3)
    break
else:
  print(-1,-1)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>vec(N-1);
  vector<int>vv(N);
  for (int X=0; X<N-1; X++){
    cin >> vec.at(X);
    vv.at(vec.at(X)-1)+=1;
  }
  for (int X=0; X<N; X++){
    cout << vv.at(X) << endl;
  }
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	string p=s;
	int n=s.length();
	reverse(p.begin(),p.end());
	if(s!=p){
		cout<<"No"<<endl;
		return 0;
	}
	string t=s.substr(0,(n-1)/2);
	string k=s.substr((n+3)/2-1);
	string l=t;
	reverse(l.begin(),l.end());
	string y=k;
	reverse(k.begin(),k.end());
	if(y==k&&l==t){
		cout<<"Yes"<<endl;
		return 0;
	}
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]

    count = 0
    if N == 2:
        if a[0] == a[1]:
            count += 1
    else:
        for i, x in enumerate(a[1:-1]):
            idx = i + 1
            l = a[idx - 1]
            r = a[idx + 1]
            if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
                x = get(l, r)
                count += 1
                a[idx] = x
        # print(a)
    print(count)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<vector<ll>> g(n);
    REP(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    // dist[i] = iの高さ
    vector<ll> dist(n);
    function<void(ll,ll)> dfs1 = [&](ll v, ll p) {
        for(auto i: g[v]) if(i != p) {
            dist[i] = dist[v] + 1;
            dfs1(i, v);
        }
    };

    dfs1(0, -1);
    // cout << dist << endl;
    ll ma = 0, idx = -1;
    REP(i, n) {
        if(ma < dist[i]) {
            ma = dist[i];
            idx = i;
        }
    }
    // cout << idx << endl;

    dist.assign(n, 0);
    dfs1(idx, -1);
    ma = 0;
    REP(i, n) chmax(ma, dist[i]);
    ma++;
    // cout << ma << endl;

    if(ma%3 == 2) cout << "Second" << endl;
    else cout << "First" << endl;

    return 0;
}


Measured memory_bytes: 28416
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro split-ints-and-bind (vars string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str (gensym "STR")))
    (labels ((expand (vars &optional (init-pos1 t))
	       (if (null vars)
		   body
		   `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			    (,pos2 (position #\space ,str :start ,pos1 :test #'char=))
			    (,(car vars) (parse-integer ,str :start ,pos1 :end ,pos2)))
		       ,@(expand (cdr vars) nil))))))
      `(let ((,str ,string))
         (declare (string ,str))
	 ,@(expand vars)))))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (m (read))
         (edges (make-array m :element-type 'list)) ; (from to -cost)
         (dp (make-array n :element-type 'fixnum :initial-element most-positive-fixnum)))
    (setf (aref dp 0) 0)
    (dotimes (i m)
      (split-ints-and-bind (a b c) (read-line)
        (setf (aref edges i) (list (- a 1) (- b 1) (- c)))))
    (labels ((forward ()
               (loop for (src dest neg-cost) across edges
                     when (and (/= most-positive-fixnum (aref dp src))
                               (< (+ (aref dp src) neg-cost)
                                  (aref dp dest)))
                     do (setf (aref dp dest) (+ (aref dp src) neg-cost)))))
      (if (= (loop repeat (- n 1) do (forward)
                   finally (return (aref dp (- n 1))))
             (loop repeat n do (forward)
                   finally (return (aref dp (- n 1)))))
          (println (- (aref dp (- n 1))))
          (println "inf")))))

#-swank(main)


Measured memory_bytes: 15076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll n,a,b; cin >>n>>a>>b;
    vector<ll> v(n); rep(i,n) cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());

    ll res = 0;
    for (int i = 0; i < a; i++) {
        res += v[i];
    }
    double m = ((double)res)/a;
    cout << setprecision(10) << m << endl;

    const ll MAX_N = 100; 
    vector<vector<ll> > c(MAX_N, vector<ll>(MAX_N, 0));
    for (ll i = 0; i < MAX_N; i++) {
        c[i][0] = 1;
        c[i][1] = i;
    }
    for (ll i = 1; i < MAX_N; i++) {
        for (ll j = 1; j <= i; j++) {
            c[i][j] = c[i-1][j] + c[i-1][j-1];
        }
    }

    int count0 = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] == v[a-1]) {
            count0++;
        } 
    }

    if (v[0] != v[a-1]) {
        int count = 0;
        for (int i = 0; i < a; i++) {
            if (v[i] == v[a-1]) {
                count++;
            } 
        }
        cout << c[count0][count] << endl;
    } else {
        ll ans = 0;
        for (int l = a; l <= b; l++) {
            if (l <= count0) {
                int count = 0;
                for (int i = 0; i < l; i++) {
                    if (v[0] == v[i]) {
                        count++;
                    } 
                }
                ans += c[count0][count];
            }
        }
        cout << ans << endl;        
    } 

    return 0;
}



Measured memory_bytes: 384
#pragma once
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()

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

	ll N;
	float ans = 0;

	cin >> N;

	if (N % 2 == 0) {
		ans = ((float)N/2.0f)/(float)N;
	}
	else {
		ans = ((float)(N+1)/2.0f)/(float)N;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   if(a==0)
   cout<<1;
   if(b==0)
   cout<<2;
   if(c==0)
   cout<<3;
   if(d==0)
   cout<<4;
   if(e==0)
   cout<<5;
   return 0;	
} 

Measured memory_bytes: 3620