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

#define int long long

const int N = 1e4 + 10;
int n, ans, cnt[3]; // B- -A BA
string s;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int j = 0; j < (int)s.size() - 1; j++)
			if (s[j] == 'A' && s[j + 1] == 'B')
				ans++;
		
		if (s[0] == 'B' && s.back() == 'A')
			cnt[2]++;
		else if (s[0] == 'B')
			cnt[0]++;
		else if (s.back() == 'A')
			cnt[1]++;
	}
	
	if (!cnt[2])
		cout << ans + min(cnt[0], cnt[1]);
	else {
		int a = cnt[0], b = cnt[1];
		if (a) {
			a--;
			ans++;
		}
		if (b) {
			b--;
			ans++;
		}
		cout << ans + cnt[2] - 1 + min(a, b);
	}
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def main():
    S = input()
    pre = S[0]
    ans = 0
    for i, c in enumerate(S):
        if i == 0: continue
        if c != pre:
            ans += 1
            pre = c
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 67448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) { cin >> h[i]; }
    // output
    ll tmp = h[0];
    rep(i, n - 1)
    {
        if (tmp - h[i+1]>= 2) {
            puts("No");
            return 0;
        }
        tmp = max(h[i + 1], tmp);
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<malloc.h>
#include<string.h>
using namespace std;
typedef struct node{
	int key;
	struct node *prev,*next;
}q,*qq;
node *head;//仅声明还没有内存分配 
void init()//关键的初始化！！！ 
{
	head=(q*)malloc(sizeof(q));
	head->next=head;//!!! 
	head->prev=head;//!!!
}
void insert(int key) 
{
	/* 尾插入法 
	qq tt=head;
	while(tt->next)
	{
		tt=tt->next;
	}
	qq ttnode=(q*)malloc(sizeof(q));
	ttnode.prev=tt;
	ttnode.next=null;
	ttnode.key=key;*/
	
	//头插入法
	qq ttnode=(q*)malloc(sizeof(q));
	ttnode->key=key;
	ttnode->prev=head;
	ttnode->next=head->next; 
	head->next->prev=ttnode;
	head->next=ttnode;
}

qq listsearch(int key)
{
	qq cur = head->next;//从头结点后面的元素开始访问 
	while(cur!=head&&cur->key!=key)
	{
		cur=cur->next;
	}
	return cur;
}

void deleteNode(qq t)//删除指定结点 
{
	if(t==head)
		return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst()
{
	deleteNode(head->next);	
} 

void deleteLast()
{
	deleteNode(head->prev);
}

void deleteKey(int key)
{
	deleteNode(listsearch(key));
}

void printList()
{
	qq ppp=(q*)malloc(sizeof(q));
	ppp=head->next;
	int flag=0;
	while(ppp!=head)
	{
		if(flag!=0)
			cout<<" "<<ppp->key;
		else
			cout<<ppp->key;
		flag++;
		ppp=ppp->next;
	}
	printf("\n"); 
}
int main()
{
	int n;
	cin>>n;
	char com[20];
	int kkey;
	init();
	while(n--)
	{
		scanf("%s%d",com,&kkey);//使用效率更高的输入函数
		if(com[0]=='i')
		{
			insert(kkey);
			//printList();
			//cout<<endl;
			//cout<<"dadada"<<endl;
		}
			
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F')
					deleteFirst();
				else if(com[6]=='L')
					deleteLast();
				}
			else
				deleteKey(kkey);
			}
	} 
	printList();
	return 0;
}
/*
7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
*/
	



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string l;
    cin >> l;
    int32 n = l.size();
    vector<vector<int64>> dp(n, vector<int64>(2, 0));   //0 : < , 1 : =
    dp[0][0] = 1;
    dp[0][1] = 2;
    FOR(i,1,n){
        if(l[i] == '0'){
            dp[i][0] = (dp[i-1][0] * 3) % MOD;
            dp[i][1] = dp[i-1][1];
        }else{
            dp[i][0] = (dp[i-1][0] * 3 + dp[i-1][1]) % MOD;
            dp[i][1] = (dp[i-1][1] * 2) % MOD;
        }
    }
    ANS((dp[n-1][0] + dp[n-1][1]) % MOD);
    return 0;
}

Measured memory_bytes: 5840
#include<cstdio>
#include<math.h>
 
int main(){
    double a,b,c,d;
    scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
    printf("%f\n", sqrt((c - a) * (c - a) + (d - b) * (d -b)));
    return 0;
}

