akhauriyash/Code-Regression huggingface dataset:
n, *a_l = map(int, open(0).read().split())
before = a_l[0]
not_decrease, not_increase = False, False
cnt = 1
for a in a_l:
    if not_decrease:
        if before > a:
            cnt += 1
            not_decrease = False
    elif not_increase:
        if before < a:
            cnt += 1
            not_increase = False
    else:
        if before == a:
            continue
        elif before < a:
            not_decrease = True
        else:
            not_increase = True
    before = a
print(cnt)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    ll x, k ,d, ans;
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d >= k){
        ans = x - d*k;
    }else{
        k -= x/d;
        x = x - d*(x/d);
        if(k%2==0)ans = x;
        else ans = abs(x - d);
    }
    cout << ans << endl;
    return 0;
}

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

#define MAXN 10005
#define MAXD 105
#define int long long
#define LL long long
#define pii pair<long, long>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;

string K;
int N[MAXN];
int D;
int n;
int mod = 1e9+7;
int dp[11][MAXN][MAXD];

signed main() {
    fastio;
    cin >> K;
    cin >> D;
    for (char c: K) {
        N[++n] = c - '0';
    }
    for (int i = 0; i < 10; i++) {
        dp[i][1][i%D] = 1 % mod;
        dp[10][1][i%D] = (dp[10][1][i%D] + 1) % mod;
    }
    
    for (int j = 2; j <= n; j++) {
        for (int i = 0; i < 10; i++) {
            for (int d = 0; d < D; d++) {
                dp[i][j][(d+i)%D] = (dp[i][j][(d+i)%D] + dp[10][j-1][d]) % mod;
            }
            for (int d = 0; d < D; d++) {
                dp[10][j][d] = (dp[10][j][d] + dp[i][j][d]) % mod;
            }
        }
    }

    int ans = 0;
    int d = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < N[i]; j++) {
            ans = (ans + dp[j][n-i+1][(D-d)%D]) % mod;
        }
        
        d = (d + N[i]) % D;
        if (i == n && d == 0) ans = (ans + 1) % mod;
    }
    ans = (ans - 1 + mod) % mod;
    cout << ans << endl;
    return 0;
}

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

int main()
{
	string s;
	int c = 0, d = 0;

	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'T' || s[i] == 'G') {
			c++;
		}
		else {
			if (c > d) d = c;
			c = 0;
		}
	}

	if (c > d) d = c;
	c = 0;

	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& v) {
    return is >> v.first >> v.second;
}

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

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

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

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    int n; in(n);
    ll ans = (ll) n*(n - 1)/2;
    out(ans);
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
debug = True

debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()

INF = 10 ** 18
MOD = 10 ** 9 + 7

def main():
    N = II()
    S = SI()

    #mark = [-1 for i in range(N)]
    ans = -1

    from collections import defaultdict
    posd = defaultdict(list)

    for i, c in enumerate(S):
        posd[c].append(i)

    for i in range(N):
        si = S[i]

        # headの文字の位置のリスト
        pos_list = posd[si]

        for pos in pos_list:
            if pos >= i:
                # 自分より前のところだけを探す
                continue

            # この場合は直前により長いシーケンスを見ているので見なくていい
            if pos > 0 and S[pos - 1] == S[i - 1]:
                continue

            # どこまであうかをやっていく
            for j in range(N):
                # 前回見たシーケンスは見ない
                # 自分のところまで来てたらやめる
                if pos+j == i:
                    break
                # 突き抜けたらやめる
                if i+j == N:
                    break

                you = pos + j
                me = i + j

                # 違ったらやめる
                if S[you] != S[me]:
                    break

                # 同じなら、マークする
                ans = max(ans, j)
                #mark[you] = max(mark[you], j)

    #dprint(mark)
    #print(max(mark)+1)
    print(ans + 1)

main()

Measured memory_bytes: 44508
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  
  map<ll, ll> memo;
  rep(i, N) memo[A.at(i)]++;
  
  bool res = true;
  for(auto && iter = memo.begin(); iter != memo.end(); iter++){
    if(iter->second >= 2){
      res = false;
      break;
    }
  }
  
  if(res) cout << "YES";
  else cout << "NO";
  
  
  
      
      
}

Measured memory_bytes: 14336
a, b, m = gets.chomp.split.map(&:to_i)

