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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int m = 0, x = 0;
    REP(i, N)
    {
        if (S[i] == 'I')
            x++;
        else
            x--;
        m = std::max(m, x);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N)
	m := map[string]int{}
	for i := 0; i < N; i++ {
		w := ""
		fmt.Scan(&w)
		m[w]++
	}
	fmt.Scan(&M)
	for i := 0; i < M; i++ {
		w := ""
		fmt.Scan(&w)
		m[w]--
	}
	max := 0
	for _, v := range m {
		if v > max {
			max = v
		}
	}
	fmt.Println(max)
}

Measured memory_bytes: 512
p = int(input())
A = list(map(int, input().split()))
comb = [0]*p
comb[0] = 1
for i in range(1, p):
    comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p

B = [0]*p
for i in range(p):
    if A[i] == 0:
        continue
    B[0] += 1
    Pow = 1
    for j in range(p):
        B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p
        Pow = Pow * (-i) % p
print(*[b % p for b in B])

Measured memory_bytes: 43612
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define Vec(K,L,N,S) vector<L> K(N,S);
#define DV(K,L,N,M) vector<vector<L>> K(N, vector<L>(M));
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main(){
  lli A,B,D,E,N,M,K,sum=0,num=0,ans=0;
  cin >> N;
  Vec(P,lli,N,0);Vec(Q,lli,100001,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,0,N)Q[P[i]]++;
  rep(i,1,99999)sum=max(sum,Q[i]+Q[i-1]+Q[i+1]);
  Out(sum);
}


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

int n;
vector<long long> a;

int main()
{
    cin >> n;
    a.resize(n);
    for (auto &i : a)
        cin >> i;

    vector<long long> dp(n);
    vector<int> prev(n);
    for (int i = 0; i < n; i++)
    {
        long long max_ = a[i];
        int argmax = -1;
        for (int j = 0; j < i - 1; j++)
        {
            if ((i - j) % 2 != 0)
                continue;
            if (a[i] + dp[j] > max_)
            {
                max_ = a[i] + dp[j];
                argmax = j;
            }
        }
        dp[i] = max_;
        prev[i] = argmax;
    }

    int pos = distance(dp.begin(), max_element(dp.begin(), dp.end()));
    long long ans1 = dp[pos];

    vector<int> keiro;
    while (pos >= 0)
    {
        keiro.push_back(pos);
        pos = prev[pos];
    }


    vector<int> ans3;
    for (int i = n - 1; i > keiro[0]; i--)
    {
        ans3.push_back(i + 1);
    }
    for (int i = 0; i<keiro.size()-1; i++)
    {
        for (int j = (keiro[i] + keiro[i + 1]) / 2; j > keiro[i+1]; j--)
        {
            ans3.push_back(j + 1);
        }
    }
    for (int i = 0; i < keiro.back(); i++)
    {
        ans3.push_back(1);
    }

    int ans2 = ans3.size();
    cout << ans1 << "\n"
         << ans2 << "\n";
    for (auto i: ans3)
    {
        cout << i << "\n";
    }
    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = a + b +c;
  if (ans >= 22){
  	cout << "bust" << endl;
  }
  else{
  	cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = input()
	if S == "SUN":
		print(7)
	elif S == "MON":
		print(6)
	elif S == "TUE":
		print(5)
	elif S == "WED":
		print(4)
	elif S == "THU":
		print(3)
	elif S == "FRI":
		print(2)
	elif S == "SAT":
		print(1)
	


if __name__ == '__main__':
	main()

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int n, m;
    vi to[100005];
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].pb(b);
        to[b].pb(a);
    }

    queue<int> q;
    vi dist(n, INF);
    vi pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF)
                continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if(i == 0)
            continue;
        int ans = pre[i];
        ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10724
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
monster=sum(b)
for i in range(n+1):
  if i==0:
    k=min(a[0],b[0])
    a[0]-=k
    b[0]-=k
  elif i==n:
    k=min(a[i],b[i-1])
    a[i]-=k
    b[i-1]-=k
  else:
    k=min(a[i],b[i]+b[i-1])
    a[i]-=k
    if b[i-1]<k:
      b[i]-=k-b[i-1]
      b[i-1]=0
    else:
      b[i-1]-=k