Measured memory_bytes: 1080
#include <stdio.h>

int main()
{
	int a[4],b[4],i,j,h,bl;

	while(scanf("%d %d %d %d",a,a+1,a+2,a+3)!=EOF){
		scanf("%d %d %d %d",b,b+1,b+2,b+3);
		h=bl=0;
		for(i=0;i<4;i++){
			if(a[i]==b[i]) h++;
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(i!=j){
					if(a[i]==b[j]) bl++;
				}
			}
		}
		printf("%d %d\n",h,bl);
	}
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=0,ans=0;
    for(int i=0;i<s.length();i++)
    {

         if(s[i]=='R') c++;
         else c=0;
         ans=max(ans,c);
    }
    cout<<ans;

}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int s, i = 1;
  cin >> s;
  while (s != 4 && s != 2 && s != 1) {
    if (s % 2 == 0) s /= 2;
    else s = 3 * s + 1;

    ++i;
  }
  cout << i + 3 << endl;
  return 0;
}


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

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int x = a;
	int flag = 0;
	for(int i = 1; i <= 1e5; i++)
	{
		if(x%b == c)
		{
			flag = 1;
			break;
		}
		else
		{
			x = x + a;
		}
	}
	if(flag == 1) printf("YES\n");
	if(flag == 0) printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;




int main(){
    ll n;
    vector<ll> a;
    cin>>n;
    ll mx=-1;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        mx=max(b,mx);
        a.push_back(b);
    }
    ll w=-1;
    double mx2=E;
    for(int i=0;i<n;i++){
        if(abs((double)mx/2-a[i])<mx2){mx2=abs((double)mx/2-a[i]); w=a[i];}
    }
    if(w==mx){w=a[0];}
    if(w==mx){w=a[1];}
    cout<<mx<<" "<<w<<endl;
    
    return 0;
}


Measured memory_bytes: 1400
# TODO: P3: Create modint library with Python 
"""
【競プロ】繰り返し二乗法と再帰関数
https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
「1000000007 で割ったあまり」の求め方を総特集！ 〜 逆元から離散対数まで 〜
https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
Pythonでmodintを実装してみた
https://qiita.com/wotsushi/items/c936838df992b706084c

"""
# No mod

# def pow(a,n):
#     """
#     繰り返し二乗法 (半分の数の 2 乗)
#     a の n 乗を O(logN) で計算する
#     """
#     if n == 0:
#         return 1
#     x = pow(a, n//2)
#     x *= x
#     if n%2 == 1:
#         x *= a
#     return x
# def choose(n, a):
#     """
#     nCa (n 個から a 個選ぶ組み合わせ)
#         分子: n!
#         分母: a! * (n-a)!
#     約分して
#         分子: n * (n-1) * ... * (n-a+1) = (n-i) の積の和 (i=0 ~ a-1)
#         分母: a!
#     逆元
#      フェルマーの小定理より
#         1 ≡ x**(p-1) (mod p)
#         => 1/x ≡ x**(p-2) (mod p)
#         => 1/x%p = x**(p-2)%2
#     """
#     x = 1 # 分子
#     y = 1 # 分母
#     for i in range(a):
#         x *= n-i
#         y *= i+1
#     pow
#     return x / y

