akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int ma[100000000];
int calu(int a,int b){
    int s = 1,w = 1;
    for(int x = a;x > a-b;x--){
        s *= x;
    }
    for(int y = 1;y <= b;y++){
        w*=y;
    }
    if(w==0)return 0;
    return s / w;
}
int main(){
    LL N;cin >> N;
    V<LL> vec;
    REP(a,N){
        CIN(b);
        vec.pb(b);
    }
    int MA = *max_element(ALL(vec));
    int n = MA/2;
    LL ans = 0;
    LL ins = 0;
    for(int a = 0;a < N;a++){
        if(ans <= (MA-vec.at(a))*vec.at(a)){
            ans = (MA-vec.at(a))*vec.at(a);
            ins = vec.at(a);
        }
    }
    cout<<MA<<" "<<ins<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) repi(i,0,n)

int n;

void solve()
{
  vector<int> v;
  rep(i, n) {
    int s; cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());

  int sum = 0;
  repi(i, 1, n - 1) sum += v[i];
  cout << sum / (n - 2) << endl;
}

int main()
{
  while (cin >> n and n) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 1220
[x,y]=[int(i) for i in input().split(" ")]
d=[y-x]
c={-1:1,1:0}
for i in [-1,1]:
 for j in [-1,1]:
   d.append(y*i-x*j+c[i]+c[j])
c=min(i for i in d if i>0)
print(c)


Measured memory_bytes: 3316
/*

Sviatoslav Bidzilia 2019
CF: anakib1

*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <functional>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define sz(a) (int)(a.size())
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long

template<typename A, typename B, typename C>
struct triple
{
	A X;
	B Y;
	C Z;
	triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
	return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
	if (a.X != b.X)
		return a.X < b.X;
	if (a.Y != b.Y)
		return a.Y < b.Y;
	return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
	ofs << "( " << p.F << " , " << p.S << " )";
	return ofs;
}
template<typename T>
void print(T a)
{
	for (auto i : a)
		cout << i << ' ';
	cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
	return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
	return min(a, min(b, c));
}
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
const int mod = 2019;
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	string s; cin >> s; int n = sz(s);
	vi a(n); rngi(i, n) a[i] = s[i] - '0';
	vi p(n + 1);
	p[0] = 1; rngi(i, n) p[i + 1] = (p[i] * 10) % mod;
	vi b(mod); b[0]++;
	int d = 0;
	for (int i = n - 1; i >= 0; i--) {
		int v = d + p[n - i - 1] * a[i]; v %= mod;
		b[v]++; d = v;
	}
	int ans = 0; 
	rngi(i, mod) ans += (b[i]) * (b[i] - 1) / 2;
	cout << ans << '\n';
}

Measured memory_bytes: 6752
import math
n = int(input())
s = int(input())

if s == n:
    print(n + 1)
    exit()
elif s > n:
    print(-1)
    exit()

for i in range(2, math.floor(math.sqrt(n)) + 1):
    new_n = n
    remain = 0
    while new_n > 0:
        remain += new_n % i
        new_n //= i

    if remain == s:
        print(i)
        exit()

for i in range(math.floor(math.sqrt(n)) + 1, 0, -1):
    b = (n - s) // i + 1
    st = n % b + n // b
    if n // b != b and st == s:
        print(b)
        exit()

print(-1)


Measured memory_bytes: 9216
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin), idx##_sz = (int)(end); idx < idx##_sz; ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

char solve(string A, string B, string C, char turn) {

	switch (turn) {
	case('a'):
		if (A == "") return 'A';
		return solve(A.substr(1), B, C, A[0]);
		break;
	case('b'):
		if (B == "") return 'B';
		return solve(A, B.substr(1), C, B[0]);
		break;
	case('c'):
		if (C == "") return 'C';
		return solve(A, B, C.substr(1), C[0]);
		break;
	}

	return '*';
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string A, B, C;
	cin >> A >> B >> C;

	cout << solve(A.substr(1), B, C, A[0]);
	return 0;
}

Measured memory_bytes: 384
S = int(input())
A = S // 100
B = S % 100
MMA = False
MMB = False
if 1 <= A and A <= 12:
  MMA = True
if 1 <= B and B <= 12:
  MMB = True

if MMA and MMB:
  print('AMBIGUOUS')
elif MMA and not(MMB):
  print('MMYY')
elif not(MMA) and MMB:
  print('YYMM')
else:
  print('NA')

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


int isP(string s){
  //  cout << s << endl;
    int i,j;
    for(i=0,j=s.size()-1;i<j;j--,i++)
        if( s[i] != s[j])
            break;
    return (i<j)?0:1;
}
main(){
    string s;
    cin >> s;
    int mid = s.size()/2;
    if( isP(s) && isP(s.substr(0,mid))  && isP( s.substr(mid+1,mid) ) )
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

pos_list = [0] * n
# print(index_list) [0, 0, 0, 0] n = 4 のとき
for index, i in enumerate(p, 0):
    # print(index, i)
    pos_list[i - 1] = index
    # print(index_list)

left_next_index = list(range(-1, n-1)) + [-1, -1]
right_next_index = list(range(1, n+1)) + [n, n]

answer = 0
# print(left_next_index)    [-1, 0, 1, -1, -1]
# print(right_next_index)   [1, 2, 3, 3, 3]
for i in range(1, n):
    index = pos_list[i-1]
    l1 = left_next_index[index]
    l2 = left_next_index[l1]
    r1 = right_next_index[index]
    r2 = right_next_index[r1]
    # print(index, l1, l2, r1, r2, i)
    answer += i * ((index-l1) * (r2-r1) + (r1-index) * (l1-l2))

    left_next_index[r1] = l1
    right_next_index[l1] = r1

print(answer)

Measured memory_bytes: 20152
from collections import defaultdict
import numpy as np

[n, m] = list(map(int, input().split()))
py = [list(map(int, input().split())) for _ in range(m)]

d = defaultdict(int)
py = np.array(py)
argsort = np.argsort(py[:, 1])
t = []
for [p, y] in py[argsort]:
    d[p] += 1
    t.append(d[p])
t = np.array(t)[np.argsort(argsort)]

for [p, y], t in zip(py, t):
    print('{0:06d}{1:06d}'.format(p, t))

Measured memory_bytes: 46876
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
cnt = 0
for i, aa in enumerate(a):
    if aa < 0:
        a[i] = -aa
        cnt += 1
if cnt % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - min(a) * 2)


Measured memory_bytes: 12508
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    ab = []
    for i in range(N):
        a,b = inputMap()
        ab.append((a,b))
        
    cd = []
    for i in range(M):
        c,d = inputMap()
        cd.append((c,d))
        
    man = []
    for i,val in enumerate(ab):
        a,b = val
        tmp = []
        for j,vol in enumerate(cd):
            c,d = vol
            tmp.append(abs(a-c)+abs(b-d))
        
        tmptmp = 0
        ind = 0
        for k, v in enumerate(tmp):
            if k == 0:
                tmptmp = v
            else:
                if tmptmp > v:
                    tmptmp = v
                    ind = k
        print(ind+1)
        
        
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 41584
#include<iostream>
#include<cstdio>
#include<math.h>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for (int i=0;i<n;i++){
        cin>>h[i];
    }
    vector<ll> dp(n);
    dp[0]=0;
    for (int i=0;i<n-1;i++){
        ll x=pow(10,9);
        for (int j=1;j<min(i+1,k)+1;j++){
            if (dp[i+1-j]+abs(h[i+1]-h[i+1-j])<x){
                x=dp[i+1-j]+abs(h[i+1]-h[i+1-j]);
            }
        }
        dp[i+1]=x;
    }
    cout<<dp[n-1];

}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    string s; cin >> s;
    string s2 ;
    for ( int i = 1 ; i < s.size(); i++ ){
        s2 = s.substr(0,s.size()-i);
        int num = s2.size()/2;
        if ( s2.size() ==  num*2 && s2.substr(0,num) == s2.substr(num,num)){
            cout << s2.size() << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
#define ll long long int
#define  INF pow(10,9)
#define vi vector<long long int>
#define fast ios_base::sync_with_stdio(false)
#define pb push_back
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll c=1;
    ll max;
    cin>>max;
    for(ll i=1;i<n;i++){
        ll x;
        cin>>x;
        if(x>=max){
            c++;
            max = x;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2707.cc: Jail
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  ll p = 0;
  for (int i = 1; i < n; i++)
    p += p / (k - 1) + 1;

  printf("%lld\n", p);
  return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int minAns = 1010101010;
	vector<int> a(5);
	rep(i, 5) cin >> a[i];
	
	do {
		int ans = 0;
		rep(i, 5)
		{
			if (ans % 10 != 0) while (ans % 10 != 0) ans++;
			ans += a[i];
		}
		minAns = min(ans, minAns);
		
	} while (std::next_permutation(a.begin(), a.end()));
	cout << minAns << endl;
	return 0;
}

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

int main(){
    int N, i, j, jadge, dal_4[30], dal_7[30];
    cin >> N;
    dal_4[0] = 0;
    dal_7[0] = 0;
    jadge = 0;
    for(i=1; i<30; i++){
        dal_4[i] = dal_4[i-1] + 4;
    }
    for(j=1; j<30; j++){
        dal_7[j] = dal_7[j-1] + 7;
    }

    for(i=0; i<25; i++){
        for(j=0; j<25; j++){
            if(dal_4[i] + dal_7[j] == N){
                cout << "Yes" <<endl;
                jadge = 1;
                i = 25;
                j = 25;
            }
        }
    }

    if(jadge == 0){
        cout << "No" <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
if n==1:
  start=0
  goal=10
else:
  start=10**(n-1)
  goal=10**n
ans=-1
for i in range(start,goal):
  x='0'+str(i)
  ok=True
  for j in range(m):
    if x[sc[j][0]] != str(sc[j][1]):
      ok=False
  if ok:
    ans=i
    break
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

class Program
{
	public static int Main(string[] args)
	{
		string[] str = Console.ReadLine().Split(' ');
		int a = int.Parse(str[0]);	
        int b = int.Parse(str[1]);
        int answer = a * b - a - b + 1;
        Console.WriteLine(answer);
		return 0;
	}
}


Measured memory_bytes: 11092
N = int(input())
a = list(map(int, input().split()))

#「3倍する」操作は考慮する必要がない
#各数値が2で何回割れるかの合計が答えとなる
ans = 0
for n in a:
    count = 0
    while n % 2 == 0:
        n //= 2
        count += 1
    ans += count

print(ans)

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

#define sz(s) (int)(s).size()
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 100000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}


int main()
{	
	int n, m;
	cin >> n >> m;
	int t = n, p = m;
	string s, x;
	while (t --)
	{
		s += char(m + 48);
	}
	while (p --)
	{
		x += char(n + 48);
	}
	if (s > x)
		cout << x;
	else
		cout << s;
		









	getchar();
	getchar();
	return 0;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int main()
{
	CIN(int, N);
	int i;
	for (i = 1; i <= N; i <<= 1);
	cout << (i >> 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    int ans=0;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(i%2==0 && a[i]%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

bool cmp(const pair<int, LL> &x, const pair<int, LL> &y){
    return x.second==y.second ? x.first < y.first : x.second < y.second;
}

int main() {
    int n;
    vector<pair<LL, LL>> a;
    vector<LL> a_value;
    vector<LL> a_sorted_idx;
    vector<LL> a_sorted_value;
    LL tmp_a;
    LL ans=0;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(make_pair(i, tmp_a+i));
        a_value.push_back(i-tmp_a);
        a_sorted_idx.push_back(0);
        a_sorted_value.push_back(0);
    }

    sort(a.begin(),a.end(), cmp);

    for(int i=0; i<n; i++){
        a_sorted_idx[i] = a[i].first;
        a_sorted_value[i] = a[i].second;
        //cout << a[i].first << " " << a[i].second << endl;
    }

    for(int i=0; i<n; i++){
        auto it_value_start = lower_bound(a_sorted_value.begin(), a_sorted_value.end(), a_value[i]);
        auto it_value_end = lower_bound(a_sorted_value.begin(), a_sorted_value.end(), a_value[i]+1);
        int dist_start = distance(a_sorted_value.begin(), it_value_start);
        int dist_end = distance(a_sorted_value.begin(), it_value_end);
        auto it_idx_start = lower_bound(a_sorted_idx.begin()+dist_start, a_sorted_idx.begin()+dist_end, i);
        //auto it_idx_end = lower_bound(a_sorted_idx.begin()+dist_start, a_sorted_idx.begin()+dist_end, i+1);
        int dist_idx_start = distance(a_sorted_idx.begin(), it_idx_start);
        //int dist_idx_end = distance(a_sorted_idx.begin(), it_idx_end);
        ans+=dist_idx_start-dist_start;
        //cout << i << " " << a_value[i] << " " << dist_start << " " << dist_end << " " << dist_idx_start << " " << dist_idx_end << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13504
#include <bits/stdc++.h>
#include <utility>
#include <algorithm>
#include <math.h>
#include <cmath>

using namespace std;
typedef long long ll;

ll dp[100005];
ll arr[100005];
int n=0;
int k;
ll dpfun(int i)
{
	if(dp[i]!= -1)
		return dp[i];
	if(i==n-1)
		return dp[i]=0;
	if(i==n-2)
		return dp[i]=abs(arr[i]-arr[i+1]);
	ll mini = INT_MAX;
	for(int j=1;j<=k && (i+j)<n;j++)
	{
		mini = min(abs(arr[i]-arr[i+j]) + dpfun(i+j), mini);
	}

	dp[i]=mini;
		return dp[i];
}

int main()
{
	ios_base::sync_with_stdio(false); 
	cin>>n>>k;
	memset(dp,-1, sizeof dp);
	int i;
	for(i=0;i<n;i++)
		cin>>arr[i];

	cout<<dpfun(0)<<endl;
	return 0;
}

Measured memory_bytes: 6528
N = int(input())
factor = dict()
if N%2 == 0:
    factor[2] = 0
    while N%2 == 0:
        factor[2] += 1
        N/=2
f = 3
while f**2 <= N:
    if N%f == 0:
        factor[f] = 0
        while N%f == 0:
            factor[f] += 1
            N/= f
    else:
        f += 2
p = len(factor.values())
ans = 0
for k in range(p):
    A = list(factor.values())[k]
    for l in range(1,100):
        A -= l
        if A < 0:
            break
        ans += 1
if N != 1:
    ans += 1
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  vector<tuple<int,int> > vec;
  while(true)
  {
    int a,b;
    cin>>a>>b;
    if((a==0) && (b==0)) break;
    vec.emplace_back(a,b);
  }


  for (int i = 0; i < vec.size(); i++)
  {
    int H,W;
    H = get<0>(vec[i]);
    W = get<1>(vec[i]);

    for (int h = 0; h < H; h++)
    {
      for (int w = 0; w < W; w++)
      {
        if((h+w)%2 == 0)
        cout<<"#";
        else
        cout<<".";
      }
      cout<<endl;
    }
      cout<<endl;
    
  }

  return;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3016
#include<cstdio>
#include<iostream>
#define neko 100005
#define heko 405
#define qwq return putchar('Y'),putchar('E'),putchar('S'),0; 
#define orz return putchar('N'),putchar('O'),0; 
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
static int n,H;
typedef int arr[heko];
static arr fa,book,dgi,dgo,out;
namespace IO
{
	const unsigned int bufsize=1<<16,outsize=1<<24;
	static char ch[bufsize],*S=ch,*T=ch;
	inline char getc()
	{return ((S==T)&&(T=(S=ch)+fread(ch,1,bufsize,stdin),S==T)?0:*S++);}
	static char Out[outsize],*nowp=Out;
	inline void flush(){fwrite(Out,1,nowp-Out,stdout);nowp=Out;}
	template<typename T>
		void read(T &x)
		{
			char c=getc();x=0;
			for(;!isdigit(c);c=getc());
			for(;isdigit(c);x=(x<<1)+(x<<3)+(c^'0'),c=getc());
		}
	template<typename T>
		void write(T x,char c='\n')
		{
			if(!x)*nowp++='0';
			static unsigned int stk[50],tp=0;
			for(;x;x/=10)stk[++tp]=x%10;
			for(;tp;*nowp++=stk[tp--]^'0');*nowp++=c;
		}
}
inline int find(int x){return fa[x]^x?fa[x]=find(fa[x]):x;}
int main()
{
	using namespace IO;
	int x,y,z,o,X,Y,HH;
	read(n),read(H),HH=H<<1;
	f(i,0,HH)fa[i]=i;
	f(i,1,n)
	{
		read(x),read(y),read(z),read(o);
		if(z==0)X=H+x;
		else X=H-z;
		if(o==0)Y=H-y;
		else Y=H+o;
		book[X]=book[Y]=1;
		++dgi[Y],++dgo[X];
		fa[find(Y)]=find(X);

	}
	f(i,0,H)if(dgi[i]<dgo[i])orz;
	f(i,H+1,HH)if(dgi[i]>dgo[i])orz;
	f(i,0,HH)out[fa[i]]|=(dgi[i]^dgo[i]);
	f(i,0,HH)if(fa[i]==i&&book[i]&&!out[fa[i]])orz;
	qwq;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int h, n; scanf("%d%d", &h, &n);

	std::vector<int> dp(h + 1, 1 << 30); dp[0] = 0;
	while(n--) {
		int a, b; scanf("%d%d", &a, &b);

		for(int j = 0; j < dp.size(); j++) {
			int to = std::min(j + a, h);
			dp[to] = std::min(dp[to], dp[j] + b);
		}
	}

	printf("%lld\n", dp.back());
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[200005];
int f[200005][2];//f[i][0]: last str length ==1 f[i][1]: last str length == 2
int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    memset(f,-1,sizeof(f));
    f[1][0]=1;
    f[2][1]=1;
    if(s[1]!=s[2])f[2][0]=2;
    for(int i=3;i<=n;++i){
        for(int j=0;j<2;++j){
            if(f[i-j-1][j^1]!=-1){
                f[i][j]=f[i-j-1][j^1]+1;
            }
            bool equallast=true;
            for(int k=0;k<=j;++k){
                if(s[i-j+k]!=s[i-2*j-1+k]){
                    equallast=false;break;
                }
            }
            if(!equallast)f[i][j]=max(f[i][j],f[i-j-1][j]+1);
        }
    }
    printf("%d\n",max(f[n][0],f[n][1]));
    return 0;
}
/*
a
aa 1
a aa 2 
a aa a 0
a aa aa 1
a aa a aa 2
*/

Measured memory_bytes: 1920
A, B, C, D = [int(_) for _ in input().split()]

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

def calc(A, B, x):
    s = A // x * x
    if s < A:
        s += x
    e = B // x * x
    result = (e - s) // x + 1
    #print(s, e, result)
    return result

result = B - A + 1 - (calc(A, B, C) + calc(A, B, D) - calc(A, B, C * D // gcd(C, D)))

print(result)


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	
	auto pal = [](string t) {
		int i = 0, j = t.length() - 1;
		while(i < j) {
			if(t[i++] != t[j--]) return false;
		}
		return true;
	};
	
	bool ok = pal(s);
	int n = s.length();
	string t = s.substr(0, n/2);
	ok &= pal(t);
	t = s.substr(n/2+1, n/2);
	ok &= pal(t);
	cout << (ok ? "Yes" : "No") << endl;
	
}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const LL  INF  = 1<<30;
const int mod  = 1e9+7;

int s[10];

void solve(){
    for(int i=1;i<=3;i++){
        scanf("%d",&s[i]);
    }
    sort(s+1,s+4);
    int ans = 0 ;
    for(int i=2;i<=3;i++){
        ans += s[i]-s[i-1];
    }
    printf("%d\n",ans);
    return;
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int cas = 1,t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.lang.StringBuilder

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val ans = readLine()!!.replace('?', 'D')
    println(ans)

}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 41220
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            cout << "Bad";
            return 0;
        }
    }   
    cout << "Good";
}