print(monster-sum(b))

Measured memory_bytes: 18476
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	double total = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> u[i];
		if (u[i] == "JPY")
		{
			total += x[i];
		}
		else
		{
			total += x[i] * 380000.0;
		}
	}

	cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX=10000;
static const int INFTY=2000000000;

vector<pair<int,int> > A[MAX];
int dk[MAX],H[MAX+1],tail,where[MAX];

void cminHeap(int i){
    int left,right,least;
    left=2*i;right=left+1;least=i;
    if(left<=tail&&dk[H[left]]<dk[H[i]])least=left;
    if(right<=tail&&dk[H[right]]<dk[H[least]])least=right;
    if(i==least)return;
    swap(H[i],H[least]);swap(where[H[i]],where[H[least]]);
    cminHeap(least);
}

void pminHeap(int i){
    int parent=i/2;
    if(parent==0||dk[H[parent]]<=dk[H[i]])return;
    swap(H[parent],H[i]);swap(where[H[parent]],where[H[i]]);
    pminHeap(parent);
}

void heap_update(int u){
    int x=H[u];
    cminHeap(u);
    if(H[u]==x)pminHeap(u);
}

void SSSP(int n){
    for(int i=0;i<n;i++){
        dk[i]=INFTY;
        H[i+1]=i;
        where[i]=i+1;
    }
    dk[0]=0;
    tail=n;
    int v;
    while(tail>0){
        v=H[1];H[1]=H[tail];where[H[tail]]=1;
        tail--;where[v]=-1;
        cminHeap(1);
        vector<pair<int,int> >::iterator it;
        for(it=A[v].begin();it<A[v].end();it++){
            pair<int,int> item=*it;
            if(where[item.first]!=-1){
                if(dk[item.first]>dk[v]+item.second){
                    dk[item.first]=dk[v]+item.second;
                    heap_update(where[item.first]);
                }
            }
        }
    }
}

int main(){
    int n,v,k,u,d;
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d %d",&v,&k);
        for(int j=0;j<k;j++){
            scanf("%d %d",&u,&d);
            A[v].push_back(make_pair(u,d));
        }
    }
    SSSP(n);
    for(int i=0;i<n;i++)printf("%d %d\n",i,dk[i]);
}


Measured memory_bytes: 7996
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m,k = map(int, readline().split())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))

sa = [0]*(n+1)
sb = [0]*(m+1)

for i in range(n):
    sa[i+1] = sa[i]+a[i]
for i in range(m):
    sb[i+1] = sb[i]+b[i]

isb=m
ans = 0
for isa in range(n+1):
    if sa[isa]>k:
        break
    #while isb>0 and sa[isa]+sb[isb]>k:
    while sa[isa]+sb[isb]>k:
        isb-=1
    ans = max(ans, isa+isb)
    
print(ans)

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using ll = long long;

int main() {
    FAST;

    int d, t, s;
    cin >> d >> t >> s;

    cout << ((s*t >= d) ? "Yes" : "No") << "\n";

    return 0;
}


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

struct Cube {
	int cube[31], s;
	
	Cube() {}
	
	void rot1() {
		swap(cube[1], cube[24]);
		swap(cube[4], cube[27]);
		swap(cube[7], cube[30]);
		swap(cube[10], cube[21]);
		swap(cube[16], cube[18]);
	}
	
	void rot2() {
		swap(cube[3], cube[22]);
		swap(cube[6], cube[25]);
		swap(cube[9], cube[28]);
		swap(cube[12], cube[19]);
		swap(cube[13], cube[15]);
	}
	
	void rot3() {
		swap(cube[1], cube[28]);
		swap(cube[2], cube[29]);
		swap(cube[3], cube[30]);
		swap(cube[15], cube[16]);
		swap(cube[19], cube[21]);
	}
	