def pow(a, n, MOD):
    """
    繰り返し二乗法 (半分の数の 2 乗)
    Compute nth power of a -- O(logn)
    """
    if n == 0:
        return 1
    x = pow(a, n//2, MOD)
    x = (x%MOD * x%MOD) % MOD
    if n%2 == 1:
        x = (x%MOD * a%MOD) % MOD
    return x

def choose(n, a, MOD):
    """
    nCa (Choose a from n)
        numerator (分子): n!
        denominator(分母): a! * (n-a)!
    Reduce... (約分)
        numerator:: n * (n-1) * ... * (n-a+1) = (n-i) の積の和 (i=0 ~ a-1)
        denominator: a!
    iverse (逆元)
     フェルマーの小定理
        1 ≡ x**(p-1) (mod p)
        => 1/x ≡ x**(p-2) (mod p)
        => 1/x%p = x**(p-2)%2
    """
    x = 1 # numerator
    y = 1 # denominator
    for i in range(a):
        x = (x%MOD * (n-i)%MOD) % MOD
        y = (y%MOD * (i+1)%MOD) % MOD
    return (x * pow(y, MOD-2, MOD)) % MOD

"""
AC: https://atcoder.jp/contests/abc156/submissions/10294982
N**2 - 1 - nCa - nCb

pow(2,n)
140625001
nCa
-483404860
nCb
589953354
"""

n, a, b = map(int, input().split())
MOD = 1000000007
# n,a,b = 4,1,3
# n,a,b = 1000000000,141421,173205

ans = pow(2, n, MOD)
ans -= 1
ans = (ans%MOD - choose(n,a,MOD)) % MOD
ans = (ans%MOD - choose(n,b,MOD)) % MOD
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  ll piv = vec[0];
  ll ans = 0;
  rep(i,n){
    if(piv > vec[i]){
      ans += piv - vec[i];
    }else{
      piv = vec[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4788
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    ns=int(N**0.5+1)
    ans=0
    for i in range(1,ns):
        ni=N-i
        d,m=divmod(ni,i)
        if m==0 and d>i:
            ans+=d
    print(ans)





if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
	int n;
	cin >> n;
	bool flag = false;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0 && max(i, n / i) < 10) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0] * 1
M = line[1] * 1 
C = line[2] * 1
B = lines.shift().split(' ')
cnt = 0
for (i=0;i<N;i++) {
    line = lines[i].split(' ')
    sum = 0
    for (j=0;j<M;j++) {
        sum += line[j] * B[j]
    }
    if (sum + C > 0) {
        cnt++
    }
}
console.log(cnt)


Measured memory_bytes: 7372
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){

    y=x;

    if(z->key<x->key) x=x->left;
    else x=x->right;
  }

    z->parent=y;

  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;

}


