akhauriyash/Code-Regression huggingface dataset:
MOD = 10 ** 9 + 7


# def dfs(graph, start):
#     options = [(-1, 0), (0, 1), (1, 0), (0, -1)]
#     W = len(graph)
#     H = len(graph[0])
#     ans = 0

#     for x in range(len(graph)):
#         for y in range(len(graph[x])):
#             if graph[x][y] == '#':
#                 continue

#             val = 1
#             path = []
#             stack = [(x, y, options)]
#             # print(x, y)

#             while stack != []:
#                 v = stack.pop()

#                 if v not in path:
#                     path.append(v)

#                 for op in v[2]:
#                     n = (v[0] + op[0], v[1] + op[1], [op])

#                     if n[0] >= 0 and n[0] < W and n[1] >= 0 and n[1] < H:
#                         f = graph[n[0]][n[1]]
#                         if n not in path and f == '.':
#                             stack.append(n)
#                             val += 1

#             ans = max(ans, val)
#             # print(ans)

#             if ans == 3999:
#                 return ans

#     return ans


def main():
    H, W = map(int, input().split())
    S = [None] * H
    w_score = [[0 for i in range(W)] for i in range(H)]
    h_score = [[0 for i in range(W)] for i in range(H)]
    stack = []

    for i in range(H):
        S[i] = list(input())

    for x in range(H):
        v = 0
        stack = []
        for y in range(W+1):
            if x >= 0 and x < H and y >= 0 and y < W and S[x][y] == '.':
                v += 1
                stack.append((x, y))
            else:
                if len(stack) == 0:
                    # w_score[x][y] = 0
                    stack = []
                elif len(stack) == 1:
                    first = stack.pop(0)
                    w_score[x][first[1]] = v
                    stack = []
                    v = 0
                else:
                    first = stack.pop(0)
                    last = stack.pop()
                    for y in range(first[1], last[1]+1):
                        w_score[x][y] = v
                    stack = []
                    v = 0

    for y in range(W):
        v = 0
        stack = []
        for x in range(H+1):
            if x >= 0 and x < H and y >= 0 and y < W and S[x][y] == '.':
                v += 1
                stack.append((x, y))
            else:
                if len(stack) == 0:
                    # w_score[x][y] = 0
                    stack = []
                elif len(stack) == 1:
                    first = stack.pop(0)
                    h_score[first[0]][y] = v
                    stack = []
                    v = 0
                else:
                    first = stack.pop(0)
                    last = stack.pop()
                    for x in range(first[0], last[0]+1):
                        h_score[x][y] = v
                    stack = []
                    v = 0

    ans = 0
    for x in range(H):
        for y in range(W):
            ans = max(ans, w_score[x][y] + h_score[x][y])

    print(ans-1)
    # print(w_score)
    # print(h_score)
    # print(dfs(S, S[0][0]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 253448
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;

long long h;