	void rot4() {
		swap(cube[7], cube[22]);
		swap(cube[8], cube[23]);
		swap(cube[9], cube[24]);
		swap(cube[10], cube[12]);
		swap(cube[13], cube[18]);
	}
	
	bool fail(int a, int b) {
		for(int i=a+1;i<=b;++i) if (cube[a] != cube[i]) return 1;
		return 0;
	}
	
	bool solved() {
		if (fail(1,9)) return 0;
		if (fail(10,12)) return 0;
		if (fail(13,15)) return 0;
		if (fail(16,18)) return 0;
		if (fail(19,21)) return 0;
		if (fail(22,30)) return 0;
		return 1;
	}
};

int main() {
	int N;
	cin >> N;
	
	for(int i=0;i<N;++i) {
		Cube ini;
		for(int i=1;i<=30;++i) cin >> ini.cube[i];
		ini.s = 0;
		
		queue< Cube > q;
		q.push(ini);
		
		while (!q.empty()) {
			Cube c = q.front(); q.pop();
			
			if (c.solved()) {
				cout << c.s << endl;
				break;
			}
			
			++c.s;
			
			c.rot1();
			q.push(c);
			c.rot1();
			
			c.rot2();
			q.push(c);
			c.rot2();
			
			c.rot3();
			q.push(c);
			c.rot3();
			
			c.rot4();
			q.push(c);
		}
	}
	
	return 0;
}

Measured memory_bytes: 12168
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
void solve()
{
	ll n;
	cin>>n;
	ll mx=0;
	ll a,maxin=0;
	ll ans=0;
	rep(i,0,n)
	{
		cin>>a;
		if(i==0)
		{
			mx=a;
			ans++;
			continue;
		}
		mx=min(mx,a);
		if(mx==a)
		{
			ans++;
		}
	}
	cout<<ans;
}	

int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A = gets.chomp.split(' ').map{|n| n.to_i}
four = 0
two = 0
one = 0
A.each{|a|
	if(a%4==0)
		four += 1
	elsif(a%2==0)
		two += 1
	else
		one += 1
	end
}
if(four>=one ||
	four+1==one && two==0)
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 9736
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        long[] nm = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long row = nm[0] >= 2 ? (nm[0] - 2) : 1;
        long column = nm[1] >= 2 ? (nm[1] - 2) : 1;

        Console.WriteLine(row * column);
    }
}

Measured memory_bytes: 13268
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun primeFactorize(N: Int): Map<Int, Int> {
    if (N <= 1) return mapOf()
    val fact = mutableMapOf<Int, Int>()
    var n = N
    var i = 2
    while (i * i <= n) {
        while (n%i == 0) {
            fact[i] = (fact[i] ?: 0) + 1
            n /= i
        }
        i++
    }
    if (n != 1) {
        fact[n] = (fact[n] ?: 0) + 1
    }
    return fact
}


fun solve(N: Int): Int {
    var mp = mutableMapOf<Int, Int>()
    for (n in 2..N) {
        primeFactorize(n).forEach { kv ->
            mp[kv.key] = (mp[kv.key] ?: 0) + kv.value
        }
    }

    val hs = ArrayList<Int>()
    hs.addAll(mp.values)

    var ans = 0
    fun dfs(n: Int, res: Long) {
        if (n >= hs.size) {
            if (res == 75L) ans++
            return
        }

        if (res > 75L) return

        for (i in 0..hs[n]) {
            dfs(n+1, res*(i+1))
        }
    }

    dfs(0, 1L)

    return ans
}


fun main(args: Array<String>) {
    val N = readInt()

    val ans = solve(N)

    println(ans)
}


Measured memory_bytes: 32016
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}

ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}

int main(void) {
	int a, b, x;
	cin >> a >> b >> x;
	int aa=a* (x / 1000)+min(a, b * (int)ceil((x%1000) / 500.0)), bb=b* (x / 500) + min(a, b * (int)ceil((x % 500) / 500.0));
	cout << min(aa,bb) << endl;
	return 0;
}


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

