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

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

  int N;
  cin >> N;
 
  vector<int> L(N);  
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  } 
  sort(L.begin(), L.end());
  
  int a, b, c, idx2, idx3, cnt;

  cnt = 0;
  idx2 = 1;
  for (int i = 0; i < (N - 2); i++) {
	a = L.at(i);

    idx3 = idx2 + 1;
    for (int j = idx2; j < N; j++) {
      b = L.at(j);

      for (int k = idx3; k < N; k++) {
        c = L.at(k);

        if (c < a + b)
          cnt++;      
      }
      
      idx3++;
    }
    
    idx2++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  ll ans = 0;
  REP(i, s.size()) if (s.at(i) == 'o') ans++;
  if (15-s.size()+ans <= 7) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, M, Q = MI()
    D = [[] for _ in range(Q)]
    for i in range(Q):
        a, b, c, d = MI()
        a -= 1
        b -= 1
        D[i] = [a, b, c, d]

    ans = 0
    for K in comb_w(range(1, M+1), N):
        score = 0
        for q in range(Q):
            a, b, c, d = D[q]
            if K[b] - K[a] == c:
                score = score + d
        ans = max(ans, score)

    print(ans)


if __name__ == '__main__':
    solve()


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

using namespace std;

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
#define trace(x) cerr << #x << ": " << x << " " << endl;

#define sz(a) ( (int) (a).size() )
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for(auto (it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end()) //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<int>::iterator vit;

const int N = 1e9 + 7;

void solve() {
    int l;
    cin >> l;
    double d = l*l*l/27.0;
    printf("%.12lf\n", d);
}

int32_t main(int32_t argc, char** argv) {
    fastio;
    solve();
    return 0;
}

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

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int a=x;
  int b=y;
  int c=z;
  int t=a;
  a=b;
  b=t;
  t=a;
  a=c;
  c=t;
  cout<<a<<" "<<b<<" "<<c<<"\n";
}

Measured memory_bytes: 256
#include <iostream>

int main(){

    int n;
    std::cin >> n;

    int min;
    int max_diff;

    int r;

    for(int i = 0; i < n; i++){
        std::cin >> r;
        if(i==0){
            min = r;
            continue;
        }else if(i==1){
            max_diff = r - min;
        }else if(max_diff < r - min){
            max_diff = r - min;
        }
        if(min > r){
            min = r;
        }
    }

    std::cout << max_diff << std::endl;

}


Measured memory_bytes: 3096
read N A B
ans=0
for (( i=1; i<=$N; i++ ));do
  s=$((i%10+(i/10)%10+(i/100)%10+(i/1000)%10+(i/10000)%10))
  if [ $s -le $B -a $s -ge $A ];then
    : $((ans+=i))
  fi
done
echo $ans

Measured memory_bytes: 504
def solve():
    from sys import stdin
    f_i = stdin
    
    N, T = map(int, f_i.readline().split())
    AB = [tuple(map(int, f_i.readline().split())) for i in range(N)]
    AB.sort()
    
    dp = [[0] * T for i in range(N + 1)]
    
    for i, AB_i in enumerate(AB, start=1):
        A_i, B_i = AB_i
        dp_i = dp[i]
        dp_pre = dp[i-1]
        dp_i[:A_i] = dp_pre[:A_i]
        for j, t in enumerate(zip(dp_pre[A_i:], dp_pre), start=A_i):
            x, y = t
            if x < y + B_i:
                dp_i[j] = y + B_i
            else:
                dp_i[j] = x
    
    ans = max(dp[k][-1] + AB[k][1] for k in range(N))
    print(ans)

solve()

Measured memory_bytes: 357500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 Scanner sc = new Scanner(System.in);
		 int N = sc.nextInt();
		 if(N<3) {
			 System.out.println("0");
		 }
		 else {
			 System.out.println(N/3);
		 }
	}

}


Measured memory_bytes: 26972
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,q,an;
ll a[100111],ans[100111];
priority_queue<pair<ll,ll> >pq;
int main()
{
	getii(n,q);
	a[an++]=n;
	for(int i=1;i<=q;i++)
	{
		ll x;
		geti(x);
		while(an>0&&a[an-1]>=x)an--;
		a[an++]=x;
	}
	pq.push(MP(a[an-1],1));
	for(int i=an-1;i>=0;i--)
	{
		ll cur=a[i],sum=0;
		while(!pq.empty()&&pq.top().FF>cur)
		{
			pair<ll,ll> p=pq.top();pq.pop();
			sum+=(p.FF/cur)*p.SS;
			if(p.FF%cur!=0)pq.push(MP(p.FF%cur,p.SS));
		}
		pq.push(MP(cur,sum));
	}
	while(!pq.empty())ans[pq.top().FF]+=pq.top().SS,pq.pop();
	for(int i=n;i>=1;i--)ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++)putsi(ans[i]);
	return 0;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
