akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N;
    long long sum=0;
    const long long mod = 1e9+7;
    cin >> N;
    vector<int> v(N);

    for(int i=0; i<N; i++)
    {
        cin >> v[i];
        sum += v[i];
        sum %= mod;
    }
    long long ans=0;
    for(int i=0; i<N; i++)
    {
        sum -= v[i];
        if (sum < 0) sum += mod;
        ans += v[i]*sum;
        ans %= mod;
    }
    cout << ans;
    
    return 0;
}

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

using namespace std;

long H, W;
vector<vector<int>> masu;

int dir_x[4] = {0, 1, 0, -1};
int dir_y[4] = {1, 0, -1, 0};

class Vertex{
public:
    int i, j;
    int distance;

    bool operator<(const Vertex &b) const{
        if(distance < b.distance){
            return true;
        }else{
            return false;
        }
    }
};

vector<vector<bool>> visited;
vector<vector<long>> DISTANCE;
void dijkstra(){
    queue < Vertex > pq;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(DISTANCE[i][j] == 0){
                pq.push(Vertex{i, j, 0});
            }
        }
    }
    while(!pq.empty()){
        Vertex p=pq.front();
        pq.pop();
        int I = p.i;
        int J = p.j;
        for(int idx=0; idx<4; ++idx){
            if(I+dir_x[idx] >=0 && I+dir_x[idx]<H && J+dir_y[idx] >=0 && J+dir_y[idx]<W){
                if(DISTANCE[I+dir_x[idx]][J+dir_y[idx]] > DISTANCE[I][J] + 1){//} && visited[I+dir_x[idx]][J+dir_y[idx]] == false){
                    visited[I+dir_x[idx]][J+dir_y[idx]] = true;
                    DISTANCE[I+dir_x[idx]][J+dir_y[idx]] = DISTANCE[I][J] + 1;
                    pq.push(Vertex{I+dir_x[idx], J+dir_y[idx], DISTANCE[I][J] + 1});
                    
                }
            }
        }
    }
}

int main(){
    cin>>H>>W;
    string s;
    masu = vector<vector<int>>(H, vector<int>(W, 0));
    DISTANCE = vector<vector<long>>(H, vector<long>(W, 1000*1000));
    visited = vector<vector<bool>>(H, vector<bool>(W, false));
    for(int i=0; i<H; ++i){
        cin>>s;
        for(int j=0; j<W; ++j){
            if(s[j] == '#'){
                masu[i][j] = 1;
                DISTANCE[i][j] = 0;
                visited[i][j] = true;
            }
        }
    }

    dijkstra();
    long ans=0;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            ans = max(ans, DISTANCE[i][j]);
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 24336
import sys

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n, x = read_int_list()
    a = read_int_list()
    a.insert(0, 0)
    n += 1
    res = 0
    for i in range(1, n):
        if a[i - 1] + a[i] > x:
            diff = a[i - 1] + a[i] - x
            res += diff
            a[i] -= diff
    print(res)


main()


Measured memory_bytes: 14224
#[warn(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        mut s: Chars,
    }
    let n = s.len();

    // 回文判定用
    let mut rs = s.clone();
    rs.reverse();

    let head = s[0..(n-1)/2].to_vec();
    let mut rev_head = head.clone();
    rev_head.reverse();

    let tail = s[(n+3)/2-1..n].to_vec();
    let mut rev_tail = tail.clone();
    rev_tail.reverse();

    println!("{}", if s == rs && head == rev_tail && tail == rev_tail { "Yes" } else { "No" });
}


Measured memory_bytes: 2188
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def to_26(X):
    X -= 1
    if int(X / 26):
        return to_26(int(X / 26)) + string.ascii_lowercase[X % 26]
    else:
        return string.ascii_lowercase[X % 26]


def solve():
    N = Scanner.int()
    print(to_26(N))


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


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

