akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 100005
char a[N];
int f[N][15];
signed main()
{
	scanf("%s",a+1);
	int n=strlen(a+1);
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]=='?')
		{
			for(int j=0;j<=9;j++)
			{
				for(int k=0;k<13;k++)
				{
					f[i][(k*10+j)%13]=(f[i][(k*10+j)%13]+f[i-1][k])%mod;
				}
			}
		}
		else
		{
			int get=a[i]-'0';
			for(int k=0;k<13;k++)
			{
				f[i][(k*10+get)%13]=(f[i][(k*10+get)%13]+f[i-1][k])%mod;
			}
		}
	}
	cout<<f[n][5]<<endl;
#ifndef ONLINE_JUDGE
//	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 12032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;

string changes(int i){
	string res;
	stringstream ss;
	ss << i;
	ss >> res;
	return res;
}

int main(){
	cin >> n;
	int ans = INF;
	REP(i, 11000){
		bool f = 1;
		string s = changes(i);
		REP(i, s.size() / 2){
			if (s[i] != s[s.size() - 1 - i])f = 0;
		}
		if (f){
			if (abs(n - i) < abs(n - ans)){
				ans = i;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1224
<?php

$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$ma = (int)$input[1];
$mb = (int)$input[2];

$yaku=[];
$a_max = 0;
$b_max = 0;
for ($i=1; $i <= $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$yaku[]=[
		(int)$input[0],
		(int)$input[1],
		(int)$input[2],
	];
	$a_max += (int)$input[0];
	$b_max += (int)$input[1];
}

$inf=5000;
$dp = [];
for ($i=0; $i <= $n; $i++) { 
	for ($ca=0; $ca <= $a_max ; $ca++) { 
		for ($cb=0; $cb <=$b_max ; $cb++) { 
			$dp[$i][$ca][$cb] = $inf;
		}
	}
}
$dp[0][0][0] = 0;

for ($i=0; $i < $n; $i++) { 
	$tmp_y = $yaku[$i];
	for ($ca=0; $ca <= $a_max ; $ca++) { 
		for ($cb=0; $cb <=$b_max ; $cb++) { 
			if ($dp[$i][$ca][$cb] == $inf) {
				continue;
			}
			// 薬品追加しない場合
			$dp[$i+1][$ca][$cb] = min($dp[$i][$ca][$cb], $dp[$i+1][$ca][$cb]);
			// 薬品追加する場合
			$dp[$i+1][$ca+$tmp_y[0]][$cb+$tmp_y[1]] = 
				min(
					$dp[$i+1][$ca+$tmp_y[0]][$cb+$tmp_y[1]],
					$dp[$i][$ca][$cb]+$tmp_y[2]
				);
		}
	}
}
$min = $inf;
for ($i=1; $i <= $n; $i++) { 
	for ($ca=1; $ca <= $a_max ; $ca++) { 
		for ($cb=1; $cb <=$b_max ; $cb++) { 
			if ($ca*$mb === $cb*$ma) {
				$min = min($min, $dp[$i][$ca][$cb]);
			}
		}
	}
}
if ($min >= $inf) {
	echo '-1';
}else{
	echo $min;
}



Measured memory_bytes: 133624
// 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<int(pow(2,h));i++){
        vector<vector<char>> b=a;
        rep(ii,h){
            if(i>>ii&1){ //i行目を選択
                rep(iii,w){
                    b[ii][iii]='R';
                }
            }
        }
        int total=0;
        rep(c,h){
            rep(cc,w){
                if(b[c][cc]=='#'){
                    total++;
                }
            }
        }
        rep(j,int(pow(2,w))){
            int total2=total;
            rep(jj,w){
                if(j>>jj&1){ //i行目を選択
                    rep(jjj,h){
                        if(b[jjj][jj]=='#') total2--;
                    }
                }
            }
            if(total2==k) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int A, B;
  cin >> A >> B;
  int num = 1, ans = 0;
  while(num < B) {
    num = num-1+A;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

#define bit(b, i) (((b) >> (i)) & 1)
#define PC __builtin_popcountll
#define BL(a) (a ? 64 - __builtin_clzll(a) : 0)

int main() {
	IN(int, h, w, k);
	vector<string> s(h);
	cin >> s;
	
	int ans = 0;
	inc(bi, 1 << h) {
	inc(bj, 1 << w) {
		int c = 0;
		inc(i, h) {
		inc(j, w) {
			if(bit(bi, i) == 0 && bit(bj, j) == 0 && s[i][j] == '#') { c++; }
		}
		}
		if(c == k) { ans++; }
	}
	}
	OUT(ans);
}


Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) break;
			T[] ts = new T[n];
			for (int i=0;i<n;i++) {
				String name = sc.next();
				int p = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(),
					d = sc.nextInt(), e = sc.nextInt(), f = sc.nextInt(), s = sc.nextInt(), m = sc.nextInt();
				ts[i] = new T(f * s * m - p, a + b + c + ( d + e) * m, name);
			}
			sort(ts);
			for (int i=0;i<n;i++) {
//				debug(ts[i].v, ts[i].w);
				System.out.println(ts[i].name);
			}
			System.out.println("#");
		}
	}
	
	class T implements Comparable<T> {
		int v, w;
		String name;
		T(int v, int w, String name) {
			this.v = v;
			this.w = w;
			this.name = name;
		}
		@Override
		public int compareTo(T o) {
			// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?
			if (v * o.w != o.v * w) return o.v * w - v * o.w;
			return name.compareTo(o.name);
		}
	}
	
	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 36072
from bisect import bisect_left
N = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()
for na,a in enumerate(L[:N-2]):
    for nb_,b in enumerate(L[na+1:N-1]):
        nb = nb_+na+1
        nc = bisect_left(L,a+b)
        ans += nc-nb-1
print(ans)


Measured memory_bytes: 45532
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w;
  cin>>n>>w;
 	vector<long long> dp(200005);
  for(int i=0;i<n;i++)
  {
    int a,b;
    cin>>a>>b;
    for(int j=w-a;j>=0;j--)
    {
      dp[j+a]=max(dp[j+a],dp[j]+b);
    }
  }
  cout<<dp[w]<<" ";
  return 0;
}


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

typedef double Num;
typedef complex<Num> Pt2;
typedef vector<Pt2>  Polygon2;

struct Line2 : public vector<Pt2> {
	Line2(Pt2 a, Pt2 b) { push_back(a); push_back(b); }
};

const double eps = 1e-10;
Num  dot  (Pt2 a, Pt2 b) { return (a*conj(b)).real(); }
Num  cross(Pt2 a, Pt2 b) { return (conj(a)*b).imag(); }
Pt2  vec  (Line2 l)      { return l[1]-l[0]; }

int ccw(Pt2 a, Pt2 b, Pt2 c) {
	b-=a; c-=a;
	if(cross(b,c) > 0 ) return +1; // ccw
	if(cross(b,c) < 0 ) return -1; // cw
	if(  dot(b,c) < 0 ) return +2; // cab
	if(norm(b)<norm(c)) return -2; // abc
	return 0;                      // acb
}

int ccw(Line2 s, Pt2 p) {
	return ccw(s[0], s[1], p);
}

bool intersectSP(Line2 s, Pt2 p) {
	return abs(s[0]-p)+abs(s[1]-p) < abs(s[1]-s[0])+eps;
}

bool intersectSS(Line2 s, Line2 t) {
	return ccw(s,t[0])*ccw(s,t[1]) <= 0 
	    && ccw(t,s[0])*ccw(t,s[1]) <= 0;
}

Pt2 projection(Line2 l, Pt2 p) {
  double t = dot(p-l[0], vec(l)) / norm(vec(l));
  return l[0] + t*(vec(l));
}

Pt2 reflection(Line2 l, Pt2 p) {
	return p + 2.0*(projection(l,p) - p);
}

Num distanceSP(Line2 s, Pt2 p) {
  Pt2 r = projection(s,p);
  if(intersectSP(s,r)) return abs(r-p);
  return min(abs(s[0]-p), abs(s[1]-p));
}

Num distanceSS(Line2 s, Line2 t) {
  if(intersectSS(s,t)) return 0;
  return min(min(distanceSP(s,t[0]), distanceSP(s,t[1])),
             min(distanceSP(t,s[0]), distanceSP(t,s[1])));
}

bool convex_contains(Polygon2 g, Pt2 p)
{
	for(int i=0; i<g.size(); i++)
	{
		if(ccw(Line2(g[i],g[(i+1)%g.size()]), p)==-1) return false;
	}
	return true;
}

double dist(Line2 s, Line2 t, double h) {
	double d=distanceSS(s,t);
	if(d<=h) return d;
	return (d*d+h*h)/(2*h);
}


int main()
{
	int N;
	while(cin>>N, N)
	{
		Num x1,y1,x2,y2,h;
		cin>>x1>>y1>>x2>>y2;
		Line2 course(Pt2(x1,y1),Pt2(x2,y2));

		double ans=1e10;
		while(N--)
		{		
			cin>>x1>>y1>>x2>>y2>>h;
			Polygon2 g(4);
			g[0]=Pt2(x1,y2); g[3]=Pt2(x2,y2);
			g[1]=Pt2(x1,y1); g[2]=Pt2(x2,y1);

			if(convex_contains(g,course[0]) || convex_contains(g,course[1]))
			{
				ans=0;
			}

			for(int i=0; i<g.size(); i++)
			{
				ans = min(ans, dist(course,Line2(g[i],g[(i+1)%g.size()]),h));
			}

		}
		cout.setf(ios::fixed);
		cout.precision(5);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1032
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<limits>
#include<map>
#include<queue>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1e+7
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	priority_queue<int> pq;
	rep(i, N) {
		int x;
		cin >> x;
		pq.push(x);
	}
	rep(i, M) {
		int y = pq.top();
		y /= 2;
		pq.pop();
		pq.push(y);
	}

	ll ans = 0;
	rep(i, N) {
		ans += pq.top();
		pq.pop();
	}

	cout << ans << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,mm,i,ans,m1;
	scanf("%d %d",&n,&m);
	mm=(int)sqrt(m);ans=0;
	for(i=1;i<=mm;i++)
	{
		if(m%i==0)
		{
			m1=m/i;
			if(m/i>=n)ans=max(ans,i);
			if(m/m1>=n)ans=max(ans,m1);
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main(){
    int a,b,c;
    int count=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	for(int i=0;i<5;i++)
	{
		if(a[i]==0)
		{
			cout<<i+1<<'\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3588
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll X,Y;
    cin >>X>>Y;
    //-----------------------------------

    ll a=Y-2*X, b=4*X-Y;

    cout << ((a>=0 && a%2==0 && b>=0 && b%2==0) ? "Yes" : "No") <<'\n';


    return (0);
}

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

int A[300005];

int main()
{
	int N;
	cin>>N;
	
	int i;
	
	for (i=1;i<=3*N;i++)
	{
		cin>>A[i];
	}
	
	sort(A+1,A+3*N+1);
	
	long long sum=0;
	int cnt=0;
	
	for (i=3*N-1;cnt<N && i>0;i-=2)
	{
		sum+=A[i];
		cnt++;
	}
	
	cout<<sum;
}

Measured memory_bytes: 1408
import itertools

n = int(input())

cnt = [0] * (10 ** 4 + 1)

for x, y, z in itertools.product(range(1, 10 ** 2), repeat=3):
    idx = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if idx <= 10 ** 4:
        cnt[idx] += 1


for num in cnt[1 : n + 1]:
    print(num)


Measured memory_bytes: 68508
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	n := nextInt(sc)
	set := make(map[string]bool)
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		sc.Scan()
		line := sc.Text()
		ss := strings.Split(line, " ")
		if ss[0] == "insert" {
			set[ss[1]] = true
		} else {
			ans := "no"
			if _, ok := set[ss[1]]; ok {
				ans = "yes"
			}
			fmt.Fprintln(wtr, ans)
		}
	}
	wtr.Flush()
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}



Measured memory_bytes: 40544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
const int maxn=1e5+5;
int n;
vector<pair<int,int>> tree(8*maxn);
pair<int,int> merge(pair<int,int> a,pair<int,int> b,bool fl){
    vector<int> v={a.first,a.second,b.first,b.second};
    if(fl==0) sort(v.rbegin(),v.rend());
    else sort(v.begin(),v.end());
    return {v[0],v[1]};
}
void build(int v,int tl,int tr,bool fl=0){
    if(tl==tr){
        if(fl==0) tree[v]={-1,-1};
        else tree[v]={n,n};
        return ;
    }
    int mid=(tl+tr)>>1;
    build(2*v,tl,mid,fl);
    build(2*v+1,mid+1,tr,fl);
    tree[v]=merge(tree[2*v],tree[2*v+1],fl);
}
void update(int v,int tl,int tr,int pos,int val,int fl){
    if(pos > tr or pos < tl) return;
    if(tl==tr and pos==tl){
        tree[v].first=val;
        return;
    }
    int mid=(tl+tr)>>1;
    update(2*v,tl,mid,pos,val,fl);
    update(2*v+1,mid+1,tr,pos,val,fl);
    tree[v]=merge(tree[2*v],tree[2*v+1],fl);
}
pair<int,int> query(int v,int tl,int tr,int ql,int qr,bool fl){
    if(ql > qr or qr < tl or ql > tr){
        if(fl==0) return {-1,-1};
        else return {n,n};
    }
    if(tl>=ql and tr<=qr) return tree[v];
    int mid=(tl+tr)>>1;
    return merge(query(2*v,tl,mid,ql,qr,fl),query(2*v+1,mid+1,tr,ql,qr,fl),fl);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n;
    stack<int> s1;
    vector<int> p(n);
    for(int i=0;i<n;i++) {cin >> p[i];p[i]--;}
    vector<pair<int,int>> rpos(n),lpos(n);
    build(1,0,n-1,1);  
    update(1,0,n-1,p[n-1],n-1,1);
    rpos[n-1]={n,n};
    for(int i=n-2;i>=0;i--){
        rpos[i]=query(1,0,n-1,p[i]+1,n-1,1);
        update(1,0,n-1,p[i],i,1);
       // cout << rpos[i].first << " " << rpos[i].second << endl; 
    }
    build(1,0,n-1,0);
    update(1,0,n-1,p[0],0,0);
   // cout << query(1,0,n-1,0,0,0).first <<" "<< query(1,0,n-1,0,0,0).second << endl;

    lpos[0]={-1,-1};
    for(int i=1;i<n;i++){
        lpos[i]=query(1,0,n-1,p[i]+1,n-1,0);
        update(1,0,n-1,p[i],i,0);
      //  cout << lpos[i].first << " " << lpos[i].second << endl; 
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll cont=0;
        p[i]++;
        cont+=(rpos[i].second-rpos[i].first)*(i-lpos[i].first);
        cont+=(lpos[i].first-lpos[i].second)*(rpos[i].first-i);
        dbg(cont);
        ans+=cont*p[i];
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 8448
S=input()

ans = 0
count=0
while count <= len(S)-2:
    if S[count]==S[count+1]:
        count = count+3
        ans+=2
        if count == len(S):
            ans -= 1
        if count == len(S)+1:
            ans -= 2

    else:
        count = count+1
        ans +=1


print(ans+1)

Measured memory_bytes: 3500
#include <iostream>
using namespace std;
 
int main() {

    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    if ((x - r)>=0 &&(x + r)<=W&&(y - r)>=0 &&(y + r)<=H)
    {
            cout << "Yes" <<endl;
    }else
    {
            cout << "No" <<endl;
    }
        
}


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

int main()
{
  int n;
  cin >> n;
  auto n_u(n / 2), n_l((n / 2) - 1);
  vector<int> d(n);
  for (auto idx(0); idx < n; ++idx) {
    cin >> d[idx];
  }
  std::sort(d.begin(), d.end());
  cout << d[n_u] - d[n_l] << endl;
}


Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    H1,M1,H2,M2,K = map(int, input().split())
    if M2>=M1:
        print((H2-H1)*60+M2-M1-K)
    else:
        print((H2-H1-1)*60+60+M2-M1-K)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61652
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <istream>
#include <set>
#include <queue>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define ps push_back 
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	string s;
	set<string>a;
	rep0(i, n - 1) {
		cin >> s;
		a.insert(s);
	}
	cout << ((a.size() == 4) ? "Four" : "Three") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<string>
#include<vector>
#include<math.h>
#include<time.h>
#include<utility>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
int black,white; 
int colour[100008];
vector<int> connect[100008];
queue<int> q;
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		connect[x].push_back(y);
		connect[y].push_back(x);
	}
	//for(int i=1;i<=n;i++){
	//	for(int j=0;j<connect[i].size();j++) cout<<connect[i][j]<<" ";
	//	cout<<endl;
	//}
	memset(colour,0,sizeof(colour));
	colour[1]=1;colour[n]=2;
	q.push(1);q.push(n);
	while(!q.empty()){
		int f=q.front();
		q.pop();
		for(int i=0;i<connect[f].size();i++){
			if(!colour[connect[f][i]]){
				q.push(connect[f][i]);
				colour[connect[f][i]]=colour[f];
			}
		}
	}
	for(int i=1;i<=n;i++){
		//cout<<colour[i]<<" ";
		if(colour[i]==1) black++;
	    else white++;
	}
	if(black>white) cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
} 

Measured memory_bytes: 6272
# -*- coding: utf-8 -*-
class DisjointSets:
    '''
    Implementing disjoint sets using disjoint sets forests structure.

    --- methods ---
    __init__(size): size should be the number of elements in this disjoint sets
    unite(x, y): unite sets that contain x and y into a new set
    same(x, y): check if x and y are in the same set
    '''

    def __init__(self, size):
        self.size = size
        self.roots = [x for x in range(self.size)]
        self.ranks = [0] * self.size

    def _link(self, x, y):
        if self.ranks[x] > self.ranks[y]:
            self.roots[y] = x
        else:
            self.roots[x] = y
            if self.ranks[x] == self.ranks[y]:
                self.ranks[y] += 1

    def _find_set(self, x):
        # compression of the path
        if x != self.roots[x]:
            self.roots[x] = self._find_set(self.roots[x])

        return self.roots[x]

    def unite(self, x, y):
        self._link(self._find_set(x), self._find_set(y))

    def same(self, x, y):
        return self._find_set(x) == self._find_set(y)


if __name__ == '__main__':
    '''
    an example of using this function
    AIZU ONLINE JUDGE - DSL_1_A
    '''

    import sys
    n, q = map(int, input().split())
    ds = DisjointSets(n)

    for line in sys.stdin.readlines():
        query, x, y = map(int, line.strip().split())
        if query == 0:
            ds.unite(x, y)
        elif query == 1:
            if ds.same(x, y):
                print(1)
            else:
                print(0)



Measured memory_bytes: 13976
io = STDIN
n=io.gets.to_i
a,b=io.gets.split.map(&:to_i)
pn=io.gets.split.map(&:to_i)
p1=pn.select{|t|t<=a}.size
p2=pn.select{|t|a<t && t<=b}.size
p3=pn.select{|t|b<t}.size
puts [p1,p2,p3].min


Measured memory_bytes: 3836
#include<iostream>
#include<cstring>

using namespace std;

const int MAX = 40;

string kang[] = {"ld","mb","mp","nc","nd","ng","nt","nw","ps","qu","cw","ts"};
int ans[MAX][MAX];

int kang2int(const string& s){
  // cout << " s " << s << endl;
  if(s.length()==1){
    char c = s[0];
    return c-'a';
  }
  for(int i = 0; i < 12; i++)
    if(s == kang[i]) return 27+i;

  return -1;
}

string int2kang(int n){
  if(n < 27){
    char c = 'a'+n;
    string s = "";
    s += c;
    return s;
  }
  return kang[n-27];
}

string getString(const string& s, int idx){
  if(kang2int(s.substr(idx,2)) != -1) return s.substr(idx,2);
  return s.substr(idx,1);
}

void solve(const string& s){

  int idx = 0;

  while(1){
    while(s[idx] == ' ') idx++;

    string s1 = getString(s,idx);
    idx += s1.length();

    if(idx >= (int)s.length()) break;
    if(s[idx] == ' ') continue;

    string s2 = getString(s,idx);
    // cout << s1 << " " << s2 << endl;
    // idx+=s2.length();
    ans[kang2int(s1)][kang2int(s2)]++;
  }

}

void print(){
  for(char c = 'a'; c <= 'z'; c++){
    string tmp = "";
    tmp += c;
    int pos = 0;
    int kpos = kang2int(tmp);
    for(int i = 0; i < MAX; i++) if(ans[kpos][pos] < ans[kpos][i]){pos = i;}
    cout << c << " " << int2kang(pos) << " " << ans[kpos][pos] << endl;
  }

  for(int i = 0; i < 12; i++){
    int kpos = kang2int(kang[i]);
    int pos = 0;
    for(int j = 0; j < MAX; j++) if(ans[kpos][pos] < ans[kpos][j]){pos = j;}
    cout << kang[i] << " " << int2kang(pos) << " " << ans[kpos][pos] << endl;
  }
}

int main(){

  
  memset(ans,0,sizeof(ans));
  int n;
  cin >> n;
  cin.ignore();
  while(n--){
    string s;
    getline(cin,s);
    solve(s);
  }
  print();
  return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    vector<string> S(N);
    REP(i,0,N) {
        cin >> S[i];
        sort(ALL(S[i]));
    }
    map<string,ll> C;
    ll cnt = 0;
    REP(i,0,N) ++C[S[i]];
    FORR(c,C) cnt += c.second * (c.second - 1) / 2;
    PR(cnt);

    return 0;
}

/*



*/

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

int main(){

	while(true){
		int n;
		cin >> n;

		if(n == 0){
			break;
		}

		char* bef = new char[n];
		char* aft = new char[n];

		for(int i = 0; i < n; i++){
			cin >> bef[i] >> aft[i];
		}

		int nn;
		cin >> nn;
		char* moji = new char[nn];

		char* Moji = new char[nn];

		for(int i = 0; i < nn; i++){
			cin >> moji[i];
		}

		for(int i = 0; i < nn; i++){
			for(int j = 0; j < n; j++){
				if(moji[i] == bef[j]){
					moji[i] = aft[j];
					break;
				}
			}
			cout << moji[i];
		}
		cout << endl;

	}

}

Measured memory_bytes: 1300
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[100005];
int main()
{
	scanf("%d",&n);
	if(n%2) {printf("0");return 0;}
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	printf("%d",a[n/2+1]-a[n/2]);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
int main(){
	int l,r,d;
	int s=0;
	scanf("%d%d%d",&l,&r,&d);
	for(int i=l;i<=r;i++){
		if(i%d==0) s=s+1;
		
	}
	printf("%d",s);
} 

Measured memory_bytes: 1720
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char s[10];
int main(void)
{
	int i;
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++){
		if(s[i]=='A'&&s[i+1]=='C'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 128
def main():
    n,k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n

    def cost(i,j):
        return abs(h[i]-h[j])

    for i in range(1,n):
        if i <= k:
            dp[i] = cost(0,i)
        else:
            dp[i] = min([dp[i-j] + cost(i,i-j) for j in range(1,k+1)])
    print(dp[n-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 52832
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<string,int> NODE;

int di[] = {1,-1,4,-4};

bool check(int n){return n<8 && n>=0;}

int main(){
	NODE now;
	map<string,int> done;
	queue<NODE> Q;
	Q.push(make_pair("01234567",0));
	while(!Q.empty()){
		now = Q.front();Q.pop();
		done[now.first] = now.second;		
		int x = now.first.find("0");
		for(int i=0;i<4;i++){
			if((x)  %4 == 0 && i == 1)continue;
			if(!((x+1)%4||i))continue;
			if( !check(x+di[i]) )continue;
			swap(now.first[x],now.first[x+di[i]]);
			if( done.find(now.first) == done.end() )Q.push(make_pair(now.first,now.second+1));
			swap(now.first[x],now.first[x+di[i]]);
		}
	}
	string t;
	while(getline(cin,t)){
		t.erase(remove(t.begin(),t.end(),' '),t.end());
		cout << done[t] << endl;
	}
}

Measured memory_bytes: 2228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e3 + 10;


int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    int n; scanf("%d", &n);
    n = n % 10;
    if (n == 3) printf("bon");
    else if (n == 0 || n == 1 || n == 6 || n == 8) printf("pon");
    else printf("hon");



    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <cmath>
using namespace std;
inline void prime_fac(int n){
	int m=(int)floor(sqrt(n)+0.5);
	for (int i=2;i<=m;++i){
		while (n%i==0){
			n/=i;
			cout<<" "<<i;
		}
	}
	if (n!=1){
        cout<<" "<<n;
    }
}
int main(){
	int n;
	cin>>n;
	cout<<n<<":";
	prime_fac(n);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ba(m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        ba[i] = make_pair(b - 1, a - 1);
    }
    sort(ba.begin(), ba.end());
    int ans = 0;
    int tmp = -1;
    for (int i = 0; i < m; i++)
    {
        if (tmp < ba[i].second)
        {
            ans++;
            tmp = ba[i].first - 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int N, M, X, Y,i,buf;
	vector<int> x, y;
	cin >> N >> M >> X >> Y;
	for (i = 0; i < N; i++) {
		cin >> buf;
		x.push_back(buf);
	}
	for (i = 0; i < M; i++) {
		cin >> buf;
		y.push_back(buf);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	if ((x[N - 1] < y[0])&&(x[N-1] < Y)&&(y[0] > X))cout << "No War";
	else cout << "War";
	return(0);
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

using node = tuple<ll, int, int, int>;

const int MAX_X = (int)(1e3 + 5);
const int MAX_Y = (int)(1e3 + 5);
const int MAX_Z = (int)(1e3 + 5);
const int MAX_K = (int)(3e3 + 5);

int x, y, z, k;
ll a[MAX_X], b[MAX_Y], c[MAX_Z];

int main(void) {
  // Here your code !
  scanf("%d %d %d %d", &x, &y, &z, &k);

  for (int i = 0; i < x; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 0; i < y; ++i) {
    scanf("%lld", &(b[i]));
  }

  for (int i = 0; i < z; ++i) {
    scanf("%lld", &(c[i]));
  }

  sort(a, a + x, greater<ll>());
  sort(b, b + y, greater<ll>());
  sort(c, c + z, greater<ll>());

  priority_queue<node> pq;
  pq.push(node(a[0] + b[0] + c[0], 0, 0, 0));

  set<node> visited;
  // visited.insert(node(a[0] + b[0] + c[0], 0, 0, 0));

  int cnt = 0;
  while (!pq.empty()) {
    node cur = pq.top();
    pq.pop();

    if (visited.find(cur) != visited.end()) continue;

    visited.insert(cur);

    ll cost = get<0>(cur);
    int ia = get<1>(cur);
    int ib = get<2>(cur);
    int ic = get<3>(cur);

    printf("%lld\n", cost);

    cnt += 1;

    if (cnt == k) {
      break;
    }

    if (ia + 1 < x) pq.push(node(cost - a[ia] + a[ia + 1], ia + 1, ib, ic));
    if (ib + 1 < y) pq.push(node(cost - b[ib] + b[ib + 1], ia, ib + 1, ic));
    if (ic + 1 < z) pq.push(node(cost - c[ic] + c[ic + 1], ia, ib, ic + 1));
  }

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node {
  struct node *left, *right;
  int number;
};

static struct node *root = NULL;
#define BUF_SIZE 30
#define COMMAND_MAX 500001

void insert(int num) {
  struct node *nod = malloc(sizeof(struct node));
  nod->number = num;
  nod->left = nod->right = NULL;
  if(!root) {
    root = nod;
    return;
  }
  struct node **tmp = &root;
  while(*tmp) {
#ifdef DEBUG
    printf("%d: %d\n", num, (*tmp)->number);
#endif
    tmp = ((*tmp)->number > num) ? &(*tmp)->left : &(*tmp)->right;
  }
  // tmp = &nod is not the answer!
  *tmp = nod;
  return;
}

struct node** find(int num) {
  struct node **node = &root;
  while(*node) {
    struct node *cur = *node;
    if(cur->number > num) {
      node = &cur->left;
    } else if (cur->number == num) {
      return node;
    } else {
      node = &cur->right;
    }
  }
  return NULL;
}

struct node** findmin(struct node *node) {
  struct node** min = &node;
  while(1) {
    if((*min)->left) {
      min = &(*min)->left;
    } else {
      return min;
    }
  }
  return min;
}

void delete(int num) {
  struct node **node = find(num);
  if(node == NULL) return;
  struct node *cur = *node;
  if(!cur->left && !cur->right) {
    *node = NULL;
  } else if (cur->left && cur->right) {
    struct node** pmin = findmin(cur->right);
    struct node* min = (*pmin);
    (*pmin) = min->right;
    min->left = cur->left;
    // null when cur->right is min itself
    min->right = cur->right == min ? NULL : cur->right;
    (*node) = min;
  } else {
    (*node) = cur->left ? cur->left : cur->right;
  }
  free(cur);
}

void pre_order(struct node *node) {
  if(!node) return;
  printf(" %d", node->number);
  pre_order(node->left);
  pre_order(node->right);
}

void in_order(struct node *node) {
  if(!node) return;
  in_order(node->left);
  printf(" %d", node->number);
  in_order(node->right);
}

void print(void) {
  in_order(root);
  putchar('\n');
  pre_order(root);
  putchar('\n');
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  int num;
  sscanf(line, "%d", &num);

  int i, j;
  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    char command[8];
    int n;
    sscanf(line, "%s %d", command, &n);
    if(!strncmp(command, "insert", 6)) {
      insert(n);
    } else if (!strncmp(command, "print", 5)) {
      print();
    } else if (!strncmp(command, "find", 4)) {
      struct node **res = find(n);
      printf("%s\n", res ? "yes" : "no");
    } else if (!strncmp(command, "delete", 6)) {
      delete(n);
    }
  }
  return 0;
}


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

int comp(const void *a,const void *b){ return *(int*)a - *(int*)b; }

int main(){
  int P[3];
  
  scanf("%d %d %d",&P[0],&P[1],&P[2]);

  qsort( P, 3, sizeof(int), comp );

  printf("%d\n",P[0]+P[1]);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int H,W,N;

int main(){
    cin>>H>>W>>N;

    map<pair<int,int>,int> black;
    int x,y;
    for (int i = 0; i < N; ++i) {
        scanf("%d %d",&x,&y); x--; y--;
        for (int j = -2; j <= 0; ++j) {
            for (int k = -2; k <= 0; ++k) {
                if(x+j<0 || x+j+2>H-1 || y+k<0 || y+k+2>W-1)continue;
                black[make_pair(x+j, y+k)]++;
            }
        }
    }

    vector<ll> cnt(10,0ll);

    for(auto itr=black.begin();itr!=black.end();++itr){
        for (int i = 0; i < 10; ++i) {
            if((itr->second)==i) cnt[i]++;
        }
    }

    cnt[0]=(ll)(H-2)*(W-2);
    for (int i = 1; i < 10; ++i) {
        cnt[0]-=(ll)cnt[i];
    }
    for (int i = 0; i < 10; ++i) {
        cout<<cnt[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * 不安なら ll を使う.
 * 小数は double を忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/

/* ===== コーナーケースに気をつけろ ===== */

int main()
{
    string s;
    cin >> s;
    deque<char> deq;
    REP(i, s.size())
    {
        deq.push_back(s[i]);
    }

    int q;
    cin >> q;
    bool flip = false;
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            flip = !flip;
        }
        if (t == 2)
        {
            int f;
            char c;
            cin >> f;
            cin >> c;
            // 通常
            if (!flip)
            {
                if (f == 1)
                {
                    deq.push_front(c);
                }
                else
                {
                    deq.push_back(c);
                }
            }
            // 反転時
            if (flip)
            {
                if (f == 2)
                {
                    deq.push_front(c);
                }
                else
                {
                    deq.push_back(c);
                }
            }
        }
    }

    if (flip)
    {
        while (!deq.empty())
        {
            char v = deq.back();
            deq.pop_back();
            cout << v;
        }
        cout << endl;
    }
    else
    {
        while (!deq.empty())
        {
            char v = deq.front();
            deq.pop_front();
            cout << v;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 896
S = list(input())
T = list(input())

S.sort()
T.sort(reverse=True)

n = len(S)
m = len(T)

for i in range(min(n,m)):
    if S[i] > T[i]:
        print('No')
        exit()
    elif S[i] < T[i]:
        print('Yes')
        exit()

if n >= m:
    print('No')
else:
    print('Yes')

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int n;
  cin >> n;
  vector<ll> t(n);
  REP(i,n)cin >> t[i];
  ll lcm = t[0];
  for(int i = 1;i < n;i++){
    lcm = lcm/__gcd(lcm,t[i])*t[i];
  }
  cout << lcm << endl;




  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main ()
{
    int n;
    cin>>n;
    string s[200001];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(&(s[0]),&(s[n]));
    int d=1;
    for(int i=0;i<n-1;i++)
    {
        
        if(s[i]!=s[i+1])
        {
            d++;
        }
    }
    cout<<d;
}

Measured memory_bytes: 9896
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

signed main()
{
	
 	FLASH

 	int n;
 	string s, t;
 	cin>>n>>s>>t;

 	int ind = n - 1;

 	fr(i,0,n)
 	{
 		bool ok = 1;
 		fr(j,0,n - i)
 		{
 			if(s[i + j] != t[j]) ok = 0;
 		}
 		if(ok == 1)
 		{
 			ind = i - 1;
 			break;
 		}
 	}

 	cout<<n + ind + 1;
}

Measured memory_bytes: 256
import java.util.Scanner;

//A Thief
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Case = 1;
		while(true){
			int W = sc.nextInt();
			if(W==0)break;
			int n = sc.nextInt();
			int[] w = new int[n+1];
			int[] v = new int[n+1];
			for(int i=1;i<=n;i++){
				String[] s = sc.next().split(",");
				v[i] = Integer.parseInt(s[0]);
				w[i] = Integer.parseInt(s[1]);
			}
			int[][] dp = new int[n+1][W+1];
			int maxV = Integer.MIN_VALUE;
			int minW = Integer.MAX_VALUE;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=W;j++){
					if(j-w[i]>=0){
						dp[i][j] = Math.max(Math.max(dp[i-1][j], 0), dp[i-1][j-w[i]]+v[i]);
						if(maxV < dp[i][j]){
							maxV = dp[i][j];
							minW = j;
						}
						else if(maxV == dp[i][j]){
							minW = Math.min(minW, j);
						}
					}
					else dp[i][j] = dp[i-1][j];
				}
			}
			System.out.println("Case " + Case++ + ":\n" + maxV + "\n" + minW);
			
		}
	}
}

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

int main(){
  ll n;
  cin>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  reverse(b,b+n);
  ll j=0;
  for(int i=0;i<n;i++){
    if(a[i]==b[i]){
      for(;j<n;j++){
        if(a[i]!=b[j] && a[j]!=b[i]){
          swap(b[i],b[j]);
          break;
        }
      }
      if(a[i]==b[i]){cout<<"No"<<endl;return 0;}
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++)cout<<b[i]<<" ";
  cout<<endl;
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  vector<vector<int>> a(26),b(26);
  for(int i=0;i<s.size();i++){
    a[s[i]-'a'].push_back(i);
    b[t[i]-'a'].push_back(i);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  bool f=true;
  for(int i=0;i<26;i++){
    for(int j=0;j<min(a[i].size(),b[i].size());j++){
      if(a[i][j]!=b[i][j]){
        f=false;
        break;
      }
    }
    if(!f){
      break;
    }
  }
  if(f){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, y;

int main(){
	IOS
	cin >> n >> y;
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=n;j++){
			ll k=n-i-j;
			if(k<0) continue;
			if(10000*i+5000*j+1000*k==y){
				cout << i << ' ' << j << ' ' << k << '\n';
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << ' ' << -1 << '\n';
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  lint n,a,b,c,d,e; cin >> n >> a >> b >> c >> d >> e;

  lint ans=5, m=min(a,min(b,min(c,min(d,e))));

  if(n>m) {
    ans += (n/m-1);
    if(n%m > 0) { ans++; }
  }

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

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


#define ll long long
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const ll maxn = 2e5+5;
const int MOD = 1e9+7;

int main(){
    FASTIO
	ll n,x;cin >> n >> x;//n is no of box and x is the target
	vector<ll> arr(n);
	for(ll &x:arr) cin >> x;
	ll ans = 0;
	for(ll i=1;i<n;i++){
		
		if(arr[i-1] > x){
			ans += abs(arr[i-1]-x);
			arr[i-1] = x;
		}
		if(arr[i-1] + arr[i] > x){
			
			ll t = abs(arr[i-1] + arr[i] - x);
			ans += t;
			arr[i] -= t;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = input()
K = int(K)
print(N[K-1])



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

int main(void)
{
  long n, k;
  cin >> n >> k;
  long ans = 0;
  vector<long> enehp(n);
  for (int i = 0; i < n; i++)
    cin >> enehp[i];
  sort(enehp.rbegin(), enehp.rend());
  if (n <= k)
  {
    cout << 0 << endl;
    return 0;
  }
  for (int i = k; i < n; i++)
  {
    ans += enehp[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
class Graph
  attr_accessor :n, :ver, :matrices
  def initialize(number_of_vertexes)
    @n = number_of_vertexes
    gets_adj_list
    create_vertexes
  end

  def dijkstra(n=0)
    init_all_vers_property
    set_root(n)
    loop do
      break unless u = next_mincost_vertex
      add_minimum_spanning_tree(u)
      update_mindists(parent: u)
    end
  end

  def puts_dists
    ver.each{|v| puts "#{v.id} #{v.weight}"}
  end

  private
    def init_all_vers_property
      ver.each {|v| v.init_color_and_dist }
    end

    def gets_adj_list
      v_c = []
      n.times do |i|
        _,_,*v_c[i] = gets.split.map(&:to_i)
      end
      @matrices = Array.new(n){Array.new(n,Float::INFINITY)}
      v_c.each_with_index do |vc,idx|
        vc.each_slice(2) do |v,c|
          matrices[idx][v] = c
        end
      end
    end

    def set_root(v)
      ver[v].weight = 0
      ver[v].parent = -1
    end

    def next_mincost_vertex
      mincost = Float::INFINITY
      u = nil
      ver.each do |v|
        if v.color != :black && v.weight < mincost
          mincost = v.weight
          u = v.id
        end
      end
      u
    end

    def add_minimum_spanning_tree(u)
      ver[u].color = :black
    end

    def update_mindists(parent:)
      matrices[parent].each_with_index do |cost,idx|
        if ver[idx].color != :black && cost + ver[parent].weight < ver[idx].weight
          ver[idx].weight = cost + ver[parent].weight
          ver[idx].parent = parent
          ver[idx].color = :gray
        end
      end
    end

    def create_vertexes
      @ver = []
      n.times {|i| ver << V.new(i)}
    end
end

class V
  attr_accessor :id, :color, :weight, :parent
  def initialize(id)
    @id = id
    init_color_and_dist
  end

  def init_color_and_dist
    @color = :white
    @weight = Float::INFINITY
  end
end

n = gets.to_i
graph = Graph.new(n)
graph.dijkstra
graph.puts_dists



Measured memory_bytes: 7132