akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray(object):
    """
    construct:
        suffix array: O(N(logN)^2)
        lcp array: O(N)
        sparse table: O(NlogN)
    query:
        lcp: O(1)
    """
    def __init__(self,s):
        """
        s: str
        """
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()
 
    # suffix array
    def __suffix_array(self):
        s=self.__s; n=self.__n
        # initialize
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        # iterate
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank
 
    # LCP array
    def __lcp_array(self):
        s=self.__s; n=self.__n
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            j=sa[rank[i]-1]
            if h>0: h-=1
            if rank[i]==0: continue
            while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp
 
    # sparse table
    def __sparse_table(self):
        n=self.__n
        logn=max(0,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=self.__lcp[:]
        # construct
        from itertools import product
        for i,k in product(range(1,logn),range(n)):
            if k+(1<<(i-1))>=n:
                table[i][k]=table[i-1][k]
            else:
                table[i][k]=min(table[i-1][k],table[i-1][k+(1<<(i-1))])
        self.__table=table
 
    def lcp(self,a,b):
        """
        a,b: int 0<=a,b<n
        return LCP length between s[a:] and s[b:]
        """
        if a==b: return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        i=max(0,(r-l-1).bit_length()-1)
        table=self.__table
        return min(table[i][l],table[i][r-(1<<i)])
def resolve():
    n=int(input())
    s=input()
    sa=SuffixArray(s)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            ans=max(min(j-i,sa.lcp(i,j)),ans)
    print(ans)
resolve()

Measured memory_bytes: 53488
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N,K;
	cin>>N>>K;
	vector<bool>DP(K+1,false);
	vector<int>Moves(N+1);
	int i,j;
	for(i=0;i<N;i++){
		cin>>Moves[i];
	}
	/*for(i=0;i<N;i++){
		if(i<Moves[0]){
			DP[i]=2;
		}
		else{
			
		}
	}*/
	for(i=0;i<=K;i++){
		if(DP[i]){
			continue;
		}
		else{
			for(j=0;j<N;j++){
				if(i+Moves[j]<=K){
					DP[i+Moves[j]]=true;
				}
			}
		}
	}
	if(DP[K]){
		cout<<"First";
	}
	else{
		cout<<"Second";
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int f[100010], n, m, ans;

inline int getf(int x) {return f[x] = f[x] == x ? x : getf(f[x]);}

int main(void) {
	scanf("%d%d", & n, & m);
	for (int i = 1; i <= n; ++i)
		f[i] = i;
	for (int i = 1, x, y; i <= m; ++i)
		scanf("%d%d", & x, & y),
		f[getf(x)] = f[getf(y)];
	for (int i = 1; i <= n; ++i)
		ans += f[i] == i;
	printf("%d\n", ans - 1);
	return 0;
}

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define SQR(n) ((n) * (n))

//???
struct Point
{
  double x, y;
  
  Point(double x, double y) : x(x), y(y) {}

  Point operator + (Point p) { return (Point(x + p.x, y + p.y)); }
  Point operator - (Point p) { return (Point(x - p.x, y - p.y)); }
  Point operator * (double a) { return (Point(x * a, y * a)); }
  Point operator / (double a) { return (Point(x / a, y / a)); }

  void input() { scanf("%lf %lf", &x, &y); }
  double abs() { return sqrt(Norm()); }
  double Norm() { return (SQR(x) + SQR(y)); }
  
  bool operator < (const Point &p) const {
    return (equals(x, p.x) ? y < p.y : x < p.x);
  }

  bool operator == (const Point &p) const {
    return (equals(x, p.x) && equals(y, p.y));
  }

};

//??????
struct Segment
{
  Point p1, p2;
  
  Segment(Point p1 = Point(0.0, 0.0), Point p2 = Point(0.0, 0.0)) : p1(p1), p2(p2) {}

  void input() { p1.input(); p2.input(); }
  
};

struct Circle
{
  Point c;
  double r;
  Circle(Point c = Point(0.0, 0.0), double r = 0.0): c(c), r(r) {}
};
  
//??´???
typedef Segment Line; 
//????????????
typedef Point Vector;
typedef vector < Point > Porigon;

double dot(Vector a, Vector b)
{
  return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
  return (a.x * b.y - a.y * b.x);
}

bool isParallel(Vector a, Vector b)
{
  return (equals(cross(a, b), 0.0));
}

bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
  return (isParallel(a1 - a2, b1 - b2));
}

bool isParallel(Segment s1, Segment s2)
{
  return (isParallel(s1.p1, s1.p2, s2.p1, s2.p2));
}

bool isOrthogonal(Vector a, Vector b)
{
  return (equals(dot(a, b), 0.0));
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
{
  return (isOrthogonal(a1 - a2, b1 - b2));
}

bool isOrthogonal(Segment s1, Segment s2)
{
  return (isOrthogonal(s1.p1, s1.p2, s2.p1, s2.p2));
}
main()
{
  int n;
  Segment s1, s2;

  cin >> n;
  for(int i = 0; i < n; i++) {
    s1.input(); s2.input();
    if(isParallel(s1, s2)) cout << 2 << endl;
    else if(isOrthogonal(s1, s2)) cout << 1 << endl;
    else cout << 0 << endl;
  }

  return (0);
}

Measured memory_bytes: 3200
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(long[]);
    auto b = readln.split.to!(long[]);

    if (a.sum() < b.sum()) {
        writeln(-1);
        return;
    }

    int ans;
    long less;
    long[] un, ov;

    foreach (i ; 0 .. n) {
        long d = a[i] - b[i];
        if (d < 0) {
            less += -d;
            ans++;
        }
        else if (d > 0) {
            ov ~= d;
        }
    }

    ov.sort!"a > b"();

    foreach (ovi ; ov) {
        if (less <= 0) {
            break;
        }
        ans++;
        less -= ovi;
    }

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 9820
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int main() {
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    //freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
    int n, m;
    cin >> n >> m;
    ld t = 0;
    ld p = 1;
    ld z = 1 - ((ld)1 / (1 << m));
    ld addt = (n - m) * 100 + m * 1900;
    ld answer = addt;
    for (int lvl = 0; lvl < 1000; lvl++) {
        p *= z;
        t += addt;
        answer += t * p * (1 - z);
    }
    cout << floor(answer + 0.5) << endl;
    return 0;
}



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

int main(){
    long long S, c;   //S, c
    cin >> S >> c;
    long long X = 0;
    //1.S + c + c
    if(2*S <= c){ //Sの個数に対しcが十分にある
        X += S;  //Sの個数分だけ"Scc"ができる
        c -= 2*S; 
    }else{
        X = c/2; //Sの個数に対しcが足りない場合
        c = 0;
    }
    //2.c + c + c + c
    X += c/4;
    cout << X << endl;
    return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll k;cin>>k;
  ll n=s.size();
  auto dp=make_v(n+1,4,2,0LL);
  dp[0][0][0]=1;
  rep(i,0,n){
    rep(j,0,4){
        if(j<3)dp[i+1][j+1][1]+=dp[i][j][1]*9;
        dp[i+1][j][1]+=dp[i][j][1];
        if(s[i]!='0')dp[i+1][j][1]+=dp[i][j][0];
        else dp[i+1][j][0]+=dp[i][j][0];
        if(j<3){
          dp[i+1][j+1][1]+=dp[i][j][0]*max(0,(s[i]-'1'));
        }
        if(s[i]!='0'&&j<3){
          dp[i+1][j+1][0]+=dp[i][j][0];
        }
    }
    //debug(dp[i+1],4,2);cout<<endl;
  }
  rep(i,0,2)res+=dp[n][k][i];
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) cin >> B[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      int A;
      cin >> A;
      sum += A * B[j];
    }
    sum += C;
    if (sum > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

N = INT()
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = MAP()

A.sort()
B.sort()
if N % 2 == 0:
    mn = (A[N//2-1]+A[N//2]) / 2
    mx = (B[N//2-1]+B[N//2]) / 2
    ans = int((mx-mn)*2) + 1
else:
    mn = A[N//2]
    mx = B[N//2]
    ans = (mx-mn) + 1
print(ans)


Measured memory_bytes: 75652
#include<stdio.h>
#define MAX 2000000

int size, A[MAX];

void maxHeapify(int);
int extract();
void increaseKey(int,int);
void insert(int);

int main(){
  int key;
  char com[20];
 
  while(1){
 
    scanf("%s", com);
 
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    }
    else if ( strcmp(com, "extract") == 0  ){
      printf("%d\n", extract());
    }
    else break;
  }  
  return 0;
}
 
void maxHeapify(int i){
  int l, r;
  int largest;
  int t;
   
  l = 2 * i;
  r = 2 * i + 1;
 
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
     
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}
 
int extract(){
  int max;
  if ( size < 1 ) return;
  max= A[1];
  A[1] = A[size--];
  maxHeapify(1);
   
  return max;
}
 
void increaseKey(int i, int key){
   
  int tmp;
   
  if ( key < A[i] ) return;
   
  A[i] = key;
   
  while ( i > 1 && A[i/2] < A[i] ){
     
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
     
  }
}
 
void insert(int key){
   
  size++;
  A[size] = -1000000000;
  increaseKey(size, key);
}

Measured memory_bytes: 4696
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<LL, LL> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 1000 + 47;
const int MIN = 88;
const int MOD = INF;

LL F[MIN];
vector<PII> X[MIN];


int main()
{
    // freopen("in.txt", "r", stdin);
    
    F[0] = F[1] = 1;
    FOR(i, 2, MIN)
        F[i] = F[i-1] + F[i-2];
    
    X[1].PB(MP(1, 2));
    X[1].PB(MP(1, 3));
    X[1].PB(MP(1, 4));
    
    FOR(i, 1, MIN-3)
    {
        FOR(j, 0, SZ(X[i]))
        {
            LL a = X[i][j].first;
            LL b = X[i][j].second;
            
            while (true)
            {
                a += b;
                if (a > F[i] + F[i+3])break;
                
                X[i+1].PB(MP(b, a));
            }
        }
    }
    
    int q;
    cin >> q;
    FOR(qq, 0, q)
    {
        LL n, m;
        cin >> n >> m;
        if (n > m)swap(n, m);
        int k = 1;
        while(F[k+1] <= n && F[k+2] <= m)
            ++k;
        LL ans = 0;
        if (k == 1)
        {
            ans = n * m % MOD;
        }
        else
        {
            FOR(i, 0, SZ(X[k-1]))
            {
                LL x = X[k-1][i].first;
                LL y = X[k-1][i].second;
                
                if (y <= n)ans = (ans + (m - x) / y) % MOD;
                if (y <= m)ans = (ans + (n - x) / y) % MOD;
            }
        }
        cout << k << " " << ans << endl;
    }
    
    
    

    return 0;
}





Measured memory_bytes: 4096
/*
A fallen time that's bygone
A crude elite that's from a distant zone
You turn a blind eye on what's "brave"
You don't know if it's the truth you told

Anger looks on the quiet dreaming
Seals the sense incandescent ones

Hold back desire for danger
A bet you lose, you'll have no way to turn
I see the man who lives and breathes corruption
Into a circle that you call your own

Don't run away, from the pain. A claim that you deal with
A power game, from within. Impossible for you to see this

Laid down the laws of deceit
The ones who cherish are the ones who'll go
Into the ashes of a tortured world
Only in mind's eye can you see a light

Harmony breaks, dark awakes, in old eyes - the trouble, feel it
Here to stay, mark the way, improvise the judgement hearing

Don't run away, from the pain. A claim that you deal with
A power game, from within. Impossible for you to see this

Anger looks on the quiet dreaming
Seals the sense incandescent ones

All remains of the glowing embers
Is a bleak cold irrelevance
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 610031;

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, m, a[50], b[50], par[50], cnt=0;
vector<int> adj[50];
void dfs(int cur) {
	if (par[cur]) return;
	par[cur] = cnt;
	for (int j = 0; j < adj[cur].size(); j++) dfs(adj[cur][j]);
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> a[i] >> b[i], a[i]--, b[i]--;
    int ret = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) { adj[j].clear(); par[j] = 0; }
		for (int j = 0; j < m; j++) if (i != j) {
            adj[a[j]].push_back(b[j]);
            adj[b[j]].push_back(a[j]);
        }
		cnt = 0;
		for (int j = 0; j < n; j++) {
            if (par[j]) continue;
            cnt++; dfs(j);
        }
		if (cnt != 1) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
long long N,M;


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

	cin >> N >> M;

	int A,B;
	vector<pair<long long ,long long>> Q;
	REP(i,N){
		cin >> A >> B;
		Q.push_back(make_pair(A,B));
	}

	sort(Q.begin(),Q.end());

	long long  ans = 0,n = 0;
	int t = 0;
	while(1){
		ans += min(Q[t].second,M - n) * Q[t].first;
		n += min(Q[t].second,M - n);
		t++;
		if(M == n) break;
	}

	cout << ans << endl;

}


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

int main(){
  int M,D;
  cin >> M >> D;
  int n=0;
  vector <int> d(2);
  for(int i=1;i<=M;i++){
    for(int j=10;j<=D;j++){
      d.at(1)=j/10;
      d.at(0)=j%10;
      if(d.at(1)<2){
        continue;
      }
      if(d.at(0)<2){
        continue;
      }
      if(d.at(0)*d.at(1)==i){
        n++;
      }
    }
  }
  cout << n << endl;
  return 0;
}


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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve() {
        int n = in.nextInt();
        int k = in.nextInt();

        int x = in.nextInt();
        int y = in.nextInt();

        int ans = n>k? k*x+(n-k)*y : n*x;
        out.print(ans);
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }

    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

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

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using vvvvector = vector<vvector<vector<t>>>;
template<class t>
using vvvvvector = vector<vvvvector<t>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	string str;
	cin >> str;
	vector<int> line(str.size()+1, 0);
	while(true){
		bool flag = false;
		rep(i, str.size()){
			if(str[i]=='<'){
				if(line[i] >= line[i+1]){
					line[i+1] = line[i] + 1;
					flag = true;
				}
			}
		}
		per(i, str.size()){
			if(str[i]=='>'){
				if(line[i] <= line[i+1]){
					line[i] = line[i+1] + 1;
					flag = true;
				}
			}
		}
		if(!flag)break;
	}
	ll ans = 0;
	foreach(i, line)ans += i;
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 2820
import java.util.Scanner;

public class Main {

	/**
	 * Minimization
	 */
	public static void main(String...args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if ((n - 1) % (k - 1) == 0) {
				System.out.println((n - 1) / (k - 1));
			} else {
				System.out.println((n - 1) / (k - 1) + 1);
			}
		}
	}
}

Measured memory_bytes: 23892
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}





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

int N, M, H[100000+10], A[100010];

int main(void)
{
    cin >> N >> M;
    for (int i = 1; i <= N; ++i) {
        cin >> H[i];
        A[i] = 0;
    }
    for (int i = 1; i <= M; ++i) {
        int a, b;
        cin >> a >> b;
        A[a] = max(A[a], H[b]);
        A[b] = max(A[b], H[a]);
    }

    int counter=0;
    for (int i = 1; i <= N; ++i) {
        counter += H[i] > A[i];
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 4404
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];

    ll pos = 0;
    rep(i, n)if(a[i] == pos+1)pos++;

    if(pos == 0)cout << -1 << endl;
    else cout << n-pos << endl;
}

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

int par[202020];
long long size[202020];

int find(int x) {
	if (par[x] == x) return x;
	return par[x] = find(par[x]);
}

long long unite(int x, int y) {
	x = find(x);
	y = find(y);
	long long res = size[x] * size[y];
	size[x] += size[y];
	par[y] = x;
	return res;
}


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

	for (int i = 0; i < 202020; i++) {
		par[i] = i;
		size[i] = 1;
	}

	vector<long long> a(n + 1), b(n + 1);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		b[a[i]] = i;
	}

	long long ans = 0;
	for (int j = n; j >= 1; j--) {
		int i = b[j];
		ans += a[i];
		if (i - 1 >= 1 && a[i - 1] > a[i]) {
			ans += unite(i - 1, i) * a[i];
		}
		if (i + 1 <= n && a[i + 1] > a[i]) {
			ans += unite(i + 1, i) * a[i];
		}
	}
	cout << ans << endl;
}

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

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

  int k, s;
  cin >> k >> s;

  int res = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int z = s - x - y;

      if (z >= 0 && z <= k) res++;
    }
  }

  cout << res << "\n";
}


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

