akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
	string s;
	cin >> s;
	replace(ALL(s), ',', ' ');
	cout << s << "\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c;
	d = 0;
	for (int x = a; x <= b;x++){
		if (c%x == 0){
			d++;
		}
	}
	cout << d << endl;


	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

long point(long n,long r,long N){//mod3でrになる点nパート
    return N*(r%3)+n;
}

int main(){
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> u(M),v(M);
    for(int i=0;i<M;i++){
        cin>>u.at(i)>>v.at(i);
        u.at(i)--;
        v.at(i)--;
    }
    long S,T;
    cin>>S>>T;
    S--;
    T--;
    
    
    //計算
    vector<set<long>> out(N*3,set<long>());
    for(int i=0;i<M;i++){
        for(int r=0;r<3;r++) out.at(point(u.at(i),r,N)).insert(point(v.at(i),r+1,N));
    }
    
    vector<long> used(N*3,false);
    vector<long> cost(N*3,INF);
    
    queue<long> que;
    que.push(point(S,0,N));
    used.at(point(S,0,N))=true;
    cost.at(point(S,0,N))=0;
    while(!que.empty()){
        long p=que.front();
        que.pop();
        //cout<<"("<<p%N+1<<","<<p/N<<")"<<"での探索開始"<<endl;
        
        
        for(auto ite=out.at(p).begin();ite!=out.at(p).end();++ite){
            //cout<<"　->　("<<*ite%N+1<<","<<*ite/N<<")"<<"を入れるか？？"<<endl;
            if(!used.at(*ite)) {
                que.push(*ite);
                used.at(*ite)=true;
                cost.at(*ite)=cost.at(p)+1;
                //cout<<"　 　->("<<*ite%N+1<<","<<*ite/N<<")"<<"を入れた"<<endl;
            }
        }
        
        //cout<<"("<<p%N+1<<","<<p/N<<")"<<"での探索終了"<<endl;
        /* 残り["<<endl;
        for(auto itete=que.begin();itete!=que.end();++itete) cout<<"("<<*itete%N<<","<<*itete/N<<"), ";
        cout<<"]です"<<endl;*/
    }
    
    long ans=cost.at(point(T,0,N));
    if(ans==INF) cout<<"-1"<<endl;
    else cout<<ans/3<<endl;
}


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

int main(){
    int n; cin >> n;
    long long A[200005];
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    for (int i = 0; i < n; i++)
    {
        A[i] *= 2;
    }
    
    for (int i = 1; i < n; i++)
    {
        A[i] = A[i-1] + A[i];
    }
    long long near = 1e18;
    for (int i = 0; i < n; i++)
    {   
        near = min(near, abs(A[i] - sum));
    }
    cout << near << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

vector<vector<ll>> Warshall_Floyd(Graph G){
    //Gの各点は0~N-1にすること
    ll N = sz(G);
    vector<vector<ll>> d(N ,vector<ll>(N));
    
    rep(i,N) rep(j,N){
        if(i == j) d[i][j] = 0;
        else d[i][j] = 1e15;
    }
    
    rep(i,N) for(auto e : G[i]) d[i][e.first] = e.second; 
    rep(k,N) rep(i,N) rep(j,N) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    return d;
}

int main(){
    ll N,M; cin >> N >> M;
    Graph G(N);
    vector<ll> A(M),B(M),C(M);
    rep(i,M){
        ll a,b,c; cin >> a >> b >> c;
        a--, b--;
        A[i] = a, B[i] = b, C[i] = c;
        G[a].pb({b,c});
        G[b].pb({a,c});        
    }

    vector<vector<ll>> WF = Warshall_Floyd(G);
    ll ans = 0;
    rep(i,M){
        ll a = A[i], b = B[i];
        if(WF[a][b] != C[i]) ans++;
    }
    pr(ans);
    return 0;
}

Measured memory_bytes: 512
def q2():
    s = input()
    d,m = divmod(len(s), 2)
    s_a = s[:d]
    s_b = ''.join(reversed(s[d+m:]))
    ans = 0
    
    for i in range(d):
        if s_a[i] != s_b[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    q2()


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>
#include <set>
#include <vector>

using namespace std;

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

	map<int, set<vector<int>>> precompute;

	for (int i = 1; i <= 100; i++)
	{
		for (int j = 1; j <= 100; j++)
		{
			for (int k = 1; k <= 100; k++)
			{
				int check_value = i * i + j * j + k * k + i * j + j * k + i * k;
				vector<int> value_list = { i, j, k };

				precompute[check_value].insert(value_list);
			}
		}
	}

	int N;
	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		cout << precompute[i].size() << "\n";
	}

	return 0;
}