mt19937 rnd(1337);
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define pNN pair <Node *, Node *>
#define SZ(x) (int)(x).size()
#define pii pair <int, int>
#define pb push_back
#define rev reverse
#define ins insert
#define ers erase
#define S second
#define F first
const int N = 3e5 + 10, INF = 1e9 + 10;

void solve() {
	int x;
	cin >> x;
	cout << (x / 500) * 1000 + ((x % 500) / 5) * 5;
}
 
signed main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    #ifdef Solenoid555
        freopen("input.txt", "r", stdin);
    #endif
    solve();
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc051b()
}

fun abc051b() {
    val (k, s) = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val z = s - x - y
            if (z in 0..k) cnt++
        }
    }

    println(cnt)
}


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

long long gauss_sum(long long n,long long m,long long a,long long b){
    long long ans=0;
    if (a>=m){
        ans+=(n-1)*n*(a/m)/2;
        a%=m;
    }
    if (b>=m){
        ans+=n*(b/m);
        b%=m;
    }
    long long y_max=(a*n+b)/m,x_max=y_max*m-b;
    if (y_max==0) return ans;
    ans+=(n-(x_max+a-1)/a)*y_max;
    ans+=gauss_sum(y_max,a,m,(a-x_max%a)%a);
    return ans;
}

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

    for (;T--;){
        int N,M,A,B; cin >> N >> M >> A >> B;
        cout << gauss_sum(N,M,A,B) << '\n';
    }
}

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

int main()
{
	ios::sync_with_stdio(false);
	int a,b;
	while(cin>>a>>b){
		if(b==100){
			b+=1;
		}
		if(a==1){
			b*=100;
		}
		if(a==2){
			b*=10000;
		}
		cout<<b<<endl;
	}
	return 0;
}

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

if k>(n-1)*(n-2)//2:
    print(-1)
    exit()

m = n*(n-1)//2-k

print(m)

i=1
while m>0:
    for j in range(i,n):
        print(i,end=' ')
        print(j+1)
        m-=1
        if m==0:
            break
    i+=1




Measured memory_bytes: 47336
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int n,x;
	int js=0;
	getline (cin,a);
	n=a.size();
	for(int i=0;i<n;i++)
	{
		if(a[i]=='C')
		{
			x=i;
			for(int i=x;i<n;i++)
            {
		        if(a[i]=='F')
		        {
		            js++;
		            break;
		        }
	       } 	
		}
    }  
	if(js!=0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
i4 = np.int32
i8 = np.int64
u4 = np.uint32

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    from numba import njit
    from numba.types import int64, Array, uint32
    cc = CC('my_module')

    @njit
    def factorization(N):
        p = np.zeros(N + 1, u4)
        n_max = int(np.sqrt(N)) + 1
        p[0] = 1
        p[1] = 1
        for i in range(2, n_max):
            if p[i] == 0:
                j = i
                while j <= N:
                    p[j] = i
                    j += i
        for i in range(n_max, N + 1):
            if p[i] == 0:
                p[i] = i
        return p

    @cc.export('solve', (Array(uint32, 1, 'C'),))
    def solve(A):
        a = np.sort(A)
        p_max = a[-1]
        p = factorization(p_max)
        primes_num = 0
        for i in range(p.shape[0]):
            if i == p[i]:
                primes_num += 1
        a_start = 0
        while a[a_start] == 1:
            a_start += 1
            if a_start == a.shape[0]:
                return 0
        a = a[a_start:]
        if len(a) > primes_num:
            return 1
        check = np.zeros(p_max + 1, i8)
        stack = np.empty(20, i8)
        p_stack = 0
        for d in a:
            while d > 1:
                x = p[d]
                for i in range(p_stack):
                    if stack[i] == x:
                        break
                else:
                    stack[p_stack] = x
                    p_stack += 1
                d //= x

            while p_stack > 0:
                p_stack -= 1
                check[stack[p_stack]] += 1

        if check.max() > 1:
            return 1
        else:
            return 0
    cc.compile()
    exit()


def main(in_file):
    stdin = open(in_file)
    stdin.readline()
    A = np.fromstring(stdin.readline(), u4, sep=' ')
    ans = solve(A)
    if ans:
        g = np.gcd.reduce(A)
        if g > 1:
            ans = 2
        else:
            ans = 1
    p = ['pairwise coprime', 'setwise coprime', 'not coprime']
    print(p[ans])


if __name__ == '__main__':
    from my_module import solve
    main('/dev/stdin')

Measured memory_bytes: 46544
# coding: utf-8
# Your code here!
# coding: utf-8

def main():
    weather = input()
    
    if weather == 'Sunny':
        print('Cloudy')
        
    elif weather == 'Cloudy':
        print('Rainy')
        
    elif weather == 'Rainy':
        print('Sunny')
    
    return 0


if __name__ == '__main__':
    main()

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

struct Card{
    string suit;
    int val;
};

void bubbleSort(Card A[], int n){
    bool flag = 1;
    for ( int i = 0; flag; i++){
        flag = 0;
        for ( int j = n - 1; j >= 0; j--){
            if ( A[j].val < A[j-1].val) {
                swap(A[j], A[j-1]);
                flag = 1;
            }
        }
    }
}

void selectionSort(Card A[], int n){
    for ( int i = 0; i < n; i++){
        int minj = i;
        for ( int j = i; j < n; j++){
            if (A[j].val < A[minj].val) minj = j;
        }
        if ( minj != i) swap(A[minj], A[i]);
    }
}

int main(){
    int n, v;
    char suit;
    Card A[10000], B[10000];
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> suit >> v;
        A[i].suit = B[i].suit = suit;
        A[i].val = B[i].val = v;
    }

    bubbleSort(A, n);
    selectionSort(B, n);

    for ( int i = 0; i < n; i++){
        if ( i ) cout << " " ;
        cout << A[i].suit << A[i].val;
    }
    cout << endl;
    
    cout << "Stable" << endl;
    
    for ( int i = 0; i < n; i++){
        if ( i ) cout << " " ;
        cout << B[i].suit << B[i].val;
    }
    cout << endl;
    
    string state = "Stable";
    for ( int i = 0; i < n; i++){
      if ( A[i].suit != B[i].suit) state = "Not stable";
    }
    cout << state << endl;

    return 0;
}