string a,b="CF"; //打表
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ //当找到一个的时候加一
            bl++;
            if(bl==2)   //都找到的时候就退出
                break;
        }
    if(bl==2) cout<<"Yes"; //判断并且输出
    else cout<<"No";
    cout<<endl;//最后不要忘了打个换行
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

h, w = Is()
maze = LSR(h)

def bfs(sy, sx):
    vmaze = [[INF] * w for _ in range(h)]
    move = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    que = deque()
    que.append((sy, sx))
    vmaze[sy][sx] = 0

    while que:
        py, px = que.popleft()
        for ymove, xmove in move:
            ny = py + ymove
            nx = px + xmove
            if 0 <= ny < h and 0 <= nx < w and maze[ny][nx] != '#' and vmaze[ny][nx] == INF:
                vmaze[ny][nx] = vmaze[py][px] + 1
                que.append((ny, nx))

    ret = 0
    for y in range(h):
        for x in range(w):
            if vmaze[y][x] != INF:
                ret = max(ret, vmaze[y][x])
    return ret

ans = 0
for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] == '#':
            continue
        ans = max(ans, bfs(sy, sx))

print(ans)


Measured memory_bytes: 72024
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	mn := newSegment(n)
	mx := newSegment(n)
	for i := 0; i < n; i++ {
		mn.add(i, math.MaxInt32)
		mx.add(i, -math.MaxInt32)
	}
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		mn.updatemin(i, a)
		mx.updatemax(i, a)
	}
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		t := getNextInt(scanner)
		b := getNextInt(scanner)
		e := getNextInt(scanner)
		if t == 0 {
			fmt.Fprintln(writer, mn.min(b, e))
			continue
		}
		fmt.Fprintln(writer, mx.max(b, e))
	}
}

type segment [][]int

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]int, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]int, 1))
	return seg
}
func (seg segment) add(i int, x int) {
	for h := 0; h < len(seg); h++ {
		seg[h][i] += x
		i >>= 1
	}
}
func (seg segment) sum(l, r int) int {
	var s int
	for h := 0; h < len(seg) && l < r; h++ {
		if l%2 == 1 {
			s += seg[h][l]
			l++
		}
		l >>= 1
		if r%2 == 1 {
			s += seg[h][r-1]
		}
		r >>= 1
	}
	return s
}
func (seg segment) updatemin(i int, x int) {
	for h := 0; h < len(seg); h++ {
		seg[h][i] = seg.choosemin(x, seg[h][i])
		i >>= 1
	}
}
func (seg segment) choosemin(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func (seg segment) min(l, r int) int {
	var s int = seg[0][l]
	for h := 0; h < len(seg) && l < r; h++ {
		if l%2 == 1 {
			s = seg.choosemin(s, seg[h][l])
			l++
		}
		l >>= 1
		if r%2 == 1 {
			s = seg.choosemin(s, seg[h][r-1])
		}
		r >>= 1
	}
	return s
}
func (seg segment) updatemax(i int, x int) {
	for h := 0; h < len(seg); h++ {
		seg[h][i] = -seg.choosemin(-x, -seg[h][i])
		i >>= 1
	}
}
func (seg segment) max(l, r int) int {
	var s int = seg[0][l]
	for h := 0; h < len(seg) && l < r; h++ {
		if l%2 == 1 {
			s = -seg.choosemin(-s, -seg[h][l])
			l++
		}
		l >>= 1
		if r%2 == 1 {
			s = -seg.choosemin(-s, -seg[h][r-1])
		}
		r >>= 1
	}
	return s
}



Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int main(){
    double a,b;
    int la,ua,lb,ub;
    cin>>a>>b;
    la=ceil(a/0.08);
    ua=floor((a+1)/0.08)-1;
    lb=ceil(b/0.10);
    ub=floor((b+1)/0.10)-1;
    if (ua<lb || ub<la) cout<<-1;
    else cout<<max(la,lb);
}




Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
using namespace std;
int main(){
    int H,W,i,j,q;
    cin >> H >> W;
    char S[H][W];
    char p[W];
    char c;
    for(i = 0;i < H;i++){
        cin >> p;
        for(j = 0;j < W;j++){
            S[i][j] = p[j];
        }
    }
    for(i = 0;i < H;i++){
        for(j = 0;j < W;j++){
            if(S[i][j] == '#'){
                if(j == W - 1){
                    printf("%c\n",'#');
                }
                else{
                    printf("%c", '#');
                }
            }
            else{
                q = 0;
                if(S[i - 1][j - 1] == '#' && i > 0 && j > 0){
                    q++;
                }
                if (S[i - 1][j] == '#' && i > 0){
                    q++;
                }
                if (S[i - 1][j + 1] == '#' && i > 0 && j < W - 1){
                    q++;
                }
                if (S[i][j - 1] == '#' && j > 0){
                    q++;
                }
                if (S[i][j + 1] == '#' && j < W - 1){
                    q++;
                }
                if (S[i + 1][j - 1] == '#' && i < H - 1 && j > 0){
                    q++;
                }
                if (S[i + 1][j] == '#' && i < H - 1){
                    q++;
                }
                if (S[i + 1][j + 1] == '#' && i < H - 1 && j < W - 1){
                    q++;
                }
                c = '0' + q;
                if (j == W - 1){
                    printf("%c\n",c);
                }
                else{
                    printf("%c",c);
                }
            }
        }
    }
}

Measured memory_bytes: 3772
#include <iostream>
using namespace std;
int main(){
   long long int say=0;
   cin>>say;
   long long int counter=0;
   long long int syof=0,syob=0,syofi=0,syobu=0;
    long long int a=0;
   for(int i=1;i<=say;i++){
       syofi=i/3;
       syobu=i/5;
       syof=i%3;
       syob=i%5;
       counter=0;
       if(syof==0){
           //cout<<"Fizz";
           counter+=1;
       }
       if(syob==0){
           //cout<<"Buzz";
           counter+=1;
       }
       /*else if(syof==0&&syob==0){
           cout<<"FizzBuzz"<<endl;
           counter+=1;
       }*/
       
       if(counter==0){
           a=a+i;
       }
       //cout<<endl;
   }
   cout<<a<<endl;
}


Measured memory_bytes: 3160
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();

        System.out.print(A*B);



        //END
    }
}



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