Measured memory_bytes: 256
H, W = map(int, input().strip().split())
S = ['.' *(W+2)]
for _ in range(H):
  s = input().strip()
  S.append('.' + s + '.')
S.append('.'*(W+2))

for i in range(1, H+1):
  for j in range(1, W+1):
    if S[i][j] == '.':
      k = 0
      k += 1 if S[i-1][j-1]=='#' else 0
      k += 1 if S[i-1][j]=='#' else 0
      k += 1 if S[i-1][j+1]=='#' else 0
      k += 1 if S[i][j-1]=='#' else 0
      k += 1 if S[i][j+1]=='#' else 0
      k += 1 if S[i+1][j-1]=='#' else 0
      k += 1 if S[i+1][j]=='#' else 0
      k += 1 if S[i+1][j+1]=='#' else 0
      print(k, end='')
    else:
      print('#', end='')
  print()

Measured memory_bytes: 3444
A, B = list(map(int, input().split()))
if A >= 2 and B >= 2:
    if A > B:
        print("Alice")
    elif A < B:
        print("Bob")
    else:
        print("Draw")
else:
    if A == 1 and B != 1:
        print("Alice")
    elif A != 1 and B == 1:
        print("Bob")
    else:
        print("Draw")

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>
#include <cassert>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<lint>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
using si = set<int>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20
#define yes "Yes"
#define no "No"

