akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    string in; cin >> in;

    int res = 0;
    rep(i, 1, n){
        string S = in.substr(0, i);
        string T = in.substr(i);

        set<char> s; for(auto& e : S) s.insert(e);
        set<char> t; for(auto& e : T) t.insert(e);

        int cur = 0;
        for(auto& e : s){
            if(t.find(e) != end(t)){
                cur++;
            }
        }
        chmax(res, cur);
    }

    cout << res << endl;

    return 0;
}


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

using namespace std;

typedef pair<int, int> P;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int count = 0;
    for(int i=0;i<N;++i){
        cin >> A[i];
        if(A[i] > 0){
            ++count;
        }
    }

    int x;
    vector< P > ans;
    if(count >= N-1){
        sort(A.begin(), A.end());
        x = A[0];
        for(int i=1;i<N-1;++i){
            ans.push_back(P(x, A[i]));
            x -= A[i];
        }
        ans.push_back(P(A[N-1], x));
    }
    else if(count <= 1){
        sort(A.begin(), A.end(), greater<int>());
        x = A[0];
        for(int i=1;i<N;++i){
            ans.push_back(P(x, A[i]));
            x -= A[i];
        }
    }
    else{
        sort(A.begin(), A.end());
        x = A[0];
        int y = A[N-1];
        for(int i=1;i<N-1;++i){
            if(A[i] < 0){
                ans.push_back(P(y, A[i]));
                y -= A[i];
            }
            else{
                ans.push_back(P(x, A[i]));
                x -= A[i];
            }
        }
        ans.push_back(P(y, x));
    }

    cout << ans.back().first - ans.back().second << endl;
    for(P p : ans){
        cout << p.first << " " << p.second << endl;
    }
}