Measured memory_bytes: 3460
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;

int si[10010];
int main() {
    int N; 
    while(cin >> N){
    for(int i=0; i<=N; ++i) si[i]=true;
    si[0] = si[1]= false;
    for(int i=2; i*i<=N; ++i){
        if(si[i]){
            for(int j=2; j*i<=N; ++j){
                si[i*j]=false;
            }
        }
    }
    
    int ans=0;
    for(int i=1; i<=N; ++i){
        if(si[i]&&si[N-i+1]) ans++;
    }
    cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 3128
"use strict"
const input = require('fs').readFileSync('/dev/stdin','utf8');
const arr = input.split('\n')
for (let i in arr) {
	const list = arr[i].split(' ');
	const h = parseInt(list[0]);
	const w = parseInt(list[1]);
	if (h === 0 && w === 0) break;
	printCheeboard(h, w);
	console.log('');
}

function printCheeboard(h, w) {
	let line = '';
	const black = '#';
	const white = '.';
	for (let i = 0; i < h; i++) {
		for (let j = 0 ;j < w; j++) {
			if (isBlack(i, j)) line += black;
			else line += white;
		}
		console.log(line);
		line = '';
	} 
}

function isBlack(i, j) {
	if (i % 2 === 0 && j % 2 === 0) return true;
	if (i % 2 !== 0 && j % 2 !== 0) return true;
	return false;
}


Measured memory_bytes: 18512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  ll k;
  cin>>k;
  int one=0;
  for(int i=0;i<n;i++){
    if(s[i]=='1') one++;
    else break;
  }
  if(one>=k) cout<<1<<endl;
  else cout<<s[one]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  rep(i, 100) {
    C -= B;
    if(C <= 0) {
      fin("Yes");
      return 0;
    }
    A -= D;
    if(A <= 0) {
      fin("No");
      return 0;
    }
  }
  
  
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>

struct Data{
	long long x,y,z;
	long long value;
	Data(long long i_x,long long i_y,long long i_z,long long i_value)
		:x(i_x),y(i_y),z(i_z),value(i_value){}
	bool operator<(const Data &otherobj)const{
		if(this->value<otherobj.value){
			return true;
		} else if(this->value>otherobj.value){
			return false;
		}
		if(this->x<otherobj.x){
			return true;
		} else if(this->x>otherobj.x){
			return false;
		}
		if(this->y<otherobj.y){
			return true;
		} else if(this->y>otherobj.y){
			return false;
		}
		if(this->z<otherobj.z){
			return true;
		} else if(this->z>otherobj.z){
			return false;
		}
		return false;
	}
};

void use_stdsort(){
	//入力機構
	size_t N,M;
	std::cin>>N>>M;
	std::vector<long long> X,Y,Z;//10,000,000,000の値が入りintだとオーバーする可能性大。__int64はGCCで使えないため用いないこと。
	X.reserve(N);
	Y.reserve(N);
	Z.reserve(N);
	for(size_t i=0;i<N;i++){
		long long x,y,z;
		std::cin>>x>>y>>z;
		X.push_back(x);
		Y.push_back(y);
		Z.push_back(z);
	}

	//処理機構
	long long ans=0;
	long long xAns,yAns,zAns;//それぞれ(綺麗さの合計),(おいしさの合計),(人気度の合計)を指す
	std::vector<Data> dataVec;
	dataVec.reserve(N);
	for(size_t i=0;i<N;i++){
		dataVec.push_back(Data(0,0,0,0));
	}
	//xAns,yAns,zAnsの全ての正負について考える。計8パターン。
	int pattern[8][3]={{-1,-1,-1},{-1,-1,1},{-1,1,-1},{-1,1,1},{1,-1,-1},{1,-1,1},{1,1,-1},{1,1,1}};
	for(size_t i=0;i<8;i++){
		//各合計を記入
		for(size_t j=0;j<N;j++){
			dataVec[j]=Data(X[j],Y[j],Z[j],X[j]*pattern[i][0]+Y[j]*pattern[i][1]+Z[j]*pattern[i][2]);
		}
		//vecが大きい順にindexをソート
		std::sort(dataVec.begin(),dataVec.end());
		//q_sort(vec,index,0,N-1);//クイックソート直実装
		xAns=0;
		yAns=0;
		zAns=0;
		for(size_t j=0;j<M;j++){
			xAns+=dataVec[j].x*pattern[i][0];
		}
		for(size_t j=0;j<M;j++){
			yAns+=dataVec[j].y*pattern[i][1];
		}
		for(size_t j=0;j<M;j++){
			zAns+=dataVec[j].z*pattern[i][2];
		}
		long long pal=std::abs(xAns)+std::abs(yAns)+std::abs(zAns);
		if(ans<pal){
			ans=pal;
		}
	}

	//出力機構
	std::cout<<ans<<std::endl;


}

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


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

const int mod = (int) 1e9 + 7;

long long power(long long n, long long expo)
{
    long long ans = 1;

    while(expo)
    {
        if(expo % 2)
            ans = ans * n % mod;
        
        n = n * n % mod;
        expo /= 2;
    }

    return ans;
}

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

    int n, a, b;
    cin >> n >> a >> b;

    long long x1 = 0, x2 = 0, curr = 1;

    for(int i=1; i<=max(a, b); i++)
    {
        curr = curr * (n - i + 1) % mod * power(i, mod - 2) % mod;

        if(i == a)
            x1 = curr;
        if(i == b)
            x2 = curr;
    }

    long long ans = power(2, n) + mod - 1 + mod - x1 + mod - x2;

    cout << ans % mod << "\n";
    return 0;
}


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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(all(v));

    int ans = 0;
    for(int i = 0; i < k; i++) ans += v[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
def main():
    n,m = map(int,input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]
    for i in range(n-m+1):
        for j in range(n-m+1):
            for k in range(m):
                if b[k] != a[i+k][j:j+m]: break
            else:
                print("Yes")
                return 0
    else:
        print("No")
main()


Measured memory_bytes: 3060
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
L = []
for i, a in enumerate(A):
    L += [i+1] * a
for i in range(H):
    if i&1 == 0:
        print(" ".join(map(str, (L[W*i:W*(i+1)]))))
    else:
        print(" ".join(map(str, reversed(L[W*i:W*(i+1)]))))


Measured memory_bytes: 3572
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  int m = n * 2;
  int id = -1;
  for (int i = 1; i * i <= m; i++) {
    if (i * (i + 1) == m) {
      id = i;
    }
  }
  if (id < 0) {
    cout << "No" << endl;
    return 0;
  }
  set<int> s;
  for (int i = 0; i < n; i++) {
    s.insert(i);
  }
  cout << "Yes" << endl;
  m = m / id;
  vector<vector<int>> ans(m);
  for (int i = 0; i < m; i++) {
    for (int j = 0; ans[i].size() < id; j++) {
      int k = *s.begin();
      s.erase(s.begin());
      ans[i].push_back(k);
      ans[i + j + 1].push_back(k);
    }
  }
  cout << m << endl;
  for (int i = 0; i < m; i++) {
    cout << ans[i].size();
    for (int j = 0; j < ans[i].size(); j++)
      cout << " " << ans[i][j] + 1;
    cout << endl;
  }
  return 0;
}


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

#define ll long long

int main(){
	ll n;
	cin>>n;
	ll m=n-1;
	ll total=0;
	for (ll i=1;i*i<=m;i++)
		if (m%i==0){
			if (i!=1) total++;
			if (m/i!=i) total++;
		}
	vector<ll> a;
	for (ll i=1;i*i<=n;i++)
		if (n%i==0){
			a.push_back(i);
			if (n/i!=i) a.push_back(n/i);
		}
	for (ll i=0;i<a.size();i++){
		if (a[i]==1) continue;
		ll tmp=n;
		while (tmp%a[i]==0) tmp/=a[i];
		if (tmp%a[i]==1) total++;
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI W(N);
    int sumb = 0;
    REP(i,N) {
        cin >> W[i];
        sumb += W[i];
    }

    int suma = 0;
    int ans = abs(sumb);

    REP(i,N){
        suma += W[i];
        sumb -= W[i];
        int tmp = abs(suma-sumb);
        if(tmp < ans) ans = tmp;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func solve(count, hp int) int {
	if hp == 1 {
		return count + 1
	}
	count = solve(count, hp/2) * 2
	return count + 1
}

func main() {
	var h int
	fmt.Scan(&h)
	fmt.Println(solve(0, h))
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
using namespace std;
long long n,x,m,a;
vector<long long> v;
vector<long long> v1;
map<long long,int> ma;
long long mod;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>x>>m;
	mod=m;
	long long idx=n,ans=0;
	a=x;
	long long xx=n;
	for(int i=1;i<=n;i++){
		xx=i;
		if(ma[a]){
			idx=ma[a]-1;
			break;
		}
		ma[a]=i;
		ans+=a;
		v.push_back(a);
		a=a*a%mod;
	}
	int  len=v.size();
	for(int i=0;i<len;i++) if(i>=idx) v1.push_back(v[i]);
	long long cnt=n-xx+1;/*?*/
	long long sum=0;
	for(int i=0;i<v1.size();i++) sum+=v1[i];
	if(v1.size()){
		ans+=cnt/v1.size()*sum;
		for(int i=0;i<cnt%v1.size();i++) ans+=v1[i];
	}
	cout<<ans;
}

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll N,M;
    ll ANS=0;
    cin>>N>>M;
    if(M-N*2<0)ANS+=M/2;
    else {
        ANS+=N;
        M-=N*2;
        ANS+=M/4;
    }

    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Here your code !
    for(int i=0;i<9;i++) {
        for(int j=0;j<9;j++) {
            printf("%dx%d=%d\n", i+1, j+1, (i+1)*(j+1));
        }
    }
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    int a=N%1000;
    if(a==0) cout << 0 << endl;
    else cout << 1000-a << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,s,e) for(ll i=(s);(s>e)?i>e:i<e;(s>e)?i--:i++)
ll mod1 = 1e9 + 7;
ll mod2 = 998244353;

//ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}

ll g(ll x,ll y){
	ll ans = 1;
    while(y>1){
    	ll temp = __gcd(x,y);
    	y/= temp;
    	ans*= temp;
    	if(temp == 1)break;
    }
    return ans;
}
const long double pi = 3.141592653589793238;
void solve(){
 	ll n;
 	ll t;
 	cin>>n;
 	ll cnt[n];
 	fo(i,n)cnt[i]= 0;
 	fo(i,n-1){
 		cin>>t;
 		cnt[t-1]++;
 	}
 	fo(i,n){
 		cout<<cnt[i]<<endl;
 	}
}





int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
    		






}

Measured memory_bytes: 5208
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v,int N,bool visited[nmax]){
	
	bool all_visited=true;
	
	Rep(i,N){
		if(visited[i]==false) all_visited=false;
	}
	
	if(all_visited){
		return 1;
	}
	
	int ret=0;
	
	Rep(i,N){
		if(graph[v][i]==false) continue; //以下の処理をスキップ
		if(visited[i]) continue;
		
		visited[i]=true;
		ret+=dfs(i,N,visited);
		visited[i]=false;
	}
	
	return ret;
	
}


int main(){
	
	int N,M;
	cin>>N>>M;
	Rep(i,M){
		int A,B;
		cin>>A>>B;
		graph[A-1][B-1]=true;
		graph[B-1][A-1]=true;
	}
	
	bool visited[nmax];
	Rep(i,N) visited[i]=false;
	visited[0]=true;
	
	cout<<dfs(0,N,visited)<<endl;
	
	  return 0;
  }


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N,K;
    cin >> N >> K;
    ll ans = 0;
    rep(i,0,N){
        ll tmp;
        cin >> tmp;
        ans += min(abs(K-tmp),abs(tmp));
    }
    cout << ans * 2 << endl;



    return 0;
}


Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var r = one[0];
  var D = one[1];
  var x2000 = one[2];
  var output = new Array(11);
  output[0] = x2000;
  for(var i = 1; i <= 10; i++){
    output[i] = r * output[i - 1] - D;
  }
  output.shift();
  myout(myconv(output,9));
}

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