int main() {
    int n, weight;
    cin >> n >> weight;
    vector<long> w(n), v(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    
    const long b = *min_element(w.begin(), w.end());
    vector<long> val[4];
    for (int i = 0; i < 4; i++) val[i].emplace_back(0);
    for (int i = 0; i < n; i++) {
        val[w[i] - b].emplace_back(v[i]);
    }
    
    for (int i = 0; i < 4; i++) {
        sort(val[i].begin() + 1, val[i].end(), greater<long>());
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < val[i].size(); j++) {
            val[i][j+1] += val[i][j];
        }
    }
    
    long ans = 0;
    for (long i = 0; i < val[0].size(); i++) {
        for (long j = 0; j < val[1].size(); j++) {
            for (long k = 0; k < val[2].size(); k++) {
                for (long l = 0; l < val[3].size(); l++) {
                    const long sv = val[0][i] + val[1][j] + val[2][k] + val[3][l];
                    const long sw = b * i + (b + 1) * j + (b + 2) * k + (b + 3) * l;
                    if (sw <= weight) ans = max(ans, sv);
                }
            }
        }
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, K) = Slice2<int>();
            var Vi = Slist();
            var uLim = Min(N, K);
            var cnt = 0L;
            for (var a = 0; a <= uLim; ++a)
            {
                var lst = Vi.GetRange(0, a);
                for (var b = 0; b <= uLim - a; ++b)
                {
                    if (a == 0 && b == 0) continue;
                    if (0 < b)
                        lst.Add(Vi[N - b]);
                    lst.Sort();
                    var sum = lst.Sum();
                    cnt = Max(cnt, lst.Sum());
                    var k = Min(lst.Count, K - (a + b));
                    for (var r = 0; r < k; ++r)
                    {
                        sum = sum - lst[r];
                        cnt = Max(cnt, sum);
                    }
                }
            }
            WriteLine(cnt);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28600
def slove():
    import sys
    input = sys.stdin.readline
    H, W = tuple(map(int, input().split()))
    s = tuple(input().rstrip() for _ in range(H))
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                L[i][j] = 0
            else:
                if i == 0:
                    L[i][j] = 1
                else:
                    L[i][j] = L[i - 1][j] + 1
            if s[-i-1][j] == "#":
                R[-i-1][j] = 0
            else:
                if i == 0:
                    R[-i-1][j] = 1
                else:
                    R[-i-1][j] = R[-i][j] + 1
            if s[i][j] == "#":
                U[i][j] = 0
            else:
                if j == 0:
                    U[i][j] = 1
                else:
                    U[i][j] = U[i][j-1] + 1
            if s[i][-j-1] == "#":
                D[i][-j-1] = 0
            else:
                if j == 0:
                    D[i][-j-1] = 1
                else:
                    D[i][-j-1] = D[i][-j] + 1
    mn = 0
    for i in range(H):
        for j in range(W):
            mn = max(mn, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
    print(mn)


if __name__ == '__main__':
    slove()

Measured memory_bytes: 177160
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, ipti().split()))

    k_lim = ((n - 2) * (n - 1)) // 2

    if k_lim < k:
        print(-1)
        sys.exit()

    m1 = n - 1
    m2 = k_lim - k

    print(m1 + m2)

    for i in range(2, n + 1):
        print(1, i)

    e1 = 2
    e2 = 3
    e_num = 0

    while e_num < m2:
        print(e1, e2)
        e_num += 1
        e2 += 1
        if e2 > n:
            e1 += 1
            e2 = e1 + 1



if __name__ == '__main__':
    main()


Measured memory_bytes: 42736
#include <stdio.h>
#define N 200000
#define INFTY 1000000000
double cnt=0;
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
 
void merge(int *A,int left,int mid,int right){
  int i,j,k;
  int x1,x2;
  int L[N],R[N];
 
  x1=mid-left;
  x2=right-mid;
   
  for(i=0;i<x1;i++){
    L[i]=A[left+i];
  }
 
  for(i=0;i<x2;i++){
    R[i]=A[mid+i];
  }
 
  L[x1]=INFTY;
  R[x2]=INFTY;
 
  i=0;
  j=0;
   
  for(k=left;k<right;k++){
    if(L[i]<R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      cnt=cnt+(x1-i);
      j++;
    }
  }
   
}
 
void mergeSort(int *A,int left,int right){
  int middle;
 
  if(left+1<right){
    middle=(left+right+1)/2;
    mergeSort(A,left,middle);
    mergeSort(A,middle,right);
    merge(A,left,middle,right);
  }
}
 
int main()
{
  int i,n,A[N];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
  mergeSort(A,0,n);
 
  printf("%.0f\n",cnt);
 
  return 0;
}