int main() {
	string str;
     cin>>str;
  
  	int sum=0;
  	for(int i;i<3;i++){
    	if(str.at(i)=='1'){
          sum++;
        }
    }
  cout<<sum<<endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(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(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	vector<string> S(N);
	FDS(i,N){
		cin>>S[i];
	}
	vector<string> ans(N);
	if(N%2==0){
		int k=N/2;
		ans[k]=S[0];
		for(int i=1;i<N;i++){
			if(i%2==0){
				k+=i;
				ans[k]=S[i];
			}
			if(i%2==1){
				k-=i;
				ans[k]=S[i];
			}			
		}
		FDS(i,N){
			cout<<ans[i]<<' ';
		}
	}
	if(N%2==1){
		int k=N/2;
		ans[k]=S[0];
		for(int i=1;i<N;i++){
			if(i%2==0){
				k-=i;
				ans[k]=S[i];
			}
			if(i%2==1){
				k+=i;
				ans[k]=S[i];
			}			
		}
		FDS(i,N){
			cout<<ans[i]<<' ';
		}
	}
}

Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
int main(){
    vector <long long> v;
    long long a,b=100,c=0,d=0,e=1,f=0,g=0,i,j,k=1,l=0,r=1,n,m[300001],z[400001],h[600001],p[600001],sum[10001];
    string s,t,x,y[200001];
    double q,u,w;
    cin>>a;
    while(b<a){
        b+=(b/100);
        d++;
    }
    cout<<d;
}

Measured memory_bytes: 9844
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;

    rep(i, n) {
        int num = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            num++;
        }
        ans += num;
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

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

using namespace std;

const int SIZE = 100010;

vector<int> way[SIZE];
bool visited[SIZE];
int id[SIZE];
int counter[2];

bool dfs(int now, int f){
  if(visited[now]){
    return id[now] == f;
  }

  visited[now] = true;
  id[now] = f;
  counter[f]++;
  
  for(int i=0;i<(int)way[now].size();i++)
    if(dfs(way[now][i], !f) == false) return false;

  return true;
}

bool solve(){
  int n, m;
  int a, b;

  scanf("%d%d", &n, &m);

  if(n == 0)return false;
  
  for(int i=0;i<n;i++) way[i] = vector<int>();
  memset(visited, 0, sizeof(visited));
  counter[0] = counter[1] = 0;  
  
  for(int i=0;i<m;i++){
    scanf("%d%d", &a, &b);
    a--; b--;

    way[a].push_back(b);
    way[b].push_back(a);
  }

  if(!dfs(0,0)){
    puts("0");
  }else{
    //cerr << counter[0] << " " << counter[1] << endl;
    if(counter[0] > counter[1]) swap(counter[0] , counter[1]);

    vector<int> vec;
    
    if(counter[0]%2==0){
      vec.push_back(counter[0]/2);
    }

    if(counter[0] != counter[1] && counter[1]%2 == 0){
      vec.push_back(counter[1]/2);
    }

    printf("%d\n", (int)vec.size());
    
    for(int i=0;i<vec.size();i++){
      printf("%d\n", vec[i]);
    }
  }
  
  return true;
}

int main(){
  while(solve());
}




Measured memory_bytes: 5760
import heapq as pq
inf = float("inf")
n = int(input())
M = [None] * n

for i in range(n):
    L = list(map(int, input().split()))
    M[L[0]] = []
    for j in range(L[1]):
        M[L[0]].append([L[2 * j + 2], L[2 * j + 3]])

def dijkstra(s):
    color = [0] * n
    d = [inf] * n
    d[s] = 0
    H =[]
    pq.heappush(H, [0, s])

    while len(H) != 0:
        u2,u1 = pq.heappop(H)
        color[u1] = 1
        if d[u1] < u2:
            continue
        for v1,v2 in M[u1]:
            if color[v1] == 1: continue
            if d[u1] + v2 < d[v1]:
                d[v1] = d[u1] + v2
                pq.heappush(H, [d[v1], v1])
    return d

d = dijkstra(0)
for i,v in enumerate(d):
 print("{} {}".format(i,v))

Measured memory_bytes: 85564
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 105;
int a[maxN];
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int best = 1e9;
    for (int j = -100; j <= 100; j++) {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += abs(a[i] - j) * abs(a[i] - j);
        }
        best = min(best, ans);
    }
    cout << best;
    return 0;
}

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