int main() {
  int N;
  cin >> N;
  int P, W, G, Y;
  P = W = G = Y = 0;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "P") P++;
    else if (S == "W") W++;
    else if (S == "G") G++;
    else Y++;
  }
  if (Y) cout << "Four" << endl;
  else cout << "Three" << endl;  
}


Measured memory_bytes: 3616
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    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 ans = Integer.MAX_VALUE;
    for (int i = 0; i <= N - K; i++) {
      ans = Math.min(ans, h[i + K - 1] - h[i]);
    }

    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 24828
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;
use std::cmp::min;
use std::iter::FromIterator;

fn main() {
    input!{
        n: usize,
        v: [(i64, i64); n]
    }
    if n <= 2 {
        println!("1");
        return;
    }
    let set: HashSet<(i64, i64)> = HashSet::from_iter(v.clone());
    let mut ans = n;
    for i in 0..n - 1 {
        for j in i + 1..n {
            let p = v[i].0 - v[j].0;
            let q = v[i].1 - v[j].1;
            let mut t = 0;
            for k in 0..n {
                if !set.contains(&(v[k].0 - p, v[k].1 - q)) {
                    t += 1;
                }
            }
            ans = min(ans, t);
        }
    }
    println!("{}", ans);
}


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


const int max_n = 300010;
int a[max_n];
multiset<int>s , s1;