Measured memory_bytes: 2204
#include <stdio.h>
#define long long long
long arr[200003];
int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
	long mn = 0;
	long res = 0;

	if(arr[1])
	{
		printf("-1\n");
		return 0;
	}
	for(int i = n; i >= 1; i--)
	{
		mn--;
		if(mn > arr[i])
		{
			printf("-1\n");
			return 0;
		}
		else if(mn == arr[i]) continue; 
		else
		{
			res += arr[i];
			mn = arr[i];
		}
	}
	printf("%lld\n", res);
}











Measured memory_bytes: 1664
#include<cstdio>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	int sum = 0; vector<int> v;
	for(int i = 0; i < n; i++){
		int s; scanf("%d", &s);
		sum += s;
		if(s % 10 != 0) v.push_back(s);
	}
	sort(v.begin(), v.end());
	if(sum % 10 != 0) printf("%d\n", sum);
	else if(v.size() == 0) puts("0");
	else printf("%d\n", sum - v[0]);
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0])
       << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a;
int ans[100005];
const int INF = 1e8;
int main() {
  int n;
  cin >> n;
  fill(ans,ans+n+1,INF);
  ans[0] = 0;
  int six = 6;
  int nine = 9;
  a.push_back(1);
  while(six <= n) {
    a.push_back(six);
    six *= 6;
  }
  while(nine <= n) {
    a.push_back(nine);
    nine *= 9;
  }
  sort(a.begin(),a.end());
  for(int i = 0; i <= n; i++) {
    for(int j = 0; j < a.size(); j++) {
      if(i - a[j] < 0) continue;
      ans[i] = min(ans[i],ans[i-a[j]] + 1);
    }
  }
  cout << ans[n] << endl;
}
  


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    ll n; cin >> n;

    ll ans = n - 1;
    for(ll i = 2; i * i <= n; i++){
        if(n % i == 0){
            ll tmp = i + (n / i) - 2;
            ans = min(ans, tmp);
        }
    }
    OP(ans);
}


Measured memory_bytes: 256
import sys
M = 10**9 + 7
n = int(input()) * 2
s = list(map(lambda x: int(x == "W"), input()))

lr = [0] * n # L: 0, R: 1

if s[0] or s[-1]:
    print(0)
    sys.exit()

l = 1
ans = 1
for i, v in enumerate(s[1:], 1):
    if v:
        if l % 2:
            l += 1
        else:
            ans *= l
            l -= 1
            lr[i] = 1
    else:
        if l % 2 == 0:
            l += 1
        else:
            ans *= l
            l -= 1
            lr[i] = 1
    if ans > M:
        ans %= M
    if l < 0:
        print(0)
        sys.exit()

if not lr[-1] or l:
    print(0)
    sys.exit()

def fact(n):
    result = 1
    for i in range(2, n + 1):
        result *= i
        if result > M:
            result %= M
    return result