int n,k;
string s;
vector <pair<int,int> > H;

int main(){
	cin>>n>>k>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='0'){
			int j=i;
			for(;j<n&&s[j]=='0';++j);
			H.push_back(make_pair(i+1,j));
			i=j;
		}
	}
	int m=H.size();
	if(m<=k){
		printf("%d\n",n);
		return 0;
	}
	int ans=0;
	for(int i=m-1;i>=0;i--){
		int j=min(i+k-1,m-1);
		int L=(i==0?0:H[i-1].second);
		int R=(j==m-1?n+1:H[j+1].first);
		ans=max(ans,R-L-1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1020
// Aizu 1046: Ghost Buster!
// 2017.9.6 bal4u@uu

#include <stdio.h>
#include <string.h>

#define QMAX 100000
typedef struct { int t, ax, ay, bx, by; } Q;
Q q[QMAX+3], *top, *end, *qend = q + QMAX;

int gm[9][2] = { {0},{0},{1,0},{0},{0,-1},{0,0},{0,1},{0},{-1,0} };
int m[4][2] = { {1,0},{-1,0},{0,1},{0,-1} };

char map[22][22];
unsigned char mk[22][22][22][22][11];
char p[12]; int plen;
int ax, ay, bx, by;

int main()
{
	int h, w, i, k, x, y, t, t0, axx, ayy, bxx, byy, bx2, by2, anst, ansx, ansy;
	unsigned char cno = 0;

	while (scanf("%d%d", &h, &w) && h) {
		cno++;
		for (y = 0; y < h; y++) {
			scanf("%s", map[y]);
			for (x = 0; x < w; x++) {
				if      (map[y][x] == 'A') ax = x, ay = y, map[y][x] = '.';
				else if (map[y][x] == 'B') bx = x, by = y, map[y][x] = '.';
			}
		}
		scanf("%s", p), plen = strlen(p);
		for (k = 0; k < plen; k++) p[k] -= '0';

		top = end = q;
		end->t = 0, end->ax = ax, end->ay = ay, end->bx = bx, end->by = by, end++;
		mk[ax][ay][bx][by][0] = cno;
		anst = -1, t0 = -1, k = 0;
		while (top < end) {
			t = top->t, axx = top->ax, ayy = top->ay, bxx = top->bx, byy = top->by;
			if (++top >= qend) top = q;
			if (axx == bxx && ayy == byy) { ansx = axx, ansy = ayy, anst = t; break; }
			if (t != t0) {
				bx2 = bxx + gm[p[k]][1], by2 = byy + gm[p[k]][0];
				if (bx2 < 0 || bx2 >= w || by2 < 0 || by2 >= h) bx2 = bxx, by2 = byy;
				t0 = t; if (++k >= plen) k = 0;
			}
			for (i = 0; i < 4; i++) {
				x = axx + m[i][1], y = ayy + m[i][0];
				if (x < 0 || x >= w || y < 0 || y >= h || map[y][x] == '#') x = axx, y = ayy;
				if (mk[x][y][bx2][by2][k] == cno) continue;
				mk[x][y][bx2][by2][k] = cno;
				end->t = t+1, end->ax = x, end->ay = y, end->bx = bx2, end->by = by2;
				if (++end >= qend) end = q;
			}
		}
		if (anst < 0) puts("impossible");
		else printf("%d %d %d\n", anst, ansy, ansx); 
	}
	return 0;
}

Measured memory_bytes: 4168
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;
const double EPS=1e-12;

void solve(long long N){
  rep(x,50000){
    ll n2 = ll(double(x)*1.08+EPS);
    if(n2!=N) continue;
    else{
      cout << x << endl;
      return;
    }
  }
  cout << ":(" << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		if(N==1&&M==1){
			System.out.println(1);
		}
		else if(N==1){
			System.out.println(M-2);
		}else if(M ==1){
			System.out.println(N-2);
		}else System.out.println((N-2)*(M-2));
		sc.close();
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  int num, tmp1=1, tmp2=1, tmp3=1;
  string S;
  cin >> S;
  num = S.size();
  //cout << "num=" << num << endl;

  for(int i=0; i<num; i++){
    if(S[i]!=S[num-1-i]) tmp1 = 0;
  }
  for(int i=0; i<(num-1)/2; i++){
    if(S[i]!=S[(num-1)/2-1-i]) tmp2 = 0;
  }
  for(int i=0; i<num+1-(num+3)/2; i++){
    if(S[(num+3)/2-1+i]!=S[num-1-i]) tmp3 = 0;
  }
  if (tmp1*tmp2*tmp3 == 1){
    cout << "Yes";
  } else {
    cout << "No";
  }
  //cout << endl << tmp1 <<" "<< tmp2 <<" "<< tmp3;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q, t, a, b;
    cin >> n >> q;
    stack<int> v[n];
    rep(i, q) {
        cin >> a >> t;
        if(a == 0) {
            cin >> b;
            v[t].push(b);
        } else if(a == 1) {
            if(v[t].size()) cout << v[t].top() << "\n";
        } else {
            if(v[t].size()) v[t].pop();
        }
    }
}



Measured memory_bytes: 4168
n = int(input())
primes = {}
for i in range(2, int(n**0.5)+1):
    if n%i==0:
        cnt = 0
        while n%i==0:
            n //= i
            cnt += 1
        primes[i] = cnt
    if n==1:
        break
else:
    if n!=1:
        primes[n] = 1
ans = 0
for i in primes.values():
    for j in range(1, 100000):
        if j*(j+1)//2<=i:
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 63644
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define R(n) for(L i=0;i<n;i++)
#define X return
W S(V<W>&p,L E){if(!E){X{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}V<W>c(4,W(3));c[3]=W(3,1);R(2){for(W x:T[i]){L Q=(2*x[0]+x[1])%3;c[i][Q]^=1;}}R(2){if(c[!i]==c[2]||c[!i]==c[3]){W ans=S(T[i],E-1);ans[0]*=2;ans[1]*=2;ans[1]+=i;X ans;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;X A;}
int main(){L M=2e17;L n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

Measured memory_bytes: 37052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
using ll = long long;
using Pa = pair<ll,ll>;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vec<T>>;

int main(){
    ll N,K;
    cin >> N >> K;
    if(N+1<2*K){
        cout << -1 << endl;
        return 0;
    }
    vec<Pa> ab;
    for(int i=0;i<N/2;i++){
        ab.emplace_back(K+i,K+N+(N+1)/2+i);
    }
    for(int i=N/2;i<N;i++){
        ab.emplace_back(K+i,K+N+(i-N/2));
    }
    sort(ab.begin(),ab.end(),[](Pa& a, Pa& b){
        return a.first+a.second<b.first+b.second;
    });
    for(int i=0;i<N;i++){
        cout << ab[i].first << " " << ab[i].second << " " << K+2*N+i << endl;
        assert(ab[i].first+ab[i].second<=K+2*N+i);
    }
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
P color[11][100010];
vector<int> g[100010];
int main(){
	int N,M,Q,u,v,d,c;
	scanf("%d%d",&N,&M);
	for(d=0;d<=10;d++)
		for(u=1;u<=N;u++)
			color[d][u].first=-0x3f3f3f3f;
	for(int i=0;i<M;i++){
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++){
		scanf("%d%d%d",&v,&d,&c);
		for(int k=0;k<=d;k++)
			color[k][v]=P(i,c);
	}
	for(d=10;d>=1;d--){
		for(u=1;u<=N;u++){
			for(int i=0;i<(int)g[u].size();i++){
				v=g[u][i];
				if(color[d][u].first>color[d-1][v].first){
					color[d-1][v]=color[d][u];
				}
			}
		}
	}
	for(u=1;u<=N;u++)
		printf("%d\n",color[0][u].second);
	return 0;
}

Measured memory_bytes: 15096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N), B(N), C(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];
	for (ll i = 0; i < N; ++i) cin >> B[i];
	for (ll i = 0; i < N; ++i) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	vector<ll> sum(N+1, 0);
	for (ll i = 0; i < N; ++i)
		sum[i+1] = C.end() - upper_bound(C.begin(), C.end(), B[i]) + sum[i];

	
	std::cout << std::endl;
	ll res{0};
	for (ll a = 0; a < N; ++a)
	{
		ll l = upper_bound(B.begin(), B.end(), A[a]) - B.begin();
		res += sum[N] - sum[l];
	}
	std::cout << res << std::endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    int a = 0, b = 0, ab = 0, ans = 0;
    cin >> n;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        switch ((s.front() == 'B') << 1 | (s.back() == 'A') ) {
            case 1: ++a; break;
            case 2: ++b; break;
            case 3: ++ab; break;
        }
        for (int j = 0; j < int(s.size()) - 2; ++j) if (s.at(j) == 'A' && s.at(j + 1) == 'B') ++ans;
    }
    if (ab) ans += ab + 1 - (a == 0) - (b == 0), a -= (a != 0), b -= (b != 0);
    ans += max(0, min(a, b));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int dx[]={1,0,-1,0};
		int dy[]={0,1,0,-1};
		while(in.hasNext())
		{
			int H=in.nextInt(),W=in.nextInt();
			int N=in.nextInt();
			int sh=0,sw=0,gh=0,gw=0;
			int ans=0,cnt=0;
			int visit[][]=new int[H][W];
			char map[][]=new char[H][W];
			LinkedList<String>que=new LinkedList<String>();
			for(int i=0;i<H;i++)
			{
				String st=in.next();
				for(int j=0;j<W;j++)
				{
					map[i][j]=st.charAt(j);
					if(map[i][j]=='S')
					{
						sh=i;
						sw=j;
					}
					else if(map[i][j]=='1')
					{
						gh=i;
						gw=j;
					}
				}
			}
			que.add(sh+" "+sw);
			while(!que.isEmpty())
			{
				int size=que.size();
				for(int i=0;i<size;i++)
				{
					String now[]=que.poll().split(" ");
					int nh=Integer.valueOf(now[0]);
					int nw=Integer.valueOf(now[1]);
					if(nh==gh&&nw==gw)
					{
						i=size-1;
						while(!que.isEmpty())
							que.poll();
						cnt++;
						if(cnt==N)
							break;
						else
							for(int j=0;j<H;j++)
								for(int k=0;k<W;k++)
								{
									if(cnt==1)
										if(map[j][k]=='2')
										{
											gh=j;
											gw=k;
										}
									if(cnt==2)
										if(map[j][k]=='3')
										{
											gh=j;
											gw=k;
										}
									if(cnt==3)
										if(map[j][k]=='4')
										{
											gh=j;
											gw=k;
										}
									if(cnt==4)
										if(map[j][k]=='5')
										{
											gh=j;
											gw=k;
										}
									if(cnt==5)
										if(map[j][k]=='6')
										{
											gh=j;
											gw=k;
										}
									if(cnt==6)
										if(map[j][k]=='7')
										{
											gh=j;
											gw=k;
										}
									if(cnt==7)
										if(map[j][k]=='8')
										{
											gh=j;
											gw=k;
										}
									if(cnt==8)
										if(map[j][k]=='9')
										{
											gh=j;
											gw=k;
										}
								}
						visit =new int[H][W];
					}
					for(int j=0;j<4;j++)
					{
						int h=dy[j]+nh;
						int w=dx[j]+nw;
						if(h>=0&&h<H&&w>=0&&w<W&&map[h][w]!='X'&&visit[h][w]==0)
						{
							que.add(h+" "+w);
							visit[h][w]=1;
						}
					}
				}
				if(cnt==N)
					break;
				ans++;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 22000
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
int n;
const int N = 1e5;
int opt[N],cnt;
int dp[N];
void pA(int *a, int c){
	for(int i =0;i<c;i++){
		printf("%d\n", a[i]);
	}
}
void pre(){
	int i;
	for(i=6;i<=n;i*=6){
		opt[cnt ++] = i;
	}
	for(i=9;i<=n;i*=9){
		opt[cnt ++] = i;
	}
	dp[0] = 0;
	sort(opt,opt + cnt);
	for(int i = 1;i<=n;i++){
		dp[i] = dp[i - 1] + 1;
		for(int j = 0;opt[j] <= i && j < cnt;j ++){
			dp[i] = min(dp[i], dp[i - opt[j] ] + 1);
		}
		//printf("%d\n", dp[i]);
	}
}
void inp(){
	scanf("%d",&n);
	pre();
	printf("%d", dp[n]);
}
//c.cc by xsthunder at Fri Jul 27 23:30:07 2018


Measured memory_bytes: 512