Measured memory_bytes: 3188
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rgL2iRE5WGj?4|8b)jT3>?N)<}_ku(P|23B=UVhl-tUpuA&n(hTNJKh<OUFzlt{%z_;ZBCiaq!bdIj;BT&oOGrt5iCkal9cmJYYJ-a{Yn^KXPQ|eDN_auUWgL1QPut}wv`-E3?L~<O4yIFyHyxLH5JJ;Sisi6FvuA=c8EQEsYwbX1Iblxn}cW=jWCtAv&HLsid>8AYwWmb94|;>tSo13Ilifd>9hi$+v^)DkQGJf%n-YIy3W0NQ-tjfYT~Te(*dg;t`k@8pYV(|%~f1LXuG3V`6mib_!|V_1Mx(%b@QF>RB}B^PLA2$4HzgFiMs-Z^SHE!H4Gg?A1p3p>Y1ss(RM1S;X#BdN_|Q;)P(sF(f`zQG;wTx^+u?Bg!)IwUa(1rR~9axWbvt%>=t1k*-LecE}HO#Y=yVjd5gVm{s4*i!n^")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12956
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ld N,M;
    cin>>N>>M;
    ld t=N*M;
    //cout<<fixed<<setprecision(20)<<N*M<<endl;
    cout<<fixed<<setprecision(0)<<floor(t);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3832
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define size 300010
#define ll long long
#define db double
#define il inline
#define rint register int
#define gc getchar()
#define rep(i,s,n) for (register int i=s;i<=n;i++)
#define sro_zyb_orz int main()

using namespace std;

il ll r()
{
	char c; ll x,f=1;
	for (c=gc;!isdigit(c);c=gc) if (c=='-') f=-1; x=c-'0';
	for (c=gc;isdigit(c);c=gc) x=x*10+c-'0'; return x*f;
}

int N,A;


sro_zyb_orz
{
	N=r(); A=r();
	N%=500; if (N<=A) printf("Yes\n"); else printf("No\n");
	return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;
  char ans;
  for (int i = 0; i < K; i++) {
    if (S[i] == '1') {
      continue;
    }
    ans = S[i];
    cout << ans << endl;
    return 0;
  }
  ans = '1';
  cout << ans << endl;
  return 0;
}

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

int main () {

    int64_t n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];

    std::vector<bool> visited(n, false);
    int v = 1;
    while (!visited[v - 1]) {
        visited[v - 1] = true;
        v = a[v - 1];
    }

    int sub = 0;
    int w = 1;
    while (v != w) {
        sub++;
        w = a[w - 1];
    }
    int64_t loop = std::count(visited.begin(), visited.end(), true) - sub;

    int ans = 1;
    if (k <= sub) {
        for (int64_t i = 0; i < k; i++) ans = a[ans - 1];
    } else {
        for (int64_t i = 0; i < sub + ((k - sub) % loop); i++) ans = a[ans - 1];
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n; cin >> n;
    vec<int> ans(n, 0);
    while (--n) {
        int a; cin >> a;
        ++ans[a - 1];
    }
    for (auto e : ans) cout << e << endl;
}



Measured memory_bytes: 4028
from collections import deque

n, q = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

res = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    res[p-1] += x

d = deque()
d.append(0)
visited = [False] * n
while d:
    node = d.popleft()
    visited[node] = True
    for next_node in edge[node]:
        if not visited[next_node]:
            res[next_node] += res[node]
            d.append(next_node)

for c in res:
    print(c, end=' ')

Measured memory_bytes: 105036
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll p=1e9+7;
ll inf=1e18;
vector<vector<ll>>adj(2001);
vector<ll>used(2001,0);
vector<ll>ans(2001,0);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,w,h,y,r,k,d,m,t,a,b,n,x,temp;
	cin>>n>>k;
	ll arr[n+1]={0};
	for(i=0;i<k;i++)
	{
	    cin>>x;
	    for(j=0;j<x;j++)
	    {
	        cin>>temp;
	        arr[temp]++;
	    }
	}
	ll ans=0;
	for(i=1;i<=n;i++)
	{
	    if(arr[i]==0)
	    ans++;
	}
	cout<<ans;
	return 0;
	
	
}

Measured memory_bytes: 3732
#include<cstdio>
using namespace std;
int main(void){
   while(1){
      int n;
      scanf("%d",&n);
      if(n == 0) break;
      n = 1000 - n;
      int cnt = 0;
      while(1){
         if(n >= 500){
            n -= 500;
            cnt++;
         }
         else if(n >= 100){
            n -= 100;
            cnt++;
         }
         else if(n >= 50){
            n -= 50;
            cnt++;
         }
         else if(n >= 10){
            n -= 10;
            cnt++;
         }
         else if(n >= 5){
            n -= 5;
            cnt++;
         }
         else if(n >= 1){
            n -= 1;
            cnt++;
         }
         else break;
      }
      printf("%d\n",cnt);
   }
   return 0;
}

Measured memory_bytes: 1028
import sys
n,k=map(int,input().split())
s=input()

if n == 1:
    print(0)
    sys.exit()

hap = 0
if s[0] == "R" and s[1] == "R":
    hap += 1
if s[-1] == "L" and s[-2] == "L":
    hap += 1

for i in range(1,n-1):
    if s[i] == "L" and s[i-1] =="L":
        hap += 1
    elif s[i] == "R" and s[i+1] == "R":
        hap += 1

rl = 0
lr = 0

for i in range(n-1):
    if s[i] == "L" and s[i+1] == "R":
        lr += 1
    elif s[i] == "R" and s[i+1] == "L":
        rl += 1

tmp = min(rl,lr,k)
hap += 2 * tmp

if s[0] != s[-1] and k - tmp >0:
    hap += 1
print(hap)

Measured memory_bytes: 3316
{-
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1195&lang=jp
?????????: Encryption System
?????°:
18:50 Haskell?????????????????¨????????§Haskell????????????
19:11 ????\???¢?????±???????¨???\?????????????????????
19:24 ????\???¢?????±?????????????????????????????????????????£????????????????????§??????????????????
19:32 ?????°??£????????§?????´?????????????????????
19:33 AC???????????§?????¬??????????????´???
19:36 AC????¨??????¢??°?????£????????£??¨?????¬????????????????????????
19:44 foldr??§???????????§??????
-}
import Control.Monad
import Control.Applicative
import Data.List

main = do
 info <- getLine
 unless (info == "#") $ do
 let arr = sort $ analyze info
 print (length arr)
 mapM_ putStrLn $ if length arr <= 10 then arr else take 5 arr ++ (reverse . take 5 . reverse)arr 
 main

analyze :: String -> [String]
analyze str = foldr (<=<) return arr str
 where arr = map (uncurry decipher) $ zip ['b' ..'z'] ['a' .. 'y']




-- decipher 'b' 'a' "want a aeer" = ["wbnt a aeer","want b aeer","want a beer","want a aeer"]
decipher :: Char -> Char -> String -> [String]
decipher b a str
 | b `elem` str = let (front,back) = break (==b) str in map (++back) (replaceOne a b front) -- b??\???????????????????????????????????¨back?????¨??????????????£???
 | otherwise = replaceOne' a b str



-- replaceOne 'a' 'b' "an algebra" = ["bn algebra", "an blgebra", "an algebrb"]
replaceOne :: (Eq a) => a -> a -> [a] -> [[a]]
replaceOne a b = init . replaceOne' a b -- ????????????????????????

replaceOne' :: (Eq a) => a -> a -> [a] -> [[a]]
replaceOne' _ _ [] = [[]]
replaceOne' a b (c:xs)
 | a == c = (b:xs) : map (c:) (replaceOne' a b xs) -- ???????????????????????????????????¨???????????????????????¨
 | otherwise = map (c:) (replaceOne' a b xs) -- ???????????£????????????????????????????????????

Measured memory_bytes: 34768
def main(argv)
  n = gets.chomp.to_i
  a = gets.chomp.split(' ').map(&:to_i)
  b = gets.chomp.split(' ').map(&:to_i)

  s = a.reduce(:+)
  t = b.reduce(:+)
  if s > t then
    puts 'No'
    return
  end

  c = t - s
  d = [0, 0]
  n.times do |i|
    if a[i] > b[i] then
      d[0] += a[i] - b[i]
    elsif a[i] < b[i] then
      d[1] += (b[i] - a[i]) / 2
      d[1] += 1 if (b[i] - a[i]) % 2 == 1
    end
  end

  puts (d.max <= c ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 3836
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	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 getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(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
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)

	ysp48 := makeInts(n+1, 10)
	for i := 0; i < 10; i++ {
		ysp48[n][i] = n
	}
	for i := n - 1; i >= 0; i-- {
		num := int(s[i] - '0')
		for j := 0; j < 10; j++ {
			if j == num {
				ysp48[i][j] = i
				continue
			}
			ysp48[i][j] = ysp48[i+1][j]
		}
	}
	ans := 0
	for first := 0; first < 10; first++ {
		for second := 0; second < 10; second++ {
			for third := 0; third < 10; third++ {
				if ysp48[0][first] == n {
					continue
				}
				if ysp48[ysp48[0][first]+1][second] == n {
					continue
				}
				if ysp48[ysp48[ysp48[0][first]+1][second]+1][third] == n {
					continue
				}
				ans++
			}
		}
	}
	fmt.Fprintln(writer, ans)
}

func makeInts(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 3840
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

class dice {
public:
	dice(int m1, int m2, int m3, int m4, int m5, int m6);
	~dice();
	void roll(char c);
	int getmT() { return mT; };
	int getmS() { return mS; };
	int getmE() { return mE; };
	int getmW() { return mW; };
	int getmN() { return mN; };
	int getmB() { return mB; };
private:
	int mE, mW, mS, mN;
	int mT, mB;

};

dice::dice(int m1, int m2, int m3, int m4, int m5, int m6) : mT(m1), mS(m2), mE(m3), mW(m4), mN(m5), mB(m6) {

}

dice::~dice() {

}

void dice::roll(char c) {
	switch (c) {
	case 'E':
		int tE;
		tE = mE;
		mE = mT;
		mT = mW;
		mW = mB;
		mB = tE;
		break;
	case 'W':
		int tW;
		tW = mW;
		mW = mT;
		mT = mE;
		mE = mB;
		mB = tW;
		break;
	case 'N':
		int tN;
		tN = mN;
		mN = mT;
		mT = mS;
		mS = mB;
		mB = tN;
		break;
	case 'S':
		int tS;
		tS = mS;
		mS = mT;
		mT = mN;
		mN = mB;
		mB = tS;
		break;
	}
}



int main() {
	int n;
	cin >> n;
	int* me = new int[n * 6];
	for (int i = 0; i < n * 6; i++) {
		cin >> me[i];
	}
	dice** mDice = new dice * [n];
	for (int i = 0; i < n; i++) {
		mDice[i] = new dice(me[i * 6 + 0], me[i * 6 + 1], me[i * 6 + 2], me[i * 6 + 3], me[i * 6 + 4], me[i * 6 + 5]);
	}
	string meirei = "SSSSWWWW";
	int flag = 0;
	for (int k = 0; k < n - 1; k++) {
		for (int l = k + 1; l < n; l++) {
			for (int j = 0; j < meirei.length(); j++) {
				mDice[k]->roll(meirei[j]);
				if ((mDice[k]->getmT() == mDice[l]->getmT()) &&
					(mDice[k]->getmW() == mDice[l]->getmW()) &&
					(mDice[k]->getmN() == mDice[l]->getmN()) &&
					(mDice[k]->getmE() == mDice[l]->getmE()) &&
					(mDice[k]->getmS() == mDice[l]->getmS()) &&
					(mDice[k]->getmB() == mDice[l]->getmB())) {
					cout << "No" << endl;
					flag = 1;
					break;
				}
				else if ((mDice[k]->getmT() == mDice[l]->getmT()) &&
					(mDice[k]->getmW() == mDice[l]->getmN()) &&
					(mDice[k]->getmN() == mDice[l]->getmE()) &&
					(mDice[k]->getmE() == mDice[l]->getmS()) &&
					(mDice[k]->getmS() == mDice[l]->getmW()) &&
					(mDice[k]->getmB() == mDice[l]->getmB())) {
					cout << "No" << endl;
					flag = 1;
					break;
				}
				else if ((mDice[k]->getmT() == mDice[l]->getmT()) &&
					(mDice[k]->getmW() == mDice[l]->getmE()) &&
					(mDice[k]->getmE() == mDice[l]->getmW()) &&
					(mDice[k]->getmN() == mDice[l]->getmS()) &&
					(mDice[k]->getmS() == mDice[l]->getmN()) &&
					(mDice[k]->getmB() == mDice[l]->getmB())) {
					cout << "No" << endl;
					flag = 1;
					break;
				}
				else if ((mDice[k]->getmT() == mDice[l]->getmT()) &&
					(mDice[k]->getmW() == mDice[l]->getmS()) &&
					(mDice[k]->getmS() == mDice[l]->getmE()) &&
					(mDice[k]->getmE() == mDice[l]->getmN()) &&
					(mDice[k]->getmN() == mDice[l]->getmW()) &&
					(mDice[k]->getmB() == mDice[l]->getmB())) {
					cout << "No" << endl;
					flag = 1;
					break;
				}
				if (flag == 1)break;
			}
			if (flag == 1)break;
		}
		if (flag == 1)break;
		if (k == n - 2)cout << "Yes" << endl;
	}
	for (int i = 0; i < n; i++) {
		delete mDice[i];
		mDice[i] = 0;
	}
	delete[] mDice;
	mDice = 0;
	delete[] me;
	me = 0;
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repe(i,n) for (int i = 1; i <= (n); ++i)
#define reps(i,start,end,step) for (int i = start; i <= end; i+=step)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
using namespace std;
typedef long long ll;
typedef string str;
const ll INF = 1e18;
const int MX = 2005;
const double pi = 3.141592653589793238;

int main() {

  string S;
  cin >> S;
  int cnt_all = 0;
  rep(i,S.size()){
    int cnt = 0;
    reps(j,i,S.size(),1){
      if(S[j] != 'A' & S[j] != 'C' & S[j] != 'G' & S[j] != 'T') break;
      else cnt += 1;
    }
    if(cnt > cnt_all) cnt_all = cnt;
  }
  cout << cnt_all << endl;
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<vector <int>> book(N, vector<int>(M + 1));
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < M + 1; ++j){
      cin >> book.at(i).at(j);
    } 
  }

  long min = LONG_MAX;
  for (int bit = 0; bit < (1 << N); ++bit) {
    long yen = 0;
    vector<int> sum(M, 0);
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) {
        yen += book.at(i).at(0);

        for(int j = 0; j < M; ++j){
          sum.at(j) += book.at(i).at(j + 1);
        }
      }
    }

    bool borderScore = true; 
    for(int i = 0; i < M; ++i){
      if(sum.at(i) < X) borderScore = false;
    }
    if (borderScore){
      if(min > yen) min = yen;
    }
  }

  if (min < LONG_MAX) cout << min << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 3620
while True:
    n = input()
    if n == "0000":
        break

    if n.count(n[0]) == 4:
        print("NA")
        continue

    cnt = 0
    while n != "6174":
        L, S = list(n), list(n)
        L.sort(reverse=True)
        S.sort()
        n = str(int("".join(L)) - int("".join(S))).zfill(4)
        cnt += 1

    print(cnt)

Measured memory_bytes: 7684
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) a[i] = in();
    int ans = 1e9;
    REP(x,100){
        int s = 0;
        REP(i,n){
            int d = abs(x - a[i]);
            s += d * d;
        }
        chmin(ans, s);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/20/20 21:00:19
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;

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

  ll n; cin>>n;
  ll ans = 2*n-1;
  auto check = [&](ll x) {
    ll y = 2*n/x;
    auto [a,b] = atcoder::crt({0, y-1}, {x, y});
    if (b == 0) return;
    ans = min(ans, a);
  };
  check(1);
//  check(2*n);
  for (int x = 2, sqrt2n = sqrt(2*n); x <= sqrt2n; ++x) {
    if ((2*n) % x == 0) {
      check(x);
      check(2*n/x);
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    int x; cin>>x;
    int ans=0;
    rep(i,a+1)rep(j,b+1)rep(k,c+1){
        int sum=i*500+j*100+50*k;
        if (sum==x) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
if(len(S)==2):
    if(S[0]==S[1]):
        print(1,2)
    else:
        print(-1,-1)
else:
    ans = [-1,-1]
    for ind,s in enumerate(S[:-2]):
        if(s==S[ind+1]):
            ans = [ind+1,ind+2]
            break
        elif(s==S[ind+2]):
            ans = [ind+1,ind+3]
            break
    print(*ans)


Measured memory_bytes: 3316
def main():
    import sys
    input = sys.stdin.readline

    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()

    dp = ['r'] * n
    score = 0
    to_win = {
        'r': 'p',
        's': 'r',
        'p': 's',
    }
    to_lose = {

    }
    rps_score = {
        'r': r,
        's': s,
        'p': p,
    }
    for i in range(k):
        rps = to_win[t[i]]
        dp[i] = rps
        score += rps_score[rps]

    for i in range(k, n):
        rps = to_win[t[i]]
        if dp[i-k] != rps:
            dp[i] = rps
            score += rps_score[rps]
        else:
            if i+k < n:
                dp[i] = t[i+k]

    print(score)
main()

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

const ULL M = 1000000007;

ULL powm(ULL a, ULL i) {
    if (!i) return 1;
    if (i & 1) return powm(a * a % M, i >> 1) * a % M;
    return powm(a * a % M, i >> 1);
}

ULL F[10001], I[10001], iF[10001];

ULL C(ULL n, ULL r) { return F[n] * iF[r] % M * iF[n - r] % M; }
ULL P(ULL n, ULL r) { return F[n] * iF[n - r] % M; }
ULL H(ULL n, ULL r) { return C(r + n - 1, n - 1); }

struct Problem {

    void Solve() {
        F[0] = 1; for (UL i = 1; i <= 10000; i++) F[i] = F[i - 1] * i % M;
        I[1] = 1; for (UL i = 2; i <= 10000; i++) I[i] = M - M / i * I[M % i] % M;
        iF[0] = 1; for (UL i = 1; i <= 10000; i++) iF[i] = iF[i - 1] * I[i] % M;
        ULL N, K; cin >> N >> K;
        cout << H(K, N) << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}



Measured memory_bytes: 3332
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include<string.h>
int stack[110];
int top = 0;

void push(int v){ stack[top++] = v; }
int  pop(){ return stack[--top]; }
int getInt(char *s)
{
  int i,ret=0;
  int size = strlen(s);
  for(i=0;i<size;i++)
    {
      ret += (s[i]-'0')*pow(10,size-i-1);
    }
  return ret;
}

int main()
{
  char s[1000];
  while(scanf("%s",s)!=EOF)
    {
      if('0' <= s[0] && s[0] <= '9')
	{
	  int v = getInt(s);
	  push(v);
	  continue;
	}
	  int a,b;
	  b = pop();
	  a = pop();
	  if(s[0] == '+')
	      push(a+b);
	  else if(s[0] == '-')
	    push(a-b);
	  else if(s[0] == '*')
	    push(a*b);
	  else 
	    assert(0);
    }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2044
H, W = map(int, raw_input().split())
a = [raw_input() for _ in range(H)]

F = [False]*W
for y in range(H):
  for x in range(W):
    if a[y][x]=='#':
      F[x] = True
for y in range(H):
  if '#' in a[y]:
    l = ""
    for x in range(W):
      if F[x]:
        l += a[y][x]
    print l


Measured memory_bytes: 2568
#include<iostream>
using namespace std;
int main(void){
	int N,A,B,C,D,X,Y;
	cin>>N>>A>>B>>C>>D;
	if(N%A>=1){
		X=(N/A)*B+B;
	}
	else{
		X=(N/A)*B;
	}
	if(N%C>=1){
		Y=(N/C)*D+D;
	}
	else{
		Y=(N/C)*D;
	}
	if(X<Y){
		cout<<X<<endl;
	}
	else{
		cout<<Y<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include  <stdio.h>

int main()
{
	int  x[100][100];     
	int y[1000];     
	int a, b;    
	int sum;     
	int i, j;          
	scanf("%d %d", &a, &b);          
	for(i=0; i<a; i++)
	{         
		for(j=0; j<b; j++)
		{             
			scanf("%d", &x[i][j]);         
		}     
	}           
	for(i=0; i<b; i++)
	{         
		scanf("%d", &y[i]);     
	}           
	for(i=0; i<a; i++)
	{        
		sum = 0;         
		for(j=0; j<b; j++)
		{             
			sum += x[i][j]*y[j];         
		}        
		printf("%d\n", sum);    
	}           
	return 0; 
}

Measured memory_bytes: 640
N, T = map(int, input().split())
A = list(map(int, input().split()))

minAi = A[0]
maxDiff = 0
ans = 0
for ai in A[1:]:
    if ai < minAi:
        minAi = ai
    else:
        diff = ai - minAi
        if diff > maxDiff:
            maxDiff = diff
            ans = 1
        elif diff == maxDiff:
            ans += 1

print(ans)


Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int n,q;
string s;
vector<char> t(200010),d(200010);

bool c(int x){
  int now=x;
  rep(i,q){
    if(s[now]==t[i]){
      if(d[i]=='L') now--;
      else now++;
    }
    if(now==-1 || now==n) return true;
  }
  return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>q>>s;
    rep(i,q) cin>>t[i]>>d[i];
    int low=-1,high=n,mid;
    while(high-low>1){
      mid=(low+high)/2;
      if(c(mid)) low=mid;
      else high=mid;
    }
    int low2=-1,high2=n,mid2;
    while(high2-low2>1){
      mid2=(low2+high2)/2;
      if(c(mid2)) high2=mid2;
      else low2=mid2;
    }
    if(low>=high2) cout<<0<<endl;
    else cout<<n-(low+1)-(n-high2)<<endl;
}

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> donus(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> donus.at(i);
    X -= donus.at(i);
  }
  sort(donus.begin(), donus.end());
  int ans = X / donus.at(0) + N;
  cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size() + 1;
  vector<int> less(N,0),gre(N,0);
  less.at(0) = 0; gre.at(N-1) = 0;
  for (int i=1; i < N; i++) {
    if (S.at(i-1) == '<')  less.at(i) = less.at(i-1) + 1;
    else less.at(i) = 0;
  }
  for (int i=N-2; i >= 0; i--) {
    if (S.at(i) == '>')  gre.at(i) = gre.at(i+1) + 1;
    else gre.at(i) = 0;
  }
  ll ans = 0;
  for (int i=0; i < N; i++) {
    ans += max(less.at(i), gre.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 4740
import sys
inputs = sys.stdin.readlines()

from itertools import cycle
N, K = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))
B_ = A + A
MOD = 10 ** 9 + 7

N, K
list(A+A)

counts = [0, 0]
for i in range(N):
    for j in range(i, N):
        if B_[i] > B_[j]:
            counts[0] += 1
for s in range(1, N):
    for i in range(N-s):
        if B_[i+s] > B_[N-1+s]:
            counts[1] += 1
print((counts[0] * K*(K+1)//2 + counts[1] * K*(K-1)//2) % MOD)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n;
    cin>>n;
    int sum=0,tmp=n;
    while(tmp>0){
        sum+=(tmp%10);
        tmp/=10;
    }
    if(n%sum==0)cout<<"Yes"<<endl;
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int n,i,b,f,r,v,room[4][3][10] = { 0 };
 
    scanf("%d\n", &n);
 
    for (i = 0; i < n; i++, room[b-1][f-1][r-1] += v)
        scanf("%d %d %d %d", &b, &f, &r, &v);
 
    for (b = 0; b < 4; b++) {
        for (f = 0; f < 3; f++) {
            for (r = 0; r < 10; r++) {
                putchar(' ');
                printf("%d", room[b][f][r]);
            }
            putchar('\n');
        }
        if (3 - b) {
            for (i = 0; i < 20; i++)
                putchar('#');
            putchar('\n');
        }
    }
 
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll rec(const ll& limit, ll target, int a, int b, int c) {
  if(target > limit) return 0;

  int ret = 0;
  if(a && b && c) ret++;
  ret += rec(limit, 10*target + 3, 1, b, c);
  ret += rec(limit, 10*target + 5, a, 1, c);
  ret += rec(limit, 10*target + 7, a, b, 1);
  return ret;
}

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

  ll N; cin>>N;
  int ans = rec(N, 0, 0, 0, 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] &&
        s[2] == s[3] &&
        s[0] != s[2])
        cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


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

int n,m;
struct ele{
	int x,y,id,sum;
	bool operator < (ele b)const{
		return this->id < b.id;
	}
};
int cnt,d;
ele data[100006];vector<ele> line[100060];
int getdis(ele a,ele b){
	return abs(a.x-b.x) + abs(a.y-b.y);
}
ele pos[100006];
int main(){
	scanf("%d%d",&n,&m);
	scanf("%d",&d);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int t;
			scanf("%d",&t);
			data[++cnt]=(ele){i,j,t,0};
		}
	}
	sort(data+1,data+1+cnt);
	for(int i=1;i<=cnt;i++){
		line[data[i].id%d].push_back(data[i]);
		pos[data[i].id] = (ele){data[i].id%d,line[data[i].id%d].size()-1,0,0};
	//	cout<<data[i].id<<" "<<line[data[i].id%d].size()-1<<endl;
	}
	for(int i=0;i<d;i++){
		for(int j=1;j<(int)line[i].size();j++){
			line[i][j].sum = line[i][j-1].sum + getdis(line[i][j],line[i][j-1]);
		}
	}
	int Q;
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		int pid = pos[a].x;
		int l = pos[a].y;
		int r = pos[b].y;
	//	l--;
	//	l = max(0,l);
	//	cout<<pid<<" "<<l<<" "<<r<<endl;
		printf("%d\n",line[pid][r].sum-line[pid][l].sum);
	}
	return 0;
	
}

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

int main()
{
  int N;
  cin >> N;
  vector<long long> vx(N), vy(N), vh(N);
  int si = -1;
  for (int i = 0; i < N; i++)
  {
    cin >> vx[i] >> vy[i] >> vh[i];
    if (vh[i] > 0)
      si = i;
  } // h>0 の場所が一か所でも分かればよい

  long long resx = -1, resy = -1, resh = -1;
  for (long long x = 0; x <= 100; x++)
  {
    for (long long y = 0; y <= 100; y++)
    {
      long long h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]); // H を計算する
      bool ok = true;
      for (int i = 0; i < N; i++)
      {
        if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]))
          ok = false;
        if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
          ok = false;
      }
      if (ok)
        resx = x, resy = y, resh = h;
    }
  }
  cout << resx << " " << resy << " " << resh << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
typedef pair<int,int> P;
int main(){
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        int c=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)c++;
        }
        if(c==8)ans++;
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 256
import bisect
n,k=map(int,input().split())
s=[0 for _ in range((10**5)+1)]
maxa=0
for i in range(n):
    a,b=map(int,input().split())
    s[a]+=b
    maxa=max(maxa,a)
s=s[:maxa]
#print(s)
for i in range(1,len(s)):
    s[i]+=s[i-1]
#print(s)
print(bisect.bisect_left(s, k))

Measured memory_bytes: 9608
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>

int r, c, n;

int format(int x, int y)
{
    if (y == 0)
        return x;
    else if (x == r)
        return r + y;
    else if (y == c)
        return r + c + (r - x);
    return 2 * r + c + (c - y);
}

signed main()
{
    std::cin >> r >> c >> n;

    std::vector<std::pair<int, int>> v;
    for (int i = 0; i < n; ++i)
    {
        int x1, y1, x2, y2;
        std::cin >> x1 >> y1 >> x2 >> y2;
        if (x1 != 0 && x1 != r && y1 != 0 && y1 != c)
            continue;
        if (x2 != 0 && x2 != r && y2 != 0 && y2 != c)
            continue;
        v.push_back({format(x1, y1), i});
        v.push_back({format(x2, y2), i});
    }
    std::sort(v.begin(), v.end());

    std::stack<int> store;
    for (const auto &iter : v)
    {
        if (!store.empty())
        {
            if (store.top() == iter.second)
                store.pop();
            else
                store.push(iter.second);
        }
        else
            store.push(iter.second);
    }
    std::cout << (store.empty() ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <string>
#include <unordered_map>
using namespace std;
long long ans = 10000000000;
int main(void){
    long long N,K;
    cin >> N >> K;
    long long h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    sort(h,h+N);
    ans = h[N-1] - h[0];
    for(int i=0;i+K-1<N;i++){
        ans = min(ans,h[i+K-1]-h[i]);
    }
    cout << ans;
}


Measured memory_bytes: 3920
#include <iostream>
#include <cstring>
using namespace std;
int h,w;
int a[210][210];
int c[210][210];
int ans=0;
int main(){
/*	memset(a,0,sizeof(a));
	memset(c,0,sizeof(c));*/
	cin>>h>>w;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			cin>>c[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	}
	for(int p=0;p<=9;p++){
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				if(c[i][p]+c[p][j]<c[i][j])c[i][j]=c[i][p]+c[p][j];
			}
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]!=-1)ans+=c[a[i][j]][1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#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;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    rep(k,K) {
        vector<int> B(N+1);
        rep(i,N) {
            int l = max(0, i-A[i]);
            int r = min(i+A[i]+1, N);
            B[l]++;
            B[r]--;
        }
        rep(i,N) B[i+1] += B[i];
        B.pop_back();
        if (A == B) break;
        A = B;
    }
    rep(i,N) cout << A[i] << endl;
    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;

	vector<int> V(N);
	for (int i = 0; i < N; i++)
	{
		cin >> V[i];
	}

	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		ans += max(0, V[i] - tmp);
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a=inp()
        a-=1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    h,w = inpm()
    maze = []
    for _ in range(h):
        s = tuple(input())
        maze.append(s)
    ans = 0
    dx = (1,0,-1,0)
    dy = (0,1,0,-1)

    for sx in range(h):
        for sy in range(w):
            if maze[sx][sy] == '#':
                continue
            else:
                d = [[-1 for _ in range(w)] for _ in range(h)]
                que = deque()
                d[sx][sy] = 0
                que.append((sx,sy))
                M = 0
                while que:
                    (qx,qy) = que.popleft()
                    for i in range(4):
                        nx=qx+dx[i]
                        ny=qy+dy[i]
                        if nx>=0 and h>nx and ny>=0 and w>ny and maze[nx][ny]=="." and d[nx][ny]==-1:
                            d[nx][ny]=d[qx][qy]+1
                            if d[qx][qy]+1>M:
                                M= d[qx][qy]+1
                            que.append([nx,ny])
                ans = max(ans,M)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 47192
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    int a;
    if(h>w)a=h;
    else a=w;
    int ans = n/a + (n%a!=0);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
a = list(map(int, input().split()))

cr = 0
count = 1
for i in range(N):
  if(a[i] == count):
    count += 1
  else:
    cr += 1

if(cr == N):
  print('-1')
else:
  print(cr)


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

template<class T>
void chmin(T &a, T b)
{
	if (a > b) a = b;
}

const ll MAX = 101000;
ll N, K;
vector<ll> H;
ll dp[MAX];

int main(int argc, char **argv)
{
	cin >> N >> K;
	H.resize(N); for (ll i = 0; i < N; ++i) cin >> H[i];

	for (ll i = 0; i < MAX; ++i) dp[i] = 1ll << 60;
	dp[0] = 0;

	for (ll i = 0; i < N; ++i)
	{
		for (ll k = 1; k <= K; ++k)
		{
			chmin(dp[i+k], dp[i] + abs(H[i] - H[i+k]));
		}
	}
	std::cout << dp[N-1] << std::endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll res;
char s[500005];

vector <ll> v;
multiset <ll> remain;

void all_print(){
	auto it = remain.begin();
	//pe("element = ");
	for(int i=0;i<remain.size();i++){
		//pe(*it);
		it++;
	}
	//el;
}

int main(){
    cin >> n;
    m = (1ll << n);
    for(i=0;i<m;i++){
    	cin >> x[i];
    	x[i] *= -1;
    }
    sort(x,x+m);
    v.pb(x[0]);
    for(i=0;i<m-1;i++){
    	remain.insert(x[i+1]);
    }
    ll idx = 1;
    bool dame = false;
    for(i=0;i<n;i++){
    	for(j=0;j<idx;j++){
    		all_print();

    		auto it = remain.lb(v[j] + 1);
    		if(it == remain.end()){
    			dame = true;
    			break;
    		}
    		ll element = *it;
    		//pe(element);
    		remain.erase(it);
    		v.pb(element);
    	}
    //	el;
    	idx *= 2;
    	
    }
    Yes(!dame);

    return 0;
}


















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

int main() {
  int N,W;
  cin >> N>>W;
  vector<int> w(N+1);
  vector<int> v(N+1);
  long long int dp[N+1][W+1]; //価値の最大値
  for(int i=1;i<=N;i++)cin>>w[i]>>v[i];
  dp[0][0]=0;

  for(int i=0;i<=N;i++){ //N個の品物について
      for(int j=0;j<=W;j++){
        if(i==0||j==0)dp[i][j]=0;
        else{
          dp[i][j]=dp[i-1][j]; 
          if(j>=w[i])dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
        }
      }
	}
cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 79104
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
using ll = long long;
const int N = 1e5+5;

int n,m,dp[1<<12];

int main(){
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;++i){
		int a,b, k=0;
		scanf("%d%d", &a, &b);
		for(int j=0;j<b;++j){
			int c;
			scanf("%d", &c);
			k |= 1<<(c-1);
		}
		for(int i=0;i<(1<<n);++i){
			if(dp[i] < 0) continue;
			int h = i | k;
			if(dp[h]<0 || dp[h] > dp[i]+a) dp[h] = dp[i] + a;
		}
	}
	printf("%d\n", dp[(1<<n) - 1]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  
  int cnt = 0;
  int N,H,W;

  cin >> N >> H >> W;

  for(int i = 0; i < N; i++){

    int A,B;

    cin >> A >> B;

    if(H <= A && W <= B){
      cnt++;
    }
  }

  cout << cnt << "\n";
  
  return 0;
}


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

int main () {
    
    int n; cin >>n;
    vector<int> h(n); REP(i,n) cin >> h[i];
    reverse(h.begin(), h.end());

    int minv = h[0];
    int maxv = 0;
    for (int i = 0; i < n; i++) {
        maxv = max(maxv, h[i] - minv);
        minv = min(minv, h[i]);
    }

    if (maxv > 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    } 
    return 0;
}





Measured memory_bytes: 640