print((ans * fact(n // 2)) % M)


Measured memory_bytes: 56800
#include <stdio.h>
#include <iostream>
#include <sstream>

#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; while(getline(stream,res,sp_word))
#define rem_space(x) x.erase(remove(all(x), ' '),x.end())
#define scl(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())

using namespace std;

int main(){
  int X,A,B;
  scanf("%d%d%d",&X,&A,&B);

  if(B - A <= X){
    if(B - A <= 0) puts("delicious\n");
    else puts("safe\n");
  }else puts("dangerous\n");

  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

int main(){
    map<string, llong> dict;
    llong n;
    char command[100];
    string s;
    cin >> n;
    for(int i=0; i<n; i++){
        scanf("%s", command);
        cin >> s;
        if(command[0]=='i'){
            dict[s] += 1;
        }else if(command[0]=='f'){
            if(dict[s]){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 52632
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class T>
vector<T> sumup(const vector<T>& a) {
  int N = a.size();
  vector<T> res(N + 1);
  for (int i = 0; i < N; i++) res[i + 1] = res[i] + a[i];
  return res;
}

int main() {
  ll L;
  int N;
  while (cin >> L >> N) {
    vector<ll> X(N);
    for (int i = 0; i < N; i++) cin >> X[i];
    vector<ll> Y(N);
    for (int i = 0; i < N; i++) Y[i] = L - X[i];
    reverse(Y.begin(), Y.end());
    auto Xsum = sumup(X);
    auto Ysum = sumup(Y);
    auto f = [](const vector<ll>& Xsum, const vector<ll>& Ysum, int R, int L) {
      int wR, wL;
      if (R < L) {
        wR = R;
        wL = R + 1;
      } else {
        wR = wL = L;
      }
      return 2 * ((Xsum[R] - Xsum[R - wR]) + (Ysum[L] - Ysum[L - wL]));
    };
    ll res = 0;
    chmax(res, X.back());
    chmax(res, Y.back());
    for (int R = 1; R < N; R++) {
      int L = N - R;
      chmax(res, f(Xsum, Ysum, R - 1, L) + X[R - 1]);
      chmax(res, f(Ysum, Xsum, L - 1, R) + Y[L - 1]);
    }
    cout << res << endl;
  }
  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    string s, t;
    cin >> s >> t;

    if(t.substr(0, sz(s)) == s)
    {
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        HashMap week = new HashMap<String, Integer>();
        week.put("SUN", 7);
        week.put("MON", 6);
        week.put("TUE", 5);
        week.put("WED", 4);
        week.put("THU", 3);
        week.put("FRI", 2);
        week.put("SAT", 1);
        System.out.println(week.get(s));
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

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

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
int main()
{
    ios_base::sync_with_stdio(false);
    ll a,p;
    cin>>a>>p;
    show(((a*3)+p)/2);
    return 0;
}


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

n=10**6
#primeに素数を保管する下準備
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
from collections import defaultdict
def prime_factorization(N):
    dic=defaultdict(int)
    for some in prime:
        if N%some==0:
            while N%some==0:
                N=N//some
                dic[some]+=1
        else:
            pass
    if N!=1:
        dic[N]=1
    return dic
ans=0
K=prime_factorization(N)
import bisect
H=[i*(i-1)//2 for i in range(10**4)]

for value in K.values():
    ans+=bisect.bisect_right(H,value)-2
print(ans)



Measured memory_bytes: 200192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int test,i,j,ac=0,wa=0,tle=0,re=0;
    string ch;
    cin>>j;
    for(i=0;i<j;i++)
    {
        cin>>ch;
        if(ch=="AC")
        {
            ac+=1;
        }
        else if(ch=="WA")
        {
            wa+=1;
        }
         else if(ch=="TLE")
        {
            tle+=1;
        }
        else if(ch=="RE")
        {
            re+=1;
        }


    }
    cout<<"AC"<<" "<<"x"<<" "<<ac<<endl<<"WA"<<" "<<"x"<<" "<<wa<<endl<<"TLE"<<" "<<"x"<<" "<<tle<<endl<<"RE"<<" "<<"x"<<" "<<re<<endl;;

    return 0;


}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);


   int n,u,v;
   cin>>n>>u>>v;
   vector <vector <int> > adj(n+1);
   for (int i=0;i<n-1;i++)
   {
      int a,b;
      cin>>a>>b;
      adj[a].push_back(b);
      adj[b].push_back(a);
   }
   queue <int> q;
   bool vis[100001]={};
   q.push(u);
   vector <int> distT(n+1,0);
   distT[u]=0;
   vis[u]=true;
   while (!q.empty())
   {
      int s=q.front();
      q.pop();
      for (auto it: adj[s])
      {
         if (!vis[it])
         {
            q.push(it);
            distT[it]=distT[s]+1;
            vis[it]=true;
         }
      }
   }

   memset (vis,0,sizeof(vis));

   vector <int> distA(n+1,0);
   distA[v]=0;
   q.push(v);
   vis[v]=true;
   while (!q.empty())
   {
      int s=q.front();
      q.pop();

      for (auto it: adj[s])
      {
         if (!vis[it])
         {

            q.push(it);
            distA[it]=distA[s]+1;
            vis[it]=true;
         }
      }
   }

   vector <pair <int,int> > ans(n+1);
   for (int i=1;i<=n;i++)
   {
      ans.push_back({distA[i],i});
   }
   int fans=0;

   sort(ans.rbegin(),ans.rend());

   for (auto it : ans)
   {

      if (adj[it.second].size()!=1)
         {

            continue;
         }
      if (it.first>distT[it.second])
      {
         fans=it.first-1;
         break;
      }
   }
   cout<<fans;

}


Measured memory_bytes: 8320
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    n = II()
    A = LI()
    th = 1_000_000_000_000_000_000
    ans = 1
    if 0 in A:
        print(0)
        return

    for a in A:
        ans *= a
        # print(a, ans)
        if ans > th:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 83992
/*********************"ANJAN AGARWALA"************************
***************************@anjn98****************************/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

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

typedef long long int ll;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define IO 				ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 			v.begin(),v.end()
#define PR(a) 			cout<<"("<<a<<")";
#define ED 				cout<<'\n';
#define endl 			'\n'
#define loop(j,a,n) 	for(int j=a;j<=n;j++)
#define loop1(j,a,n) 	for(int j=a;j>=n;j--)
#define fr1(j,n) 		for(int j=0;j<n;j++)
#define fr(n) 			for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB 				push_back
#define MP 				make_pair
#define pii 			pair<int,int>
#define pll 			pair<long long int,long long int>
#define F 				first
#define S 				second 
#define binf 			2000000000000000001
#define mod 			1000000007

const int  M=105,N=1e5+9;
ll dp[M][N];
vector<pll> v(M);

int32_t main()
{	
	IO
    int n,w;cin>>n>>w;
    fr(n) cin>>v[i+1].F>>v[i+1].S;
    sort(v.begin(),v.begin()+n);
    for(int i=1;i<=n;i++)
    {
        
        for(int j=1;j<=w;j++)
        {
            if(j-v[i].F>=0)   dp[i][j]=dp[i-1][j-v[i].F]+v[i].S;
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            dp[i][j]=max(dp[i][j],dp[i][j-1]);
        }
        
    }
    cout<<dp[n][w]<<endl;
    
    
}

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

int main(){
  int n,k; cin>>n>>k;
  int ans=k;
  rep(i,n-1) ans*=(k-1);
  cout<<ans<<endl; 

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;


int main(void) {
	double l; cin >> l;
	double x = l / 3;

	printf("%.7f", x*x*x);
	return 0;
}

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

main = do
  [a, b, c, d, p] <- replicateM 5 readLn

  let x = a * p
      y = calc p c b d

  print $ min x y


calc p c b d
  | p < c = b
  | otherwise = b + (p - c) * d

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

int main()
{
    string s;
    cin >> s;
    for (int i = 1; i < 4; ++i)
        if (s[i] == s[i-1]) {
            cout << "Bad" << endl;
            return 0;
        }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
// using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    int n, m;
    cin >> n;
    vector<string> s(110);
    rep(i, n) cin >> s[i];
    cin >> m;
    vector<string> t(110);
   rep(i, m) cin >> t[i];

    map<string, int> a;
    rep(i, n) { a[s[i]] += 1; }
    rep(i, m) a[t[i]] -= 1;
    int ma =0;
    for (auto p :a){
        if (ma < a.at(p.first)) ma = a.at(p.first);

    }
    if(ma>0)cout << ma << endl;
    else
        cout << 0 << endl;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
   int num,temp,rem,sum=0;
   cin>>num;
   temp=num;
   while(temp!=0)
{
  rem=temp%10;
  sum=sum*10+rem;
  temp=temp/10;
}
if(num==sum) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> a(m);

    for (int i = 0; i < m; i++) {
        cin >> a.at(i);
    }
    int sum = accumulate(a.begin(), a.end(), 0);

    if (n >= sum) {
        cout << n - sum << endl;
    }
    else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll a[51],b[51],c[51],d[51];

ll f(ll x1,ll x2,ll y1,ll y2){
	return abs(x1-x2)+abs(y1-y2);
}

int main(){
	int n,m;
	cin >> n >> m;
	rep(i,n){
		cin >> a[i] >> b[i];
	}
	rep(i,m){
		cin >> c[i] >> d[i];
	}
	ll ans,num;
	rep(i,n){
		ans = 1;
		num = f(a[i],c[0],b[i],d[0]);
		arep(1,j,m){
			if(num>f(a[i],c[j],b[i],d[j])){
				ans=j+1;
				num=f(a[i],c[j],b[i],d[j]);
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;
const int   mod = 1e9 + 7;

void add(int&a,int b)   {   a += b; if (a >= mod)   a -= mod;   }
void sub(int&a,int b)   {   a -= b; if (a <  0)     a += mod;   }

int mul(int a,int b)    {   return  1ll * a * b % mod;  }
int inv(int a,int p)    {   return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;    }

typedef pair<int,int>   ii;

vector<int> g[N];
vector<int> a[N];

int p[N], s[N];
int e[N], r[N];

int lead(int x) {   return  x == p[x] ? x : p[x] = lead(p[x]);  }
int join(int x,int y)   {
    x = lead(x);
    y = lead(y);

    e[x]++;

    if (x == y) return  0;
    if (s[x] < s[y])
        swap(x,y);
    
    p[y] = x;
    s[x] += s[y];
    e[x] += e[y];

    return  1;
}
vector<int> vec[N];

int Fac[N], Inv[N];
int nxt[N], nCh[N];
int ban[N];

void Try(int u,int p)   {
    nxt[u] = p;

    for(int v : g[u])   if (v != p && ban[u] != v)
        Try(v,u);
}
void dfs(int u) {
    if (nCh[u])
        return;
        
    nCh[u] = 1;

    for(int v : a[u])
        dfs(v),
        nCh[u] += nCh[v];
}
int cal(int R)  {
    int ans = 1;

    for(int x : vec[R]) a[x] = vector<int>(g[x].begin(),lower_bound(all(g[x]),nxt[x]));
    for(int x : vec[R]) dfs(x), ans = mul(ans,Inv[nCh[x]]);
    for(int x : vec[R]) nCh[x] = 0;

    //cerr << ans << "\n";
    return  ans;
}

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    Inv[1] = 1;
    Fac[0] = Fac[1] = 1;

    for(int i = 2 ; i < N ; ++i)
        Inv[i] = mul(mod - mod / i,Inv[mod % i]),
        Fac[i] = mul(Fac[i - 1],i);

    int n;  cin >> n;

    fill(ban,ban + n + n,-1);

    iota(p,p + n + n,0);
    fill(s,s + n + n,1);

    vector<ii>  Cycle_Edges;

    for(int i = 0 ; i < n + n ; ++i)    {
        int x;  cin >> x;   x -= 1;
        int y;  cin >> y;   y += n - 1;
        
        if(!join(x,y))  {
            Cycle_Edges.pb(x,y);
            ban[x] = y;
            ban[y] = x;
        }
        g[x].pb(y);
        g[y].pb(x);
    }
    for(int i = 0 ; i < n + n ; ++i)    sort(all(g[i]));
    for(int i = 0 ; i < n + n ; ++i)    {
        if (i == lead(i) && s[i] != e[i])   {
            cout << 0;
            return  0;
        }
        vec[p[i]].pb(i);
    }
    int ans = Fac[n + n];

    for(ii  e : Cycle_Edges)    {
        int R = lead(e.X);
        int C = 0;

        Try(e.X,e.Y);   add(C,cal(R));
        Try(e.Y,e.X);   add(C,cal(R));

        ans = mul(ans,C);
    }
    cout << ans << endl;
}

Measured memory_bytes: 36248
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

int n;
int h[7];
bool m[6010][7];
int b[1010][5];

int main()
{
    while (true)
    {
        cin >> n;
        if (n == 0)
            break;
        for (int i = 0; i < 5500; i++)
        {
            for (int j = 0; j < 7; j++)
                m[i][j] = false;
        }
        for (int i = 0; i <= 6; i++)
        {
            h[i] = 0;
        }
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                cin >> b[i][j];
                if (j == 1)
                {
                    ans += b[i][j];
                }
            }
        }
        for(int i = 0;i < n;i++){
            if(b[i][0] == 1){
                int hmax = h[b[i][2]];
                for(int j = 0;j < b[i][1];j++){
                    hmax = max(hmax,h[b[i][2]+j]);
                }
                hmax++;
                for(int j = 0;j < b[i][1];j++){
                    h[b[i][2]+j] = hmax;
                    m[hmax][b[i][2]+j] = true;
                }
            }else{
                int hmax = h[b[i][2]];
                for(int j = 1;j <= b[i][1];j++){
                    m[hmax+j][b[i][2]] = true;
                }
                h[b[i][2]] = hmax + b[i][1];
            }
            int hmax = h[1];
            for(int j = 1;j <= 5;j++) hmax = max(hmax,h[j]);
            set<int> s;
            for(int j = 1;j <= hmax;j++){
                int count = 0;
                for(int k = 1;k <= 5;k++)if(m[j][k] == true)count++;
                if(count == 5){
                    ans -= 5;
                    s.insert(j);
                }
            }
            int nj = 1;
            for(int j = 1;j <= hmax;j++){
                if( s.find(j) != s.end() )continue;
                for(int k = 1;k <= 5;k++){
                    m[nj][k] = m[j][k];
                }
                nj++;
            }
            for(int j = nj;j < 5050;j++){
                for(int k = 1;k <= 5;k++)m[j][k] = false;
            }
            for(int j = 1;j <= 5;j++){
                h[j] = 0;
                for(int k = hmax;k >= 0;k--){
                    if(m[k][j] == true){
                        h[j] = k;
                        break;
                    }
                }
            }
        }
        int hmax = h[1];
        for(int j = 1;j <= 5;j++) hmax = max(hmax,h[j]);
        for(int j = hmax;j >= 1;j--){
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3160
import fractions

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

a,b,c,d=map(int,input().split())
d1=b//c
d2=b//d
d3=b//lcm(c,d)

d4=(a-1)//c
d5=(a-1)//d
d6=(a-1)//lcm(c,d)

ansb=b-(d1+d2-d3)
ansa=a-1-(d4+d5-d6)
print(ansb-ansa)


Measured memory_bytes: 5076
#include<stdio.h>
int main(void)
{
	int i,x,flg,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++) {
		flg=0;
		if(i%3==0) flg=1;
			x=i;
		while(0<x) {
			if(x%10==3) flg=1;
			x/=10;
		}
		if(flg==1) printf(" %d",i);
	}
	printf("\n");
	
	return 0;
}



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

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

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

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

using namespace std;

//-------------------------------------------------
//--Range Set
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<T> v;
    ::std::unordered_map<T, ::std::vector<int> > data;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_){
        int sz = v.size();
        for(int i=0;i<sz;i++){
            T t = v[i];
            data[t].push_back(i);
        }
    }
    int query(T x){
        if (!data.count(x)) return 0;
        return data[x].size();
    }
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!data.count(x)) return 0;
        auto right = ::std::upper_bound(data[x].begin(),data[x].end(),b);
        auto left  = ::std::lower_bound(data[x].begin(),data[x].end(),a);
        return right-left;
    }
    void update(int k, T x){
        int ei = v[k];
        auto eitr = ::std::lower_bound(data[ei].begin(),data[ei].end(),k);
        data[ei].erase(eitr);
        v[k] = x;
        if (data.count(x)){
            auto itr = ::std::lower_bound(data[x].begin(),data[x].end(),k);
            data[x].insert(itr, k);
        }else{
            data[x].push_back(k);
        }
    }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vll a(n);
    rep(i,n){cin>>a[i]; a[i]--;}
    vll s(n+1);
    s[0] = 0;
    rep(i,n) s[i+1]=(s[i]+a[i])%k;
    RangeSet<ll> rs(s);
    ll ans=0;
    rep(i, n){
        ans+=rs.query(i+1, i+k-1, s[i]);
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

string s;

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

	cin >> s;
	int pos = -1, cnt = 0, ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'T')
		{
			if (cnt > 0)
			{
				cnt--;
			}
			else
			{
				pos = i;
				ans++;
			}
		}
		else
		{
			cnt++;
		}
	}

	cout << ans * 2 << endl;
}



Measured memory_bytes: 720
import math

n = int(input())
root_n = int(math.sqrt(n))


def digit(x):
    return len(str(x))


l = []
for i in range(2, root_n + 1):
    if n % i == 0:
        a = int(n / i)
        l.append(max(digit(a), digit(i)))
if l:
    print(min(l))
else:
    print(digit(n))


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b, c; cin >> a >> b >> c;
  if(b > c) swap(b, c);
  if(a > b) swap(a, b);
  if(b > c) swap(b, c);

  int ans = (c - b);
  a += ans;
  b += ans;

  ans += (b - a) / 2;
  if((b - a) % 2) {
    ans += 2;
  }
  cout << ans << endl;

}
























Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MAX 100005
#define MAXV 3000000000
using namespace std;

int a[MAX];

int root(int x){
  if(x != a[x]) a[x] = root(a[x]);
  return a[x];
}

int main(){
  int n, m, p[MAX], x, y, c = 0;
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= n; i++){
    scanf("%d", &p[i]);
    a[i] = i;
  }
  for(int i = 0; i < m; i++){
    scanf("%d%d", &x, &y);
    a[root(x)] = root(y); 
  }
  for(int i = 1; i <= n; i++){
    if(root(p[i]) == root(i)) c++;
  }
  printf("%d", c);
}


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

int main(void){
    int a, b;
    cin >> a >> b;
    for(int i=1; i<1010; i++){
        if(a == i*8/100 && b == i*10/100){
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 3584