void inorder(Node u){
  if(u==NIL) return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;

  printf(" %d",u->key); 
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    char c;
    rep(i,19) {
        cin>>c;
        if(c==',') cout<<" ";
        else cout<<c;
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
module AtCoder

    export readline

    function readline(T)
        return Base.parse(T, Base.readline(Base.stdin))
    end

end


module ABC162

    import Main.AtCoder
    export task_a

    function evaluate_task_a(target_integer::Core.UInt16)

        given_integer = AtCoder.readline(Core.UInt16)
        data_digits   = Base.digits(given_integer)

        for itr = 1:1:Base.size(data_digits, 1)
            if (data_digits[itr] == target_integer)
                return "Yes"
            end
        end

        return "No"

	end
	
	function execute_task_a()
		Base.println(evaluate_task_a(Base.convert(Core.UInt16, 7)))
	end

end

ABC162.execute_task_a()

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

int main(){
    int n,t;
    cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        cin>>t;
        if(s.find(t)==s.end())
            s.insert(t);
    }
    if(n==s.size())
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	for ( int n; cin >> n, n ; )
	{
		int W, H;
		cin >> W >> H;
		
		VVI board( H + 2, VI( W + 2, 0 ) );
		REP( i, 0, n )
		{
			int x, y;
			cin >> x >> y;
			board[ y ][ x ] = 1;
		}
		int s, t;
		cin >> s >> t;

		int res = 0;
		for ( int i = 1; i + s - 1 <= W; i++ )
		{
			for ( int j = 1; j + t - 1 <= H; j++ )
			{
				int tmp = 0;

				REP( k, 0, s )
				{
					REP( l, 0, t )
					{
						tmp += board[ j + l ][ i + k ];
					}
				}

				res = max( res, tmp );
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
long long n;
int ans;
int dp[100];
int d[100][100];
bool chk[1000006];
vector<long long>sosu;
long long POW(long long v, int a)
{
	if(!a)return 1;
	long long tmp = POW(v,a/2);
	return tmp*tmp*(a%2?v:1);
}
int getval(long long v, long long p)
{
	int ret = 0;
	while(v%p==0)
	{
		v/=p;
		ret++;
	}
	return ret;
	/*
	int s = 1, e = 1, mid;
	long long tmp = p;
	while(1LL*tmp*p<=v)
	{
		e++;
		tmp*=1LL*p;
	}
	int ans = 1;
	while(s<=e)
	{
		int mid = s+e>>1;
		//printf("in bs %d %d %d\n",s,e,mid);
		if(v%POW(p,mid)==0)
		{
			ans = max(ans,mid);
			s = mid+1;
		}
		else
		{
			e = mid-1;
		}
	}
	return ans;
	*/
}
int main()
{
	cin>>n;
	for(int i=2;1LL*i*i<=n;i++)
	{
		if(chk[i])continue;
		sosu.push_back(i);
		for(int j=i*2;1LL*j*j<=n;j+=i)
		{
			chk[j] = true;
		}
	}
	for(int i=1;i<100;i++)d[i][i] = 1;
	for(int i=1;i<100;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(!d[i][j])continue;
			dp[i] = max(dp[i],d[i][j]);
			for(int k=j+1;i+k<100;k++)
			{
				d[i+k][k] = max(d[i+k][k],d[i][j]+1);
			}
		}
	}
	for(auto k:sosu)
	{
		if(k>n)break;
		if(n%k)continue;
		//printf("%d\n",k);
		int tmp = getval(n,k);
		//printf(" %d\n",tmp);
		n/=POW(k,tmp);
		ans += dp[tmp];
		//printf("n %d ans %d\n",n,ans);
	}
	if(n>1)ans++;
	cout<<ans;
}

Measured memory_bytes: 5268
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int n;
    cin >> n;
    vector<int> s(n,0);
    vector<int> v;
    rep(i,n){
        cin >> s.at(i);
        if(s.at(i)%10)v.push_back(s.at(i));
    }
    ll sum = accumulate(s.begin(),s.end(),int());
    sort(v.begin(),v.end());
    if(v.empty()){
        cout << 0 << endl;
        return 0;
    }
    rep(i,n){
        if(sum%10 != 0){
            cout << sum << endl;
            return 0;
        }else{
            sum -= v[i];
        }
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <complex>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

typedef complex<double> P;

int main(){
  while(const int n = getInt()){
    vector<P>   pos(n);
    vector<double> v(n);

    REP(i,n){
      const int x = getInt();
      const int y = getInt();
      v[i] = getInt();
      pos[i] = P(x, y);
    }

    const double r = 0.98;
    P p(0, 0);

    auto calc = [&](P p){
      auto mx = make_pair(0.0, 0);
      REP(i,n) mx = max(mx, make_pair(abs(p - pos[i]) / v[i], i));
      return mx;
    };

    for(double d = 1000; d > 1e-8; d *= r){
      auto mx = calc(p).second;
      p += (pos[mx] - p) / abs(pos[mx] - p) * d;
    }

    printf("%.8f\n", calc(p).first);
  }

  return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < 4; i++) {
		if(s[i] == '2') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;	
}


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

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

	if (k == 0) {
		cout <<1ll* n * n;
		return 0;
	}

	ll count = 0;
	for (int b = k + 1;b <= n;b++) {
		count += max(0, (b - k)*(n / b));
		count += max(0, n%b - k + 1);
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  for(int c = min(a, b); c < max(a, b) + 1; c++)
  {
    if((a * b * c) % 2 == 1)
    {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char input[10] = {0};
  fgets(input, 10, stdin);
  for(int i = 0; i < 3; i++){
    if(input[i] == '1'){
      input[i] = '9';
    }else if(input[i] == '9'){
      input[i] = '1';
    }
  }
  printf("%s", input);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int n;
	
	cin >> n;
	
	int a[n];
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	int mi = 1e9;
	
	for(int i = 1; i <= 100; ++i) {
		int sm = 0;
		
		for(int j = 0;j < n; ++j) {
			sm += pow((a[j]-i),2);
		}
		
		mi = min(mi , sm);
	}
	
	cout << mi;
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N; cin >> N;
    if (N == 3) {
        cout << "2 5 63\n";
        return 0;
    }
    vector<int> ans = {2,4,3,9};
    N -= 4;
    int curr = 15;
    while (N >= 2 && curr+6 <= 30000) {
        ans.push_back(curr);
        ans.push_back(curr+6);
        curr += 12;
        N -= 2;
    }
    curr = 8;
    while (N >= 2 && curr+2 <= 30000) {
        ans.push_back(curr);
        ans.push_back(curr+2);
        curr += 6;
        N -= 2;
    }
    curr = 6;
    while (N > 0 && curr <= 30000) {
        ans.push_back(curr);
        curr += 6;
        N--;
    }
    //output
    //cout << "sz = " << ans.size() << '\n';
    for (int i: ans) {
        cout << i << ' ';
    }
    cout << '\n';
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    typedef pair<LL, LL> PLL;
    const LL MAXN = 100000, INF = 1e18, mod = 1e9 + 7;
    vector<PLL> g[MAXN];
    LL dp[2][MAXN], N, M, S, T, sp[2][MAXN];
    void shortest(LL S, LL* dp, LL* sp) {
      priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
      fill(dp, dp + N, INF), fill(sp, sp + N, INF);
      dp[S] = 1;
      sp[S] = 0;
      pq.push({sp[S], S});
      while (pq.size()) {
        auto P = pq.top(); pq.pop();
        LL cur = P.first, v = P.second;
        if (cur != sp[v]) continue;
        for (PLL Q: g[v]) {
          LL d = Q.second, u = Q.first;
          if (d + cur == sp[u]) dp[u] = (dp[u] + dp[v]) % mod;
          else if (d + cur < sp[u]) sp[u] = d + cur, dp[u] = dp[v], pq.push({sp[u], u});
        }
      }
    }
     
    int main() {
      scanf("%lld%lld", &N, &M);
      scanf("%lld%lld", &S, &T), --S, --T;
      LL v, u, d;
      for (int i = 0; i < M; ++i)
        scanf("%lld%lld%lld", &v, &u, &d), --u, --v, 
        g[u].push_back({v, d}), g[v].push_back({u, d});
      shortest(S, dp[0], sp[0]), shortest(T, dp[1], sp[1]);
      LL D = sp[0][T], ans = dp[0][T] * dp[0][T] % mod;
      assert(dp[0][T] == dp[1][S]);
      LL pre = 0, diag = 0;
      auto sq = [=](LL x){x %= mod; return x * x % mod;};
      for (int i = 0; i < N; ++i) if (sp[0][i] * 2 == D and sp[1][i] * 2 == D) 
        pre = (pre + dp[0][i] * dp[1][i]) % mod, diag = (diag + sq(dp[0][i] * dp[1][i]))%mod;
      for (int v = 0; v < N; ++v) for (PLL P: g[v]) {
        LL u = P.first, dis = P.second;
        if (sp[0][u] * 2 < D and sp[1][v] * 2 < D and sp[0][u] + sp[1][v] + dis == D)
          pre = (pre + dp[0][u] * dp[1][v]) % mod, diag = (diag + sq(dp[0][u] * dp[1][v]))%mod;
      }
      printf("%lld\n", (pre * pre - diag)%mod);
    }

Measured memory_bytes: 18772
n = int(input())
num = []
while n > 0:
    num.append(n%10)
    n //= 10
if num[0] == 2 or num[0]== 4 or num[0]== 5 or num[0]== 7 or num[0]== 9:
    print("hon")
elif num[0] == 0 or num[0]== 1 or num[0]== 6 or num[0]== 8:
    print("pon")
else:
    print("bon")

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

i64 nCr(i64 n, i64 r)
{
    if (r == 0 || n == r)
        return 1;
    return nCr(n - 1, r) * n / (n - r);
}

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

    vector<int> a(n);
    for (auto &&i : a)
    {
        cin >> i;
    }

    vector<int> dup(n + 10);
    for (auto &&ai : a)
    {
        dup[ai]++;
    }

    vector<i64> bis(n + 10);
    i64 sum = 0;
    for (size_t i = 1; i <= n; i++)
    {
        if (dup[i] <= 1)
        {
            bis[i] = 0;
            continue;
        }
        bis[i] = nCr(dup[i], 2);
        sum += bis[i];
    }

    for (size_t k = 1; k <= n; k++)
    {
        if (dup[a[k-1]] <= 1)
        {
            cout << sum << endl;
        }
        else
        {
            cout << sum - dup[a[k-1]] + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 11904
#include <iostream>

using namespace std;

int main(void){
  string s;
  cin>>s;
  int ans=0;
  int head=0;
  int tail=s.length()-1;
  int hxnum=0;
  int txnum=0;
  while(1){
    while(s[head]=='x'){
      head++;
      hxnum++;
    }
    while(s[tail]=='x'){
      tail--;
      txnum++;
    }
    if(s[head]!=s[tail]){
      cout<<-1<<endl;
      return 0;
    }
    if(head==tail){
      if(hxnum>txnum) ans+=hxnum-txnum;
      else ans+=txnum-hxnum;
      cout<<ans<<endl;
      return 0;
    }
    if(hxnum>txnum) ans+=hxnum-txnum;
    else ans+=txnum-hxnum;
    head++;
    tail--;
    hxnum=0;
    txnum=0;
    if(head>tail){
      cout<<ans<<endl;
      return 0;
    }
  }
  return 0;
}

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

int main(){

    // 1. 入力情報.
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    // 2. 判定.
    bool ok = (c >= a);
    ok &= (c <= b);
    
    // 3. 出力.
    printf("%s\n", ok ? "Yes" : "No");
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll dp[101][1000001];
ll knapsack(int n,ll wt,ll w[],ll v[]){
	if(n==0||wt==0)
	return 0;
	if(dp[n][wt]!=-1)
	return dp[n][wt];
	if(w[n-1]>wt){
	return dp[n][wt]=knapsack(n-1,wt,w,v);
    }
	else{
    dp[n][wt]=max(knapsack(n-1,wt,w,v),v[n-1]+knapsack(n-1,wt-w[n-1],w,v));
    }
	return dp[n][wt];
}
int main(){
	int n;
	ll wt;
	cin>>n>>wt;
	ll w[n],v[n];
	for(int i=0;i<n;i++)
	cin>>w[i]>>v[i];
	//int dp[n+1][wt+1];
	memset(dp,-1,sizeof(dp));
    cout<<knapsack(n,wt,w,v)<<"\n";	
}


Measured memory_bytes: 792660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int d[N];
  for(int i = 0; i < N; i++){
    cin >> d[i];
  }
  int c;
  for(int i = N - 1; i > 0; i--){
    for(int j = i - 1; j >= 0; j--){
      c += (d[i] * d[j]);
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import sys
import copy

k = int(input())


class Chessboard:
    def __init__(self):
        self.row = [True] * 8
        self.col = [True] * 8
        self.dpos = [True] * 15
        self.dneg = [True] * 15
        return

    def put(self, r, c):
        # queen が r, c に配置されたときに攻撃されるマスの記録
        self.row[r] = False
        self.col[c] = False
        self.dpos[r + c] = False  # 左下が攻撃される
        self.dneg[r + 7 - c] = False  # 右下が攻撃される
        return

    def safe(self, r, c):
        # r, c が攻撃されていないか確認する　攻撃されていないときTrue を返す
        return self.row[r] and self.col[c] and self.dpos[r + c] and self.dneg[r + 7 - c]

    def is_row(self, r):
        return self.row[r]


board = Chessboard()
ans = [['.'] * 8 for _ in range(8)]
for _ in range(k):
    r, c = map(int, sys.stdin.readline().strip().split())
    board.put(r, c)
    ans[r][c] = 'Q'
final_ans = None


def search(r=0, board=board, ans=ans):
    global final_ans
    if r == 8:  # 最終行を終了し探索する行が存在しないときに終了する
        final_ans = ans
        return ans
    if not board.is_row(r):
        # すでに Q が配置されている行の探索はスキップする
        search(r=r+1, board=board, ans=ans)

    for c in range(8):
        board_temp = copy.deepcopy(board)
        ans_temp = copy.deepcopy(ans)
        if board_temp.safe(r, c):
            board_temp.put(r, c)
            ans_temp[r][c] = 'Q'
            search(r=r+1, board=board_temp, ans=ans_temp)
        else:
            continue


ans = search()
for r_ans in final_ans:
    print(''.join(r_ans))




Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    string s;
    ll k;
    cin >> s >> k;
    if(k < 1 || k > 100)k = 100;
    rep0(i, min((ll)s.size(),k)){
        if(s[i] != '1'){
            pf(s[i]);
            return 0;
        }
    }
    pf(1);
    return 0;
}



Measured memory_bytes: 256
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

//メイン関数
int main() {
	//入力の取得
	int N;
	std::vector<int> Ai;
	std::cin >> N;

	for(int i=0; i<N; ++i) {
		int A;
		std::cin >> A;
		Ai.push_back(A);
	}

	int kisuu = 0;
	for(int i=0; i<N; ++i) {
		if(Ai[i] % 2 == 1) {
			kisuu++;
		}
	}

	//答え
	std::string answer;

	if(kisuu % 2 == 0) {
		answer = "YES";
	} else {
		answer = "NO";
	}

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}


Measured memory_bytes: 1020
n = int(input())

ans = 0
maxcount = 0
for i in range(int(n/2)+1, n+1):
  tmp = i
  count = 0
  while tmp % 2 == 0:
    tmp = tmp / 2
    count += 1
  if count >= maxcount:
    ans = i
    maxcount = count

print(ans)

Measured memory_bytes: 3060
#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 REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll M;
int D[200100];
ull C[200100];

ll func(int& d, ll c){
    ll num = 0;
    vector<int> tmp;
    while(c > 0){
        if(c & 1){
            tmp.push_back(d);
            c--;
            continue;
        }
        else{
            num += c/2;
            d *= 2;
            if(d >= 10){
                d = d/10 + d%10;
                num += c/2;
            }
        }
        c >>= 1;
    }

    int t = tmp[0];
    REPi(i, 1, tmp.size()){
        int x = tmp[i];
        t += x;
        num++;
        if(t >= 10){
            t = (t/10) + (t%10);
            num += 1;
        }
    }

    d = t;
    return num;
}

int main(){
    cin >> M;
    ull ans = 0;
    REP(i,M){
        int d;
        ull c;
        cin >> d >> c;
        ans += func(d, c);
        //cout << tmp << endl;
        D[i] = d;
        C[i] = c;
    }

    int d = D[0];
    REPi(i,1,M){
        int x = D[i];
        d += x;
        ans++;
        if(d >= 10){
            d = (d/10) + (d%10);
            ans += 1;
        }
    }

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


Measured memory_bytes: 2560
N, M = map(int, input().split())

student = [  tuple( map(int, input().split()) ) for x in range(N)]
point = [ tuple( map(int, input().split()) ) for x in range(M)]


for (x1, y1) in student :
    data =  [ abs(x1 - x2) + abs(y1 - y2) for (x2, y2) in point ]
    ans = data.index(min(data))
    print(ans + 1)

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

int main() {
	int n;

	while (cin >> n) {
		int count = 0;
		
		if (n <= 36) {
			for (int a = 0;a <= 9;a++) {
				for (int b = 0;b <= 9;b++) {
					for (int c = 0;c <= 9;c++) {
						for (int d = 0;d <= 9;d++) {
							if (a + b + c + d == n) {
								count++;
							}
						}
					}
				}
			}
		}
		
		cout << count << endl;
	}
	return 0;
}

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

min=1000000000000000
left_sum=0
right_sum=sum(a)
for i in range(n-1):
    left_sum += a[i]
    right_sum -= a[i]
    xy=abs(left_sum-right_sum)
    if xy < min:
        min=xy
print(min)


Measured memory_bytes: 24824
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll n,m,ans;
int main(){
	scanf("%lld%lld",&n,&m);
	ans=(m-n)*(m-n+1)/2-m;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define maxn 15
#define inf (int)1e9
int a[maxn][maxn];
int crp[maxn];
int i,j,n,x,m,dau,tmp,k;
int res=inf;
int main(){
  cin>>n>>m>>x;
  for(i=0;i<n;i++){
    for(j=0;j<=m;j++){
        cin>>a[i][j];
    }
  }
  for(i=0;i<(1<<n);i++){
        tmp=0;
        memset(crp,0,sizeof(crp));
        dau=0;
    for(j=0;j<n;j++){
        if((i>>j)&1){
          tmp+=a[j][0];
          for(k=0;k<m;k++) crp[k]+=a[j][k+1];
        }
    }
    for(k=0;k<m;k++){if(crp[k]<x){dau=1;break;}}
    if(dau==0) res=min(res,tmp);
  }
  if(res<inf) cout<<res;else cout<<-1;
  return 0;
}


Measured memory_bytes: 3636
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-8 19:59:26
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int D, X;
int A[110];

int main()
{
  cin >> N;
  cin >> D >> X;
  for (auto i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  int ans = X;
  for (auto i = 0; i < N; i++)
  {
    ans += (D + A[i] - 1) / A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		Arrays.sort(h);
		int min = Integer.MAX_VALUE;
		for (int i = 0; i + K - 1 < N; i++) {
			min = Math.min(min, h[i+K-1] - h[i]);
		}
		System.out.println(min);
	}
}


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

int main(){
	int x[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};
	
	int k;	cin>>k;
	cout<<x[k-1]<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
  cin>>n;
  int res = 0;
  while(n>=2){n>>=1; res++;}
  cout<<(1<<res)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll ls=s.length();
    ll lt=t.length();
    ll as[26]={0};
    ll at[26]={0};
    vector<ll> a[26];
    for(ll i=0;i<ls;i++)
    {
        as[s[i]-97]++;
        a[s[i]-97].push_back(i);
    }
    for(ll i=0;i<lt;i++)
    {
        at[t[i]-97]++;
    }
    ll flag=0;
    ll siz[26]={0};
    for(ll i=0;i<26;i++)
    {
        if(at[i]!=0)
        {
            if(as[i]==0)
            {
                flag=1;
                break;
            }
        }
    }
    if(flag==1)
    {
        cout<<"-1";
    }
    else
    {
        ll k=0;ll sz=0;ll tmp=-1;
        while(k!=lt)
        {
            if(siz[t[k]-97]==a[t[k]-97].size())
            {
                for(ll i=0;i<26;i++)
                {
                    siz[i]=0;
                }
                tmp=a[t[k]-97][0];
              siz[t[k]-97]++;
                sz++;
                k++;
            }
            else
            {
                if(a[t[k]-97][siz[t[k]-97]]<=tmp)
                {
                    siz[t[k]-97]++;
                }
                else
                {
                    tmp=a[t[k]-97][siz[t[k]-97]];
                    siz[t[k]-97]++;
                    k++;
                }
            }
        }
        ll d = sz*ls+tmp;
        cout<<d+1;
    }
    // #ifndef ONLINE_JUDGE
    //     cout<<"\nTime Elapsed : "<< 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    // #endif
    
    return 0;
}


Measured memory_bytes: 1736
import java.util.*;

class Restaurant implements Comparable<Restaurant> {
  String city;
  int point;
  int i;
  public Restaurant(String city, int point, int i) {
    this.city = city;
    this.point = point;
    this.i = i;
  }

  public int compareTo(Restaurant other) {
    int ans = city.compareTo(other.city);
    if (ans != 0) return ans;
    return Integer.compare(other.point, point);
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      List<Restaurant> list = new ArrayList<Restaurant>();
      int n = sc.nextInt();
      for (int i = 1; i <= n; i++) {
        String city = sc.next();
        int point = sc.nextInt();
        list.add(new Restaurant(city, point, i));
      }
      Collections.sort(list);
      for (Restaurant restaulant: list) {
        System.out.println(restaulant.i);
      }
    } finally {
      sc.close();
    }
  }
}


Measured memory_bytes: 35932
#include<iostream> 
#include<algorithm> 
#include<set> 
#include<string>
#include<cmath>
#include<cstring>
using namespace std; 
const int maxn=100005;
long long w[maxn]={0};
int main() 
{ 
	int n,x,i;
	long long mn=0x3f3f3f3f;
	cin>>n>>x;
	for(i=1;i<=n;i++)
	{
		cin>>w[i];
		w[i]=abs(w[i]-x);
		if(w[i]<mn)
		mn=w[i];
		
	}
	for(i=1;i<=n;i++)
	{
		if(w[i]%mn==0)
		continue;
		else
		{
			long long a,b,q;
			a=w[i];b=mn;
			q=a%b;
			while(q!=0)
			{
				a=b;
				b=q;
                                q=a%b;
			}
			mn=b;
		}
	}
	printf("%lld",mn);
	return 0; 
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
main(){
  string S;
  int num[4];
  cin >> S;
  for (int i = 0; i<4; i++){
    num[i] = (int)S[i] -(int)'0';
//    cout << num[i] << endl;
  }
  int num_before = num[0];
  string result = "Good";
  for (int i = 1; i<4; i++){
    if (num[i] == num_before){
      result = "Bad";
      break;
    }
    num_before = num[i];
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;

ll n,k,m;
string s,t;

int main() {
  cin >> n >> m;
  ll ans=min(m/2,n)+max(m-min(m/2,n)*2,(ll)0)/4;
  cout << ans << endl;
}

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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n,k; cin >> n>> k;
    //0-index
    vector<int> h(100100), dp(100100,INF);
    rep(i,n) cin >> h[i];
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int j=1; j<=k; j++){
            chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
n = gets.to_i
A = gets.split.map(&:to_i)

def partation(arr, p, r)
  std = arr[r]
  i = p - 1
  for j in (p...r)
    if arr[j] <= std
      i += 1
      arr[j], arr[i] = arr[i], arr[j]
    end
  end
  arr[i + 1], arr[r] = arr[r], arr[i + 1]
  arr[i + 1] = "[#{arr[i + 1]}]"
  puts arr.join(' ')
end

partation(A, 0, n - 1)



Measured memory_bytes: 13948
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int a, b;

int main(int argc, char ** argv) {
	scanf("%d%d", &a, &b);
	if(a+b == 5) puts("1");
	else if(a+b == 3) puts("3");
	else puts("2"); 
	return 0;
}





Measured memory_bytes: 256