x = [0] * N

for i in range(N):
    if S[i] == "I":
        x[i] = x[i-1] + 1
    else:
        x[i] = x[i-1] - 1

if max(x) > 0:
    print(max(x))
else:
    print(0)


Measured memory_bytes: 2940
import fractions
a, b = map(int, input().split())
 
c =fractions.gcd(a,b)
c2 = c
F = []
while c2%2==0:
    c2 //= 2
if c2<c:
    F.append(2)
f = 3
while f*f<c2:
    while c2 %f ==0:
        c2//=f 
        if F:
            if F[-1]<f:
                F.append(f)
        else:
            F.append(f)
    f += 2
if c2>1:
    F.append(f)
print(len(F)+1)    


Measured memory_bytes: 66156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		int K = sc.nextInt();
		System.out.println(A[K-1]);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int count = 0;
    rep(i, n)_rep(j, i + 1, n)_rep(k, j + 1, n){
        if(l[i] != l[j] and l[j] != l[k] and l[i] != l[k]){
            if(l[i] + l[j] > l[k]) count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  long sum = 0;
  for (int i = 0; i < s.size(); ++i) {
    sum += s[i] - '0';
  }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

ll dp[200010];

int main(){
    ll n;cin>>n;
    vector<ll> coin;
    coin.push_back(1LL);
    rep(i,1,7)coin.push_back((ll)pow(6,i));
    rep(i,1,6)coin.push_back((ll)pow(9,i));
    rep(i,0,n+1)dp[i]=1e9;
    dp[0]=0;
    rep(i,0,n+1){
        rep(j,0,coin.size()){
            dp[i+coin[j]]=min(dp[i+coin[j]],dp[i]+1);
        }
    }
    cout<<dp[n]<<endl;
}

    









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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

void solve() {
    rd1(string, s);
    int n = s.size();
    if(s[n - 1] == 's') {
        string ans = s.substr(0, n) + "es";
        cout << ans;
    } else {
        cout << s << "s";
    }
}

int main() {
	
	fastio;
// 	rd1(ll, t);
    ll t = 1;
    
    while(t--) {
        solve();
    }


	return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m,x;
        cin>>n>>m>>x;
        ll c[n],a[n][m];
        f(i,0,n-1)
        {
            cin>>c[i];
            f(j,0,m-1)
            {
                cin>>a[i][j];
            }
        }
        ll ans=llinf;
        f(i,0,(1ll<<n)-1)
        {
            ll cost=0;
            ll mx[m]={0};
            f(j,0,n-1)
            {
                if((i>>j)&1)
                {
                    cost+=c[j];
                    f(k,0,m-1)
                    {
                        mx[k]+=a[j][k];
                    }
                }
            }
            bool p=1;
            f(j,0,m-1)
            {
                p&=(mx[j]>=x);
            }
            if(p)
            {
                ans=min(ans,cost);
            }
        }
        if(ans==llinf)
        {
            ans=-1;
        }
        d1(ans);
    }
    return 0;
}


















Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        Pattern space = Pattern.compile(" ");
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        int[] first = space.splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();
        int n = first[0];
        int p = first[1];
        int[] a = space.splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();

        long[][] dp = new long[n + 1][2];
        dp[0][a[0] % 2] = 1;
        for (int i = 0; i < n; i++) {
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] += dp[i][1];
            if (a[i] % 2 == 0) {
                dp[i + 1][0] += dp[i][0];
                dp[i + 1][1] += dp[i][1];
            } else {
                dp[i + 1][1] += dp[i][0];
                dp[i + 1][0] += dp[i][1];
            }
        }
        System.out.println(dp[n][p]);
    }
}