Measured memory_bytes: 100992
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] == arr[i - 1]) {
				System.out.println("Bad");
				return;
			}
		}
		System.out.println("Good");
	}
}


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


void solve(long long K, long long A, long long B){
    for(int i = A/K; i*K <= B; ++i) {
        if(A <= i*K && i*K <= B) {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    int max_cnt = 0;
    for(int i=0;i<n;++i) {
        cin >> s[i];
        ++mp[s[i]];
        max_cnt = max(max_cnt, mp[s[i]]);
    }

    set<string> ans;
    for(int i=0;i<n;++i) {
        if(mp[s[i]] == max_cnt) ans.insert(s[i]);
    }

    for(string t: ans) {
        cout << t << endl;
    }
}


Measured memory_bytes: 34816
# ABC109D - Make Them Even
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    A = list(list(map(lambda x: int(x) % 2, input().split())) for _ in range(H))
    ans = set()
    for i in range(H):  # move left to right
        for j in range(W - 1):
            if A[i][j]:
                A[i][j + 1] ^= 1
                ans |= {"{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)}

    for i in range(H - 1):  # move up to down
        if A[i][W - 1]:
            A[i + 1][W - 1] ^= 1
            ans |= {"{} {} {} {}".format(i + 1, W, i + 2, W)}
    print(len(ans))
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 21472
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll mod = 2019;

int main()
{
    ll L, R;
    cin >> L >> R;

    if (R - L >= 673 * 3)
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = 2019;

        for (ll i=L;i<=R;++i)
        for (ll j=i+1;j<=R;++j)
        {
            const ll x = (i * j) % mod;
            ans = min(ans, x);
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from itertools import product
N,M,X = map(int,input().split())
C = []
A = []
for n in range(N):
    a = list(map(int,input().split()))
    C.append(a[0])
    A.append(a[1:])
INF = 10**9
ans = INF
for p in product([0,1], repeat=N):
    sm = [0] * M
    cost = 0
    for i in range(N):
        if p[i]: # bitが立っていたら
            for m in range(M):
                sm[m] += A[i][m]
            
            cost += C[i] 
    #print (p,sm)
    if min(sm) >= X:
        ans = min(ans,cost)
if ans==INF: # 更新されていなければ-1を出力
    print (-1)
else:
    print (ans)

Measured memory_bytes: 9168
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
if n == 1:
  if b[0] >= a[0]:
    ans = ans + a[0]
  else:
    ans = ans + b[0]
else:
  for i in range(n):
    if b[i] > a[i]:
      ans += a[i]
      b[i] -= a[i]
      if b[i] >= a[i+1]:
        ans += a[i+1]
        a[i+1] = 0
      else:
        ans += b[i]
        a[i+1] -= b[i]
    elif b[i] == a[i]:
      ans += a[i]
    else:
      ans += b[i]

print(ans)

Measured memory_bytes: 82020
#include <stdio.h>

int main () {
    int ns,nt;
    scanf("%d ",&ns);
    int s[ns];
    int pre;
    for (pre=0;pre<ns;pre++) {
        scanf (" %d",&s[pre]);
    }
    scanf("%d ",&nt);
    int t[nt];
    for (pre=0;pre<nt;pre++) {
        scanf (" %d",&t[pre]);
    }

    int result=0;
    for (pre=0;pre<nt;pre++) {
    int r=ns,l=0,m=0;
        while (l < r) {
            m =(r+l)/2;
            if (t[pre] == s[m]) {
                result++;
                break;
            }else if (s[m] < t[pre]) {
                l = m+1;
            }else if (s[m] > t[pre]) {
                r = m;
            }
        }
    }
    printf("%d\n",result);

    return 0;
}


Measured memory_bytes: 2412
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
   //if(B<=A) cout<<0<<endl;
  if(B==1) cout<<0<<endl;
  else if(A==B) cout<<1<<endl;
  else if((B-A)%(A-1)==0) cout<<(B-1)/(A-1)<<endl;
  else cout<<1+(B-1)/(A-1)<<endl;
}

Measured memory_bytes: 3600
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  ll A, B, C;

  cin >> A >> B >> C;

  if (A == B && B == C)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  // if(A+B>C && A+C>B && B+C>A){
  //   cout << "Yes" << endl;
  // }
  // else{
  //   cout << "No" << endl;
  // }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

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

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> a(4);
    rep(i,0,4) cin >> a[i];
    int x = (a[2]+a[1]-1)/a[1];
    int y = (a[0]+a[3]-1)/a[3];
    if(x<=y){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int n,m,num[100010],red[100010],ans;

void work()
{
	scanf("%d %d",&n,&m),red[1]=1;
	for (int i=1; i<=n; i++)  num[i]=1;
	for (int i=1,x,y; i<=m; i++)
		{
			scanf("%d %d",&x,&y);
			if (red[x])  red[y]=1;
			num[x]--,num[y]++;
			if (!num[x])  red[x]=0;
		}
	for (int i=1; i<=n; i++)  ans+=red[i];
	printf("%d",ans);
}

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


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = GetNumbers();
            var area = num[0] * num[1];
            var surround = 2 * num[0] + 2 * num[1];
            Console.WriteLine(area + " " + surround);
        }

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static List<int> GetNumbers()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
        }

        static List<string> GetStrings()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
    }
}

Measured memory_bytes: 9992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e6 + 5;
const int mod = 1e9 + 7;
int a[maxn];
int main(){
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n;i++)
	for (int j = i + 1; j <= n; j++){
		ans += a[i] * a[j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr int MOD = 1000000007;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

VL prime_decomposition(ll n) {
	ll i = 2;
	VL table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace_back(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace_back(n);
		return table;
	}
}

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

	ll m = sqrt(n * 2);
	if (m*(m + 1) != n * 2) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	cout << m + 1 << endl;

	VVL mat = VVL(m + 1, VL(m, 0));

	ll num = 0;
	REP(i, m) {
		FOR(j, i, m) {
			mat[i][j] = ++num;
			mat[j + 1][i] = num;
		}
	}
	
	REP(i, m + 1) {
		cout << m;
		REPC(x, mat[i]) {
			cout << " " << x;
		}
		cout << endl;
	}

}

Measured memory_bytes: 2944
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{for(T&x:v)i>>x;return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;for(T&x:v)s<<' '<<x;return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}

const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

vvi e[20];

int main() {
  int n;
  string s;
  cin >> n >> s;
  vi a(26);
  rep(i,n) if (i%2==0) a[s[i]-'a']++;
  int ans = n;
  e[0].pb(vi());
  rep(i,9) {
    for (vi ne : e[i]) {
      int j = 1;
      if (sz(ne)) j = ne.back();
      for (;j<=9;++j) {
        vi me = ne; me.pb(j);
        e[i+j].pb(me);
      }
    }
  }
  rep(i,1<<10) if ((i&3) == 3) {
    int now = -9;
    vi b(10);
    rep(j,10) b[j] = i>>j&1;
    rep(j,10) if (b[j]) now += 4;
    // if (i == 47) cout<<now<<endl;
    vi s(10);
    bool ok = true;
    rep(c,26) {
      int x = a[c], z = INF;
      for (vi ne : e[x]) {
        int nz = 0;
        for (int j : ne) {
          if (!b[j]) {
            if (j == 1) nz += 2; else nz += 4;
          } else {
            nz += 2;
          }
        }
        mins(z,nz);
      }
      if (z == INF) ok = false;
      now += z;
      // if (i == 47) cout<<c<<" "<<z<<endl;
    }
    // if (i == 47) cout<<i<<" "<<now<<endl;
    // rep(j,10) if (b[j] && !s[j]) ok = false;
    if (ok) mins(ans, now);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3228
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int n, u, v;
vector <int> edge[150005];
double dp[150005];

void dfs(int cur, int par) {
    int sz = edge[cur].size();
    if (par >= 0) sz--;
    for (auto child : edge[cur]) {
        if (child == par) continue;
        dfs(child, cur);
        dp[cur] += (dp[child] + 1.0) / (double)sz;
    }
}

void dfs2(int cur, int par, double par_e) {
    dp[cur] = 0.0;
    double sz = (double)(edge[cur].size());
    for (auto child : edge[cur]) {
        if (child == par) dp[cur] += (par_e + 1.0) / sz;
        else dp[cur] += (dp[child] + 1.0) / sz;
    }

    for (auto child : edge[cur]) {
        if (child == par) continue;
        double next_par_e;
        if (par == -1 && sz == 1.0) next_par_e = 0.0;
        else next_par_e = (dp[cur] * sz - (dp[child] + 1.0)) / (sz - 1.0);
        dfs2(child, cur, next_par_e);
    }
}

int main() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        u--; v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    dfs(0, -1);
    dfs2(0, -1, 0);
    for (int i = 0; i < n; i++) {
        cout << fixed << setprecision(12) << dp[i] << "\n";
    }

    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    vi a(N);
    Rep(i,N){
        Scd(a[i]);
    }
    auto c = []( int a, int b ){ return a==b?-1:a>b?0:1; };
    int ans = 1;
    int tmp = c(a[0],a[1]);
    Rep(i,N-1){
        if( c(a[i],a[i+1]) == -1 ) continue;
        if( tmp != -1 && tmp != c(a[i],a[i+1]) ) i++, ans++;
        tmp = c(a[i],a[i+1]);
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,ans = 0, tmp = 0;
  string S;
  cin >> N >> S;
  rep(i,N){
    if(S[i] == 'I'){
      tmp++;
      ans = max(tmp,ans);
    }
    else{
      tmp--;
      ans = max(tmp,ans);
    }
  }
  cout << ans;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long int
#define IOS cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define pb push_back
using namespace std;
ll arr[100001];
map<int,vector<int> > mp;
ll fun(ll x){
	if(mp.find(x)==mp.end()){
		arr[x]=0;
		return 0;
	}else if(arr[x]!=-1)
	return arr[x];
	else if(arr[x]==-1) {
		ll temp=0;
		for(ll i=0;i<mp[x].size();i++){
			if(arr[mp[x][i]]!=-1){
				temp=max(temp,1+arr[mp[x][i]]);
			}else {
				temp=max(temp,1+fun(mp[x][i]));
			}
		}
		arr[x]=temp;
		return temp;
	}
}
int main() {
	IOS;
	ll n,m,x,y;
	ll const num=100001;
	for(ll i=1;i<num;i++)arr[i]=-1;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		if(mp.find(x)!=mp.end()){
			mp[x].pb(y);
		}else {
			vector<int> vec;
			vec.pb(y);
			mp.insert({x,vec});
		}
	}
	ll temp=0;
	for(ll i=1;i<=n;i++){
		if(arr[i]==-1){
			
			fun(i);
		}
		temp=max(temp,arr[i]);
	}
	cout<<temp;
	
}


Measured memory_bytes: 16128
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#include<stack>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
using namespace std;
typedef long long ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}

//------------------変数-----------------------//
ll cnt = 0;
string a;
//-------------------関数----------------------//

int main() {
	cin >> a;
	REP(i, a.size()-1) {
		char moto = a[i];
		if (a[i + 1] != moto) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    
    if(A==B){
    cout<<C<<endl;
    }
    if(A==C){
    cout<<B<<endl;
    }
    if(B==C){
    cout<<A<<endl;
    }
    
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {

    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        char[] s = in.next().toCharArray();
        char[] t = in.next().toCharArray();
        Arrays.sort(t);
        Arrays.sort(s);
        int n = t.length;
        for (int i = 0; i < n / 2; i++) {
            char ut = t[i];
            t[i] = t[n - i - 1];
            t[n - i - 1] = ut;
        }
//        out.println(s);
//        out.println(t);
        for (int i = 0; i < Math.min(t.length, s.length); i++) {
            if (s[i] < t[i]) {
                out.println("Yes");
                return;
            }
            if (t[i] < s[i]) {
                out.println("No");
                return;
            }
        }
        if (t.length > s.length) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21460
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string n;
	cin >> n;

	int ans = 0;
	for(char c : n)ans += c - '0';
	int a = 0;
	rep(i,n.size()) {
		if (n[i]!='0') {
			ans = max<int>(ans, a + (n[i]-'0'-1) + (n.size() - i - 1) * 9);
		}
		a += n[i] - '0';
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;

int main() {

    ll A,B;
    cin >> A >> B;
    if((A+B)%2==0) cout << (A+B)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n[101]={0},a,kai=0,i;
    while(scanf("%d",&a)!=EOF){
        n[a]++;
        if(kai<n[a])kai=n[a];
    }
    for(i=0;i<101;i++)if(kai==n[i])printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int l, i=0, a[3];
    while(cin>>l){
        a[i] = l;
        i++;
    }
  if(a[0]*a[1]<a[2]){
  	printf("%d",a[0]*a[1]);
  }else{
    printf("%d",a[2]);
  }
}

Measured memory_bytes: 256
from collections import defaultdict
N=int(input())

counter=defaultdict(int)

X=map(str,(range(1,N+1)))
for x in X:
    h=x[0]
    t=x[-1]
    counter[(h,t)]+=1

ans=0
items=list(counter.items())
for (h,t),cnt in items:
    ans+=cnt*counter[(t,h)]

print(ans)

Measured memory_bytes: 3316
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(A[K-1])

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int w, h, n;
int x[100], y[100];
int d[100][1001];
struct vertice {
	int id, bl; int cost;
	bool operator<(const vertice &v)const {
		if (v.cost != cost)return cost > v.cost;
		if (v.id != id)return v.id > id;
		else return v.bl > bl;
	}
};
priority_queue<vertice> q;
void init() {
	rep(i, 100) {
		rep(j, 1001) {
			d[i][j] = mod;
		}
	}
}
int main() {
	init();
	cin >> w >> h >> n;
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	rep(i, n) {
		int z = x[i] - 1 + y[i] - 1;
		q.push({ i,z,z });
		d[i][z] = z;
	}
	int ans = mod;
	//dijkstra
	while (!q.empty()) {
		vertice v = q.top(); q.pop();
		int id = v.id,bl=v.bl,cost=v.cost;
		int dis = h - x[id] + w - y[id];
		ans = min(ans, cost+max(0, dis - bl));
		rep(i, n) {
			if (i == id)continue;
			int dis = abs(x[id] - x[i]) + abs(y[id] - y[i]);
			dis = max(0, dis - bl-1);
			if (d[i][dis] > cost + dis) {
				d[i][dis] = cost + dis;
				q.push({ i,dis,cost + dis });
			}
		}
	}
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 4224
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<lli>/*------------------*/vlli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()
#define makepair/*---------------------*/make_pair

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	lli a,b,i,j,c,d;
	string s,t;
    cin >> a;
    cout << (24 + (24-a));
	return 0;
}










Measured memory_bytes: 256
/**
ID: albert.28
LANG: C++14
PROB: poetry
**/

/// Time:

#include <bits/stdc++.h>

/**
Mod operations in O(lg n)
Source: Benjamin Qi, https://github.com/bqi343/USACO/blob/master/Implementations/11%20-20(4)/Operators/modOp.cpp?fbclid=IwAR0m2afS-1xVg9kgeF8q8EJIeP9TP3Lct8dYb_hPJuI5gqHP1Utp5EkiOQ8
**/

using namespace std;

#define MAXN 100005
#define MOD 1000000007

#define FOR(g,i,n) for(int i = g; i < n; i++)
#define FORD(g,i,n) for(int i = g; i >= n; i--)

#define apple() ios_base::sync_with_stdio(0)
#define hentai() cin.tie(); cout.tie()

#define mp make_pair
#define pb push_back
#define	ll long long
// #define int ll
#define INF (1e9*1)+5
#define LL_INF (1e18*1)+5
#define bitinc(s) (s&-s)
#define endl '\n'

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mi;
#define f first
#define s second
typedef vector<pii> vii;
typedef set<pii> sii;
typedef map<pii, pii> mii;

void fileio(char* in, char* out)
{
	freopen(in, "r", stdin);
	freopen(out, "w", stdout);
}

namespace modOp
{
    int ad(int a, int b, int mod = MOD) { return (a+b)%mod; }
    int sub(int a, int b, int mod = MOD) { return (a-b+mod)%mod; }
    int mul(int a, int b, int mod = MOD) { return (ll)a*b%mod; }

    int AD(int& a, int b, int mod = MOD) { return a = ad(a,b,mod); }
    int SUB(int& a, int b, int mod = MOD) { return a = sub(a,b,mod); }
    int MUL(int& a, int b, int mod = MOD) { return a = mul(a,b,mod); }

    int po (int b, int p, int mod = MOD) { return !p?1:mul(po(mul(b,b,mod),p/2,mod),p&1?b:1,mod); }
    int inv (int b, int mod = MOD) { return po(b,mod-2,mod); }

    int invGeneral(int a, int b) { // 0 < a < b, gcd(a,b) = 1
        if (a == 0) return b == 1 ? 0 : -1;
        int x = invGeneral(b%a,a);
        return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
    }
}

using namespace modOp;

int n,m,dp[MAXN];
si a;
int main()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int w;
		cin >> w;
		a.insert(w);
	}
	dp[0]=1;
	for(int i = 1; i <= n; i++) if(!a.count(i)) // not a bad vertex
	{
		dp[i] = (dp[i-1] % MOD + (i==1 ? 0 : dp[i-2] % MOD))%MOD;
	}
	cout << dp[n] << endl; // number of ways to get to nth step
}


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

int main(){
	string S;
	cin >> S;
	ll ans = 0;
	int b = 0;
	rep(i,S.size()){
		b += S[i]=='B';
		if (S[i] == 'W') ans += b;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3740
n = list(str(input()))
l = len(n)
for i in range(l):
	n[i] = int(n[i])
k = int(input())
dp0 = [[0 for _ in range(4)] for _ in range(l+1)]
dp1 = [[0 for _ in range(4)] for _ in range(l+1)]
dp0[1] = [1, n[0]-1, 0, 0]
dp1[1] = [0, 1, 0, 0]
for i in range(2,l+1):
	for j in range(4):
		p = n[i-1]
		if j == 0:
			if p == 0:
				dp0[i][j] = dp0[i-1][j]
				dp1[i][j] = dp1[i-1][j]
			else:
				dp0[i][j] = 1
				dp1[i][j] = 0
		elif p == 0:
			dp1[i][j] = dp1[i-1][j]
			dp0[i][j] = dp0[i-1][j] + 9 * dp0[i-1][j-1]
		else:
			dp1[i][j] = dp1[i-1][j-1]
			dp0[i][j] = dp0[i-1][j] + 9 * dp0[i-1][j-1] + dp1[i-1][j] + (p-1) * dp1[i-1][j-1]
print(dp0[l][k] + dp1[l][k])

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

ll n;

int main () {
	cin>>n;
  	ll happy=0;
  	ll se=n/500;
  	happy+=se*1000;
  	n-=se*500;
  	se=n/5;
  	happy+=se*5;
  	cout<<happy<<endl;
}

Measured memory_bytes: 256
def main():

    N = int(input())
    A= list(map(int,input().split()))
    against = list(range(1,N+1))
    count = 0

    for i in range(N-1):
        if A[i]!=against[i]:
            count +=1
    
    if count < 3:
        print("YES")
    else:
        print("NO")




if __name__== "__main__":
    main() 


Measured memory_bytes: 38384
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
n, x = map(int, raw_input().split())
d = map(int, raw_input().split())
g = abs(x - d[0])
for z in d:
    g = gcd(g, abs(z - x))
print g

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

int n;
string S[50];

int count[50][26];
const int a = int('a');

void readInput(){
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> S[i];
    }
}

void initCountArray(){
    for(int i=0; i<50; i++){
        for(int j=0; j<26; j++){
            ::count[i][j]=0;
        }
    }
}

void countChar(){
    for(int i=0; i<n; i++){
        int size = S[i].size();
        for(int j=0; j<size; j++){
            int c = int(S[i][j])-a;
            ::count[i][c]++;
        }
    }
}

void printOutput(){
    int min;
    for(int i=0; i<26; i++){
        min = 10000;
        for(int j=0; j<n; j++){
            if(min > ::count[j][i]){
                min = ::count[j][i];
            }
        }
        for(int j=0; j<min; j++){
            cout << char(i+a);
        }
    }
    cout << endl;
}

int main(void){
    readInput();
    initCountArray();
    countChar();
    printOutput();
    return 0;
}


Measured memory_bytes: 384
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

def solve():
    n = INT()
    a = LIST()
    ans = 0
    tmp = a[0]
    for i in range(1, n):
        ans += max(0, tmp-a[i])
        tmp = max(tmp, a[i])
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 34176
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let n = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let d = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let mut v :Vec<Vec<i32>> = Vec::new();
	for i in 0..n {
		v.push(Vec::new());
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let mut iter = buf.split_whitespace();
		for j in iter {
			v[i as usize].push(j.parse::<i32>().ok().unwrap());
		}
	}
	
	let mut cnt = 0;
	for i in 0..n {
		for j in (i+1)..n {
			let mut dis:i32 = 0;
			for k in 0..d {
				dis += (v[ j as usize][k as usize] - v[i as usize][k as usize])*(v[j as usize][k as usize] - v[i as usize][k as usize]);
			}
			let mut k = 0;
			while(k <= dis){
				if k*k == dis {
					cnt += 1;
					break;
				}
				k += 1;
			}
		}
	}
	println!("{}", cnt);
}

Measured memory_bytes: 4352
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>

const long long INF = 10000000000000000;

using namespace std;

int main(){
	string s;
	cin>>s;
	bool flg=false;
L1:
	for(int i=1;i<s.size()-1;i++){
		if(s[i-1]!=s[i+1]){
			s.erase(i,1);
			flg=!flg;
			goto L1;
		}
	}
	if(flg) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;	
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;
int N;

int search(int *rot, int t, int cost){
	if(t == N) return cost;
	if(!rot[t]) return search(rot, t+1, cost);
	int rn = rot[t];
	int min = 10;
	for(int i=t;i<N;i++){
		int tmp[12];
		memcpy(tmp, rot, sizeof(tmp));
		for(int j=t;j<=i;j++) tmp[j]=(tmp[j]-rn+10)%10;
		int ret = search(tmp, t+1, cost+1);
		if(ret<min)min=ret;
	}
	return min;
}

int main(){
	int i,j;
	while(cin >> N,N){
		char s[12], t[12];
		cin >> s >> t;
		int rot[12];
		for(i=0;i<N;i++){
			rot[i] = (t[i]-s[i]+10)%10;
		}

		cout << search(rot, 0, 0) << endl;
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;


int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<ll> B(N);
    REP(i, N) cin >> B[i];
    vector<ll> C(N);
    REP(i, N) C[i] = A[i] - B[i];
    sort(ALL(C));
    ll ans = 0;
    ll cnt = 0;
    REP(i, N) {
        if (C[i] < 0){
            cnt++;
            ans += C[i];
        }
    }
    if (ans == 0) {
        PRINT(0);
        return 0;
    }
    REPR(i, N) {
        if (C[i] > 0) {
            cnt++;
            ans += C[i];
            if (ans >= 0) break;
        } else {
            PRINT(-1);
            return 0;
        }
    }
    PRINT(cnt);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if(k==0){
        ans = n*n;
        cout << ans << endl;
        return 0;
    }
    for(int i = k+1; i < n+1; i++){
        ans += (n/i)*(i-k);
        int tmp = n%i;
        if(tmp>=k){ans += tmp-k+1;}
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256