long long dp[max_n] , dp1[max_n];


int main()
{
	int n;
	cin >> n;
	for(int i=0;i<3*n;i++) cin >> a[i];
	long long sum1 = 0 , sum2 = 0;
	for(int i=0;i<n;i++)
	{
		s.insert(a[i]);
		sum1+=a[i];
	}
	for(int i=3*n-1;i>=2*n;i--)
	{
		s1.insert(-a[i]);
		sum2+=a[i];
	}
	dp[n-1] = sum1;
	for(int i=n;i<=2*n;i++)
	{
		int x = *s.begin();
		if(a[i] > x) 
		{
			s.erase(s.begin());
			s.insert(a[i]);
			dp[i] = dp[i-1] + a[i] - x;
		}
		else 
			dp[i] = dp[i-1];

	}
	dp1[2*n] = sum2;
	for(int i=2*n-1;i>=n;i--) 
	{
		int x = -(*s1.begin());
		if(a[i] < x)
		{
			s1.erase(s1.begin());
			s1.insert(-a[i]);
			dp1[i] = dp1[i+1] + a[i] - x;
		}
		else 
			dp1[i] = dp1[i+1];
	}

	long long ans = -1e16;
	for(int i=n-1;i<2*n;i++) 
	{
		ans = max(ans , dp[i] - dp1[i+1]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; ++i) {
        cout << s[i];
        cout << t[i];
    }
    return 0;
}



Measured memory_bytes: 256
import scala.io.Source

object Main extends App {
  val line: String = Source.stdin.getLines.toList.head

  def isCapital(c: Char): Boolean = ('A' to 'Z').toList.contains(c)

  val str = line.map { c => if (isCapital(c)) c.toString.toLowerCase else c.toString.capitalize }

  str.map(print)
  println()
}

Measured memory_bytes: 49904
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
using namespace std;

int N;
vector<vector<int>> G, W;
vector<int> color;
vector<bool> visited;

void dfs(int u) {
    visited[u] = true;

    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (visited[v]) continue;
        color[v] = (color[u] + W[u][i]) % 2;
        dfs(v);
    }
}