a_arrays = gets.chomp.split.map(&:to_i)
b_arrays = gets.chomp.split.map(&:to_i)

temp_smallest = a_arrays.min + b_arrays.min

m.times do
  n1, n2, n3 = gets.chomp.split.map(&:to_i)
  price = a_arrays[n1 -1] + b_arrays[n2 -1] - n3
  if price < temp_smallest 
    temp_smallest = price
  end
end

puts temp_smallest

Measured memory_bytes: 19996
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var sum = cin.ReadIntArray(2).Sum();
            if (sum >= 10) WriteLine("error");
            else WriteLine(sum);
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;
int mx[200010];


int32_t main(){
INIT
int h=0;
mx[0]=0;
cin>>n; for(int i=1; i<=n; i++){cin>>a[i];mx[i]=max(mx[i-1], a[i]); h+=(mx[i]-a[i]); }
cout<<h;


return 0;
}





Measured memory_bytes: 6776
#include<iostream>
using namespace std;
int a[200010];
int main()
{
	int n;	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<=n;i++)
		if(a[i-1]>a[i])
			ans+=a[i-1]-a[i] , a[i]=a[i-1];
	cout<<ans<<endl;
}

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

int64_t mcomb(int n, int k)
{
  static map<pair<int, int>, int64_t> cmb;
  return cmb.count({n, k}) != 0 ? cmb[{n, k}] : n < k ? 0 : k == 0 ? 1 :
    cmb[{n, k}] = (mcomb(n - 1, k - 1) + mcomb(n - 1, k)) % 1000000007;
}

int main()
{
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cout << mcomb(n - k + 1, i + 1) * mcomb(k - 1, i) % 1000000007 << endl;
  }
}


Measured memory_bytes: 125312
readlines.each do |line|

    break if line[0..2] == "0 0"

    line = line.split.map(&:to_i)

    for i in 1..line[0]

      i == 1 || i == line[0] ? puts("#" * line[1]) : puts("#" + "." * (line[1]-2) + "#")

    end

    puts ""

  end


