akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

    int N; cin >> N; int a[ N ]; for( int i = 0; i < N; cin >> a[ i++ ] );

    int count = 0;

    for( int i = 0, j = 1; j < N; i = j++ )
        if ( a[ i ] == a[ j ] )
            a[ j ] = -1, count++;

    cout << count;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define HMAX 52
#define WMAX 52

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

ll H,W;
static const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};

int main(){
	cin >> H >> W;
	cout << (((H%500) <= W) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  set<ll> d;
  rep(i,n){
    ll a;
    cin>>a;
    d.insert(a);
  }
  COUT(sz(d));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

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

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

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("Yes\n");
}

void no()
{
    printf("No\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    ll x;
    sc(x);
    if(x<30)no();
    else yes();
}

int main()
{
    ll t=1;
  //  sc(t);
    while(t--) solve();
}





Measured memory_bytes: 3688
import sys
# gcd
from fractions import gcd
from bisect import bisect_right
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_2.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    s = list(next(tokens))  # type: str
    n = len(s)
    cnt = 0
    lastfin = -1
    # write code
    num = 0
    while(num<n):
        if s[num] == 'A':
            j = num
            tmpcnt = []
            tmpa = []
            while (j < n-1):
                if s[j] == 'A':
                    tmpa.append(j)
                    j += 1
                elif s[j] == 'B' and s[j + 1] == 'C':
                    tmpcnt.append(j)
                    j += 2
                else:
                    break
            num = j+1
            # print(tmpa, tmpcnt, num)
            # print(len(tmpcnt))
            for t in tmpa:
                cnt += len(tmpcnt)-bisect_right(tmpcnt,t)
            # cnt.append(tmpcnt)
        else:
            num += 1
            continue
    print(cnt)
            



Measured memory_bytes: 15316
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
B = LIST()
C = LIST()

su = 0
for i in range(N - 1):
	if A[i+1] == A[i] + 1:
		su += C[A[i] - 1]

print(sum(B) + su)

Measured memory_bytes: 5444
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  cin >> s;
  set<char> v;
  rep(i, s.size()) v.insert(s[i]);
  int x = INF;
  for (char c : v) {
    string t = s;
    int i    = 0;
    while (any_of(all(t), [&](char x) { return x != c; })) {
      string u = "";
      rep(i, t.size() - 1) u += (t[i] == c || t[i + 1] == c) ? c : t[i];
      swap(t, u);
      i++;
    }
    cmin(x, i);
  }
  cout << x << endl;
}


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

ll dp[200][2];
int main(){
	dp[0][1]=1;
	int l,k;cin>>l>>k;
	rep(i,120)rep(j,2){
		if(j==0){
			if(i+1<=l)dp[i+1][!j]+=dp[i][j];
		}
		else{
			if(i+1<=l)dp[i+1][!j]+=dp[i][j];
			if(i+k<=l)dp[i+k][!j]+=dp[i][j];
		}
	}
	ll sum=0;
	rep(i,200)sum+=dp[i][0];
	cout<<sum<<endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;




signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  
    
        int a,v,b,w,t;
        cin>>a>>v>>b>>w>>t;
        int x=abs(a-b);
        if(abs(v-w)*t>=x && v>=w)
        {
            cout<<"YES";
        }
        else
        {
            cout<<"NO";
        }
        

} 

 

Measured memory_bytes: 3636
s[100],top,a,b;
char t[100];
push(x){s[++top]=x;}
pop(){return s[top--];}
main(){
    for(;~scanf("%s",t);){
        switch(*t){
            case'+':a=pop();b=pop();push(a+b);break;
            case'-':a=pop();b=pop();push(b-a);break;
            case'*':a=pop();b=pop();push(a*b);break;
            default:push(atoi(t));
        }
    }
    printf("%d\n",s[1]);
}

Measured memory_bytes: 1812
n = int(input())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
delta = sum(li_b) - sum(li_a)
if delta < 0:
    print('No')
    exit()
elif delta == 0:
    if li_a == li_b:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    li_d = []
    for i in range(n):
        li_d.append(li_b[i]-li_a[i])
    pa = 0
    pb = 0
    for i in li_d:
        if i >=0:
            pa += (i+1)//2
        else:
            pb += i
    if delta < max(pa, pb):
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 10540
N = int(input())
AB = [tuple(map(int,input().split())) for _ in range(N)]

AB.sort(key = lambda x:x[1])

ans,time,count = True,0,0
while count < N and ans:
	time += AB[count][0]
	if time > AB[count][1]:
		ans = False
	count += 1

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


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

int main() {
    char s;
    cin >> s;
    if(s-0x41 >= 0 && s-0x41 <= 25){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
}

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

#define IO  ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define endl '\n'
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int M=1e5+5;

int main()
{
    IO
    int n,k,ans=0,j=0;
    cin>>n>>k;
    k--;
    int arr[n+5];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(j<n-1){
            ans++;
            j+=k;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int a, b; cin >> a >> b;
	set<int> st;
	st.insert(a), st.insert(b);
	rep(i, 3) {
		if (not st.count(i + 1)) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
lo=[]
sh=[]

result=0

MAX = -(10**20)

for i  in range(n):
    xx,ll=map(int, input().split())
    lo.append(xx+ll)
    sh.append(xx-ll)
    

c=zip(sh,lo)
d=sorted(c,key=lambda x:x[1])

for i in range(n):
    if MAX <= d[i][0]:
        result+=1
        MAX=d[i][1]

print(result)

Measured memory_bytes: 19816
#!/usr/bin/env lua

a = io.read("*line")
nlist = {}
j = 1

for i in a:gmatch"%S+" do
    nlist[j] = tonumber(i)
    j = j + 1
end

num = 100 * nlist[1] + 10 * nlist[2] + nlist[3]

if num % 4 == 0 then
        print("YES")
else
        print("NO")
end


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  string s;
  cin >> s;

  int ans = 1;
  REP(i, n-1) {
    if(s[i] != s[i+1]) {
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e=0;
  cin>>a>>b>>c>>d;
  for(int i=0;i<a;i++){
    if(i<=b-1)
      e=e+c;
    else
      e=e+d;
  }
  cout<<e<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()

	mx := max(A+B, A-B)
	mx = max(mx, A*B)
	fmt.Println(mx)
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,ans=0,mem=INT_MAX,dai=INT_MIN;

main(){
	cin>>n;
	rep(i,n){
		int sute,t;
		cin>>sute>>t;
		chmin(mem,t);
		chmax(dai,sute);
	}
	ans+=mem+dai;
	dans;
}

Measured memory_bytes: 256
S = list(input())
R = int(input())
lengths = []
same = False
All = False
odd = False
sl = 1
Sum = 0
if S[0] == S[len(S)-1]:
  same = True
S.append('0')
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    sl += 1
  else:
    lengths.append(sl)
    sl = 1
if len(lengths) == 1:
  All = True
if lengths[0]%2 == 1 and lengths[len(lengths)-1]%2 == 1:
  odd = True
if same:
  if All:
    Sum += (lengths[0]*R)//2
  else:
    temp = lengths[0]
    lengths[0] = 0
    lengths[len(lengths)-1] += temp
    if odd:
      for l in range(len(lengths)):
        Sum += (lengths[l]//2)*R
      Sum -= 1
    else:
      for g in range(len(lengths)):
        Sum += (lengths[g]//2)*R
else:
  for j in range(len(lengths)):
    Sum += (lengths[j]//2)*R
print(Sum)

Measured memory_bytes: 3064
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = LONG_LONG_MAX;

int main() {
  string str;
  cin >> str;
  ll len = ((ll)str.size())/2;
  ll n = (ll)str.size();
  ll ans = 0;
  for (ll i = 0; i < len; i++) {
    if (str[i] != str[n-i-1]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {

	ll m, d,cnt=0,d1,d10;
	in(m);
	in(d);

	repeq(i, 1, m) {
		repeq(j, 11, d) {
			d1 = j % 10;
			d10 = (j - d1) / 10;
			if (d1>1 && d10 > 1 && d1 * d10 == i) {
				cnt++;
			}
		}
	}

	outn(cnt);

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;int arr[t];
	for(int i=0;i<t;i++){
		cin>>arr[i];
	}
	int dp[t];
	dp[0] = 0;
	for(int i=1;i<t;i++){
		if(i==1){
			dp[1] = abs(arr[1]-arr[0]);
		}
		else{
			dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
		}
	}
	cout<<dp[t-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    if(m==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    vector<vector<pair<ll,ll>>> p(n);
    rep(i,m){
        ll l,r,d;cin>>l>>r>>d;l--;r--;
        p[l].push_back({r,d});
        p[r].push_back({l,-d});
    }
    queue<ll>que;
    vector<ll> t(n,-1e18);
    rep(i,n){
        if(t[i]!=-1e18)continue;
        t[i]=0;
        que.push(i);
        while(que.size()){
            ll x=que.front();que.pop();
            ll tmp=t[x];
            rep(i,p[x].size()){
                ll r=p[x][i].first,d=p[x][i].second;
                if(tmp+d==t[r])continue;
                if(t[r]==-1e18){
                    t[r]=tmp+d;
                    que.push(r);
                    continue;
                }
                else{
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 16928
import itertools
nums = [int(e) for e in input().split()]
pairs = []
count = 0
for i in range(nums[1]):
    s = [int(t) for t in input().split()]
    pairs.append(s)
lis = [i for i in range(1,nums[0]+1)]
permutatin_lis = itertools.permutations(lis)
for one in permutatin_lis:
    if(one[0] != 1):
        continue
    else:
        for i in range(nums[0]-1):
            checker = [one[i],one[i+1]]
            checker.sort()
            if checker in pairs:
                pass
            else:
                break
        else:
            count += 1
print(count)

Measured memory_bytes: 41052
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-13 07:00:02
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  auto IsPrime = [](int x) -> bool {
    for (int i = 2; i * i <= x; ++i) {
      if (x % i == 0) return false;
    }
    return true;
  };

  vector<int> ans;
  int num = 1;
  while (ans.size() < 60) {
    if (IsPrime(num) && to_string(num).back() == '3') {
      ans.emplace_back(num);
    }
    ++num;
  }

  debug(ans);

  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }

  cout << '\n';

  return 0;
}

Measured memory_bytes: 256
void main()
{
    import std.stdio, std.string, std.array, std.algorithm, std.conv;
    auto b = readln.chomp.split.map!(to!int);
    b[0].solve(b[1]).writeln;
}

int solve(in int nTestCase, in int mTLE)
{
    immutable
        base = 100 * nTestCase + 1800 * mTLE,
        pInv = 1 << mTLE;
    /*
    S := 1 p + 2 pq + 3 pq^2 + ...
    qS := 1 pq + 2 pq^2 + 3 pq^3 + ...
    S = (p + pq + pq^2 + ...) / (1-q)
    S = 1 + q + q^2 + ...
    S = 1/(1-q) = 1/p = pInv;
    */
    return base * pInv;
}

unittest
{
    assert (1.solve(1) == 3800);
    assert (10.solve(2) == 18400);
    assert (100.solve(5) == 608000);
    import std.stdio;
    stderr.writeln("unittest passed!");
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import ceil


def solve(A: int, B: int):
    n = 1
    c = 0
    while(n < B):
        n += (A-1)
        c += 1

    print(c)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    n_odd = 0
    for a in A:
        n_odd += 1 if a % 2 == 1 else 0

    if n_odd % 2 == 0:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14052
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1E9+7
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";
// vector<bad()ool> v(1E5, false);


int main()
{   
    ll n;cin>>n;
    ll a[32] = {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};
    cout<<a[n-1];
} 

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    for(int i=0;4*i<=n;i++){
        for(int j=0;j*7<=n;j++){
            if(4*i+7*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
M, D = map(int, raw_input().split())
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        if len(str(d)) == 2 and d%10 >=2 and d/10 >= 2 and m == (d%10)*(d/10):
            ans += 1
print ans

Measured memory_bytes: 2692
//In the Name of God
//Let Our Voices Echo
#include<bits/stdc++.h>
using namespace std;
#define X real()
#define Y imag()
typedef long long ll;
typedef double ld; 
typedef complex<ld> point;
const ld eps=1e-9;
const int MAX=1e5+9,MOD=1e9+7;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n,x,s=0;
	cin>>n;
	while (n--) cin>>x,s^=x&1;
	if (!s) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}


Measured memory_bytes: 256
s1, s2, s3 = map(str, input().split())
S1_ord = ord(s1[0])-32
S2_ord = ord(s2[0])-32
S3_ord = ord(s3[0])-32

S1_chr = chr(S1_ord)
S2_chr = chr(S2_ord)
S3_chr = chr(S3_ord)
print(S1_chr + S2_chr + S3_chr)

Measured memory_bytes: 3060
import Foundation

let input = readLine()!

if "SSS" == input {
    print("0")
} else if "SSR" == input || "SRS" == input || "RSS" == input || "RSR" == input {
    print("1")
} else if "SRR" == input || "RRS" == input  {
    print("2")
} else if "RRR" == input {
    print("3")
}
 

Measured memory_bytes: 13032
shurui,total=map(int,input().split(" "))
s=[int(input())for i in range(shurui)]
remain=total-sum(s)
#print(remain)
flag=True
count=len(s)
while flag==True:
    if remain-min(s)>=0:
        remain=remain-min(s)
        count+=1
    else:
        flag=False
print(count)

Measured memory_bytes: 3064
L = []
for i in range(3):
    L.append(list(map(int, input().split())))

flag = True
for i in range(2):
    if L[0][i]-L[0][i+1]!=L[1][i]-L[1][i+1] or L[1][i]-L[1][i+1]!=L[2][i]-L[2][i+1] or L[i][0]-L[i+1][0]!=L[i][1]-L[i+1][1] or L[i][1]-L[i+1][1]!=L[i][2]-L[i+1][2]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> s;

    if(s.at(5)=='1') cout << "TBD" << endl;
    else if(s.at(6)=='1'||s.at(6)=='2'||s.at(6)=='3'||s.at(6)=='4'){
        cout << "Heisei" << endl;
    }
    else cout << "TBD" << endl;

//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int r; cin >> r;
    cout << r * r << endl;
}

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

using namespace std;
#define mod 1000000007
int main()
{
    string s;
    long long d;
    cin >> s >> d;
    long long n=s.size();
    long long a[100001];
    for(long long i=0;i<n;i++)
    {
        a[i]=s[i]-'0';
    }
    long long f[100005][105][2];
    memset(f,0,sizeof(f));
    f[0][0][1]=1;
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<d;j++)
        {
            f[i+1][(j+a[i])%d][1]+=f[i][j][1];
            f[i+1][(j+a[i])%d][1]%=mod;
            for(long long k=0;k<a[i];k++)
            {
                f[i+1][(j+k)%d][0]+=f[i][j][1];
                f[i+1][(j+k)%d][0]%=mod;
            }
            for(long long k=0;k<10;k++)
            {
                f[i+1][(j+k)%d][0]+=f[i][j][0];
                f[i+1][(j+k)%d][0]%=mod;
            }
        }
    }
    cout << (f[n][0][0]+f[n][0][1]-1+mod)%mod;
    return 0;
}


Measured memory_bytes: 165120
n,m = map(int, input().split())
list = [0] * n
list[0] = 1
if n >= 2:
    list[1] = 2
if n >= 3:
    for i in range(2, n):
        list[i] = list[i - 2] + list[i - 1]

if m == 0:
    print(list[n - 1] % 1000000007)
else:
    ans = 1
    o = 0
    for i in range(m):
        a = int(input())
        if a == o:
            ans = 0
            break
        if a > o + 1:
            ans = (ans * list[a - o - 2]) % 1000000007
        o = a + 1

    if a + 1 < n:
        ans = (ans * list[n - a - 2]) % 1000000007
    print(ans)

Measured memory_bytes: 460020
/**
 * @author      : cromarmot (yexiaorain@gmail.com)
 * @license     : GPL
 * @created     : 星期六 10月 05, 2019 20:05:23 CST
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define ten5 100000+10
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define iif(c,t,f) ((c)?(t):(f))
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
const double pi = acos(-1.0);

char s[110];

int main(){
  scanf("%s",s);
  ll k;
  scanf("%lld",&k);
  int n = strlen(s);
  if(n == 1){
    cout<<k/2<<endl;
    return 0;
  }
  if(n == 2){
    if(s[0] == s[1]){
      cout<<k<<endl;
    }else{
      cout<<0<<endl;
    }
    return 0;
  }
  bool allsame = true;
  rep(i,0,n-1){
    if(s[i] != s[i+1]){
      allsame = false;
      break;
    }
  }
  if(allsame){
    cout<<n*k/2<<endl;
    return 0;
  }
  int headn = 0;
  rep(i,0,n){
    if(s[i] != s[0]){
      break;
    }
    headn = i;
  }
  int tailn = 0;
  per(i,0,n){
    if(s[i] != s[n-1]){
      break;
    }
    tailn = i;
  }
  ll middlecost = 0;
  int vn = 1;
  rep(i,headn+2,tailn){
    if(s[i] != s[i-1]){
      middlecost += vn/2;
      vn = 1;
    }else{
      vn++;
    }
  }
  middlecost+=vn/2;
  if(s[0] == s[n-1]){
    cout<<(headn+1)/2 + (n-tailn)/2 + middlecost*k + (headn+1+n-tailn)/2*(k-1)<<endl;
  }else{
    cout<<((headn+1)/2 + (n-tailn)/2 + middlecost)*k<<endl;
  }
  return 0;
}

/*
 *
 * hash prime
   61,83,113,151,211,281,379,509683,911
   1217,1627,2179,2909,3881,6907,9209
   12281,16381,21841,29123,38833,51787,69061,92083
   122777,163729,218357,291143,388211,517619,690163,999983
   1226959,1635947,2181271,2908361,3877817,5170427,6893911,9191891
   12255871,16341163,21788233,29050993,38734667,51646229,68861641,91815541
   122420729,163227661,217636919,290182597,386910137,515880193,687840301,917120411
   1000000007,1000000009
 * */



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a,b;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(n+1);
    b.resize(n);
    rep(i,n+1){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    ll pre = 0;
    ll ans = 0;
    rep(i,n){
        ans += min(pre,a[i]);
        a[i] -= min(a[i],pre);
        pre = 0;
        if(b[i]>a[i]){
            ans += a[i];
            pre = b[i] - a[i];
            a[i] = 0;
        }else{
            a[i] -= b[i];
            ans += b[i];
            pre = 0;
        }
    }
    if(a[n]>pre){
        ans += pre;
    }else{
        ans += a[n];
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 1792
while True:
    n=input().split()
    n[0]=int(n[0])
    n[1]=int(n[1])
    if n[0]==0 and n[1]==0:
        break
 
    if n[0]>n[1]:
        c=n[0]
        n[0]=n[1]
        n[1]=c
    print(n[0],n[1])


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

using namespace std;
typedef long long ll;
//using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

ll N;
vector<ll> bit;

//a_1+...+a_iを返す(1_indexed)
ll sum(ll i){
    ll s = 0;
    while(i>0){
        s+=bit[i];
        i-=(i&-i);
    }
    return s;
}

//a_i+=x
void add(ll i, ll x){
    while(i <= N){
        bit[i]+=x;
        i+=(i&-i);
    }
}



int main() {
    cin >> N;
    bit.assign(N+10,0);

    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
        B[i]=A[i];
    }
    sort(B.begin(),B.end());

    for(int i=0;i<N;i++){
        A[i] = lower_bound(B.begin(),B.end(),A[i])-B.begin()+1;
    }
    
    ll ans=0;
    for(int i=0;i<N;i++){
        ans+=i-sum(A[i]);
        add(A[i],1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7584
#include <iostream>

using namespace std;

class DICE
{
public:
    void set_num (int a[])
    {
        for (int i=0; i<6; i++)
        {
            dicenum[i]=a[i];
        }
    }
    void make_move (char c)
    {
        int temp;
        if (c=='N')
        {
            temp=dicenum[4];
            dicenum[4]=dicenum[0];
            dicenum[0]=dicenum[1];
            dicenum[1]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='S')
        {
            temp=dicenum[1];
            dicenum[1]=dicenum[0];
            dicenum[0]=dicenum[4];
            dicenum[4]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='E')
        {
            temp=dicenum[2];
            dicenum[2]=dicenum[0];
            dicenum[0]=dicenum[3];
            dicenum[3]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='W')
        {
            temp=dicenum[3];
            dicenum[3]=dicenum[0];
            dicenum[0]=dicenum[2];
            dicenum[2]=dicenum[5];
            dicenum[5]=temp;
        }
    }
    int get_top ()
    {
        return dicenum[0];
    }
    int get_front ()
    {
        return dicenum[1];
    }
    int get_right ()
    {
        return dicenum[2];
    }
private:
    int dicenum[6];
};

int main()
{
    DICE dice;
    int a[6], q, b, c;
    for (int i=0; i<6; i++) cin>>a[i];
    dice.set_num(a);
    cin>>q;
    for (int i=0; i<q; i++)
    {
        cin>>b>>c;
        for (int j=0; j<4; j++)
        {
            for (int k=0; k<4; k++)
            {
                for (int l=0; l<4; l++)
                {
                    for (int m=0; m<4; m++)
                    {
                        for (int n=0; n<=j; n++) dice.make_move('N');
                        for (int n=0; n<=k; n++) dice.make_move('S');
                        for (int n=0; n<=l; n++) dice.make_move('E');
                        for (int n=0; n<=m; n++) dice.make_move('W');
                        if (dice.get_top()==b && dice.get_front()==c)
                        {
                            cout<<dice.get_right()<<'\n';
                            j=4; k=4; l=4; m=4;
                        }
                    }
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    auto solve=[&](ll x)->ll{
        ll ret=0;
        rep(i,n){
            bool flag=true;
            rep(bit,40){
                if(!((1ll<<bit)&x) && ((1ll<<bit)&a[i])) flag=false;
            }
            if(flag) ret+=b[i];
        }
        return ret;
    };
    ll ans=solve(k);
    rep(i,40){
        if((1ll<<i) & k){
            ll x=k^(1ll<<i);
            rep(j,i) x|=(1ll<<j);
            chmax(ans,solve(x));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int black[200010], white[200010];

int count(int *table, int l, int r) {
    return table[r] - table[l];
}

int main() {
    while (1) {
        int n;
        string s;
        if (!(cin >> n >> s)) return 0;
        black[0] = white[0] = 0;
        rep(i, n) {
            if (s[i] == '#') {
                black[i+1] = black[i] + 1;
                white[i+1] = white[i] + 0;
            } else {
                black[i+1] = black[i] + 0;
                white[i+1] = white[i] + 1;
            }
        }
        int ans = n;
        rep(i, n+1) {
            // [0..i) をwhite、[i..n)をblack
            ans = min(ans, count(black, 0, i) + count(white, i, n));
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2180
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORU(i,j,k) for(int i=(j);i<=(k);++i)
#define FORD(i,j,k) for(int i=(j);i>=(k);--i)

#define RDI(n) scanf("%d", &(n));
#define RDL(n) scanf("%lld", &(n));

using namespace std;

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

const long long int oo = 1000*1000*1000;

struct Coord
{
	int x, y;
	Coord(int x = 0, int y = 0) : x(x), y(y) {}
	Coord operator + (const Coord& droite) const
	{
		return Coord(x + droite.x, y + droite.y);
	}
};

struct AB
{
	int k;
	vector<lli> arbre;
	AB(int _k = 20, lli def = 0)
	{
		k = _k;
		FOR(i, 1 << k)
			arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
		FORD(i, ((1 << (k-1)) - 1), 1)
			arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
	}
	void set(int i, lli x)
	{
		int feuille = i + (1 << (k-1));
		arbre[feuille] = x;
		iset(feuille >> 1);
	}
	void iset(int noeud)
	{
		if(noeud)
		{
			arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
			iset(noeud >> 1);
		}
	}
	lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1)
	{
		if(q < p)
			q = 1 << (k-1);
		if(deb <= p && q <= fin)
			return arbre[noeud];
		if(deb >= q || fin <= p)
			return 0LL;
		int mil = (p + q) / 2;
		return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
	}
};

const int MAX_N = 100*1000+42;

lli vals[MAX_N];
lli cumulP[MAX_N];
lli cumul[MAX_N];
lli maxi;

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	FOR(i, n)
	{
		scanf("%lld", vals+i);
		cumul[i+1] = cumul[i] + vals[i];
		cumulP[i+1] = cumulP[i];
		if(vals[i] > 0)
			cumulP[i+1] += vals[i];
	}
	lli cur = cumul[k];
	FOR(i, n-k+1)
	{
		//printf("%lld %lld %lld %lld\n", cur, cumulP[i], cumulP[n], cumulP[i+k]);
		maxi = max(maxi, max(cur, 0LL) + cumulP[i] + cumulP[n] - cumulP[i+k]);
		cur = cur + vals[i+k] - vals[i];
	}
	printf("%lld\n", maxi);
	return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s[i] = bitset<32> (a[i]).to_string();
    }
    for(int j = 0; j < 32; j++){
        int cnt = 0;
        for(int i = 0; i < n; i++){
            cnt += (s[i][j] == '1');
        }
        if(cnt % 2 == 1){
            for(int i = 0; i < n; i++){
                if(s[i][j] == '1') s[i][j] = '0';
                else s[i][j] = '1';
            }
        }
    }
    for(int i = 0; i < n; i++){
        ll k = 0;
        reverse(s[i].begin(),s[i].end());
        for(int j = 0; j < 32; j++)
            k += (s[i][j] == '1') * (1 << j);
        cout << k << " ";
    }
    return 0;
}


Measured memory_bytes: 20352
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){

  int n; cin >> n;
  vector<int> A(n); for (int i=0; i<n; i++) cin >> A[i];
  int flag = 1;
  int swapCount = 0;
  while (flag){
    flag = 0;
    for (int j = n-1; j>=1; j--){
      if (A[j-1]>A[j]){
        swap(A[j-1],A[j]);
        flag = 1;
        swapCount++;
      }
    }
  }

  cout << A[0];
  for (int k=1; k<n; k++) cout << " " << A[k];
  cout << endl << swapCount << endl;

  return 0;
}



Measured memory_bytes: 3112
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    s = input()
    t = input()
    if s == t[:-1]:
        print("Yes")
    else:
        print("No")

    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 68508
#include <bits/stdc++.h>
using namespace std;
int main() {
    int q;
    string s, pre, post;
    long long ans;
    bool r = 0;
    cin >> s >> q;
    for (int i = 0; i < q; i++) {
        int t,f;
        string c;
        cin >> t;
        if (t == 2) {
            cin >> f >> c;
            if ((f*2 - 3)*(r*2 - 1) == 1) {
                pre += c;
            }else{
                post += c;
            }
        }else r = !r;
    }
    reverse(pre.begin(), pre.end());
    s = pre + s + post;
    if (r) {
        reverse(s.begin(), s.end());
    }

    cout << s << endl;

}



Measured memory_bytes: 4316