int main() {
    cin >> N;
    G.resize(N), W.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
        W[u].push_back(w);
        W[v].push_back(w);
    }

    color.resize(N, 0);
    visited.resize(N, false);

    dfs(0);

    for (int c : color) {
        cout << c << endl;
    }
    return 0;
}


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

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
  while(x->l!=NULL)x=x->l;
  return x;
}

Node treeMaximum(Node x){
 while(x->r!=NULL)x=x->r;
  return x;
}

Node treeSearch(Node u, int k){
  if(u!=NULL && k!=u->key){
    if(k<u->key)u=u->l;
    else u=u->r;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->r!=NULL) return treeMinimum(x->r);
  Node y=x->p;
  while(y!=NULL && x==y->r){
    x=y;
    y=y->p;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;

  if(z->l==NULL || z->r==NULL)y=z;
  else y=treeSuccessor(z);

  if(y->l!=NULL){
    x=y->l;
  }
  else x=y->r;

  if(x!=NULL){
    x->p=y->p;
  }
  if(y->p==NULL)root=x;
  else{
    if(y==y->p->l)y->p->l=x;
    else y->p->r=x;
  }
  if(y!=z)z->key=y->key;
  free(y);
}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NULL;
  z->r = NULL;

  while(x!=NULL){
    y=x;
    if(z->key<x->key)x=x->l;
    else x=x->r;
  }
  z->p=y;
  if(y==NULL)root=z;
  else{
    if(z->key<y->key)y->l=z;
    else y->r=z;
  }
}

