akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[11];
int ans,lena;
int main()
{
    scanf("%s",a);
    lena=strlen(a);
    for(int i=0;i<=lena;i++)
    {
        if(a[i]=='A'&&a[i+1]=='C')
        {
            ans++;
            break;
        }
    }
    if(ans==1)
    {
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

int n,r;

int main(){Tie
	cin>>n>>r;
	if(n>=10)return cout<<r<<'\n',0;
	for(int i=0;1;i++){
		if(i-(100)*(10-n)==r){
			return cout<<i<<'\n',0;
		}
	}
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  string S;
  cin >> S;
  if((S.front() == S.back()) ^ (S.size() & 1)) cout << "First" << endl;
  else cout << "Second" << endl;
}


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

int main(){
    while (true){
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int cnt = 0;
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= n; j++){
                for (int k = 1; k <= n; k++){
                    if (i < j && j < k && i + j + k == x) cnt++; 
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3092
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


Measured memory_bytes: 9204
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 10000100
//#define NIL -1

int main() {
    LL n;
    LL ans=0;
    cin >> n;

    vector<LL> num_divisor(n+1, 0);

    for(LL i=1; i<=n; i++){
        for(LL j=i; j<=n; j=j+i){
            num_divisor[j]++;
        }
    }

    for(LL i=1; i<=n; i++){
        ans=ans+i*num_divisor[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81348
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <cmath>

using namespace std;

int f[6], g[6];

int rec(int l, int r, int b1, int b2, int p)
{
    if (b1 == (1 << 6) - 1) return +1;
    if (b2 == (1 << 6) - 1) return -1;
    
    int res = (p == 0 ? -1 : +1);
    bool pass = 1;
    for (int i = 0; i < 6; i++) {
        if (p == 0) {
            if (b1 >> i & 1) continue;
            if (l == f[i]) {
                pass = 0;
                res = max(res, rec(l - 1, r, b1 | (1 << i), b2, 1));                
            }
            if (f[i] == r) {
                pass = 0;
                res = max(res, rec(l, r + 1, b1 | (1 << i), b2, 1));
            }
        } else {
            if (b2 >> i & 1) continue;
            if (l == g[i]) {
                pass = 0;
                res = min(res, rec(l - 1, r, b1, b2 | (1 << i), 0));
            }
            if (g[i] == r) {
                pass = 0;
                res = min(res, rec(l, r + 1, b1, b2 | (1 << i), 0));
            }
        }
    }

    if (pass) {
        res = rec(l, r, b1, b2, 1 ^ p);
    }
    
    return res;
}

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        bool used[13] = {};
        for (int j = 0; j < 6; j++) {
            cin >> f[j];
            used[--f[j]] = 1;
        }
        for (int j = 0, k = 0; j < 13; j++) {
            if (j != 6 && !used[j]) {
                g[k++] = j;
            }
        }
        cout << (rec(5, 7, 0, 0, 0) == 1 ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    bingo = [False]*9
    dic = dict()
    c = 0
    for _ in range(3):
        tmp = list(IL())
        for rep in tmp:
            dic[rep] = c
            c += 1
    n = I()
    for _ in range(n):
        b = I()
        idx = dic.get(b)
        if idx is None:
            continue
        bingo[idx] = True
    
    flag = False
    for i in range(0,3):
        for j in range(0,7,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return
        
    for i in range(0,7,3):
        for j in range(0,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return

    if (bingo[2] and bingo[4] and bingo[6]) or (bingo[0] and bingo[4] and bingo[8]):
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    solve()

Measured memory_bytes: 26876
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S]=0
 H=[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r()
  if'0'==f[0]:print(g(n,E,*map(int,f[2:].split())))
  else:c,d,e=map(int,f[2:].split());E[c]+=[(e,d)];E[d]+=[(e,c)]
if'__main__'==__name__:
 for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6304
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,p;cin>>a>>p;
  cout<<(a*3+p)/2<<endl;


  return 0;

}


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

signed main(){
	int n,keta = 0;
	vector<int> ans;
	cin >> n;
	int tmp = n + 1;
	while(tmp){
		tmp /= 2;
		keta++;
	}
	for(int i = 0;i < keta - 1;i++){
		if(((n + 1) >> i) & 1) ans.push_back(100 - i);
		ans.push_back(i + 1);
	}
	cout << ans.size() + 100 << endl;
	for(int i = 0;i < ans.size();i++) cout << (i ? " " : "") << ans[i];
	for(int i = 1;i <= 100;i++) cout << " " << i;
	cout << endl;
	return 0;
}

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

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

  std::vector<int> a(n);
  for (auto&& ai : a) std::cin >> ai;

  std::vector<int> leftMax(n);
  leftMax[0] = a[0];
  for (int i = 1; i < n; ++i)
    leftMax[i] = a[i] > leftMax[i - 1] ? a[i] : leftMax[i - 1];

  std::vector<int> rightMax(n);
  rightMax[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i)
    rightMax[i] = a[i] > rightMax[i + 1] ? a[i] : rightMax[i + 1];

  std::cout << rightMax[1] << std::endl;
  for (int i = 1; i < n - 1; ++i) {
    std::cout << (leftMax[i - 1] > rightMax[i + 1] ? leftMax[i - 1]
                                                   : rightMax[i + 1])
              << std::endl;
  }
  std::cout << leftMax[n - 2] << std::endl;
}

Measured memory_bytes: 3968
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        a: usize,
        b: usize
    }
    println!("{}", min(n * a, b));
}


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

int stmax(int s1, int s2){
    if(s1 > s2){
        return s1;
    }else{
        return s2;
    }
}

int main(){
    string s,t;cin>>s>>t;
    int n,m;
    n = s.length()+1;m= t.length()+1;
    vector<vector<int> > dp(n);

    for(int i = 0 ; i < n ; i++){
        dp[i].resize(m);
        for(int j = 0; j < m ; j++){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }else if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = stmax(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    //cout << dp[n-1][m-1] << endl;

    int len = dp[n-1][m-1];
    
    
    char ans[len+1];

    int i=n-1;
    int j=m-1;
    ans[len] = '\0';
    len--;
    while(i>0&&j>0){
	    if(s[i-1]==t[j-1]){
		    ans[len]=s[i-1];
		    i--;    
		    j--;
		    len--;
	    }else if(dp[i][j]==dp[i-1][j]){
		    i--;
	    }else{
		    j--;
	    }
    }

    cout << ans << endl;
}

Measured memory_bytes: 35584
use scanner::Scanner;

fn main() {
    let mut scanner = Scanner::new();
    let n: i64 = scanner.read();
    let xyh: Vec<(i64, i64, i64)> = (0..n).map(|_| (scanner.read(), scanner.read(), scanner.read())).collect();

    let (x1, y1, h1) = *xyh.iter().find(|&&p| p.2 > 0).unwrap();

    for px in 0..101 {
        for py in 0..101 {
            let h = (px - x1).abs() + (py - y1).abs() + h1;
            if xyh.iter().all(|&(xi, yi, hi)| hi == std::cmp::max(h - (px - xi).abs() - (py - yi).abs(), 0)) {
                println!("{} {} {}", px, py, h);
                return;
            }
        }
    }
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    #[allow(dead_code)]
    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = "".to_string();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        fn load(&mut self) {
            let mut s = String::new();
            ::std::io::stdin().read_line(&mut s).unwrap();
            self.words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            self.s = s;
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }
    }
}


Measured memory_bytes: 4352
from itertools import accumulate


def binary_search(key):
    bad, good = -1, len(B)
    while good - bad > 1:
        mid = (bad + good) // 2
        if B[mid] > key:
            good = mid
        else:
            bad = mid
    return good


N, M, K = map(int, input().split())
A = [0] + list(accumulate(map(int, input().split())))
B = list(accumulate(map(int, input().split())))
ans = 0
for i in range(N + 1):
    tmp = A[i]
    if tmp > K:
        break
    m = binary_search(K - tmp)
    ans = max(ans, i + m)
print(ans)


Measured memory_bytes: 45484
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,m;cin >> n >> m;
    int k;
    vector<int> count;
    count = vector<int>(m+10,0);
    //int count[m+1] = {};
    for(int i =0; i < n;i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            int index;
            cin >> index;
            count[index]++;
        }
    }
    int cnt = 0;
    for(int j = 0; j < m+1; j++)if(count[j]==n)cnt++;
    cout  << cnt << endl;
}

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

int main()
{
	long long s=1,a,b,sum=0;
	cin>>a>>b;
	while(a<=b)
	{
		a=a*2;
		sum++;
		
	}
	cout<<sum<<endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

void solv() {
	while (true)
	{
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) break;

		for (size_t i = 0; i < h; i++)
		{

			for (size_t j = 0; j < w; j++)
			{
				if (i % 2 == 0) {
					if (j % 2 == 0) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if (j % 2 == 0) {
						cout << ".";
					}
					else {
						cout << "#";

					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}



}


int main() {
	//	COMinit();
	solv();

	return 0;
}



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

int main(){
  vector <int> x(5);
  for (int &i : x){
      cin >> i;
  }
  for (int i = 0; i < x.size(); i++){
    if (x.at(i) == 0){
      cout << i+1 << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3572
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String
# DP = np.zeros((N, Y), dtype=int)

N, Y = map(int, input().split())
Y = int(Y / 1000)

for x in range(N+1):
    for y in range(N+1):
        if x + y > N:
            continue
        z = N - x - y
        if x + 5 * y + 10 * z == Y:
            print(z, y, x)
            exit(0)

print(-1, -1, -1)


Measured memory_bytes: 21524
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

//xより小さいうちの最小のインデックス
ll tansaku1(ll x,vector<ll> &v){
  ll ok = 0;
  ll ng = v.size();
  if(v[0]>=x)return -1;
  while(ng-ok>1){
    ll mid = (ok+ng)/2;
    if(v[mid]>=x)ng = mid;
    else ok = mid;
  }
  return ok;
}

//xより大きいうちの最小のインデックス
ll tansaku2(ll x, vector<ll> &v){
  ll ng = -1;
  ll ok = v.size()-1;
  if(v[ok]<=x)return ok+1;
  while(ok-ng>1){
    ll mid = (ok+ng)/2;
    if(v[mid] <= x)ng = mid;
    else ok = mid;
  }
  return ok;
}



int main(){
  ll N;
  cin >> N;
  vector<ll> A(N),B(N),C(N);
  rep(i,N)cin >> A[i];

  rep(i,N)cin >> B[i];
  rep(i,N)cin >> C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());

  ll ans = 0;
  rep(i,N){
    ans += (tansaku1(B[i],A)+1)*(N-tansaku2(B[i],C));
    //cout << ans << endl;
  }

  cout << ans << endl;

/*
  cout << tansaku1(M,A) << endl;
  cout << tansaku2(M,A) << endl;
*/
}


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


int main() {
  string s, t;
  cin >> s >> t;

  int tsize = t.size(), ssize = s.size();

  int maxi = 0;
  rep(i, ssize - tsize + 1) {
    int same = 0;
    rep(j, tsize) {
      if (t[j] == s[i + j]) same++;
    }
    if (same > maxi) maxi = same;
  }

  cout << tsize - maxi << endl;

  return 0;
}
/*
*/


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

    ll a[200005];

    int main()
    {
        ll n;
        cin>>n;
        ll s=0;
        ll ans;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            a[i]-=(i+1);
        }
        sort(a,a+n);
        ll b,bb=-1000000000;
        if(n%2)
        {
             b=a[n/2];
        }
        else
        {
            //f=1;
            ll x=a[n/2]+a[n/2-1];
            b=a[n/2];
            bb=a[n/2-1];
            /*ll p=x/2;
            if(p*2!=x)
            {
                bb=x+1;
            }
            else bb=x;
        */}

        ll sum=0;
        ll sum2=0;

            for(int i=0;i<n;i++)
            {
                sum2=sum2+abs(a[i]-bb);
            }

            for(int i=0;i<n;i++)
            {
                sum=sum+abs(a[i]-b);
            }

        if(n%2) cout<<sum<<endl;
        else cout<<min(sum,sum2)<<endl;
    }


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){
    string result;

    int R;
    cin >> R;

    if(R<1200){
        result = "ABC";
    }else if(R<2800){
        result = "ARC";
    }else{
        result = "AGC";
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
L = int(input())
N = L.bit_length()
res = []
for i in range(N - 1):
  res.append((i + 1, i + 2, 0))
  res.append((i + 1, i + 2, 2**i))
rem = L - 2**(N - 1) 
k = 2**(N - 1)
for i in range(rem.bit_length())[::-1]:
  if (rem >> i) & 1:
    res.append((i + 1, N, k))
    k += 2**i
print(N, len(res))
for r in res:
  print(*r)

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

int main(){
    int N,M,count;
    cin>>N>>M;
    count=0;
    vector<int> H(N);
    vector<int> vec(N,1);
    for(int i=0;i<N;i++){
        cin>>H.at(i);
    }
    
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        if(H.at(a-1)>=H.at(b-1)){
            vec.at(b-1)=0;
        }
        if(H.at(a-1)<=H.at(b-1)){
            vec.at(a-1)=0;
        }
    }

for(int i=0;i<N;i++){
    if(vec.at(i)==1){
        count++;
    }
}

    cout<<count<<endl;    
}

Measured memory_bytes: 4052
def main():
    ans, a = [], []
    H, W = map(int, input().split())
 
    for i in range(H):
        a += [list(map(int, input().split()))]

    for i in range(W):
        for j in range(H-1):
            if a[j][i] % 2 == 1:
                a[j][i] -= 1
                a[j+1][i] += 1
                ans += [ str(j+1) + " " + str(i+1) + " " + str(j+2) + " " + str(i+1) ]

    for i in range(W-1):
        if a[H-1][i] % 2 == 1:
            a[H-1][i] -= 1
            a[H-1][i+1] += 1
            ans += [ " ".join([str(H), str(i+1), str(H), str(i+2)]) ]
    print (len(ans))
 
    for i in ans:
        print (i)
 
main()


Measured memory_bytes: 16348
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>
#include <cstdlib>
#include <limits>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N, Z, W;
    cin >> N >> Z >> W;
    vector<uint> as(N, 0);
    for (auto &&i: irange((unsigned int) 0, N)){
        cin >> as.at(i);
    }
    auto an_w = (uint)abs((int)as.at(N-1) - (int) W);
    vector<uint> abss(N-1, 0);
    for (auto &&i: irange((unsigned int) 0, N-1)){
        abss.at(i) = (uint)abs((int)as.at(N-1) - (int) as.at(i));
    }

    uint maximum{an_w};
    for (auto &&k: irange((unsigned int) 0, N-1)){
        uint minimum{abss.at(k)};
        for (auto &&l: irange((unsigned int) k+1, N-1)){
            minimum = min(minimum, abss.at(l));
        }
        maximum = max(maximum, minimum);
    }
    cout << max(an_w, maximum);
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, M; cin >> N >> M;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	ll total = 0;
	F0R(i, N) total += arr[i];

	ll res = 0;
	for (int x : arr) {
		if (4 * M * x < total) {

		} else {
			++res;
		}
	}
	if (res >= M) {
		print("Yes");
	} else {
		print("No");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;


int main()
{
	int R[MAX],n;

	cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> R[i];
	int maxv = -2000000000;
	int minv = R[0];

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

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 1940
package main

import (
	"fmt"
)

func main() {
	var h1, m1, h2, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)

	diffTime := (h2-h1)*60 + (m2 - m1)

	if diffTime < k {
		fmt.Println(0)
	} else {
		fmt.Println(diffTime - k)
	}

}


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

int main()
{
    long long N, myXOR;

    std::cin >> N;

    long long arr[N], ans[N];

    for(int i=0; i<N;i++)
        std::cin >> arr[i];

     myXOR = 0;
    for(int i=0; i< N; i++)
         myXOR ^= arr[i];

    for(int i=0; i<N; i++)
        ans[i] = arr[i] ^  myXOR;

    for(int i=0; i<N; i++)
        std::cout << ans[i] << " ";

    std::cout << std::endl;


}

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

int main () {
    ios_base :: sync_with_stdio (0);
    cin.tie (nullptr);
    cout.tie (nullptr);
    long long a, b;
    cin >> a >> b;
    if ((a +b) % 2 == 0) {
        cout << (a + b) / 2;
    }
    else {
        cout << "IMPOSSIBLE";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
struct Node{
    int key;
    Node *p,*l,*r;
};
Node *root,*NIL;
void insert(int key){
    Node *y = NIL;//根节点的父节点
    Node *x = root;//根节点
    Node *z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->l = NIL;
    z->r = NIL;
    while(x!=NIL){
        y = x;//记录key的父节点
        if(z->key<x->key){
            x = x->l;//寻找key的父节点
        }else{
            x = x->r;
        }
    }
    z->p = y;
    if(y == NIL){
        root = z;
    }else if(y->key<z->key){//决定是左儿子还是右二子
        y->r = z;
    }else{
        y->l = z;
    }
}
void preTW(Node *u){
    if(u!=NIL){
        cout<<" "<<u->key;
        preTW(u->l);
        preTW(u->r);
    }
}
void inTW(Node *u){
    if(u!=NIL){
        inTW(u->l);
        cout<<" "<<u->key;
        inTW(u->r);
    }
}
int main()
{
    int n,key;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="insert"){
            cin>>key;
            insert(key);
        }else if(s=="print"){
            inTW(root);
            cout<<endl;
            preTW(root);
            cout<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 26596
# -*- coding: utf-8 -*-

import sys

n, y = [int(e) for e in raw_input().split()]

y /= 1000

found = False
tenK  = -1
fiveK = -1
oneK  = -1

if (y / 10.) <= n:
    for b10K in xrange(0, (y / 10) + 1):
        yr = y - (10 * b10K)
        nr = n - b10K
        if (yr / 5) > nr:
            continue
        for b5K in xrange(0, (yr / 5) + 1):
            yrr = yr - (5 * b5K)
            nrr = nr - b5K
            if yrr > nrr:
                continue
            elif yrr == nrr:
                found = True
                tenK = b10K
                fiveK = b5K
                oneK = yrr
                sys.stdout.write('%d %d %d\n' % (tenK, fiveK, oneK))
                sys.stdout.flush()
                sys.exit(0)
        
sys.stdout.write('-1 -1 -1\n')
sys.stdout.flush()


Measured memory_bytes: 3076
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}



#[allow(non_snake_case, unused_variables)]
fn main() {
    input! {
        K: usize,
        T: usize,
        a: [i32; T],
    }
    let sum = a.iter().fold(0, |sum, x| sum+x);
    let &max_a = a.iter().max().unwrap();
    let ans = 
        if sum-max_a>=max_a {
            0
        } else {
            2*max_a - sum - 1
        };
    println!("{}", ans);
}


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

int main(){
  int N, X;
  cin >> N >> X;

  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  vector<int> dist(N + 1);
  int cnt = 0;
  for (int i = 0; i < N + 1; i++){
    if (i == 0){
     dist.at(i) = 0;
    }
    else
    {
      dist.at(i) = dist.at(i - 1) + vec.at(i - 1);
    }
  }

  for (int i = 0; i < N + 1; i++){
    if (dist.at(i) > X) break;
    cnt += 1;
  }

  cout << cnt << endl;
}

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

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

    int A[2][N];
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < N; ++j) {
            std::cin >> A[i][j];
        }
    }

    // 曲がるポイントを選ぶ
    int max = 0;
    for (int i = 0; i < N; ++i) {
        int candies = 0;
        for (int j = 0; j <= i; ++j) {
            candies += A[0][j];
        }

        for (int j = i; j <= (N-1); ++j) {
            candies += A[1][j];
        }

        max = std::max(max, candies);
    } 

    std::cout << max << std::endl;

    return 0;
}


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

public class Main {
  public static void main(String[] args){
    BufferedReader in = null;
    
    String line = "";
    
    String result = "";
    
    try{
      in = new BufferedReader(new InputStreamReader(System.in));
      line = in.readLine();
      
      String A = line.split(" ")[0];
      String B = line.split(" ")[1];
      String C = line.split(" ")[2];
      
      int a = Integer.parseInt(A, 10);
      int b = Integer.parseInt(B, 10);
      int c = Integer.parseInt(C, 10);
      
      int a_org = 0;
      int b_org = 0;
      int c_org = 0;
      
      ArrayList<Integer> la = new ArrayList<Integer>();
      ArrayList<Integer> lb = new ArrayList<Integer>();
      ArrayList<Integer> lc = new ArrayList<Integer>();
      
      la.add(a);
      lb.add(b);
      lc.add(c);
      
      boolean flg = false;
      
      int cnt = 0;
      
      if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
        result = "0";
      }else{
        while(true){
          a_org = a;
          b_org = b;
          c_org = c;

          cnt++;
          
          a = (b_org / 2) + (c_org / 2);
          b = (a_org / 2) + (c_org / 2);
          c = (a_org / 2) + (b_org / 2);
          
          for(int i = 0; i < la.size(); i++){
            if(la.get(i) == a && lb.get(i) == b && lc.get(i) == c){
              flg = true;
              break;
            }
          }
          
          if(flg == true){
            result = "-1";
            break;
          }
          
          if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
            result = "" + cnt;
            break;
          }
          
        }
      }
    
    }catch(Exception e){
      e.printStackTrace();
      result = "Error!";
    }finally{
      try{
        in.close();
      }catch(Exception e){
        result = "Error!";
      }
      System.out.println(result);
    }
  }
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int main()
{
   long n;
   cin>>n;
   long count =0;
  for(int i=1;i<n;i++)
  {
      
      count+=(n/i);
      if(n%i==0)
      {
          count--;
      }
  }
  cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
p = input().split(' ')
P = list()
cnt = 0

for i in p:
    P.append(int(i))

i = 0
while i <= n-3:
    j = i + 1
    p3 = [P[i], P[i+1], P[i+2]]
    if sorted(p3)[1] == P[j]:
        cnt += 1
    i += 1

print(cnt)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();
        if (N == 2) {
            System.out.println("Yes");
            return;
        }
        if (2 <= max - min) {
            System.out.println("No");
            return;
        }
        if (max - min == 0) {
            if (max == N - 1 || max * 2 <= N) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            return;
        }
        long max_count = Arrays.stream(a).filter(i -> i == max).count();
        long min_count = Arrays.stream(a).filter(i -> i == min).count();
        if (min_count < max && 2 * (max-min_count) <= max_count){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 51076
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[6];
    for(int i=0;i<6;i++)
    cin>>s[i];
    int flag=0;
    
    for(int i=0;i<6;i++)
    {
        if(s[i]>=97 && s[i]<=122)
        flag++;
    }
    
    if(s[2]==s[3] && s[4]==s[5] && flag==6)
    cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> l(5);
  for (int i = 0; i < 5; i++) {
    cin >> l[i];
  }
  ll mini = *min_element(all(l));
  cout << (n + mini - 1) / mini + 4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> pii;

const int maxn = 100;

int A, B, dis[12][12];
int D[maxn + 5][maxn + 5];

int main() {
    scanf("%d%d", &A, &B);
    REP(i,1,A) REP(k,1,B) scanf("%d", &dis[i][k]);
    for(int a = 0; a <= 100; ++a)
        for(int b = 0; b <= 100; ++b) {
            REP(i,1,A) REP(k,1,B)
                D[a][b] = max(D[a][b], dis[i][k] - a*i - b*k);
            D[a][b] = min(D[a][b], 100);
        }
    for(int i = 1; i <= A; ++i)
        for(int k = 1; k <= B; ++k) {
            int d = 1 << 30;
            REP(a,0,100) REP(b,0,100)
                d = min(d, D[a][b] + a*i + b*k);
            if(d != dis[i][k]) exit(0 * puts("Impossible"));
        }
    puts("Possible");
    printf("%d %d\n", 202, 101*101 + 100*2);
    for(int i = 1; i <= 100; ++i) printf("%d %d X\n", i, i+1);
    for(int i = 1; i <= 100; ++i) printf("%d %d Y\n", i+101, i+1+101);
    for(int i = 0; i <= 100; ++i)
        for(int k = 0; k <= 100; ++k)
            printf("%d %d %d\n", i+1, 101-k + 101, D[i][k]);
    puts("1 202");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N,M;
    cin>>N>>M;
    int P[30]={0};
    for(int i=0;i<N;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int a;
            cin>>a;
            P[a-1]++;
        }
    }
    int sum=0;
    for(int i=0;i<M;i++){
        if(P[i]==N){
            sum++;
        }
    }
    cout<<sum<<endl;
}


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

typedef long long ll;

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

    int n; cin >> n;
    vector< pair <char,int> > p(n);
    for(int i=0;i<n;i++) cin >> p[i].first >> p[i].second;
    int s[13]={0},h[13]={0},c[13]={0},d[13]={0};
    for(int i=0;i<n;i++){
        if(p[i].first=='S') s[p[i].second-1]++;
        if(p[i].first=='H') h[p[i].second-1]++;
        if(p[i].first=='C') c[p[i].second-1]++;
        if(p[i].first=='D') d[p[i].second-1]++;
    }
    for(int i=0;i<13;i++){
        if(s[i]==0) cout << 'S' << ' ' << i+1 << endl;
    }
    for(int i=0;i<13;i++){
        if(h[i]==0) cout << 'H' << ' ' << i+1 << endl;
    }
    for(int i=0;i<13;i++){
        if(c[i]==0) cout << 'C' << ' ' << i+1 << endl;
    }
    for(int i=0;i<13;i++){
        if(d[i]==0) cout << 'D' << ' ' << i+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()

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

ans = n - 2*rl - end

if end == 0:
    if k >= rl:
        ans += 2*rl
        ans -= 1
    else:
        ans += 2*k
elif end == 1:
    if k >= rl:
        ans += 2*rl
    else:
        ans += 2*k
elif end == 2:
    if k == rl:
        ans += 2*rl
    elif k >= rl+1:
        ans += 2*rl
        ans += 1
    else:
        ans += 2*k
print(ans)

Measured memory_bytes: 9336
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll f[100][11];
ll p[100][11];
ll o[11] = {};

ll maxV = -MAX_L;
ll n;

ll calc() {
	ll sum = 0;
	repe(s, 1, n) {
		ll cnt = 0;
		repe(i, 1, 11) {
			if (o[i] && f[s][i]) {
				cnt++;
			}
		}
		sum += p[s][cnt];
	}

	return sum;
}
bool checkOpen() {
	bool ok = false;
	rep(i, 1, 11) {
		if (o[i]) {
			ok = true;
			break;
		}
	}
	return ok;
}

void dfs(ll n) {
	if (n == 11) {
		if (checkOpen()) {
			maxV = max(maxV, calc());
		}
		return;
	}

	o[n] = true;
	dfs(n + 1);

	o[n] = false;
	dfs(n + 1);
}

int main() {
	cin >> n;
	repe(i, 1, n) repe(j, 1, 10) cin >> f[i][j];
	repe(i, 1, n) rep(j, 0, 11) cin >> p[i][j];
	dfs(1);
	cout << maxV << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
n = int(input())
chars=[chr(ord('a')+i) for i in range(26)]
ans = []
while True:
    sho = (n - 1) // 26
    amr = n % 26
    # print(sho,amr)
    ans.insert(0, chars[amr - 1])
    if sho == 0:
        break
    n = sho
print("".join(ans))


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

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    reverse(h.begin(),h.end());
    h.push_back(-1);
    rep(i,n){
        if(h[i]<h[i+1]){
            if(h[i]==h[i+1]-1) h[i+1]--;
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
const int INF = (int)1e9;

ll lun[100005];
ll lun0[100005];

int check_lunlun0(ll i) {
	int origin = i;
	int a = -1;

	int jari = 1;
	while (i) {
		int ii = i % 10;
		if (a == -1) a = ii;
		else if (abs(a - ii) > 1) {
			return 1;
		}
		i /= 10,a = ii;
	}
	return 0;
}
int check_lunlun(ll i) {
	int origin = i;
	int a = -1;

	int jari = 1;
	while (i) {
		int ii = i % 10;
		if (a == -1) a = ii;
		else if (abs(a - ii) > 1) {
			if (a > ii && a < 9)
				return (jari / 10) * (10 - a - 1);
			else return 1;
		}
		i /= 10; jari *= 10, a=ii;
	}
	return 0;
}
int main() {
#ifdef WIN32
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif
	int K; scanf("%d", &K);
	int k = 1, k0=1;
	for(ll i=1;k<=K;i++){
		ll skip = check_lunlun(i);
		if (skip == 0) {
			lun[k++] = i;
			//printf("(%d)%lld, ", k-1, lun[k - 1]);
		}
		else {
			i += skip - 1;
		}
	}
	/*
	for (ll i = 1; k0 <= K; i++) {
		ll skip = check_lunlun0(i);
		if (skip == 0) {
			lun0[k0++] = i;
			assert(lun0[k0 - 1] == lun[k0 - 1]);
			//printf("(%d)%lld, ", k-1, lun[k - 1]);
		}
		else {
			i += skip - 1;
		}
	}*/

	printf("%lld\n", lun[K]);

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<int> v[mx];
vector<int> dep(mx,0);

void dfs(int n, int p, int d){
  dep[n] = d;
  for(auto to:v[n]){
    if(to==p) continue;
    dfs(to,n,d+1);
  }
}

int main(){
  int n;
  cin >> n;
  rep(i,n-1){
    int a,b; cin >> a >> b; a--; b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }
  dfs(0,-1,0);
  int a = max_element(dep.begin(),dep.end()) - dep.begin();
  dfs(a,-1,0);
  int b = max_element(dep.begin(),dep.end()) - dep.begin();
  int d = dep[b]+1;
  if(d%3!=2){
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}

Measured memory_bytes: 21376
s = input()

def op(i):
    if i == 0:
        return "+"
    else:
        return "-"

for i in range(2):
    for k in range(2):
        for j in range(2):
            f = s[0] + op(i) + s[1] + op(k) + s[2] + op(j) + s[3] 
            if eval(f) == 7:
                print(f + "=7")
                exit()

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

#define CO const
#define IN inline
typedef long long LL;
typedef long double LD;

template<class T> T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}
#define gcd __gcd

CO int mod=1e9+7;
IN int add(int a,int b){
	return (a+=b)>=mod?a-mod:a;
}
IN int mul(int a,int b){
	return (LL)a*b%mod;
}
IN int fpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}

CO int N=201;
vector<int> to[N];
int E[N][N];
int pos[N],low[N],dfn,stk[N],top;
vector<int> vcc[N];
int tot;

void tarjan(int u,int fa){
	pos[u]=low[u]=++dfn,stk[++top]=u;
	for(int v:to[u]){
		if(!pos[v]){
			tarjan(v,u);
			low[u]=min(low[u],low[v]);
			if(low[v]>=pos[u]){
				vcc[++tot].push_back(u);
				do vcc[tot].push_back(stk[top]);
				while(stk[top--]!=v);
			}
		}
		else low[u]=min(low[u],pos[v]);
	}
}

int K,C[N][N];

int circle(int n){
	int ans=0;
	for(int i=0;i<n;++i) ans=add(ans,fpow(K,gcd(n,i)));
	ans=mul(ans,fpow(n,mod-2));
	return ans;
}
int calc(CO vector<int>&vcc){
	if(vcc.size()==2) return K;
	int cnt=0;
	for(int u:vcc)for(int v:vcc)
		cnt+=E[u][v];
	cnt/=2;
	if(cnt==(int)vcc.size()) return circle(cnt);
	return C[cnt+K-1][K-1];
}
int main(){
	int n=read<int>(),m=read<int>();read(K);
	for(int i=1;i<=m;++i){
		int u=read<int>(),v=read<int>();
		E[u][v]=E[v][u]=1;
		to[u].push_back(v),to[v].push_back(u);
	}
	for(int i=1;i<=n;++i)if(!pos[i]) tarjan(i,0);
	for(int i=0;i<=m+K;++i){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;++j) C[i][j]=add(C[i-1][j-1],C[i-1][j]);
	}
	int ans=1;
	for(int i=1;i<=tot;++i) ans=mul(ans,calc(vcc[i]));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512