int main()
{
    scanf("%lld", &h);
    long long ans = 0;
    long long ast = 1;
    while (h)
    {
        ans += ast;
        h /= 2;
        ast *= 2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
# https://takeg.hatenadiary.jp/entry/2019/11/22/212816

import bisect

def solve():
    N = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()

    # O(N^2 * logN)の全探索で解く
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

if __name__ == "__main__":
    solve()


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W,N=MAP()
sr,sc=MAP()
S=input()
T=input()

h=sr
for i in range(N):
    if S[i]=='U':
        h-=1
    if h==0:
        NO()
        exit()
    if T[i]=='D':
        if h<H:
            h+=1
h=sr
for i in range(N):
    if S[i]=='D':
        h+=1
    if h>H:
        NO()
        exit()
    if T[i]=='U':
        if h>1:
            h-=1
w=sc
for i in range(N):
    if S[i]=='L':
        w-=1
    if w==0:
        NO()
        exit()
    if T[i]=='R':
        if w<W:
            w+=1
w=sc
for i in range(N):
    if S[i]=='R':
        w+=1
    if w>W:
        NO()
        exit()
    if T[i]=='L':
        if w>1:
            w-=1
YES()


Measured memory_bytes: 3896
#include <stdio.h>
int main(void)
{
    int a, f = 0;
    scanf("%d", &a);
    for (int i=1; i<10; i++){
        if (a % i == 0 && a/i < 10){
          printf("Yes"); f = 10; break;
        }
    }
	if (f == 0) printf("No");
    return 0;
}   

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

const int maxn = 112345;

char s[maxn], t[maxn];
map<ll, char> mmap;
ll n, m;

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

int main() {
    scanf("%lld%lld", &n, &m);
    scanf("%s", s);
    scanf("%s", t);
    ll ans = lcm(n, m);
    REP(i, n) mmap[ans / n * i + 1] = s[i];
    REP(i, m) {
        ll now = ans / m * i + 1;
        if (mmap.count(now) && mmap[now] != t[i]) {
            puts("-1");
            return 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; ll x = n;
  string s; cin >> s;
  
  rep(i,n-1){
    if(s.at(i) == s.at(i+1)) x--;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

int vs[100000+10];
map<int,int> v2n;
map<int,int> n2nn;

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    int v;
    scanf("%d", &v);
    v2n[v]++;
  }
  int res = n;
  FOR(it, v2n) {
    res -= it->second - 1;
  }
  if(res%2 == 0)
    --res;
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 4992
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
    #    print(str(s_x)+' '+str(s_y))

        if ((s_x != 0 or s_y !=0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
        elif  ((s_x == 0 and s_y == 0) )and (c!=count):
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1



if flag == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 11668
import Control.Monad
import Control.Applicative

question :: [Int] -> String -> Int
question [r1,r2,r3,r4,r5,r6] input =
  let [nu, nf] = fmap read (words input) :: [Int]
      ltable = [(r1, cycle [r2,r3,r5,r4]), (r2, cycle [r6,r3,r1,r4]), (r3, cycle [r6,r5,r1,r2]), (r4, cycle [r6,r2,r1,r5]), (r5, cycle [r6,r4,r1,r3]), (r6, cycle [r5,r3,r2,r4])]
   in
      maybe 0 ((flip (!!) 1) . (dropWhile (/= nf))) (lookup nu ltable)

main :: IO ()
main = do
  dice <- map read . words <$> getLine :: IO [Int]
  q <- read <$> getLine
  replicateM_ q $ putStrLn . show =<< ((question dice) <$> getLine)

Measured memory_bytes: 4044
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N; ll H;
    cin >> N >> H;

    vector<ll> a(N), b(N);
    ll m = 0;
    REP(i, N) {
        cin >> a[i] >> b[i];
        m = max(m, a[i]);
    }

    sort(b.begin(), b.end(), greater<ll>());

    ll ans = (H + m - 1) / m;
    int t = 0;
    REP(i, b.size()) {
        if (b[i] <= m ) break;

        H = max(0LL, H - b[i]);
        t += 1;
        ans = min(ans, (H + m - 1) / m + t);
    }
    
    cout << fixed << setprecision(20);
    cout << ans << endl;

}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_set>
#include <queue>
#include <unordered_map>
#include <set>

#pragma GCC optimize("O3")

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repd(i, n) for(ll i = (n) - 1; i >= 0; --i)
#define FOR(i, a, b) for(ll i = a; i <= ll(b); ++i)
#define FORD(i, a, b) for(ll i = a; i >= ll(b); --i)
#define loop while(true)
#define asort(array, size) std::sort(array, array + size)
#define cauto const auto&
#define bit(n) (1LL << (n))

int main()
{
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
	long long d,g;
	cin >> d >> g;
	long long p[d],c[d];
	for(long long i=0;i<d;i++){
		cin >> p[i] >> c[i];
	}
	long long ans=10000;
	for(int bit=0;bit<(1<<d);bit++){
		vector<int> a(d,0);
		long long com=0;
		long long count=0;
		for(int i=0;i<d;i++){
			if(bit&(1<<i)){
				a[i]=1;
				count+=p[i];
				com+=(i+1)*100*p[i]+c[i];
			}
		}
		for(int i=d-1;i>=0;i--){
			if(a[i]==0){
				if(com>=g) break;
				else if(com<g && (com+(i+1)*100*(p[i]-1))<g){
					count+=10000;
					break;
				}
				else{
					for(int j=0;j<p[i];j++){
						if(com+(i+1)*100*j>=g){
							count+=j;
							break;
						}
					}
					break;
				}
			}
		}
		ans=min(ans,count);
	}
	cout << ans << endl;
}


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

using namespace std;

const int MAXN = 100005;

vector<vector<int>> adj(MAXN);
vector<int> dp(MAXN, -1);

int dfs(int u)
{
    if (~dp[u])
        return dp[u];
    dp[u] = 0;
    for (auto &x : adj[u])
        dp[u] = max(dp[u], dfs(x)+1);
    return dp[u];
}

int main()
{
    int n, m, a, b;
    scanf("%i%i", &n, &m);
    while (m--)
    {
        scanf("%i%i", &a, &b);
        adj[a].push_back(b);
    }
    int ans = 0;
    for (int x = 1; x <= n; x++)
        ans = max(ans, dfs(x));
    printf("%i\n", ans);
}


Measured memory_bytes: 8192
#include <stdio.h>
#include <iostream>
#include <stdint.h>
#include <vector>
#include <deque>
using namespace std;



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

    vector<uint64_t> A;
    for(int i=0; i<N; i++){
        uint64_t a;
        cin >> a;
        A.push_back(a);
    }

    uint64_t ans = 0;
    uint64_t M = 1000* 1000* 1000 + 7;
    for(uint64_t i=0; i<60; i++){
        uint64_t m = (uint64_t)1u << i;
        deque<uint64_t> b0;
        deque<uint64_t> b1;
        for(int j=0; j<N; j++){
            uint64_t a = A[j];
            if((m & a) > 0){
                b1.push_back(j);
            }else{
                b0.push_back(j);
            }
        }
        for(int j=0; j<N; j++){
            uint64_t a = A[j];
            uint64_t c = m & a;
            uint64_t d =0;
            if(c > 0){
                b1.pop_front();
                d = b0.size();
            }else{
                b0.pop_front();
                d = b1.size();
            }
            ans = (((( d % M) * (m%M))%M) + ans) % M;
        }
    }
    printf("%llu\n", ans);
}


Measured memory_bytes: 6764
l = int(input())

v_count = 1
additional_e = []
while True:
  if l == 1:
    break
  elif l%2 == 0:
    l = l//2
    v_count += 1 
  elif l%2 == 1:
    l -= 1
    additional_e.append(v_count)

print(v_count, (v_count-1)*2 + len(additional_e))

for i in range(1,v_count):
  print(i, i+1, 0)
  print(i, i+1, 2**(i-1))

num = 2**(v_count-1)

for i in additional_e[::-1]:
  print(i, v_count, num)
  num = num + (2**(i-1))



Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
 
int main() {
int bottom, benefit, N, rt;
 
scanf("%d", &N);

scanf("%d", &rt);
bottom = rt; 
scanf("%d", &rt);
benefit = rt - bottom;
if(rt < bottom) bottom = rt;
 
for(int i=2; i<N; ++i) {
scanf("%d", &rt);
if(benefit < rt - bottom) benefit = rt - bottom;
if(rt < bottom) bottom = rt;
}
 
printf("%d\n", benefit);
 
return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int ascending(char *temp);
int descending(char *temp);
int a[21]={}; int L;

int main(void){
  int count; int _a;
  int large_a, small_a;
  int j,i_j; int lock;

  while(1){
    scanf("%d %d",&a[0],&L);
    if(a[0]==0 && L==0) break;

    char work[7]={};
    count=0; lock=0;

    while(lock==0){
      _a=a[count];
      for(int i=L-1;i>=0;i--){
        work[i]='0'+_a%10;
        _a/=10;
      }
      count++;
      large_a=descending(work);
      small_a=ascending(work);
      a[count]=large_a-small_a;
      for(int i=0;i<count;i++){
        if(a[count]==a[i]){
          j=i;
          i_j=count-i;
          lock++;
        }
      }
    }
    printf("%d %d %d\n",j,a[j],i_j);
  }
  return 0;
}

int ascending(char *temp){//昇順
  for(int i=0;i<L;i++){
    for(int j=i+1;j<L;j++){
      if(temp[i]>temp[j]){
        char c = temp[i];
        temp[i] = temp[j];
        temp[j] = c;
      }
    }
  }
  return atoi(temp);
}
int descending(char *temp){//降順
  for(int i=0;i<L;i++){
    for(int j=i+1;j<L;j++){
      if(temp[i]<temp[j]){
        char c = temp[i];
        temp[i] = temp[j];
        temp[j] = c;
      }
    }
  }
  return atoi(temp);
}



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

int main(){
	lint n,sum=0;
	cin>>n;
	rep(i,0,n){
		lint a;
		cin>>a;
		sum+=a;
	}
	o(sum/n);
}

Measured memory_bytes: 1156
#先頭からみぎにいけるだけいく
#→途中から始めても先頭から始めたときよりは移動できないのでその間は飛ばす
#上を繰り返す

N = int(input())
H = list(map(int,input().split()))

idx = 0
count = 0
ans = 0

while idx < N:
    for j in range(idx,N-1):
        if H[j] >= H[j+1]:
            count += 1
        else:
            break
    if count > ans:
        ans = count
    if count > 0:
        idx += count
    else:
        idx += 1
    count = 0

print(ans)


Measured memory_bytes: 63856
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<pair<string, int>, int>a, pair<pair<string, int>, int>b) {
	if (a.first.first == b.first.first) {
		return a.first.second > b.first.second;
	}
	return a.first.first < b.first.first;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>s(m);
	rep(i, m) {
		int x;
		cin >> x;
		s[i].resize(x);
		rep(j, x) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	vint p(m);
	rep(i, m) {
		cin >> p[i];
	}
	int ans = 0;
	rep(i, 1 << n) {
		rep(j, m) {
			int tmp = 0;
			rep(k, s[j].size()) {
				int tmptmp = i & (1 << s[j][k]);
				if (tmptmp != 0)tmp++;
			}
			tmp %= 2;
			if (tmp != p[j]) {
				break;
			}
			if (j == m - 1) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 1;
    vll ai(n);
    ll LLINF = 1000000000000000000LL;
    REP(i,n) {
        cin >> ai[i];
        if(ai[i]==0) {
            ans = 0;
        }
    }
    if(ans == 0){
        cout << ans << endl;
        return 0;
    }
    REP(i,n){
        ll a = ai[i];
        if(a==0){
            ans = 0;
            break;
        }
        if(ans>LLINF/a+1LL){
            cout << -1 << endl;
            return 0;
        }
        ans *= a;
        if(ans>LLINF){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM INT_MAX
#define FOR(i,n)	for(int i=0;i<n;i++)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

bool cmp(int &a,int &b){
        return a<b;                //ascending order
        return a>b;                //descending order
}

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
struct IO{
    ll pow,coin,id;
}srr[100001];

bool cmpsr(IO aa,IO bb){
    if(aa.pow==bb.pow) return aa.coin>bb.coin;
    return (aa.pow<bb.pow);
}

int main()
{
    ll a,b,c,f=0,s=0;
    cin>>a;
    if(a==5){f++;}
    if(a==7){s++;}
    cin>>b;
    if(b==5){f++;}
    if(b==7){s++;}
    cin>>c;
    if(c==5){f++;}
    if(c==7){s++;}
    if(f==2 && s==1){cout<<"YES"<<endl;}
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL INF=300000000;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    int n;
    cin>>n;
    LL a[100001];
    LL gc;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    gc=a[0];
    for(int i=0;i<n;++i){
        gc=gcd(gc,a[i]);
    }

    cout<<gc<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> d(n);
	rep(i,n) cin >> v[i];
	for (int a: v) d[a]++;
	if (!(n % 2 == d[0])) {
		cout << 0 << endl;
		return;
	}
	rep(i,n) {
		if (d[i] > 2) {
			cout << 0 << endl;
			return;
		}
	}
	ll ans = 1;
	rep(i,n/2) ans *= 2, ans %= MOD;
	cout << ans << endl;

}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4056
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var odd = 1;
        for (int i = 0; i < n; i++)
            if (a[i] % 2 == 0) odd *= 2;
        Console.WriteLine(Math.Pow(3, n) - odd);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
   int n;
   cin>>n;
   int k;
   cin>>k;
   vector<double>ar(n);
   for(int i=0;i<n;i++)
   cin>>ar[i];
   
   double eps=1e-10;double ans=1000000000;
   double l=1e-10,r=1000000000;
   while(r-l>eps)
   {
       double mid=(l+r)/2;int c=0;
       for(int i=0;i<n;i++)
       {
           if(mid>=ar[i])continue;
           else
           { int cc=ceil(ar[i]/mid);
           for(int j=max((int)2,cc-5);j<cc+5;j++)
           {
           	double xy=ar[i]/j;
           	if(xy<=mid){c+=(j-1);break;}
           }
           }
       }
       if(c<=k)
       {   if(ans>mid)ans=mid;
           r=mid-eps;
       }
       else
       l=mid+eps;
   }
   int anss=ans;
   if((ans-anss)>0.000001)anss++;
   cout<<anss<<endl;
   //for(int i=0;i<ans;i++)
}


return 0;
}





Measured memory_bytes: 6416
#include <numeric>
#include <utility>
#include <iostream>
#include <vector>

using Pair = std::pair<int, int>;

bool is_find(const int& num, const std::vector<std::vector<Pair>>& people, const int& N) {
  int people_dim {};
  for (int c = 1;c!=0;c<<=1) {
    if (c&num) {
      for (const auto& e : people[people_dim]) {
        if (e.second == 1) {
          int k = 1<<e.first;
          if ((k&num) == 0)return false;
        } else {
          int k = 1<<e.first;
          if ((k&num) != 0) return false;
        }
      }
    } else {
      bool is_ok = true;
      for (const auto& e : people[people_dim]) {
        if (e.second == 1) {
          int k = 1<<e.first;
          if ((k&num) == 0) {
            is_ok = false;
            break;
          }
        } else {
          int k = 1<<e.first;
          if ((k&num) != 0) {
            is_ok = false;
            break;
          }
        }
      }
      if (is_ok == true) return false;
    }
    ++people_dim;
    if (people_dim == N) return true;
  }
}
int bit_count(const int& num) {
  int cnt {};
  for (int c = 1;c!=0;c<<=1) {
    if (num & c) ++cnt;
  }
  return cnt;
}
constexpr int max(int a, int b) {
  return (a > b)?a:b;
}

int main(int argc, char** argv) {
  int N {};
  std::cin >> N;
  std::vector<std::vector<Pair>> People(N, std::vector<Pair>());
  for (auto i = 0;i < N;++i) {
    int c;
    std::cin >> c;
    std::vector<Pair> p(c);
    for (auto j = 0;j < c;++j) {
      std::cin >> p[j].first >> p[j].second;
      --p[j].first;
    }
    People[i] = p;
  }
  int num = (1<<N) - 1;
  if (is_find(num, People, N)) {
    std::cout << N << '\n';
    return 0;
  }
  std::vector<int> t(num);
  std::iota(t.begin(), t.end(), 0);
  int max_tmp {};
  for (const auto& e : t) {
    if (is_find(e, People, N)) {
      max_tmp = max(max_tmp, bit_count(e));
    }
  }
  std::cout << max_tmp << '\n';
}


Measured memory_bytes: 888
c = [list(map(int,input().split())) for _ in range(3)]
x = [0]
y = []

for i in range(3):
    y.append(c[0][i] - x[0])
for i in range(1,3):
    x.append(c[i][0] - y[0])

ans = True
for i in range(3):
    for j in range(3):
        if x[i]+y[j] != c[i][j]:
            ans = False

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n-1];
	unordered_map<int,int> m;
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
	    cout<<m[i]<<"\n";
	}
	
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int cur;
        cin >> cur;
        m[cur] += 1;
    }
    bool yes(true);
    for (auto& var: m) {
        if (var.second > 1) {
            yes = false;
            break;
        }
    }
    cout << ((yes) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    int n;
    int s[13] = {};
    int h[13] = {};
    int c[13] = {};
    int d[13] = {};
    int number;
    int i;
    char *mark;
    char input[6];

    fgets(input, sizeof(input), stdin);
    n = atoi(input);
    
    for (i = 0; i < n; i++){
        fgets(input, sizeof(input), stdin);
        mark = strtok(input, " ");
        number = atoi(strtok(NULL, " "));
        
        switch (*mark){
            case 67:
                c[number - 1] = 1;
                break;
            case 68:
                d[number - 1] = 1;
                break;
            case 72:
                h[number - 1] = 1;
                break;
            case 83:
                s[number - 1] = 1;
                break;
        }
    }

    for (i = 0; i < 13; i++){
        if (s[i] != 1){
            printf("S %d\n", (i + 1));
        }
    }

    for (i = 0; i < 13; i++){
        if (h[i] != 1){
            printf("H %d\n", (i + 1));
        }
    }

    for (i = 0; i < 13; i++){
        if (c[i] != 1){
            printf("C %d\n", (i + 1));
        }
    }

    for (i = 0; i < 13; i++){
        if (d[i] != 1){
            printf("D %d\n", (i + 1));
        }
    }

    return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    string ans = string(N, '#');
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        s--;

        if (N == 1) {
            if (ans[s] == '#') {
                ans[s] = '0' + c;
            } else if (ans[s] != '0' + c) {
                cout << -1 << endl;
                return 0;
            }
        } else {
            if (s == 0 && c == 0) {
                cout << -1 << endl;
                return 0;
            } else if (ans[s] == '#') {
                ans[s] = '0' + c;
            } else if (ans[s] != '0' + c) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        if (ans[i] == '#') {
            if (i == 0) {
                if (N == 1) {
                    ans[i] = '0';
                } else {
                    ans[i] = '1';
                }
            } else {
                ans[i] = '0';
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        ab: [(usize, usize); n],
    }

    let mut a = ab.iter().map(|&(a, _)| a).collect::<Vec<_>>();
    a.sort();
    let mut b = ab.iter().map(|&(_, b)| b).collect::<Vec<_>>();
    b.sort();

    let count = 
        if n % 2 == 0 {
            let a_m = a[n/2] + a[n/2-1];
            let b_m = b[n/2] + b[n/2-1];
            b_m - a_m + 1
        } else {
            let a_m = a[n/2];
            let b_m = b[n/2];
            b_m - a_m + 1
        };

    println!("{}", count);
}

Measured memory_bytes: 12824
<?php
 
 $a1 = 0; $a2 = 0; $a3 = 0;

    for($i = 0; $i < 10; $i++){
        fscanf(STDIN, "%d", $x);
        if($x > $a3){
            $a3 = $x;
        }
        if($x > $a2){
            $a3 = $a2;
            $a2 = $x;
        }
        if($x > $a1){
            $a2 = $a1;
            $a1 = $x;
        }
    }
 
    printf("%d\n%d\n%d\n", $a1, $a2, $a3);
 

Measured memory_bytes: 15260
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0)fin("Alice");
    else fin("Borys");
}



Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : April 22 2020 22:33:59 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    int T;
    cin >> T;
    int A;
    cin >> A;
    ld mn = INF;
    int ind;
    fori(i,n){
        int x;
        cin >> x;
        ld cur = abs(A-T+x*0.006);
        if(cur < mn){
            mn = cur;
            ind = i;
        }
    }
    cout << ind+1 << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    if (n==m) {
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
 
  }
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        for (int i=0;i<n;i++){
            int x = sc.nextInt();
            ans += 2*Math.min(x,k-x);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35616
#define REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <bits/stdc++.h>

using namespace std;
const int maxn = 100010;

int n, a[maxn], ans;

int main() {
#ifdef CraZYali
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	cin >> n;
	REP(i, 1, n) scanf("%d", a+i);
	REP(i, 1, n)
		if (a[i] == i) {
			swap(a[i], a[i+1]);
			ans++;
		}
	cout << ans;
	return 0;
}

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;

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

    ll num;
    cin>>num;

    ll point = 1;
    ll mod = 0;

    while(point<=num)
    {
        mod = (mod * 10) % num;
        mod = (7 % num + mod) %num;
        if(mod == 0)
            break;
        point++;
    }

    if(point <= num)
        cout<<point<<endl;
    else
        cout<<"-1"<<endl;

    return 0;
}


Measured memory_bytes: 3636
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll n, m;
    cin >> n >> m;

    priority_queue<pair<ll, ll> >pq;
    rep(i, 0, n){
        ll inp;
        cin >> inp;
        pq.push({inp - inp/2, inp});
    }

    while(m--){
        auto p = pq.top();
        pq.pop();
        auto x = p.ss/2;
        pq.push({x - x/2, x});
    }

    ll res = 0;
    while(pq.size()) res += pq.top().ss, pq.pop();

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
  void yesno(bool a){if(a){cout << ("Yes");}else{cout << ("No");}}


int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    string s,t;
    cin >> s >> t;


    int ans = t.size();

    for(int i = 0; i + t.size()-1 < s.size(); i++)
    {
    	int ans1 = 0;
    	string s2 = s.substr(i,t.size());
    	for(int j = 0; j < s2.size(); j++) ans1 += s2[j] != t[j];

    	ans = min(ans,ans1);	
    }


    cout << ans;

    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll a, b;
    cin >> a >> b;
    a %= 2;
    b %= 2;
    if (a * b == 1) {
        cout << "Odd\n";
    } else {
        cout << "Even\n";
    }

    return 0;
}

Measured memory_bytes: 3600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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 T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;

    if(p == 2 or p == 5) {
        ll ans = 0;
        rep(i, n) {
            if((s[i]-'0')%p == 0) {
                ans += i+1;
            }
        }
        cout << ans << endl;
    } else {
        int now = 1;
        int sum = 0;
        vi g(p);
        for(int i = n-1; i >= 0; i--) {
            g[((s[i]-'0')*now+sum)%p]++;
            sum += now*(s[i]-'0');
            sum %= p;
            now *= 10;
            now %= p;
        }
        ll ans = 0;
        for(int i = 1; i < p; i++) {
            ans += ll(g[i]-1)*g[i];
        }
        ans >>= 1;
        ans += ll(g[0]+1)*g[0]/2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3724
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		
		double hour = h / 12  + m / 60 * (360 / 12) / 360;
		double minutes = m / 60;
		
		double angle = 360;
		if(hour == 0) {
			angle *= 1 - minutes;
		}else if(minutes == 0) {
			angle *= 1 - hour;
		}else {
			angle *= hour < minutes ? minutes - hour : hour - minutes;
		}
		double ansSquare = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(angle));
		
		System.out.println(Math.sqrt(ansSquare));
		sc.close();
	}

}

Measured memory_bytes: 37304
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
 string s;
 cin >> s;
 if(s.at(0) == s.at(2)){
     cout << "Yes" << endl;
 }
 else{
     cout << "No" << endl;
 }
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int main() {
 
 int a,b;
 cin>>a>>b;
 for(int i=b-a+1;i<=b+a-1;i++)
    cout<<i<<" ";
return 0;
}

Measured memory_bytes: 256