void inorder(Node u){
  if(u==NULL)return;
  inorder(u->l );
  printf(" %d",u->key);
  inorder(u->r);
}
void preorder(Node u){
  if(u==NULL)return;
  printf(" %d",u->key);
  preorder( u->l);
  preorder(u->r);
}

Node find(Node u,int k){
  while(u!=NULL && k!=u->key){
    if(k<u->key)u=u->l;
    else u=u->r;
  }
  return u;
}

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

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

  return 0;
}




Measured memory_bytes: 20452
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<ArrayDeque<Integer>> lanes = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            lanes.add(new ArrayDeque<>());
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                int idx = sc.nextInt();
                sb.append(lanes.get(idx).poll()).append("\n");
            } else {
                int car = sc.nextInt();
                int min = Integer.MAX_VALUE;
                int minIdx = 0;
                for (int j = 1; j <= n; j++) {
                    if (min > lanes.get(j).size()) {
                        min = lanes.get(j).size();
                        minIdx = j;
                        if (min == 0) {
                            break;
                        }
                    }
                }
                lanes.get(minIdx).add(car);
            }
        }
        System.out.print(sb);
    }
}


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

int n,total1=0,total2=0;
int a[100005];

signed main()
{
	string s;
	cin>>s;
	n=s.size();
	
	for (int i=1;i<=n;i++)  a[i]=s[i-1]-'0';
	for (int i=1;i<=n;i++)
	{
		if (a[i]==0)  total1++;
		else total2++;
	}
	cout<<n-abs(total1-total2)<<endl;
	return 0;
}