Measured memory_bytes: 26708
# include<iostream>
using namespace std;
int f(int a, int b)
{
    if(a-b >= 0)
        return a-b;
    return b-a;
}
int main(void)
{
    int a, b, c,d;
    cin >> a>> b>>c >> d;

    if(f(a,c) <= d || f(a,c) <= d)
    {
        cout << "Yes\n";
        return 0;
    }
    if(f(a,b) <= d || f(a,b) <= d)
    {
        if(f(b,c) <= d || f(b,c) <= d)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	

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





}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e5+5,p=1e9+7;
typedef long long ll;
int n,C[2][maxn],a,b,inv[maxn];
int Appear[maxn];
void Copy(int x[],int y[],int k){
    for(int i=0;i<k;i++)
        x[i]=y[i];
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y){
    if(!b){
        d=a;x=1;y=0;
    }
    else{
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
void Inv(){
    for(int i=1;i<maxn;i++){
        ll d,x,y;
        gcd(i,p,d,x,y);
        inv[i]=(x+p)%p;
    }
}
void CalC(){
    C[0][0]=C[1][0]=1;
    for(int i=1;i<=n+a-b;i++){
        C[0][i]=((ll)C[0][i-1]*(n+a-b+1-i))%p;
        C[0][i]=((ll)C[0][i]*inv[i])%p;
    }
    for(int i=1;i<=n+1;i++){
        C[1][i]=((ll)C[1][i-1]*(n+2-i))%p;
        C[1][i]=((ll)C[1][i]*inv[i])%p;
    }
}
int main(){
    Inv();
    scanf("%d",&n);
    memset(Appear,-1,sizeof(Appear));
    int t;
    for(int i=0;i<n+1;i++){
        scanf("%d",&t);
        if(Appear[t]!=-1){
            a=Appear[t];
            b=i;
        }
        Appear[t]=i;
    }
    CalC();
    for(int k=1;k<=n+1;k++){
        int ans=C[1][k];
        if(k-1<=n+a-b)
            ans=(ans-C[0][k-1]+p)%p;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int H, W, N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W >> N;

	int ma = max(H, W);
	int ans = (N + ma - 1) / ma;
	cout << ans << endl;
}







Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  map<int,int> m;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    m[a.at(i)]=i+1;
  }
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    cout << m.at(a.at(i));
    if(i==N-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    println(H * W - (h * W + w * H - w * h))
    
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;

const int N = 302;
const int M = 998244353;

string s;
int n = 0;
int counter = 0;
int ones[N];
int dp[N][N][N]; // prefix, debt, sum

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);

	cin >> s;
	int debt;
	cin >> debt;
	s += "0";
	for (char c : s) {
		if (c == '1') {
			++counter;
		} else {
			ones[++n] = counter;
			counter = 0;
		}
	}
	//cerr << "n = " << n << endl;
	//for (int i = 1; i <= n; ++i) {
	//	cerr << ones[i] << " ";
	//}
	//cerr << endl;
	dp[0][0][0] = 1;
	int total = count(all(s), '1');
	debt = min(debt, total);
	//cerr << "d t " << debt << " " << total << endl;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= total; ++j) {
			for (int k = j; k <= debt; ++k) {
				for (int d = 0; d <= j; ++d) {
					(dp[i][j][k] += dp[i - 1][j - d][k - d]) %= M;
				}
				for (int d = 1; d <= ones[i]; ++d) {
					(dp[i][j][k] += dp[i - 1][j + d][k]) %= M;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= debt; ++i) {
		(ans += dp[n][0][i]) %= M;
	}
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 30816
def d_number_of_amidakuji(H, W, K):
    # 参考: http://sigma1113.hatenablog.com/entry/2018/11/04/235700
    MOD = 10**9 + 7
    fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34]  # W<=8なのでこれだけでいい

    # dp[i][j]: 上からi[cm]下がったところでj番目の縦線に行くようなあみだくじ数
    dp = [[0] * (W + 1) for _ in range(H + 1)]
    dp[0][1] = 1  # 1番からスタートする
    for i in range(H):
        for j in range(1, W + 1):
            if j >= 2:
                # dp[i][j]からdp[i+1][j-1]への遷移が起こる条件は
                # jとj-1の間に横棒がある
                # j-2とj-1の間、jとj+1の間に横棒がない
                # このような横棒の置き方は、
                # 縦線1から縦線j-2までの横棒の置き方 * 縦線j+1からWまでの横棒の置き方
                dp[i + 1][j - 1] += (fibonacci[j - 2] * fibonacci[W - j]) * dp[i][j]
                dp[i + 1][j - 1] %= MOD
            if j <= W - 1:
                # dp[i][j]からdp[i+1][j+1]への遷移が起こる条件は
                # jとj+1の間に横棒がある
                # j-1とjの間、j+1とj+2の間に横棒がない
                # このような横棒の置き方は、
                # 縦線1から縦線j-1までの横棒の置き方 * 縦線j+2からWまでの横棒の置き方
                dp[i + 1][j + 1] += (fibonacci[j - 1] * fibonacci[W - j - 1]) * dp[i][j]
                dp[i + 1][j + 1] %= MOD
            # dp[i][j]からdp[i+1][j+1]への遷移が起こる条件は
            # j-1とjの間、jとj+1の間に横棒がない
            # このような横棒の置き方は、
            # 縦線1から縦線j-1までの横棒の置き方 * 縦線j+1からWまでの横棒の置き方
            dp[i + 1][j] += (fibonacci[j - 1] * fibonacci[W - j]) * dp[i][j]
            dp[i + 1][j] %= MOD
    ans = dp[H][K]
    return ans

H, W, K = [int(i) for i in input().split()]
print(d_number_of_amidakuji(H, W, K))

Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if(a.charAt(0)=='H'){
            System.out.print(b);
        }
        else{
            String ans;
            if(b.charAt(0)=='H') ans = "D";
            else ans = "H";
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21588