constexpr lint MOD = 1e9 + 7;
const double PI = acos(-1);
lint A, B, C, D, E, F, G, H, I, J, K, L, M, N;
lint O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
lint ans = INT32_MAX;
bool can = false;
vvi n;
vi m;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N >> M >> X;
	n.resize(N, vi(M));

	rep(i, N) {
		rep(j, M + 1) {
			cin >> n[i][j];
		}
	}

	rep(i, pow(2, N)) {
		lint sum = 0;
		m.assign(M, 0);
		rep(j, N) {
			if (i & (1 << j)) {
				sum += n[j][0];
				rep(k, M) {
					m[k] += n[j][k + 1];
				}
			}
		}

		bool tmp = true;
		rep(j, M) {
			if (m[j] < X) {
				tmp = false;
				break;
			}
		}
		if (tmp) {
			can = true;
			ans = min(ans, sum);
		}
	}

	cout << (can ? ans : -1) << endl;
    return 0;
}

Measured memory_bytes: 4080
// Date: 2020-02-25

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL S[N][2];
int a[N], b[N];

int main() {
    mem(S, -0x3f);
    int n; scanf("%d", &n);
    for(int i = 0; i < (1 << n); ++i) scanf("%d", &a[i]), S[i][0] = a[i];
    for(int k = 0; k < n; ++k) {
        for(int i = 0; i < (1 << n); ++i) {
            if(!((i >> k) & 1)) {
                int j = (i | (1 << k));
                b[0] = S[i][0], b[1] = S[i][1];
                b[2] = S[j][0], b[3] = S[j][1];
                sort(b, b+4);
                S[j][0] = b[3], S[j][1] = b[2];
            } 
        }
    }
    LL ans = 0;
    for(int i = 1; i < (1 << n); ++i) {
        ans = max(ans, S[i][0] + S[i][1]);
        printf("%lld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 24448
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            string s;
            cin>>s;
            int ct=0,i;
            for(i=0;i<3;++i)
                ct=ct+(s[i]=='R');
            if(ct==2 && s[0]==s[2])
                --ct;
            cout<<ct<<endl;
        }
        return 0;
    }


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e5 + 5;

int dp[maxn];

int main(){
	int n,i,j;
	scanf("%d",&n);
	int h[maxn];
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	dp[1] = abs(h[1] - h[0]);
	for(i=2;i<n;i++){
		dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
	}
	printf("%d\n",dp[n-1]);
	return 0;
};

Measured memory_bytes: 1024
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

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

N = input()

flag = False
for i in range(N):
    if input() % 2 == 1:
        flag = True

if flag:
    print "first"
else:
    print "second"

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

//template<class T, size_t N> 
//size_t countof(const T (&array)[N]) { return N; }

int main() {
  int A,B,C,X,Y;

  cin >> A>>B>>C>>X>>Y;

  int min_c = A*X+B*Y;
  //Xの方が小さい
  if(min(X,Y)==X) {
    min_c = min(min_c,X*C*2 +(Y-X)*B);
    min_c = min(min_c,Y*2*C);
  }

  if(min(X,Y)==Y) {
    min_c = min(min_c,Y*C*2 +(X-Y)*A);
    min_c = min(min_c,X*C*2);
  }

  cout << min_c << endl;
  



  //  int n = sizeof(s)/sizeof(*s);

  //  cout  <<  sizeof(s)/sizeof(*s) << endl;


}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int five = 0;
		int seven = 0;
		if (A == 5) {
		    five++;    
		} else if (A == 7) {
		    seven++;
		}
		if (B == 5) {
		    five++;    
		} else if (B == 7) {
		    seven++;
		}
		if (C == 5) {
		    five++;    
		} else if (C == 7) {
		    seven++;
		}
        if (five == 2 && seven == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21460
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int n,k;
  string s;
  cin>>n>>k>>s;
  s[k-1]=tolower(s[k-1]);
  cout<<s<<endl;
}

Measured memory_bytes: 256
from collections import deque

def bfs(grid, costs, queue, wall, res):
    ans = 0
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while res:
        y,x = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall:
                continue
            queue.append([y_,x_])
            grid[y_][x_] = wall
            costs[y_][x_] = costs[y][x] + 1
            ans = max(ans, costs[y_][x_])
            res -= 1
    return ans

import sys
input = sys.stdin.readline
H,W = map(int, input().split())
wall = '#'
queue = deque([])
edges = [wall for _ in range(W+2)]
grid = [edges]
costs = [[0 for _ in range(W+2)]]

for i in range(1,H+1):
    S = [wall]+list(input().strip())+[wall]
    for j in range(1,W+1):
        if S[j] == wall:
            queue.append([i,j])
    grid.append(S)
    costs.append([0 for _ in range(W+2)])
grid.append(edges)
print(bfs(grid, costs, queue, wall, H*W - len(queue)))


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

int main() {
    string s;cin>>s;
    long long n;cin>>n;
    
    for(int i=0;i<n;++i){
        if(s[i]=='1' && n<=i+1){
            cout<<1<<endl;
            return 0;
        }
        else if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

const long double root3 = pow(3, 0.5);

struct p {
  long double x, y;
};

void koch(int x, p p1, p p2) {
  if (x == 0) return;
  p s, t, u;
  s.x = (p1.x * 2 + p2.x) / 3;
  s.y = (p1.y * 2 + p2.y) / 3;
  t.x = (p2.x * 2 + p1.x) / 3;
  t.y = (p2.y * 2 + p1.y) / 3;
  u.x = (t.x - s.x) / 2 - (t.y - s.y) * root3 / 2 + s.x;
  u.y = (t.x - s.x) * root3 / 2 + (t.y - s.y) / 2 + s.y;
  koch(x-1, p1, s);
  cout << setprecision(10) << s.x << " " << s.y << endl;
  koch(x-1, s, u);
  cout << setprecision(10) << u.x << " " << u.y << endl;
  koch(x-1, u, t);
  cout << setprecision(10) << t.x << " " << t.y << endl;
  koch(x-1, t, p2);
}

int main() {
  int n;
  cin >> n;
  p f,e;
  f.x = 0;
  f.y = 0;
  e.x = 100;
  e.y = 0;
  cout << setprecision(10) << f.x << " " << f.y << endl;
  koch(n, f, e);
  cout << setprecision(10) << e.x << " " << e.y << endl;
  return 0;
}


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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B==C+D) cout<<"Balanced"<<endl;
  else if(A+B<C+D) cout<<"Right"<<endl;
  else cout<<"Left"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import math

N= int(input())
a = math.factorial(N)
xy = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(len(xy)):
    for j in range(len(xy)):
        if i != j:
            ans += math.sqrt((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)
print(ans / N)

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

int main(){
  ll A,B,K;
  cin >> A >> B >> K;
  
  if(K >= A){
    K = K-A;
    A = 0;
  }else{
    A = A-K;
    K = 0;
  }
  
  if(K >= B){
    K = K-B;
    B = 0;
  }else{
    B = B-K;
    K = 0;
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

int main() {
    vector<int> 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};
    int k; cin >> k;

    cout << a.at(k - 1) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
#define KOZYUN(a) SORT(a); REVERSE(a) 
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    VI a(n); VIin(a);
    int ans = 0;
    bool flg = true;
    while(flg){
        rep(i,n){
            if(a[i] % 2 == 0) a[i] /= 2;
            else{
            	ANS;
              	return 0;
            }
        }
        ans++;
    }
    ANS;

    return 0;
}

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

int main() {
    string S;
    cin >> S;

    ll ans = 0;

    vector<vector<ll>> dp(S.size() + 1, vector<ll>(13));
    dp[0][0] = 1;
    rep(i, S.size()) {
        int r = S[i] == '?' ? -1 : S[i] - '0';

        rep(j, 10) {
            if (r != -1 && r != j)
                continue;

            rep(k, 13)
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
        }
        rep(j, 13) dp[i + 1][j] %= MOD;
    }

    cout << dp[S.size()][5] << endl;

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1000000007;
int N, A[100100];
int c[3];

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

  std::cin >> N;

  for(int i=0;i<N;++i){
      std::cin >> A[i];
  }

  memset(c, -1, sizeof(c));

  ll res = 1ll;

  for(int i=0;i<N;++i){
      int n = 0, j0 = -1;

      for(int j=0;j<3;++j){
          if(c[j] + 1 == A[i]){
              n += 1;
              j0 = j;
          }
      }

      res = res * n % MOD;
      c[j0] += 1;
  }

  std::cout << res << std::endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, m;
    cin >> n >> m;
    vint cnt(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        ++cnt[a];
        ++cnt[b];
    }

    rep(i, n)
    {
        if (cnt[i] % 2 == 1)
        {
            NO;
            return;
        }
    }
    YES;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 640
s=input()
t=''
for i in range(len(s)):
    if s[i]!='A':
        t+=s[i]
ans=''
if t=='KIHBR':
    cnt=0
    if s[s.index('K')+1]=='I' and s[s.index('I')+1]=='H':
        for i in range(len(s)):
            if s[i]=='A':
                cnt+=1
                if cnt==2:
                    ans='NO'
                    break
            else:
                cnt=0
        if cnt<2:
            ans='YES'
        else:
            ans='NO'
    else:
        ans='NO'
else:
    ans='NO'
print(ans)

Measured memory_bytes: 3064
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string S, T;

  cin >> S >> T;

  int len_S = S.size();

  string F = T.substr(0, len_S);
  if (S == F)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3596
a = []
a[0] = gets.to_i
a[1] = gets.to_i
a[2] = gets.to_i
a[3] = gets.to_i
a[4] = gets.to_i

mi = 0
a.each_with_index { |v,i|
  x = v % 10
  if x > 0 and x < a[mi] % 10
    mi = i
  end
}

def dceil(x,y)
  return (x+y-1)/y
end

s = 0
a.each_with_index { |v,i|
  if i != mi
    s += dceil(v, 10) * 10
  end
}


puts s + a[mi]


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
long long mod=1e9+7;

long long modpow(long long a,long long p){
    if(p==0)return 1;
    if(p%2==0){
      long long halfP=p/2;
      long long half=modpow(a,halfP);
      return half*half%mod;
    }else{
      return a*modpow(a,p-1)%mod;
    }
}

long long comb(int a,int b){
  if(b>a-b)return comb(a,a-b);
  long long ansMul=1;
  long long ansDiv=1;
  for(int i=0;i<b;i++){
    ansMul*=(a-i);
    ansDiv*=(i+1);
    ansMul%=mod;
    ansDiv%=mod;
  }
  long long ans=ansMul*modpow(ansDiv,mod-2)%mod;
  return ans;
}

int main(){
  long long n,m;
  cin>>n>>m;
  long long ans=1;
  for(int i=2;i<m&&i<1e5;i++){
    long long cnt=0;
    while(m%i==0){
      cnt++;
      m/=i;
    }
    ans*=comb(n+cnt-1,n-1);
    ans%=mod;
  }
  if(m!=1){
    ans*=comb(n,n-1);
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[10];
	scanf("%s",a);
	getchar();
	//printf("%c %c",a[2],a[3]);
	if(a[2]==a[3]&&a[4]==a[5])printf("Yes\n");
	  else printf("No\n");
	
	
	
	
	
	
	
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n, k; cin >> n >> k;
  ld ans = 0;
  for (int i = 1; i <= n; ++i) {
    int numFlips = 0;
    int j = i;
    while (j < k) {
      j*=2;
      numFlips++;
    }
    ans += 1.0 / (ld)(1<<numFlips);
  }
  ans /= n;
  cout << ans << nl;
  return 0;
}



Measured memory_bytes: 256