Measured memory_bytes: 896
program main;
var 
    x, first, second, third : integer;
begin
    readln(x);
    first := x div 100;
    second := (x mod 100) div 10;
    third := (x mod 100) mod 10;
    if (first = 7) or (second = 7) or (third = 7)
        then writeln('Yes')
        else writeln('No');
end.


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

int main(){
	string str;
	for(int i=0; i<4; i++){
		cin>>str[i];
	}
	if(str[0]==str[1] || str[1]==str[2] || str[2]==str[3]){
		cout<<"Bad"<<endl;
	}else{
		cout<<"Good"<<endl;
	}	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w,k;
vector <vector<char>> cvv;
vector <bool> ignoreHW;//startH,endW
int ans = 0;
int countSharp(vector <vector<char>> &vv, int selectH, int selectW){
    int ret = 0;
    for(int i = 0; i < vv.size(); i++){
        for(int j = 0; j < vv[i].size(); j++){
            if(vv[i][j]=='#'){
                if(i!=selectH){
                    if(j!=selectW){
                        ret++;
                    }
                }
            }
        }
    }
    return ret;
}
void checkAnswer(){
    #if 0
    for(int i = 0; i < ignoreHW.size(); i++){
        if(ignoreHW[i]){
            cout << 'T';
        }else{
            cout << 'F';
        }
    }
    cout << endl;
    #endif
    int cnt = 0;
    for(int i = 0; i < cvv.size(); i++){
        if(ignoreHW[i])continue;
        for(int j = 0; j < cvv[i].size(); j++){
            if(ignoreHW[j+h])continue;
            if(cvv[i][j]=='#'){
                cnt++;
            }
        }
    }
    if(cnt==k)ans++;
}
void dfs(bool isIgnore){
    ignoreHW.push_back(isIgnore);
    if(ignoreHW.size()==(h+w)){
        checkAnswer();
        return;
    }
    dfs(true);
    ignoreHW.pop_back();
    dfs(false);
    ignoreHW.pop_back();
}
int main(){
    cin >> h >> w >> k;
    cvv = vector <vector<char>> (h);
    for(int i = 0; i < h; i++){
        cvv[i] = vector<char>(w);
        for(int j = 0; j < w; j++){
            cin >> cvv[i][j];
        }
    }
    dfs(true);
    ignoreHW.pop_back();
    dfs(false);
    ignoreHW.pop_back();
    // for(int i = -1; i < h; i++){
    //     for(int j = -1; j < w; j++){
    //         if(k==countSharp(cvv,i,j)){
    //             cout << i << " " << j << endl;
    //             ans++;
    //         }
    //     }
    // }
    cout << ans << endl;
    #if 0
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << cvv[i][j];
        }
        cout << endl;
    }
    #endif
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<vector>
using namespace std;
#define MAX 100005
typedef long long ll;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a+b<10)
        printf("%d\n",a+b);
    else
        printf("error\n");
    return 0;
}


