akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int h,w;
int n,m;
vector <int> a;
int cou=0,dir=0;

int main(){
	cin>>h>>w>>n;
	for(int i=0;i<n;i++){
		cin>>m;
		for(int j=0;j<m;j++){
			if(cou<w-1){
				a.push_back(i+1);
				cou++;
			}else{
				a.push_back(i+1);
				if(dir==0){
					for(int k=0;k<w;k++){
						if(k<w-1){
							cout<<a[k]<<" ";
						}else{
							cout<<a[k]<<endl;
						}
					}
					dir=1;
				}else{
					for(int k=0;k<w;k++){
						if(k<w-1){
							cout<<a[w-k-1]<< " ";
						}else{
							cout<<a[w-k-1]<< endl;
						}
					}
					dir=0;
				}
				cou=0;
				a.erase(a.begin(),a.begin()+w);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return len(divisors)

N=int(input())
ans=0
for i in range(1,N+1,2):
    if make_divisors(i)==8:ans+=1
print(ans)


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<< '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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



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

int a;
cin >> a;

int ans = a + a * a + a * a * a;
cout << ans << endl;


return 0;
}

Measured memory_bytes: 3636
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: usize,
        r#as: [Usize1; n],
    }

    let mut path = vec![0];
    let mut visited = vec![false; n];
    visited[0] = true;

    loop {
        macro_rules! answer(($i:expr) => ({
            println!("{}", $i + 1);
            break;
        }));

        if path.len() > k {
            answer!(*path.last().unwrap());
        }

        path.push(r#as[*path.last().unwrap()]);

        if visited[*path.last().unwrap()] {
            let i = path
                .iter()
                .position(|&i| i == *path.last().unwrap())
                .unwrap();
            answer!(path[i + (k - i) % (path.len() - i - 1)]);
        }
        visited[*path.last().unwrap()] = true;
    }
}


Measured memory_bytes: 6308
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  ll sum=0;
  rep(i,n){
    if((i+1)%15==0||(i+1)%3==0||(i+1)%5==0) continue;
    else sum+=i+1;
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 3632
def examA():
    S, T = LSI()
    A, B = LI()
    U = SI()
    if S==U:
        print(A-1,B)
    else:
        print(A,B-1)
    return

def examB():
    S = SI()
    N = len(S)
    ans = ""
    for i in range(N):
        ans += "x"
    print(ans)
    return

def examC():
    N = I()
    A = LI()
    d = defaultdict(int)
    for a in A:
        d[a] += 1
        if d[a]>=2:
            print("NO")
            return
    print("YES")
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 101512
S = input()
N = len(S)
def isKaibun(s):
	l = len(s)
	for i in range(l):
		if s[i] != s[l-1-i]:
			return False
	return True

if not isKaibun(S):
	print("No")
	exit()
if not isKaibun(S[:(N-1)//2]):
	print("No")
	exit()
if not isKaibun(S[(N+3)//2 - 1:]):
	print("No")
	exit()
print("Yes")

Measured memory_bytes: 38480
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int a,b,t;
    cin>>a>>b>>t;
    t-=a;
    int ans=0;
    while(t+0.5>0){
        ans+=b;
        t-=a;
    }
    cout<<ans<<endl;
}

   


Measured memory_bytes: 888
/*
        _/﹋\_                                _/﹋\_
        (҂`_´)                                (҂`_´) 
        <,︻╦╤─҉- - - - - - - - => - => - =>  <,︻╦╤─҉- - - - - - - - => - => - =>   
        _/﹋\_                                _/﹋\_                          
*/
//ARC
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e6 + 5;
const double E= 1e-9;
 
//------------------------------------------------------------------------------

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*ifstream cin("input.txt");
    ofstream cout("output.txt");*/
    int l,r,n,ans=0;
    cin>>l>>r>>n;
    for(int i=l; i<=r; i++)
    {
        if(i%n==0)
        ++ans;
    }
    cout<<ans;
    return 0;
}
//Date: ###### Sat Jul 11 17:31:45 IST 2020
//------------------------------------------------------------------------------

Measured memory_bytes: 3632
from collections import Counter
import math

def comb(n):
    if n <= 1:
        return 0
    return n * (n-1) // 2

# print('input >>')
N = int(input())
A = list(map(int,(input().split())))

Ac = Counter(A)

sumc = 0

for Ae in dict(Ac):
    sumc += comb(Ac[Ae])

# print('-----output-----')

for k in A:
    print(sumc - comb(Ac[k]) + comb(Ac[k]-1))

Measured memory_bytes: 26780
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,a,b,d[N],ans;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    d[a]++;
    d[b+1]--;
  }
  for(int i=1;i<=n+1;i++)d[i]+=d[i-1];
  ans=1;
  for(int i=n+1;i>=2;i--)
    if(d[i]>=i-1)ans=max(ans,i);
  cout<<ans-1<<endl;
  return 0;
}

Measured memory_bytes: 1548
using System;

public class C
{
    public const int INF = -999999999;
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var dp0 = 0;
            var ret = C.INF;
            for (int i = 1; i <= n; i++)
            {
                var a = int.Parse(Console.ReadLine().Trim());
                var dp1 = Math.Max(dp0 + a, a);
                ret = Math.Max(ret, dp1);
                dp0 = dp1;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 9256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque> 
#include <algorithm>
 
using namespace std;
 
#define     lli                 long long int
#define     ulli                unsigned long long int

#define     ifor(st,lim)        for(int i=st;i<lim;i++)
#define     jfor(stt,llim)      for(int j=stt;j<llim;j++)
#define		Test(tt)			for(int test=1;test<=tt;test++)
#define		For(var,srt,nnd)	for(var=srt;var<nnd;var++)
#define		Rfor(var,srt,nnd)	for(var=srt;var>=nnd;var--)
 
#define     pb                  push_back
#define     mkp                 make_pair
 
#define     pi                  acos(-1)
#define     mod                 100000007
 
#define     Clear(var,val)      memset(var,val,sizeof(var))
#define     len(var)            (int)(var.length())
#define     vlen(vect)          (int)(vect.size())
#define     line(ss)            getline(cin,ss)

#define		FIO					ios_base::sync_with_stdio(false);cin.tie(NULL)

#define		sclock				int start_s=clock()
#define		eclock				int end_s=clock()
#define		pclock				printf("\nRuntime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC)
 
/****************************** IO ************************************/
#define		ina(a)				scanf("%d",&a)
#define		inb(a,b)			scanf("%d %d",&a,&b)
#define		inc(a,b,c)			scanf("%d %d %d",&a,&b,&c)
#define		ins(chr)			scanf("%s",s)
#define		inlla(a)			scanf("%lld",&a)
#define		inllb(a,b)			scanf("%lld %lld",&a,&b)
#define		inllc(a,b,c)		scanf("%lld %lld %lld",&a,&b,&c)
 
#define		outa(a)				printf("%d",a)
#define		outlla(a)			printf("%lld",a)

#define		yn(b)				puts(b ? "YES" : "NO") 

#define		outar(ar,ln,c)		for(int i=0;i<ln;i++){printf("%d%c",ar[i],c);}

#define		outCase()			printf("Case %d:",test)
 
#define		blank				printf("\n")
/**********************************************************************/

int main()
{
    FIO;
/******************************* C ************************************/
	
	
	lli n,k;
	inllb(n,k);
	
	if(n>k) n%=k;
	
	while(n>abs(n-k)) n=abs(n-k);
	
	outlla(n);blank;
	
/**********************************************************************/
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;

const double eps = 1e-8;

int N;
P D;
vector<P> ps;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

bool canExist(double t, int p) {
  double dist = abs(D - ps[p]);
  return !( equals(dist, t) || dist < t );
}

bool rec(int state, double t, int p) {
  if(state == (1<<N)-1) return true;
  for(int i = 0; i < N; ++i) {
    if(state & (1<<i)) continue;
    if(!canExist(t + abs(ps[i] - ps[p]), i)) return false;
  }
  for(int i = 0; i < N; ++i) {
    if(state & (1<<i)) continue;
    double nt = t + abs(ps[i] - ps[p]);
    if(rec(state|(1<<i), nt, i)) return true;
  }
  return false;
}

int main() {
  int hx, hy, dx, dy;
  while(cin >> N >> hx >> hy >> dx >> dy
	&&(N|hx|hy|dx|dy) ) {
    D = P(dx, dy);
    ps.resize(N+1);
    ps[N] = P(hx, hy);
    for(int i = 0; i < N; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    if(rec(0, 0.0, N)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
n, *L = map(int, open(0).read().split())
con = [[] for _ in range(n)]
for a, b in zip(*[iter(L)] * 2):
	con[a - 1].append(b - 1)
	con[b - 1].append(a - 1)
k = max(map(len, con))
q = [(0, n)]
label = [-1] * n
label[0] = 0
while q:
	cur, ex = q.pop(0)
	nxtex = label[cur]
	i = int(nxtex==0 or ex==k)
	for nxt in con[cur]:
		if label[nxt] > -1:
			continue
		if i==ex:
			i += 1
		label[nxt] = i
		q.append((nxt, nxtex))
		i += 1
print(k)
for a, b in zip(*[iter(L)] * 2):
	t = label[a - 1] + label[b - 1]
	print(t % k if t > k else t)


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


def main():
    n, m, x = map(int, input().split())

    MONEY = []
    UNDERSTAND = []
    for i in range(n):
        lst = [int(i) for i in input().split()]
        MONEY.append(lst[0])
        UNDERSTAND.append(lst[1:])

    ans = -1
    for i in range(1 << n):
        understand = [0] * m
        money = 0
        for j in range(n):
            if (i >> j) & 1 == 0:
                continue
            money += MONEY[j]
            for k in range(m):
                understand[k] += UNDERSTAND[j][k]
        if all([i >= x for i in understand]):
            if ans == -1:
                ans = money
            else:
                ans = min(ans, money)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
n,*a=`dd`.split.map &:to_i
a=[0]+a+[0]
s=a.each_cons(2).map{|x,y|(x-y).abs}.inject :+
d=->i,j{(a[i]-a[j]).abs}
puts (1..n).map{|i|s-d[i,i-1]-d[i+1,i]+d[i+1,i-1]}*$/

Measured memory_bytes: 15200
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second

int main() {
    ll a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 45
using namespace std;
int pre[N], p = 0;
int in[N];
int n;
vector<int> post;
void rec(int l, int r){
    if (l >= r) return ;
    int c = pre[p++];
    int m;
    for(m = 0; m < n; m++){
        if(in[m] == c) break;
    }
    rec(l, m);
    rec(m+1, r);
    post.push_back(c);
}
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &pre[i]);
    for(int i = 0; i < n; i++) scanf("%d", &in[i]);
    rec(0, n);
    for(int i = 0; i < post.size(); i++){
        printf("%d", post[i]);
        i == post.size()-1 ? printf("\n") : printf(" ");
    }
    return 0;
}


Measured memory_bytes: 3216
#define tasknames ""
#include <iostream>
#include <stdio.h>
using namespace std;


const int N = 1e2 + 2;
bool ck[N];
int n, k;

void Read(){
    cin >> n >> k;
    for(int i = 1; i <= k; ++i){
        int t; cin >> t;
        while(t--){
            int v;
            cin >> v;
            ck[v] = 1;
        }
    }
}

void Solve(){
    int cnt = 0;
    for(int i = 1; i <= n; ++i)
        cnt += !ck[i];
    cout << cnt;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); if(fopen(tasknames".INP", "r"))
    freopen(tasknames".INP","r",stdin),
    freopen(tasknames".OUT","w",stdout);
    Read();
    Solve();
}


Measured memory_bytes: 3668
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int r = sc.nextInt();

           if (n < 10) {
               System.out.println(r +  (100 * (10 - n)));
           } else {
               System.out.println(r);}
        }


}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int n;
LL a[100010], b[100010], c[100010], x[100010], y[100010], z[100010];

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

	for (int i = 1; i <= n; ++i) {
		std::cin >> a[i] >> b[i] >> c[i];
		x[i] = 0;
		y[i] = 0;
		z[i] = 0;
	}

	x[1] = a[1];
	y[1] = b[1];
	z[1] = c[1];

	for (int i = 2; i <= n; ++i) {
		x[i] = a[i] + std::max(y[i-1], z[i-1]);
		y[i] = b[i] + std::max(x[i-1], z[i-1]);
		z[i] = c[i] + std::max(x[i-1], y[i-1]);
	}
	std::cout << std::max({ x[n], y[n], z[n] }) << std::endl;
}


Measured memory_bytes: 4992
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static long v[];
	static int count[];

	public static long comb(int n, int r) {
		long ans = 1;
		for(int i = 1; i <= r; ++i) {
			ans *= n - i + 1;
			ans /= i;
		}
		return ans;
	}
	
	public static long count(int a) {
		long c = 0;
		int tmp = 0;
		int t = 0;
		int n = count.length;
		for(int i = 0; i < n; ++i) {
			tmp += count[i];
			if(tmp >= a){ 
				if(tmp == a)return 1;
				t = i;
				break;
			}
		}
		tmp -= count[t];
		tmp = a - tmp;
		c = comb(count[t], tmp);
		return c;
	}
	
	public static double sum(int a) {
		double sum = 0;
		int n = v.length;
		int c = 0;
		for(int i = 0; i < n; ++i) {
			c += count[i];
			if(c <= a) {
				sum += ((double)(v[n - c]) * ((double)count[i] / (double)a));
				if(c == a)return sum;
			}
			else {
				int tmp = c - count[i];
				tmp = a - tmp;
				sum += ((double)(v[n - c]) * ((double)tmp / (double)a));
				return sum;
			}
		}
		
		return sum;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		v = new long[n];
		for (int i = 0; i < n; ++i)
			v[i] = sc.nextLong();
		sc.close();
		Arrays.sort(v);
		count = new int[n];
		int j = 0;
		count[j]++;
		for(int i = n - 2; i >= 0; --i) {
			if(v[i] != v[i + 1])count[++j]++;
			else count[j]++;
		}
		double ans = 0;
		long c = 0;
		for (int i = a; i <= b; ++i) {
			double tmp  = sum(i);
			if(tmp > ans) {
				ans = tmp;
				c = count(i);
			}
			else if(tmp == ans){
				ans = tmp;
				c += count(i);
			}
		}
		System.out.printf("%f\n", ans);
		System.out.println(c);
	}

}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll h,n;
	cin>>n>>h;
	ll a[n+1];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(ll i=0;i<n;i++)
	sum=sum+a[i];
	for(ll i=n-1;i>=0;i--)
	{
		if(h>0)
		{
		sum=sum-a[i];
		h--;
		}
	}
	cout<<sum;
	
}


Measured memory_bytes: 1792
import itertools
import copy
  
N,M,Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q

now = 0
ans = 0

for i in range(Q):
  a[i],b[i],c[i],d[i] = map(int, input().split())
  
def dfs(A):
#  print('input',A)
  global ans
  if (len(A) == N):
    now = 0
    for i in range(Q):
      if A[b[i]-1] - A[a[i]-1] == c[i]:
        now += d[i]
    ans = max(now,ans)
    return
  if len(A) == 0:
    A=[1]
  else:
    A.append(A[-1])

  while A[-1] <= M:
#    print('mid',A,A[-1])
    dfs(copy.deepcopy(A))
    A[-1] +=1
  
  
dfs(list([1]))  
print(ans)

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

int main(){
    int w,h,n,x,y,a,cont=0;
    scanf("%d%d%d", &w, &h, &n);
    int mat[100][100]={0};
    for(int i=0; i<n; i++){
        scanf("%d%d%d", &x, &y, &a);
        //printf("\n");
        if(a==1){
            for(int i=0; i<x; i++){
                for(int j=0; j<h; j++){
                    mat[j][i]=1;
                }
            }
        }
        else if(a==2){
            for(int i=x; i<w; i++){
                for(int j=0; j<h; j++){
                    mat[j][i]=1;
                }
            }
        }
        else if(a==3){
            for(int i=0; i<y; i++){
                for(int j=0; j<w; j++){
                    mat[i][j]=1;
                }
            }
        }
        else{
            for(int i=y; i<h; i++){
                for(int j=0; j<w; j++){
                    mat[i][j]=1;
                }
            }
        }
//        for(int i=0; i<h; i++){
//            for(int j=0; j<w; j++){
//                printf("%d", mat[i][j]);
//            }
//            printf("\n");
//        }
//        printf("\n");
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(mat[i][j]==0)
                cont++;
        }
    }
    printf("%d", cont);
return 0;
}


Measured memory_bytes: 256
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    b = input()
    if b == "A":
        s = "T"
    elif b == "C":
        s = "G"
    elif b == "G":
        s = "C"
    else:
        s = "A"
    print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

    int N, x;
    cin >> N >> x;
    vector<int> a(N + 1);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    int l = x;
    ll ans = 0;
    for (int i = 0; i < N; i += 2) {
        l = min(l, a[i]);
        ans += max(a[i] - l, 0);
        ans += max(a[i + 1] - x + l, 0);
        l = max(x - a[i + 1], l);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string a,b; cin>>a>>b;
    int t;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    if(a<b){
        cout<<"Yes"<<endl;
        }else{ cout<<"No"<<endl;
        }
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int l,n,x,w;
	int lm=0,rm=0;
	cin>>l>>n;
	rep(i,0,n){
		cin>>x>>w;
		if(x<0) lm+=(-x)*w;
		if(x>0) rm+=x*w;
	}
	int tmp=abs(lm-rm);
	if(lm==rm) o(0);
	else if(lm<rm){
		o(1);
		o(-1<<" "<<tmp);
	}else{
		o(1);
		o(1<<" "<<tmp);
	}

}

Measured memory_bytes: 1164
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


x, y, z = LI()
x, y = y, x
x, z = z, x
print(x, y, z)

Measured memory_bytes: 39664
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    search = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    maxmove = 0
    for h in range(H):
        for w in range(W):
            if S[h][w] == ".":
                dist = [[-1 for _ in range(W)] for i in range(H)]
                q = deque()
                for di, dj in search:
                    if 0 <= h + di < H and 0 <= w + dj < W:
                        if S[h+di][w+dj] == ".": q.append((1, h + di, w + dj))
                dist[h][w] = 0
                move = 0
                while q:
                    nd, nh, nw = q.popleft()
                    if dist[nh][nw] == -1:
                        dist[nh][nw] = nd
                        move = max(move, nd)
                        for di, dj in search:
                            if 0 <= nh + di < H and 0 <= nw + dj < W:
                                if S[nh+di][nw+dj] == "." and dist[nh+di][nw+dj] == -1:
                                    q.append((nd + 1, nh+di, nw+dj))
                maxmove = max(maxmove, move)
    print(maxmove)


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    int ans=0;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int m;
    cin>>m;
    rep(i,m){
      int x,y;
      cin>>x>>y;
      if(a<=x&&x<=a+c&&b<=y&&y<=b+d)ans++;
    }
    cout<<ans<<endl;
  }

}

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

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> to[100000];
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, -1);
    vector<int> pre(n, -1);
    q.push(0);
    dist[0] = 0;
    while(!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if (dist[u] != -1) 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: 10740
#include<bits/stdc++.h>
int main()
{
	std::string a;
	std::cin>>a;
	int x,y;
	std::cin>>x>>y;
	int n=0;
	std::vector<int>x1,y1;
	for(int i=0;i<a.size();i++) 
	{
		if(a[i]=='T')
		{
			(x1.size()==y1.size()?x1:y1).push_back(n);
			n=0;
		}
		else n++;
	}
	(x1.size()==y1.size()?x1:y1).push_back(n);
	int c=x1[0],b=0;
	sort(x1.begin()+1,x1.end());
	sort(y1.begin(),y1.end());
	for(int i=x1.size()-1;i>=1;i--)
	{
		c+=x1[i]*(c>x?-1:1);
		//std::cout<<"c="<<c<<std::endl;
	}
	for(int i=y1.size()-1;i>=0;i--)
	{
		b+=y1[i]*(b>y?-1:1);
		//std::cout<<b<<std::endl;
	}
	std::cout<<(c==x&&b==y?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	long long int n,a,b;
	scanf("%lld %lld %lld",&n,&a,&b);
	long long int t[n]={};
	long long int ans=n;
	for(int i=0;i<n;i++){
		scanf("%lld",&t[i]);
		if(a<=t[i] && t[i]<b){
			ans--;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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


int main() {
    int N, K; cin >> N; cin >> K;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int h; cin >> h;
        if (K <= h) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(void){
  int x,y;
  cin >> x >> y;
 int check[12]={1,3,1,2,1,2,1,1,2,1,2,1};
  if(check[x-1]==check[y-1]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
mod = 10**9 + 7

def sum_n(n):
    return (n * (n+1))//2

ans = 0
left = [0] * N
right = [0] * N
for i in range(N):
    a = Alist[i]
    in_left = True
    for j in range(N):
        if i == j:
            in_left = False
            continue
        else:
            if Alist[j] < a:
                if in_left:
                    left[i] += 1
                else:
                    right[i] += 1
    ans += right[i] * sum_n(K)
    ans += left[i] * sum_n(K-1)
    ans %= mod
print(ans)

Measured memory_bytes: 3188
def main():
	S = input()
	lst = [False] * 26

	for ch in S:
		lst[ord(ch) - ord("a")] = True

	for i in range(26):
		if lst[i] == False:
			print(chr(i + ord("a")))
			break
	else:
		print("None")

  
if __name__ == "__main__":
  	main()

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

const int maxn=(int)1e5+10;
int h[maxn];
int dp[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	dp[1]=0; dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		//printf("(%d %d)\n",abs(h[i]-h[i-1]),abs(h[i-2]-h[i]));
		dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
	}
	printf("%d\n",dp[n]);
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,m,v,p;
  cin>>n>>m>>v>>p;
  auto as=read(n);
  sort(as.begin(),as.end());

  auto check=[&](Int x)->Int{
    vector<Int> bs;
    for(Int i=0;i<n;i++)
      if(i!=x) bs.emplace_back(as[i]);

    Int a=as[x]+m;

    // r mon touhyou sinaito
    Int r=v-1;

    Int big=0;
    while(!bs.empty() and bs.back()>a){
      bs.pop_back();
      big++;
      r--;
    }
    if(big>p-1) return 0;

    // cap mon made koete yoi
    Int cap=min(p-1-big,r);
    while(!bs.empty() and cap){
      bs.pop_back();
      cap--;
      r--;
    }
    if(bs.empty()) return 1;

    // nokori zenbu a ika
    Int sum=0;
    for(Int b:bs) sum+=min(m,a-b);
    return sum>=r*m;
  };

  Int l=-1,r=n;
  // check(l): false
  // check(r): true
  while(l+1<r){
    Int m=(l+r)>>1;
    if(check(m)) r=m;
    else l=m;
  }
  cout<<n-r<<newl;
  return 0;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;
    
    s[K-1] = (char)tolower(s[K-1]);
    cout << s << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String p = in.nextLine();
		s += s;
		if(s.indexOf(p) != -1) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 26212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            int K = int.Parse (Console.ReadLine ());

            if (K % 2 == 0 || K % 5 == 0)
            {
                Console.WriteLine (-1);
                return;
            }

            List<int> R = new List<int> ();
            int ans = 0;
            int r = 0;
            while (true)
            {
                ans++;
                r = r * 10 + 7;
                if (r % K == 0)
                {
                    Console.WriteLine (ans);
                    return;
                }
                r = r % K;
                // if (R.Contains (r)) break;
                // else R.Add (r);
            }
            Console.WriteLine (-1);
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 27756
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i*i <= x; i++) {
		if (x%i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	string s;
	cin >> s;
	int ans = s.size();
	rep(i, s.size() - 1) {
		if (s[i] != s[i + 1]) {
			ans = min(ans, max(i + 1, (int)s.size() - i - 1));
		}
	}
	cout << ans << endl;
}


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

#define SE second
#define FI first
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int) (x).size())

#define _ << " " <<
#define TR(x) if ( 1 ) cout << #x _ x << endl

using namespace std;
using ii = pair<int, int>;

const int INF = (int) 1e9 + 5;

string s;

int main() {
    cin >> s;

    cout << s[0] << SIZE(s)-2 << s[SIZE(s)-1] << endl;

    return 0;
}


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

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (1) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break ;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			break ;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
#define MAX_NUM 2001
#define MAX_SIZE 21
using namespace std;

int D[MAX_SIZE][MAX_NUM];
int n, q, A[MAX_SIZE];

bool solve(int i, int j) {
    if (D[i][j] < 0) { 
        if (j == 0) D[i][j] = 1;
        else if (i >= n) D[i][j] = 0;
        else D[i][j] = solve(i+1, j-A[i]) | solve(i+1, j);
    }
    return D[i][j];
}
    
int main(){
    int i, m;
    for (i=0; i < MAX_SIZE; i++) for (int j=0; j < MAX_NUM; j++) D[i][j] = -1;
    cin >> n;
    for (i=0; i < n; i++) scanf("%d", &A[i]);
    cin >> q;
    for (i=0; i < q; i++) {
        cin >> m;
        if (solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    // for (i=0; i < n; i++) {
    //     for (int j=0; j < 6; j++) cout << D[i][j] << " ";
    //     cout << endl;
    // }
    return 0;
} 


Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<ll> connection;

    UnionFind(int N):par(N),rank(N),connection(N){
        rep(i,N){
          par[i] = i;
          rank[i] = 0;
          connection[i] = 1;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }
    
    bool same(int x,int y){
      return root(x) == root(y);
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(!same(x,y)){
            connection[root(x)] += connection[root(y)];
            connection[root(y)] = connection[root(x)];
        }
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

    ll SIZE(int x){
        return connection[root(x)];
    }
};


int main(){
   ll N;
   cin >> N;
   vector<pair<ll,ll>> X(N),Y(N);
   rep(i,N){
       cin >> X[i].first >> Y[i].first;
       X[i].second = i;
       Y[i].second = i;
   }
   sort(ALL(X));
   sort(ALL(Y));
   vector<tuple<ll,ll,ll>> D;
   rep(i,N-1){
       D.emplace_back(X[i+1].first-X[i].first,X[i].second,X[i+1].second);
   }
   rep(i,N-1){
       D.emplace_back(Y[i+1].first-Y[i].first,Y[i].second,Y[i+1].second);
   }
   sort(ALL(D));
   UnionFind tree(N);
   ll ans = 0;
   rep(i,2*N-2){
       ll d,x,y;
       tie(d,x,y) = D[i];
       if(tree.same(x,y)) continue;
       tree.unite(x,y);
       ans += d;
   }
   cout << ans << endl;
}


Measured memory_bytes: 11632
a,b,c = map(int,input().split())
ans = 9999
ans = min(ans, abs(a-b) + abs(b-c), abs(a-c) + abs(c-b))
ans = min(ans, abs(b-a) + abs(a-c), abs(b-c) + abs(c-a))
ans = min(ans, abs(c-a) + abs(a-b), abs(c-b) + abs(b-a))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
const double r=acos(-1)*5;
int n,sx,sy,tx,ty,x,y,f[200010],b[200010],c[200010];
pi a[200010];
inline int maxx(int i)
{
	int k=0;
	for(;i;i^=i&-i)
	  k=max(k,f[i]);
	return k;
}
inline void mdf(int i,int k)
{
	for(;i<=n;i+=i&-i)
	  f[i]=max(f[i],k);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l;
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	if(sx>tx)
	  {
	   x=1;
	   sx*=-1;
	   tx*=-1;
	  }
	if(sy>ty)
	  {
	   y=1;
	   sy*=-1;
	   ty*=-1;
	  }
	scanf("%d",&n);
	for(i=1,l=0;i<=n;i++)
	  {
	   scanf("%d%d",&j,&k);
	   if(x)
	     j*=-1;
	   if(y)
	     k*=-1;
	   if(sx<=j && j<=tx && sy<=k && k<=ty)
	     {
	      a[++l]=mp(j,k);
	      b[l]=j;
	      c[l]=k;
		 }
	  }
	n=l;
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	for(i=1;i<=n;i++)
	  {
	   a[i].aa=lower_bound(b+1,b+n+1,a[i].aa)-b;
	   a[i].bb=lower_bound(c+1,c+n+1,a[i].bb)-c;
	  }
	sort(a+1,a+n+1);
	if(sx==tx || sy==ty)
	  {
	   printf("%.15lf\n",(tx-sx+ty-sy)*100.0+(n?(2*r-20):0));
	   return 0;
	  }
	for(i=1;i<=n;i++)
	  {
	   k=maxx(a[i].bb);
	   mdf(a[i].bb,k+1);
	  }
	k=maxx(n);
	printf("%.15lf\n",(tx-sx+ty-sy)*100.0+k*(r-20)+(k==min(tx-sx+1,ty-sy+1)?r:0));
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

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

	unordered_map<char, int> m;
	rep(i, N) {
		string S;
		cin >> S;

		m[S[0]]++;
	}

	char chs[5] = { 'M', 'A', 'R', 'C', 'H' };
	vector<int> perm;
	rep(i, 5) perm.push_back(i);

	int ret = 0;
	do {
		char ch1 = chs[perm[0]];
		char ch2 = chs[perm[1]];
		char ch3 = chs[perm[2]];
		ret += m[ch1] * m[ch2] * m[ch3];
	} while (next_permutation(all(perm)));

	ret /= 12;

	cout << ret << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	long int a[1000000];
	int j,n,max=0,answer,min;
	long int i;
	// for(i=0;i<200000;i++){
	// 	// a[i]=0;
	// 	b[i]=0;
	// }
	scanf("%d",&n);
	scanf("%ld",&a[0]);
	scanf("%ld",&a[1]);
	if(a[0]>a[1]) min=a[1];
	else min = a[0];
	max = a[1]-a[0];
	// printf("%d\n",n);
	for(i=2;i<n;i++){
		scanf("%ld",&a[i]);
		if(max < a[i]-min) max = a[i]-min;
		if(a[i]<min) min=a[i];
	}
	printf("%d\n",max);
	return 0;
}

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

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

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

int main(){
	int n,k,h[301]={};
	scanf("%d%d",&n,&k);
	rep(i,n) scanf("%d",&h[i+1]);

	// dp[i][j+1] := ( i 列選び, 最後に選んだ列が j であるときの最適解 )
	lint dp[301][301];
	rep(i,n-k+1) rep(j,n+1) dp[i][j]=INF;
	dp[0][0]=0;
	for(int t=1;t<=n;t++){
		for(int i=n-k-1;i>=0;i--) rep(j,t) {
			dp[i+1][t]=min(dp[i+1][t],dp[i][j]+max(h[t]-h[j],0));
		}
	}

	printf("%lld\n",*min_element(dp[n-k],dp[n-k]+n+1));

	return 0;
}


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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int n = s.size();
	if(n <= 3){
		cout << "No" << endl;
		return 0;
	}

	if(s.substr(0, 4) == "YAKI"){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <map>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <utility>
#include <math.h>
#include <stack>

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

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const long long mod = 1e9+7;

void chmod(long long &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

long long modpow(long long x, long long n){
    if(n==0) return 1;
    long long res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };



/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

const long long M = 1046527;
const int LENGTH = 14;

char ht[M][LENGTH];

void init() {
    for(int i=0; i<M; ++i) { ht[i][0] = '\0'; }
}

int get_int(char c) {
    return c - 'A' + 1;
}

long long get_key(char str[]) {
    long long key = 0;
    long long d = 1;
    for(int i=0; i<strlen(str); ++i) {
        key += d * get_int(str[i]);
        d *= 5;
    }
    return key;
}

long long h1(long long key) { return key % M; }
long long h2(long long key) { return 1 + key % (M-1); }

bool find(char str[]) {
    long long key = get_key(str);
    for(long long i=0; ;i++) {
        long long idx = (h1(key) + i*h2(key)) % M;
        if(strcmp(ht[idx], str) == 0) { return true; }
        else if(strlen(ht[idx]) == 0) { return false; }
    }
}

int insert(char str[]) {
    long long key = get_key(str);
    for(long long i=0; ;i++) {
        long long idx = (h1(key) + i*h2(key)) % M;
        if(strcmp(ht[idx], str) == 0) return 1;
        else if(strlen(ht[idx]) == 0) {
            strcpy(ht[idx], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    init();
    int n; scanf("%d", &n);

    char str[LENGTH];
    char com[10];

    for(int i=0; i<n; ++i) {
        scanf("%s %s", com, str);
        if(com[0] == 'i') { insert(str); }
        else {
            if(find(str)) { printf("yes\n"); }
            else { printf("no\n"); }
        }
    }
    
    return 0;
}



Measured memory_bytes: 17452
#include <iostream>
using namespace std;
 
int dp[41][401][401];
 
int main(){
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int a[n], b[n], c[n];
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	for(int i = 0; i <= n; i++) for(int j = 0; j <= 400; j++) for(int k = 0; k <= 400; k++) dp[i][j][k] = 1e9;
	dp[0][0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= 400; j++) for(int k = 0; k <= 400; k++){
			dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
			if(j + a[i] > 400 || k + b[i] > 400) continue;
			dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
		}
	}
	int ans = 1e9;
	for(int i = 0; i <= 400; i++) for(int j = 0; j <= 400; j++){
		if(i == 0 && j == 0) continue;
		if(ma * j != mb * i) continue;
		ans = min(ans, dp[n][i][j]);
	}
	cout << (ans == 1e9 ? -1 : ans) << endl;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  vector<int>a(n),b(n),c(n-1);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  ll ans = 0;
  rep(i,n){
    ans+=b[a[i]-1];
    if(i>0){
      if(a[i-1]+1==a[i])ans+=c[a[i-1]-1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = struct mms { lint min, max, sum; mms(lint a = numeric_limits<lint>::max(), lint b = numeric_limits<lint>::min(), lint c = 0) : min(a), max(b), sum(c) {} };
  using U = struct lf { lint a, b; lf(lint a = 1, lint b = 0) : a(a), b(b) {} };
  static T op(const T& a, const T& b) { return T{min(a.min, b.min), max(a.max, b.max), a.sum + b.sum}; }
  static const T e() { return T(); }
  static void ap(T& a, const U& g, lint k) {
    a.min = g.a * a.min + g.b;
    a.max = g.a * a.max + g.b;
    if (g.a < 0) swap(a.min, a.max);
    a.sum = g.a * a.sum + k * g.b;
  }
  static void ap(U& f, const U& g) { f.a *= g.a; f.b = g.a * f.b + g.b; }
  static const U id() { return U(); }
};

template<class M> struct ST {
  using T = typename M::T;
  using U = typename M::U;
  lint n;
  unordered_map<lint, T> t;
  unordered_map<lint, U> u;

  ST(lint n) : n(1LL << 8 * sizeof(lint) - __builtin_clzll(max(n - 1, 1LL))) {}

  void _ap(lint i, const U& f) {
    M::ap(t[i], f, 1 << __builtin_clzll(i) - __builtin_clzll(n));
    if (i < n) M::ap(u[i], f);
  }

  T get(lint l, lint r) {
    _push(l, r);
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = M::op(resl, t[l++]);
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void _push(lint l, lint r) {
    for (lint hl = 8 * sizeof(lint) - __builtin_clzll(l + n) - 1, hr = 8 * sizeof(lint) - __builtin_clzll(r - 1 + n) - 1; hr > 0; hl--, hr--) {
      lint i = r - 1 + n >> hr;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
      i = l + n >> hl;
      if (i == r - 1 + n >> hr or i >= n) continue;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
    }
  }

  void set(lint l, lint r, const U& f) {
    _push(l, r);
    for (lint i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(i++, f);
      if (j & 1) _ap(--j, f);
    }
    for (l += n; !(l & 1);) l >>= 1;
    while (l >>= 1) t[l] = M::op(t[2 * l], t[2 * l + 1]);
    for (r += n; !(r & 1);) r >>= 1;
    while (r >>= 1) t[r] = M::op(t[2 * r], t[2 * r + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  ST<M> st(n);
  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (t) {
      int l, r; cin >> l >> r;
      cout << st.get(l, r + 1).sum << '\n';
    } else {
      int l, r, x; cin >> l >> r >> x;
      st.set(l, r + 1, M::U(0, x));
    }
  }
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  int res = 1;
  int ma = 0;
  for (int i = 1; i <= N; ++i) {
    int cnt = 0;
    int x = i;
    while (x % 2 == 0) x /= 2, cnt++;
    if (ma < cnt) {
      ma = cnt;
      res = i;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256