Measured memory_bytes: 6952
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, S;
multiset<int>s, t;
int main(){
	cin >> N;
	for (int i = 0; i < (1 << N); ++i) {
		cin >> S;
		s.insert(S);
	}
	t.insert(*(--s.end()));
	s.erase((--s.end()));
	for (int i = 0; i < N; ++i) {
		vector<int>v;
		for (int j : t) {
			auto it = s.lower_bound(j);
			if (it == s.begin()) {
				puts("No");
				return 0;
			}
			--it;
			v.push_back(*it);
			s.erase(it);
		}
		for (int j : v) {
			t.insert(j);
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 13304
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
minus=[]
plus=[]
cnt=Counter(a)
zerocnt=cnt[0]
minuscnt=0
pluscnt=0
for i in range(n):
    if a[i]<0:
        minuscnt+=1
        minus.append(a[i])
    elif a[i]>0:
        pluscnt+=1
        plus.append(a[i])


if n==k:
    ans=1
    for i in range(n):
        ans*=a[i]
        ans%=mod
    print(ans%mod)
    quit()

if minuscnt==n:
    ans=1
    if k%2==0:
        for i in range(k):
            ans*=a[i]
            ans%=mod
        print(ans)
    else:
        for i in range(k):
            ans*=a[-1-i]
            ans%=mod
        print(ans)
    quit()

if minuscnt%2==1:
    minuscnt-=1

# print(minus)
plus.reverse()
# plus.append(0)
# plus.append(0)
# print(plus)

ans=1
nokori=k
m,p=0,0
# minuscnt=max(minuscnt,1)

while nokori:
    # print(pluscnt,p,m,nokori)
    if m==minuscnt:
        if p!=pluscnt:
            ans*=plus[p]
            p+=1
            nokori-=1
        else:
            ans=0
            nokori=0
    elif p==pluscnt:
        if nokori==1:
            ans=0
            nokori-=1
        else:
            ans*=minus[m]*minus[m+1]
            m+=2
            nokori-=2
    elif p+1==pluscnt:
        if nokori%2==0:
            ans*=minus[m]*minus[m+1]
            m+=2
            nokori-=2
            # if nokori==1:
        else:
            ans*=plus[p]
            p+=1
            nokori-=1
            # elif plus[p]>minus[m]*minus[m+1]:
            #     ans*=plus[p]
            #     p+=1
            #     nokori-=1
            # else:
            #     ans*=minus[m]*minus[m+1]
            #     m+=2
            #     nokori-=2
    elif nokori==1:
        ans*=plus[p]
        nokori-=1
    elif plus[p]*plus[p+1]>minus[m]*minus[m+1]:
        # if nokori%2==0:
        #     ans*=plus[p]*plus[p+1]
        #     p+=2
        #     nokori-=2
        # else:
        ans*=plus[p]
        p+=1
        nokori-=1
    else:
        ans*=minus[m]*minus[m+1]
        m+=2
        nokori-=2
    ans%=mod
print(ans%mod)


Measured memory_bytes: 134392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a = 0, b = 1000000001;
  cin >> N;
  vector<int> A(N); 
 
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if ( a < A.at(i) ){
      a = A.at(i);
  }
    if ( b >  A.at(i) ){
      b = A.at(i);   
  }
  }
cout << a - b << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int A,B,C;
  cin>>A>>B>>C;
  int Agive,Bgive,Cgive;
  bool flag=0;
  int count=0;
  if(A%2==1||B%2==1||C%2==1){
  
    cout<<count;
    return 0;
  }
  if(A==B&&B==C){
  
    cout<<-1;
    return 0;
  }
  while(flag==0){
  
    Agive=A;
    Bgive=B;
    Cgive=C;
    A=(Bgive+Cgive)/2;
    B=(Agive+Cgive)/2;
    C=(Agive+Bgive)/2;
    if(A%2==1||B%2==1||C%2==1){
  
      flag=1;
    }
    count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3580
N = input()
Ndigit = [int(c) for c in N]

Nlen = len(Ndigit)

if (
    Ndigit[len(Ndigit) - 1] == 0
    or Ndigit[len(Ndigit) - 1] == 1
    or Ndigit[len(Ndigit) - 1] == 6
    or Ndigit[len(Ndigit) - 1] == 8
):
    print("pon")
elif Ndigit[len(Ndigit) - 1] == 3:
    print("bon")
else:
    print("hon")


Measured memory_bytes: 9048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#define inf 32767
using namespace std;

int main(){
  int sum,max=0,point;
  int i,l;
  
  for(i=0;i<2;i++){
    sum=0;
    for(l=0;l<4;l++){
      cin>>point;
      sum+=point;
    }
    if(sum>max) max=sum;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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

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

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

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

// 順列・組合せ・重複組合せを計算します
// 構築 O(N)，計算結果取得 O(1)
// 使用例:
// Countings ct(MAX_N, MOD);
// cout << ct.Permutation(10, 5) << endl;        <- 10P5 = 30240
// cout << ct.Combination(10, 5) << endl;        <- 10C5 = 252
// cout << ct.HomogeneousProduct(10, 5) << endl; <- 10H5 = 2002
class Countings
{
  private:
    int mod;
    vector<long long> factList, invList;
    long long Pow(long long x, long long n)
    {
        long long ret = 1;
        while (n > 0)
        {
            if (n & 1) ret = ret * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        return ret;
    }

  public:
    Countings(int sz, int mod) : mod(mod), factList(sz + 1), invList(sz + 1)
    {
        factList[0] = 1;
        for (int i = 1; i < factList.size(); i++)
        {
            factList[i] = factList[i - 1] * i % mod;
        }
        invList[sz] = Pow(factList[sz], mod - 2);
        for (int i = sz - 1; i >= 0; i--)
        {
            invList[i] = invList[i + 1] * (i + 1) % mod;
        }
    }
    long long Permutation(int n, int r)
    {
        if (r < 0 || n < r) return 0;
        return factList[n] * invList[n - r] % mod;
    }
    long long Combination(int n, int r)
    {
        if (r < 0 || n < r) return 0;
        return factList[n] * invList[r] % mod * invList[n - r] % mod;
    }
    long long HomogeneousProduct(int n, int r){
        if (n < 0 || r < 0) return 0;
        return (r == 0 ? 1 : Combination(n + r - 1, r));
    }
};

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n, k;
    cin >> n >> k;
    LL m = n-k;

    Countings ct(5000, MOD);
    REP(i, k)
    {
        LL ans = ct.Combination(k-1, i) * ct.HomogeneousProduct(i+2, m-i) % MOD;
        //cout << ct.Combination(k-1, i) <<" " << ct.HomogeneousProduct(i+2, m-i) << endl;
        cout << ans << endl;
    }
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  vll div;
  rep(i, 1, 201){
    if(a % i == 0 && b % i == 0) div.push_back(i);
  }
  cout << div.at(div.size() - c) << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto H = aryread();
    long i, ans;
    while (i < N)
    {
        long cnt;
        while (i + cnt + 1 < N && H[i + cnt + 1] <= H[i + cnt])
            cnt++;
        ans = ans.max(cnt);
        i = i + max(1, cnt);
    }
    writeln(ans);
}


Measured memory_bytes: 4276
#include <iostream>
#include <string>

using namespace std;

int main() {
  long long H; cin >> H;
  long long k = 1;
  long long ans = 0;
  while (H > 0) {
    H /= 2;
    ans += k;
    k *= 2;
  }
  cout << ans << endl;
  
  return 0;
}



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

using namespace std;

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

  vector<size_t> A;
  bool exist1 = false;
  for (size_t i = 0; i < N; i++) {
    size_t a;
    cin >> a;
    if (a == 1) {
      exist1 = true;
    }
    A.emplace_back(a);
  }

  if (!exist1) {
    cout << -1 << endl;
    return 0;
  }

  if (A.size() == 1) {
    if (A[0] == 1) {
      cout << 0 << endl;
      return 0;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  size_t current = 1;
  size_t count = 0;
  for (size_t i = 0; i < N; i++) {
    if (A[i] != current) {
      count += 1;
    } else {
      current += 1;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    sort(All(H));
    ll res = 0;
    rep(i, N - K) { res += H[i]; }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*4 for _ in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    dp[i][0]=dp[i-1][0]*((s[i-1]=="?")*2+1)
    dp[i][1]=dp[i-1][1]*((s[i-1]=="?")*2+1)
    dp[i][2]=dp[i-1][2]*((s[i-1]=="?")*2+1)
    dp[i][3]=dp[i-1][3]*((s[i-1]=="?")*2+1)
    if s[i-1]=="A" or s[i-1]=="?":
        dp[i][1]+=dp[i-1][0]
    if s[i-1]=="B" or s[i-1]=="?":
        dp[i][2]+=dp[i-1][1]
    if s[i-1]=="C" or s[i-1]=="?":
        dp[i][3]+=dp[i-1][2]
    dp[i][0]%=mod
    dp[i][1]%=mod
    dp[i][2]%=mod
    dp[i][3]%=mod
print(dp[n][3])

Measured memory_bytes: 32012
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
const int INF = 1 << 30;
using namespace std;
#define pp pair<int,int>
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
int main() {
	string s;
	cin >> s;
	int ans;
	if (s.size() % 2 != 0) {
		if (s.size() == 1) { cout << 1 << endl; return 0; }
		ans = s.size() / 2+1;int p = s.size() / 2-1;
		char c=s[s.size()/2], l=s[p], r=s[p+2];
		while (c == l&&l == r) {
			++ans;
			--p;
			if (p >= 0) { l = s[p]; r = s[s.size() - 1 - p]; }
			else break;
		}
	}
	else {
		int p = s.size() / 2;
		ans = s.size() / 2;
		char l = s[p - 1], r = s[p],c=l;
		while (c == l&&l == r) {
			++ans;
			++p;
			if (p < s.size()) { r = s[p]; l = s[s.size() - 1 - p]; }
			else break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
from collections import deque
from heapq import heappush, heappop

N, X, Y = [int(i) for i in input().split()]
X -= 1
Y -= 1
G = [[] for _ in range(N)]
for i in range(N):
    if i!=0: G[i].append((i-1, 1))
    if i!=N-1: G[i].append((i+1, 1))
G[X].append((Y, 1))
G[Y].append((X, 1))

INF = 10**30
def Johnson(G, N):
    h = [0]*N

    update = 1
    for i in range(N):
        update = 0
        for v in range(N):
            d = h[v]
            for w, c in G[v]:
                if c + d < h[w]:
                    h[w] = d + c
                    update = 1
        if not update:
            break
    else:
        return None

    for v in range(N):
        d = h[v]
        g = G[v]
        for j, (w, c) in enumerate(g):
            g[j] = (w, c + d - h[w])

    D = []
    for i in range(N):
        dst = [INF]*N
        dst[i] = 0
        que = [(0, i)]
        while que:
            cost, v = heappop(que)
            if dst[v] < cost:
                continue
            for w, c in G[v]:
                if cost + c < dst[w]:
                    dst[w] = r = cost + c
                    heappush(que, (r, w))
        v = h[i]
        for j in range(N):
            if dst[j] == INF:
                dst[j] = INF
            else:
                dst[j] -= v - h[j]
        D.append(dst)

    return D
res = [0]*(N+2)
D = Johnson(G, N)
for i in range(N):
    for j in range(i+1, N):
        res[D[i][j]] += 1

for i in range(1, N):
    print(res[i])

Measured memory_bytes: 123956
#include <iostream>

using namespace std;

bool search(int p[], int N){
  int count = 0;
  for (int i=0; i<N; ++i){
    if (p[i] != 0) {
      count++;
    }
  }
  if (count == 1){
    return true;
  }
  else{
    return false;
  }
}


int main(void){
  int n, p;
  while (cin >> n >> p){
    if ((n == 0) && (p == 0)){
      return 0;
    }
    int *people = new int[n];
    for (int i=0; i<n; ++i){
      people[i] = 0;
    }
    //finish initialization
    int turn = 0;
    while (1){
      if (p >= 1){
	++people[turn];
	--p;
	if (p==0){
	  if (search(people, n) == true){
	    break;
	  }
	}
      }
      else{ // p<=0]
	p = people[turn];
	people[turn] = 0;
      }
      if (turn == (n-1)){
	turn = 0;
      }
      else{
	++turn;
      }
    }
    cout << turn << endl;
    delete[] people;
  }
  return 0;
}

Measured memory_bytes: 1196
function Main(input) {
  var str = input.split(" ");
  var a = parseInt(str[0],10);
  var b = parseInt(str[1],10);
  var output = "";
  if(a < b) {
    for(var i = 0;i < b;i++) {
      output += a;
    }
  }else {
    for(var i = 0;i < a;i++) {
      output += b;
    }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void){
    
    int N;
    string S;
    cin >> N >> S;
    int len = S.size();
   
    for(int i=0;i<len;i++){
        S[i] = (char)S[i] + N;
        if((int)S[i] > 90) S[i] = (char)S[i] - 26;
    }
    
    cout << S << endl;
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
)

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	d, x := nextInt(sc), nextInt(sc)

	cnt := 0
	for i := 0; i < n; i++ {
		a := nextInt(sc)
		c := (d-1)/a + 1
		cnt += c
	}

	fmt.Fprintf(out, "%d\n", cnt+x)
	return nil
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 640
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define ll long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=b;i>=a;i--)
#define maxn 1005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
using namespace std;
ll n,m,x;
ll t=0;
vector<ll> arr[15];
ll ans=-1;
void recurse(vector<ll> vect,ll ind)
{
	ll flag=0;
	rep(i,0,m+1)
	{
		vect[i]+=arr[ind][i];
		if(i>0 and vect[i]<x)
		{
			flag=1;
		}
	}
	if(ans!=-1 and vect[0]>ans)
	return;
	if(flag)
	{
		rep(j,ind+1,n)
		{
			recurse(vect,j);
		}
	}
	if(!flag)
	{
		if(ans==-1)
		ans=vect[0];
		else ans=min(vect[0],ans);
	}
}
void solve()
{
 	cin >> n >> m >> x;
 	ll cnt=0;
 	rep(i,0,n)
 	{
 		ll r;
 		cin >> r;
 		arr[i].pb(r);
 		rep(j,0,m)
 		{
 			cin >> r;
 			arr[i].pb(r);
 		}
 		
 	}
 	vector<ll> v(m+1);
	rep(i,0,n)
	{
		t=i;
		ll flag=0;
		rep(j,0,m+1)
		{
			v[j]=arr[i][j];
			if(j>0 and v[j]<x)
			flag=1;
		} 
		if(ans!=-1 and v[0]>ans)
			continue;
		if(flag)
			rep(j,i+1,n)
				recurse(v,j);
		else{
			if(ans==-1)
				ans=v[0];
			else ans=min(v[0],ans);
		}
	} 
	cout << ans;	
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}

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

#define int long long

vector<vector<int>> adj;  // adjacency list representation
int n; // number of nodes
int s; // source vertex

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

	int m;
	cin >> n >> m;
	adj.resize(n);
	for(int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	queue<int> q;
	vector<bool> used(n);
	vector<int> d(n), p(n, -1);
	
	int s = 0;
	q.push(s);
	used[s] = true;
	p[s] = -1;
	while (!q.empty()) {
	    int v = q.front();
	    q.pop();
	    for (int u : adj[v]) {
	        if (!used[u]) {
	            used[u] = true;
	            q.push(u);
	            d[u] = d[v] + 1;
	            p[u] = v;
	        }
	    }
	}
	bool flag = true;
	for(int i = 1; i < n; i++) {
		if(p[i] == -1) {
			flag = false;
		}
	}
	if(!flag) {
		return cout << "No\n", 0;
	}
	cout << "Yes\n";
	for(int i = 1; i < n; i++) {
		cout << p[i] + 1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 13748
A['   '];M;B,X,Y;W,J,I;main(){scanf("%d%d",&I,&M);for(;~scanf("%d%d",&X,&Y);){for(B=Y+1,J=1;J*J<=M;J++)I=(X+J-1)/J,W=Y/J+1,A[I]++,A[W<B?W:B]--,B=I;for(I=1;I<B;I++)(X-1)/I<Y/I?A[I]++,A[I+1]--:0;}for(I=1;I<=M;I++)A[I]+=A[I-1],printf("%d\n",A[I]);}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s, t;
	cin>>s>>t;
	long long count=0;
	for(long long i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			count++;
		}
	}cout<<count<<endl;
	return 0;
}

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 1005
#define mod 1000000007

int dist[MAXN * MAXN];
bool visited[MAXN * MAXN];
vector<pi> adj[MAXN * MAXN];
char grid[MAXN][MAXN];

void dijkstra(int s)
{
  dist[s] = 0;
  priority_queue<pi, vector<pi>, greater<pi>> q;
  q.push({dist[s], s});
  while (1)
  {
    int davez = -1;
    while (!q.empty())
    {
      int atual = q.top().sec;
      q.pop();
      if (!visited[atual])
      {
        davez = atual;
        break;
      }
    }
    if (davez == -1)
      break;
    visited[davez] = true;
    for (int i = 0; i < adj[davez].size(); i++)
    {
      int atual = adj[davez][i].fir, distt = adj[davez][i].sec;
      if (dist[atual] > dist[davez] + distt)
      {
        dist[atual] = dist[davez] + distt;
        q.push({dist[atual], atual});
      }
    }
  }
}
signed main()
{
  int n, m;
  pi s, d;
  cin >> n >> m >> s.fir >> s.sec >> d.fir >> d.sec;
  s.fir--, s.sec--, d.fir--, d.sec--;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> grid[i][j];
  for (int i = 0; i < n * m; i++)
    dist[i] = INT_MAX;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if (i + 1 < n && grid[i + 1][j] == '.')
        adj[(i * m) + j].pb({((i + 1) * m) + j, 0});
      if (j + 1 < m && grid[i][j + 1] == '.')
        adj[(i * m) + j].pb({(i * m) + j + 1, 0});
      if (i - 1 >= 0 && grid[i - 1][j] == '.')
        adj[(i * m) + j].pb({((i - 1) * m) + j, 0});
      if (j - 1 >= 0 && grid[i][j - 1] == '.')
        adj[(i * m) + j].pb({(i * m) + j - 1, 0});
      for (int k = i - 2; k <= i + 2; k++)
        for (int f = j - 2; f <= j + 2; f++)
          if (k >= 0 && k < n && f >= 0 && f < m && grid[k][f] == '.')
            adj[(i * m) + j].pb({(k * m) + f, 1});
    }
  }
  dijkstra((s.fir * m) + s.sec);
  (dist[(d.fir * m) + d.sec] == INT_MAX) ? cout << -1 << endl : cout << dist[(d.fir * m) + d.sec] << endl;
  return 0;
}

Measured memory_bytes: 363024
n, m = map(int, input().split())
c = list(map(int, input().split()))
dp = [float("inf")]*(n+1)
dp[0] = 0
for i in range(m):
    for j in range(c[i], n+1):
        dp[j] = dp[j - c[i]]+1 if dp[j - c[i]] < dp[j] else dp[j]
print(dp[n])

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s ; 
  cin  >> s ;
  
  ll num=0;
  ll res=0;
  rep(i,s.size()){
    if(s[i]=='W') res+=num;
    else num++;
  }
  cout<<res<<endl;
}
  



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

int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for (int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());
    
    long long count = 0;
    for (int i = k; i < n; i++){
        count += h.at(i);
    }
    
    cout << count << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;
    
int main()
{
    int a, b, h;
    cin >> a >> b >> h;
 
    int ans = (a + b) * h / 2;

    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const int N = 105;
int s, m, n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        int t; scanf("%d", &t);
        s += t;
        m = std::max(m, t);
    }
    puts(m < (s - m) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(N - K):
        if A[i] < A[i + K]:
            print("Yes")
        else:
            print("No")  
    
if __name__ == "__main__":
    main()

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int r, d, x;
	cin >> r >> d >> x;

	int tmp = x;
	FOR(i, 10){
		tmp = r*tmp-d;
		cout << tmp << endl;
	}

    return 0;
}


Measured memory_bytes: 256
from math import gcd

def solve(a,b,c,d):
  
    if a < b:
        return False
    if d < b:
        return False

    g = gcd(b,d)
    m = b - (b-a-1)%g - 1
    return m <= c

T = int(input())
for _ in range(T):
    print('Yes' if solve(*map(int,input().split())) else 'No')


Measured memory_bytes: 8980
# -*- coding: utf-8 -*-
import numpy as np
from math import factorial
from itertools import permutations

def solve():
    N = int(input())
    Z = np.zeros((N,1,2))
    for i in range(N):
        x, y = map(int, input().split())
        Z[i] = x,y
    W = Z.swapaxes(0,1)
    return str(np.sqrt(((Z-W)**2).sum(axis=-1)).sum()*factorial(N-1)/factorial(N))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 21748
n = int(input())
l = list(map(int, input().split()))

l.sort(reverse=True)

ans = 0

#1番長い辺(a)は固定する
for i in range(n - 2):
    #2番目に長い辺(b)＝次に長い辺とする
    j = i + 1
    #3番目の長さの辺(c)＝リストの中で最短の辺からスタート
    k = n - 1

    while j < k:
        #b<a+c,c<a+b は自明。a<b+cを判定する。
        #満たす場合、このbにおいて、cまでの全ての要素は条件を満たす(cが小さいほうから攻めているから)
        if l[i] < l[j] + l[k]:
            ans += k - j
            j += 1
        #満たさない場合、cを次に長い辺として再度判定。
        else:
            k -= 1

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/




signed main() {
	string s, t; cin >> s >> t;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == t[i])cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] array = line.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		int c = Integer.parseInt(array[2]);

		int result = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				result++;

			}

		}
		System.out.println(result);

	}

}

Measured memory_bytes: 26288
#include <cstdio>

using namespace std;

int main() {
  int r, d, x;
  scanf("%d%d%d", &r, &d, &x);
  long long ans = x;
  for (int i = 0; i < 10; ++i) {
    ans = r * ans - d;
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
   ll n,k,q;
   cin>>n>>k>>q;
   ll a,b[n];
   for(ll i=0;i<n;i++)b[i]=k-q;
   for(ll i=0;i<q;i++){
       cin>>a;
       b[a-1]++;
   }
   for(ll i=0;i<n;i++){
       if(b[i]>0)cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
   }
}

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

int main(void){
    int m,f,b;
    cin>>m>>f>>b;
    if(m+f<b){
        cout<<"NA";
    }
    if(m<b&&m+f>=b){
        cout<<b-m;
    }
    if(m>=b){
        cout<<0;
    }
    cout<<endl;
}


Measured memory_bytes: 3080
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String word = "abcdefghijklmnopqrstuvwxyz";
    char[] a = new char[word.length()];
    for(int i = 0; i<word.length(); i++) {
      char aa = word.charAt(i);
      for(int j = 0; j<s.length(); j++){
        if(aa == s.charAt(j)) break;
        if(j == s.length() - 1) {
          System.out.println(aa);
          return;
        }
      }
    }
    System.out.println("None");
  }
}


Measured memory_bytes: 24688
#include<iostream>
using namespace std;
int n;
int a[100005],b[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	b[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++) b[i]=min(b[i-1]+abs(a[i-1]-a[i]),b[i-2]+abs(a[i-2]-a[i]));
	cout<<b[n];
	return 0;
}

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

#define REPI(i, n) for(int i = 1; i < n; i+=2)
#define REPJ(j, n) for(int j = 0; j < n; j+=2)

using ll = long long;
using namespace std;

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

    string s; cin >> s;
    bool sign = 1;
    int s_len = s.length();

    REPI(i, s_len) if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') sign = 0, i += s_len;
    if(sign != 0)
        REPJ(j, s_len)
            if(s[j] != 'R' && s[j] != 'U' && s[j] != 'D') sign = 0, j += s_len;
    sign == 1 ? cout << "Yes" : cout << "No";
}


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

string to_string(const string& s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int a, b;
    cin >> a >> b;
    cout << a * b;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
def main():
    import numpy as np
    import sys
    input = sys.stdin.readline
    N, K = map(int,input().split())
    A = np.sort(list(map(int,input().split())))
    F = np.sort(list(map(int,input().split())))[::-1]
    mul = A*F
    if K >= np.sum(A)*N:
        print(0)
        exit()

    ma = A[-1]*F[0]
    mi = 0
    while ma != mi:
        tgt = (ma + mi)//2
        num = np.sum(np.maximum(0,(mul-tgt+F-1)//F))
        if num <= K:
            ma = (ma + mi)//2
        else:
            mi = (ma + mi)//2+1
    print(ma)
if __name__ == '__main__':
    main()

Measured memory_bytes: 37212
#include <iostream>

int main() {
  int n = 0, x = 0;
  std::cin >> n;
  if ((n / 1000) == 2) x++;
  if (((n / 100) % 10) == 2 ) x++;
  if (((n / 10) % 10) == 2 ) x++;
  if ((n % 10) == 2) x++;

  std::cout << x << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  int n, b;
  cin >> n;
  vector<int> a(n);

  rep(i, n - 1){
    cin >> b;
    a[b - 1]++;
  }

  rep(i, n)cout << a[i] << endl;
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,l,x=0;
  cin>>d>>l;
  while(1){
    if(d>=l){
      d-=l;
      x++;
    }
    else {
      d-=1;
      x++;
    }
    if(d==0) break;
  }
  cout<<x<<endl;
return 0;
}



Measured memory_bytes: 3104
#103_C
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = list(map(int, input().split()))

lcm = lcm_list(a)

ans = 0
for i in range(n):
    ans += (lcm-1) % a[i]
    
print(ans)

Measured memory_bytes: 9684
#include<stdio.h>

int main(){
	int a,b;
	int d,r;
	double f;

	scanf("%d %d",&a,&b);

	d = a/b;
	r = a%b;
	f = 1.0*a/b;

	printf("%d %d %f\n",d,r,f);

return 0;
}


Measured memory_bytes: 2036
//Arraysクラス利用!!!

import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int L = sc.nextInt();

		String[] s = new String[N];

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

			s[i] = sc.next();
		}

		Arrays.sort(s);

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

			System.out.print(s[i]);
		}
	}

}


Measured memory_bytes: 23508
#include <iostream>
using namespace std;
int main()
{
    char a;
    char b;
    char c;
    char d;
    int a1 = 0;
    int b1 = 0;
    int c1 = 0;
    int d1 = 0;
    cin >> a >> b >> c >> d;
    a1 = a;
    b1 = b;
    c1 = c;
    d1 = d;
    if(a1 == b1 && a1 == c1 && a1 == d1)
    {
        cout<<"No";
    }
    else if(a1 == b1 && c1 == d1)
    {
        cout<<"Yes";
    }
    else if(a1 == c1 && b1 == d1)
    {
        cout<<"Yes";
    }
    else if(a1 == d1 && b1 == c1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const packs = input[0].map(Number);

  packs.sort((a, b) => a - b);

  return packs[0] + packs[1] === packs[2] ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29636