Measured memory_bytes: 256
import itertools

def main():
    N = int(input())
    z = []
    ans = 51
    for i in range(N):
        z.append(tuple(map(int, input().split())))
    z.sort(key=lambda x: x[1])
    z.sort(key=lambda x: x[0], reverse=True)
    if len(z) == 1:
        print(1)
        return
    for i, j in itertools.combinations(range(N), 2):
        p = z[i][0] - z[j][0]
        q = z[i][1] - z[j][1]
        ans = min(ans, solve(N, z, p, q))
    print(ans)

def solve(N, z, p, q):
    passlist = set()
    cnt = 0
    for i in range(N):
        if z[i] in passlist:
            continue
        x, y = z[i][0], z[i][1]
        for j in range(N):
            s, t = x-p, y-q
            if (s, t) not in z:
                cnt += 1
                break
            passlist.add((s, t))
            x, y = s, t
    return cnt

if __name__ == "__main__":
    main()


Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

// BEGIN CUT HERE
template<class Z> map<Z, int> factorize(Z n) {
  map<Z, int> res;
  for (Z i = 2; i * i <= n; ++i) while (n % i == 0) ++res[i], n /= i;
  if (n != 1) ++res[n];
  return res;
}
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  cout << n << ':';
  for(const auto& e : factorize(n)) {
    for (int i = 0; i < e.second; ++i) {
      cout << ' ' << e.first;
    }
  }
  cout << '\n';
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int d, n, m;
int D[110000], K[110000];

signed main() {
    while (true) {
        cin >> d;
        if (d == 0) break;
        cin >> n >> m;
        for (int i = 1; i < n; i++) cin >> D[i];
        for (int i = 0; i < m; i++) cin >> K[i];
        sort(D, D + n);
        int ans = 0;
        for (int i = 0; i < m; i++) {
            auto p = upper_bound(D, D + n, K[i]);
            int s = *(p - 1), t = (p == D + n ? d : *p);
            ans += min(K[i] - s, t - K[i]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3876
let () = 
	let g (m, f, r) = 
		if m = -1 || f = -1 then "F"
		else (
			let s = m + f in
			if      s < 30 then "F"
			else if s < 50 then
				if r < 50 then  "D"
				else            "C"
			else if s < 65 then "C"
			else if s < 80 then "B"
			else                "A"
		) in
	let rec solve _ =
		let (m, f, r) = Scanf.scanf "%d %d %d\n" (fun x y z -> (x, y, z)) in
		match (m, f, r) with
			| (-1, -1, -1) -> ()
			| p -> Printf.printf "%s\n" @@ g p; solve ()
	in solve ();;


Measured memory_bytes: 2224
package main
import "fmt"

func main(){
	var N int
	fmt.Scan(&N)

	var M int
	fmt.Scan(&M)

	var rem int
	rem = (N*M)%2
	if rem == 0{
		fmt.Println("Even")
	}else{
		fmt.Println("Odd")
	}	
}

Measured memory_bytes: 512
#include <stdio.h>

long gcd(long x, long y) {
    
    long z;
    
    while ((z = x % y) != 0) {
        x = y;
        y = z;
    }
    
    return y;
    
}

long lcm(long x, long y) {
    
    return x * y / gcd(x, y);;
}

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

    long a, b;
    
    while (scanf("%ld %ld", &a, &b) != EOF) {
        printf("%ld %ld\n", gcd(a, b), lcm(a, b));
    }
    
    return 0;
}

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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

vector<ll> par;
vector<ll> hi;

void init(int n){
   hi.resize(n,0);
   par.resize(n);
   for(int i = 0; i < n; i++)
	   par[i] = i;
}

int root (int x) {
	if (par[x] == x)
		return x;
	else
		return par[x] = root(par[x]);
}

bool Same (int x, int y) {
	return (root(x) == root(y));
}

void merge (int x, int y) {
	if (Same(x, y))
		return;
	x = root(x);
	y = root(y);
	if (hi[x] < hi[y])
		swap(x, y);
	par[y] = x;
	if (hi[x] == hi[y])
		hi[y]++;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n, k;
	cin >> n >> k;
	vector<int> P(n);
	init(n+1);
	for (int i = 0; i < n; ++i) {
		cin >> P[i];
	}
	int x, y;
	while (k--) {
		cin >> x >> y;
		merge(x, y);
		merge(y, x);
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		if (Same(P[i], i+1))
			ans++;
	}
	cout << ans;
	cout << endl;


	return 0;
}


Measured memory_bytes: 2176
from collections import deque
if __name__ == "__main__":
    new_lines = deque([[[0.0, 0.0], [100.0, 0.0]]])
    n = int(input())
    sin60 = 3**0.5/2.0
    cos60 = 1.0/2.0
    for _ in range(n):
        lines = new_lines
        new_lines = deque()
        while lines:
            t1, t2 = lines.popleft()
            n1 = [(2.0*t1[0]+t2[0])/3.0, (2.0*t1[1]+t2[1])/3.0]
            n3 = [(t1[0]+2.0*t2[0])/3.0, (t1[1]+2.0*t2[1])/3.0]
            x, y = [n3[0]-n1[0], n3[1]-n1[1]]
            x60, y60 = [cos60*x - sin60*y ,sin60*x + cos60*y]
            n2 = [n1[0]+x60, n1[1]+y60]
            new_lines.append([t1, n1])
            new_lines.append([n1, n2])
            new_lines.append([n2, n3])
            new_lines.append([n3, t2])
    coordinates = list(zip(*new_lines))[0] + ([100.0, 0.0],)
    for coordinate in coordinates:
        print(*coordinate)


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


int* scanArray( int arrayLength) {

  int i;
  int* a;
  
  a = malloc( sizeof(int) * arrayLength );
  for( i=0; i<arrayLength; i++) {
    scanf("%d", &a[i]);
  }

  return a;
  
}


void swap( int *n1, int *n2) {
  
  int tmp;

  tmp = *n1;
  *n1 = *n2;
  *n2 = tmp;

}


int partition( int *a, int p, int r) {

  int x;
  int i, j;

  x = a[r];
  i = p-1;

  for( j=p; j<r; j++) {
    if( a[j] <= x ) {
      i++;
      swap( &a[i], &a[j]);
    }
  }
  swap( &a[i+1], &a[r]);
  return i+1;

}


/*
void printArray( int *a, int arrayLength) {

  int i;

  for( i=0; i<(arrayLength-1); i++) {
    printf("%d ", a[i]);
  }
  printf("%d\n", a[i]);

}
*/


void printPartitionArray( int *a, int arrayLength, int shaft) {

  int i;

  for( i=0; i<arrayLength-1; i++) {
    if( i == shaft) {
      printf("[%d] ", a[i]);
    }else {
      printf("%d ", a[i]);
    }
  }
  if( i == shaft) {
      printf("[%d]\n", a[i]);
  }else {
    printf("%d\n", a[i]);
  }

}



main() {

  int n, q;
  int* a;

  int i;

  scanf("%d", &n);
  
  a = scanArray( n);

  q = partition( a, 0, n-1);

  printPartitionArray( a, n, q);

  return 0;

}

Measured memory_bytes: 992