akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  int a[N], b[N];
  for(int i = 0; i < N; ++i){
    cin >> a[i] >> b[i];
  }
  int c[M], d[M];
  for(int i = 0; i < M; ++i){
    cin >> c[i] >> d[i];
  }
  
  for(int i = 0; i < N; ++i){
    int D = 1000000000;
    int ans = -1;
    for(int j = 0; j < M; ++j){
      if(abs(c[j]-a[i])+abs(d[j]-b[i]) < D){
	D = abs(c[j]-a[i])+abs(d[j]-b[i]);
	ans = j+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean contain7 = false;
		char[] chArr = Integer.toString(N).toCharArray();
		for(int i = 0; i < chArr.length; i ++) {
			if(chArr[i] == '7') {
				contain7 = true;
				break;
			}
		}
		if(contain7) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35844
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	double r;cin>>r;
	cout<<setprecision(10)<<2*acos(-1)*r<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3804
package main

import (
  "fmt"
)

func main() {
  var n int
  var d [] int
  var tmp int
  fmt.Scan(&n)
  for i:=0; i<n; i++ {
	fmt.Scan(&tmp)
	d = append(d,tmp)
  }
  count := 0
  for i:=0; i<n; i++ {
	if d[i] != 0 {
	  count++
	  for j:=i+1; j<n; j++ {
		if d[j] == d[i] {
		  d[j] = 0
		}
	  }
	}
  }
  fmt.Println(count)
}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,4) {
    if(s.at(i) == '+') ans++;
    else ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<stack>
#include<algorithm>
#include<vector>
#define x first
#define y second
#define pb push_back
using namespace std;
const int DN=2e5+5;
long long n,m,f,g,k,dp[DN],ma,ls,ld,val;
long long arb[2][4*DN];
vector<pair<int,int> >v[DN];
void update(int type,int nod,int st,int dr)
{
	if(dr<ls)
		return;
	if(st>ld)
		return;
	if(ls<=st&&dr<=ld)
	{
		if(type==0)
		{
			arb[0][nod]=arb[1][nod]+val;
			return;
		}
		arb[0][nod]+=val;
		arb[1][nod]+=val;
		return;
	}
	int mij=(st+dr)/2;
	update(type,2*nod,st,mij);
	update(type,2*nod+1,mij+1,dr);
	arb[0][nod]=arb[1][nod]+max(arb[0][2*nod],arb[0][2*nod+1]);
}
int main()
{
	cin>>n>>m;
	while(m--)
	{
		cin>>f>>g>>k;
		if(f>g)
			swap(f,g);
		v[g].pb({f,k});
	}
	for(int i=1;i<=n;i++)
	{
		dp[i]=max(dp[i],arb[0][1]);
		ls=ld=i;
		val=dp[i];
		update(0,1,1,n);
		for(auto j:v[i])
		{
			ls=j.x;
			ld=i;
			val=j.y;
			update(1,1,1,n);
		}
	}
	if(arb[0][1]<0)
		arb[0][1]=0;
	cout<<arb[0][1];
}

Measured memory_bytes: 25344
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,w,v,size;
double maxm;
double t[11];
 
int main(){
  while(1){
    cin>>n>>w;
    if(n==0&&w==0)break;
    for(int i=0;i<11;i++)t[i]=0;
    size=maxm=0;
    for(int i=0;i<n;i++){
      cin>>v;
      t[v/w]+=1.0;
      maxm=max(maxm,t[v/w]);
      size=max(size,v/w);
    }
    double ans=0.0;
    for(int i=0;i<=size;i++){
      ans+=(double)(size-i)*t[i];
    }
    printf("%.8f\n",ans/maxm/(double)size+0.01);
  }
  return 0;
}

Measured memory_bytes: 1188
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- omharicu@gmail.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define F               first
#define S               second
#define ull             unsigned long long
#define ll              long long
#define db              long double
#define ST              string
#define pb              push_back
#define mp              make_pair
#define el              "\n"
#define vll             vector <ll>
#define vi              vector <int>
#define pii             pair <int, int>
#define pll             pair <ll, ll>
#define vec(v)          vector <v>
#define all(v)          (v.begin(), v.end()) 
#define rall(v)         (v.rbegin(), v.rend()) 
#define is_sort(v)      is_sorted all(v)
#define max_of(v)       *max_element all(v)
#define min_of(v)       *min_element all(v)
#define itos(s)         to_string(s)
#define cntone(x)       __builtin_popcountll(x)
#define cntzro(x)       __builtin_clz(x)
#define clr(x,y) 		memset(x, y, sizeof(x))
#define For(i, a, b)    for(int i=a; i<b; i++)
#define Forr(i, a, b)   for(int i=a; i>=b; i--)
const ll mod = 1e9+7;

void solve()
{
    int x;
    cin>>x;
    cout<<(x^1);
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    /***************-Code starts from here-***************/
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0; 
} 

Measured memory_bytes: 3648
use strict;
my $com = 1000000007;
my ($n, $m) = split(' ', <>);


chomp($_ = <>);
my @a = split(' ', $_);
chomp($_ = <>);
my @b = split(' ', $_);

my $suma;
my $sumb;
for (my $i = 0; $i < $n-1; ++$i) {
    $suma += mult(($a[$i+1]-$a[$i]) , ($n - ($i+1)) , ($i+1));
    $suma %= $com;
}
for (my $i = 0; $i < $m-1;  ++$i) {
    $sumb += mult(($b[$i+1]-$b[$i]) , ($m - ($i+1)) , ($i+1));
    $sumb %= $com;
}
printf("%u\n", mult($suma, $sumb));

sub mult {
    my(@a) = @_;
    my $x = shift(@a);

    for (@a) {
        $x *= $_;
        $x %= $com;
    }
    return $x;
}


Measured memory_bytes: 27500
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	ll K; cin >> K;
	vector<int>A(N);
	rep(i, 0, N)cin >> A[i];
	vector<vector<int>>next(log2(K) + 1, vector<int>(N));
	rep(i, 0, N) {
		next[0][i] = A[i] - 1;
	}
	rep(i, 1, next.size()) {
		rep(j, 0, N) {
			next[i][j] = next[i - 1][next[i - 1][j]];
		}
	}
	int ans = 0;
	rep(i, 0, log2(K) + 1) {
		if (K & (1LL << i)) {
			ans = next[i][ans];
		}
	}
	cout << ans + 1 << "\n";

	return 0;
}

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

using namespace std;

const int INF = 1 << 30;

typedef tuple< int, int, int, int, int, int > Pi;
const int vy[] = {1, 0, -1, 0}, vx[] = {0, -1, 0, 1};

int v[100][100][11][11][4];

int main()
{
  int N, M, A;
  string S[100];

  cin >> N >> M >> A;
  for(int i = 0; i < N; i++) cin >> S[i];


  int sy, sx;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      if(S[i][j] == 'S') sy = i, sx = j;
    }
  }

  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  que.emplace(0, sy, sx, A, A, 0);
  fill_n(****v, 100 * 100 * 11 * 11 * 4, INF);
  v[sy][sx][A][A][0] = 0;

  auto isover = [&](int y, int x) -> bool
  {
    return (y < 0 || y >= N || x < 0 || x >= M || S[y][x] == '#');
  };

  while(!que.empty()) {
    int y, x, latte, malta, dir, cost;
    tie(cost, y, x, latte, malta, dir) = que.top();
    que.pop();
    if(S[y][x] == 'G') {
      cout << cost << endl;
      return (0);
    }
    if(v[y][x][latte][malta][dir] > cost) continue;
    for(int i = -1; i <= 1; i++) {
      int beet = (dir + i + 4) % 4;
      int ll = latte, rr = malta;
      int ny = y + vy[beet], nx = x + vx[beet];
      if(isover(ny, nx)) continue;
      if(S[y][x] == 'S' && i != 0) continue;
      if(S[ny][nx] == 'S' && beet == 2) continue;
      if(i != 0) {
        if((beet + (i == 1)) % 2 == 1) --ll;
        else --rr;
      }
      if(ll >= 0 && rr >= 0 && cost + (i != 0) < v[ny][nx][ll][rr][beet]) {
        v[ny][nx][ll][rr][beet] = cost + (i != 0);
        que.emplace(cost + (i != 0), ny, nx, ll, rr, beet);
      }
    }
  }
  cout << -1 << endl;
}

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

vector<int> v[100100];
int area[2];
stack<int> path;
int dif,n;

int fi_ano(int nw,int pa,int walk)
{
	if(nw==n)
	{
		dif=walk-1;
		return n;
	}
	int ck=-1,re=-1;
	for(int i=0;i<v[nw].size();i++)
	{
		if(v[nw][i]==pa)continue;
		ck=fi_ano(v[nw][i],nw,walk+1);
		if(ck==n)
		{
			path.push(nw);
			re=n;
		}
	}
	return re;
}

void cut(int nw,int pa,int team)
{
	area[team]++;
	for(int i=0;i<v[nw].size();i++)
	{
		if(v[nw][i]==pa)continue;
		cut(v[nw][i],nw,team);
	}
	return ;
}

main()
{
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	fi_ano(1,-1,0);
	int si=0,bf=path.top(),ti=0;
	path.pop();
	for(int i=0;i<v[1].size();i++)
	{
		if(!path.empty()&&v[1][i]==path.top())continue;
		if(v[1][i]==n)continue;
		cut(v[1][i],1,0);
	}
	int spfu=0;
	if(dif%2==1)spfu=1;
	//printf("area1:%d\n",area[0]);
	while(!path.empty())
	{
		int prebf=path.top();
		//printf("nw:%d\n",prebf);
		si++;
		path.pop();
		if(si>(dif/2)+spfu)ti=1;
		area[ti]++;
		for(int i=0;i<v[prebf].size();i++)
		{
			if(v[prebf][i]==bf||v[prebf][i]==1||v[prebf][i]==n)continue;
			if(!path.empty()&&v[prebf][i]==path.top())continue;
			//printf("spgo:%d tm:%d\n",v[prebf][i],ti);
			cut(v[prebf][i],prebf,ti);
		}
		bf=prebf;
	}
	for(int i=0;i<v[n].size();i++)
	{
		if(v[n][i]==bf)continue;
		if(v[n][i]==1)continue;
		cut(v[n][i],n,1);
	}
	//printf("%d %d\n",area[0],area[1]);
	if(area[0]>area[1])printf("Fennec\n");
	else printf("Snuke\n");
}
/*
6
1 2
2 3
3 4
3 5
5 6
9
1 2
2 3
2 4
4 5
2 6
6 7
6 8
6 9 
*/

Measured memory_bytes: 12416
import Control.Arrow (second)

import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInt' :: C.ByteString -> Maybe (Int, C.ByteString)
readInt' = fmap (second C.tail) . C.readInt

main = do
  n  <- readInt
  as <- VU.unfoldrN n readInt' <$> C.getLine
  print . f $ VU.toList as

f :: [Int] -> Int
f = h 0 

h :: Int -> [Int] -> Int
h s []  = s+1
h s [_] = s+1
h s (i:is@(j:_))
  | i == j    = h s is
  | i <  j    = g s (<) is
  | otherwise = g s (>) is

g :: Int -> (Int -> Int -> Bool) -> [Int] -> Int
g s _ []  = s+1
g s _ [_] = s+1
g s op (i:is@(j:_))
  | i == j    = g s op is
  | i `op` j  = g s op is
  | otherwise = h (s+1) is

Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <vector>
typedef long long int ll;

using namespace std;

int main(){
	ll x, k, d, t;
	cin >> x >> k >> d;	
	x = abs(x);
	t = x / d;
	if (t >= k) cout << x - k * d;
	else if ((k - t) % 2 == 0) cout << x - t * d;
	else cout << abs(x - (t + 1) * d);
	cout << '\n';
	return 0;	
}


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

ll ryuka[100];

ll calc(int num){
  if(ryuka[num]!=-1)return ryuka[num];
  ryuka[num] = calc(num-1)+calc(num-2);
  return ryuka[num];
;}

int main(){
  for(int i=0;i<=86;i++)ryuka[i]=-1;
  ryuka[0]=2;ryuka[1]=1;
  ll n;cin>>n;
  cout << calc(n) << endl;
}


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

int main()
{
	int n;
	scanf("%d", &n);
	vector<int> a(n), res;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);

	int t = n - 1;
	while (t >= 0)
	{
		res.push_back(t);
		t -= 2;
	}
	t = -t - 1;
	while (t < n)
	{
		res.push_back(t);
		t += 2;
	}

	for (int i = 0; i < n; i++)
		res[i] = a[res[i]];
	for (int i = 0; i < n; i++)
		printf("%d%c", res[i], " \n"[i == n - 1]);

	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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


int main(void){
  int N;
  int A[200001];
  cin >> N;
  for (int i=2; i<=N; i++){
    cin >> A[i];
  }
  
  int ans[200001];
  for (int j=2; j<=N; j++){
    ans[A[j]]++;
  }
    
  
  for (int i=1; i<=N; i++){
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4656
import sys
import numpy as np
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

H, W, K = map(int, readline().split())
s = (np.resize(np.frombuffer(read(), dtype='S1'), (H, W + 1))[:, :-1] == b'#') * 1

x, y = np.where(s == 1)
answer = np.zeros_like(s)
answer[x, y] = np.arange(1, K + 1)

np.maximum.accumulate(answer, axis=1, out=answer)
answer[answer == 0] = K + 1
answer = np.fliplr(np.minimum.accumulate(np.fliplr(answer), axis=1))
answer = np.flipud(np.minimum.accumulate(np.flipud(answer), axis=0))
answer[answer == K + 1] = 0
np.maximum.accumulate(answer, axis=0, out=answer)

for i in answer:
    print(' '.join(map(str, i.tolist())))

Measured memory_bytes: 16468
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
const int MAX_N = 100010;

int is_prime[MAX_N];
void init_prime()
{
    rep(i, 0, MAX_N)
        is_prime[i] = 1;
    is_prime[0] = is_prime[1] = 0;

    rep(i, 2, MAX_N)
    if (is_prime[i])
    {
        // cout << i << endl;
        for (ll j = i; (ll)i * j < MAX_N; j++)
        {
            // cout << i * j << endl;
            is_prime[i * j] = 0;
        }
    }
}

int is_sim[MAX_N];
void init_sims()
{
    is_sim[0] = is_sim[1] = 0;
    rep(i, 0, MAX_N)
    {
        bool is_ok = true;
        is_ok &= (i + 1) % 2 == 0;
        is_ok &= is_prime[(i + 1) / 2];
        is_ok &= is_prime[i];
        is_sim[i] = int(is_ok);
    }
}

int cumsum[MAX_N];
void init_cumsum()
{
    cumsum[0] = 0;
    rep(i, 1, MAX_N)
        cumsum[i] = cumsum[i - 1] + is_sim[i];
}
int main()
{
    init_prime();
    init_sims();
    init_cumsum();

    int q;
    cin >> q;
    rep(qq, 0, q)
    {
        int l, r; 
        cin >> l >> r;

        cout << cumsum[r] - cumsum[l - 1] << endl; 
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
typedef long long int ll;
using namespace std;
int main(){
int flag=0;
string A;
string B;
cin >> A;
int N=A.size();
if(A[0]=='A'){
	for(int k=2; k<N-1;k++){
		if(A[k]=='C'){
			flag=1;
			break;
		}
	}
}
for(int k=0; k<N;k++){
	if(int(A[k])>96){
		B=B+A[k];
	}
}
if((B.size()==N-2)&&(flag==1)){
	flag=2;
}
if(flag<=1){
	cout <<"WA" << endl;
}else{
	cout <<"AC" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
int N , M ; cin >> N >> M ;
vector <int > cnt (M , 0);
for ( int i = 0; i < N ; ++ i ) {
int K; cin >> K ;
for ( int j = 0; j < K ; ++ j ) {
int A; cin >> A ; --A ;
++ cnt [ A ];
}
}
int ans = 0;
for ( int i = 0; i < M ; ++ i ) {
if ( cnt [ i ] == N ) {
++ ans ;
}
}
cout << ans << endl ;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

bool Check(int k)
{
	char s[25];
	int len;
	sprintf(s,"%d",k);
	len=strlen(s);
	for(int i=0;i<len/2;i++)
		if(s[i]!=s[len-1-i])
			return false;
	return true;
}

int main()
{
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	for(int i=a;i<=b;i++)
		ans+=Check(i);
	printf("%d\n",ans);
	return 0;
}

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

#define ll long long

int N;
int A[1001];
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	int minans = 2000000000;

	for(int i=-100;i<101;i++){
		int candi = 0;
		for(int j=0;j<N;j++){
			candi+=(A[j]-i)*(A[j]-i);
		}
		minans = min(minans,candi);
	}
	cout << minans << endl;
	return 0;
}


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

int n;

int main()
{
	while (cin >> n) {
		int m = 0;

		if (n < 37) {
			for (int a = 0; a <= 9; a++)
				for (int b = 0; b <= 9; b++)
					for (int c = 0; c <= 9; c++)
						for (int d = 0; d <= 9; d++)
							if (a + b + c + d == n)
								m++;
		}

		cout << m << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#!/usr/bin/python

import sets
import sys

def find(parent, x):
    if parent[x] == x:
        return x
    else:
        parent[x] = find(parent, parent[x])
        return parent[x]

def union(parent, x, y):
    find(parent, x)
    find(parent, y)

    if parent[x] != parent[y]:
        parent[parent[y]] = parent[parent[x]]

def main(argv):
    tokens = sys.stdin.readline().rstrip("\n").split()

    while len(tokens) == 3:
        n, k, l = [int(i) for i in tokens]

        parent_roads = [int(i) for i in xrange(n)]
        parent_railways = [int(i) for i in xrange(n)]

        for i in xrange(k):
            x, y = [int(i) for i in raw_input().split(" ")]
            union(parent_roads, x - 1, y - 1)

        for i in xrange(l):
            x, y = [int(i) for i in raw_input().split(" ")]
            union(parent_railways, x - 1, y - 1)

        count = dict()
        for i in xrange(n):
            key = (find(parent_roads, i), find(parent_railways, i))
            if not count.has_key(key):
                count[key] = 0
            count[key] += 1

        results = []
        for i in xrange(n):
            key = (find(parent_roads, i), find(parent_railways, i))
            results.append(str(count[key]))
        print " ".join(results)

        tokens = sys.stdin.readline().rstrip("\n").split()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 49588
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
//#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 300005;
const ll mm = 1e+18;
void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    rep1(i,n) cin>>a[i];
    int vis[n+1]={0};
    vector<int>v;
    int cu=1;
    while(!vis[cu]){
        vis[cu]=1;
        v.pb(cu);
        cu=a[cu];
    }
    if((int)(v.si)>=k+1){
        cout<<v[k];
        return;
    }
    vector<int>vv;
    bool p=false;
    for(auto x:v){
        if(x==cu) p=true;
        if(p) vv.pb(x);
    }
    k-=(int)(v.si);
    int z=(int)(vv.si);
    k%=z;
    cout<<vv[k];
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // srand(time(0));
    //freopen("sp.txt","r",stdin);
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 10684
#include<iostream>
#include<vector>
#include<queue>

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

using ll = long long;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if (a > m) continue;
        // M日後のa日前に可能になる仕事の報酬を管理
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for (int i = m-1; i >=0; --i) {
        for (int b : jobs[i]) {
            q.push(b);
        }
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 5e5+10;
ll a[N];
string s;
queue<ll>q;
ll n;
ll num=0;
int main(){
	cin >> s;
	n=s.length()+1;
	if(s[0]=='<')
	q.push(0);
	for(ll i=0;i<n-1;i++){
		if(s[i]=='<'&&s[i-1]=='>')
		q.push(i);
	}
	if(s[n-2]=='>')
	q.push(n-1);
	while(!q.empty()){
		ll x=q.front();
		q.pop();
		ll l=x,r=x;
		a[x]=0;
		if(x==0){
			while(s[r]=='<'){
				a[r+1]=max(a[r]+1,a[r]);
				r++;
			}
		}
		else if(x==n-1){
			while(s[l-1]=='>'){
				a[l-1]=max(a[l-1],a[l]+1);
				l--;
			}
		}
		else{
			while(s[l-1]=='>'){
				a[l-1]=max(a[l-1],a[l]+1);
				l--;
			}
			while(s[r]=='<'){
				a[r+1]=max(a[r]+1,a[r]);
				r++;
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<=n;i++){
		ans+=a[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 5636
import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
ABC = []
for _ in range(N):
    ABC.append([int(v) for v in sys.stdin.readline().strip().split(' ')])


def memoize(f):
    cache = {}
    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper

@memoize
def find(d, p):
    if d == -1:
        return 0
    else:
        if p == 0:
            return max(ABC[d][0] + find(d - 1, 1), ABC[d][0] + find(d - 1, 2))
        elif p == 1:
            return max(ABC[d][1] + find(d - 1, 0), ABC[d][1] + find(d - 1, 2))
        else:
            return max(ABC[d][2] + find(d - 1, 0), ABC[d][2] + find(d - 1, 1))

print(max(find(N - 1, 0), find(N - 1, 1), find(N - 1, 2)))


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

int x;
int y;
int z;

int main(){
	while(true) {
		cin >> x;
		cin >> y;
		if ( x == 0 && y == 0 ) break;
		if ( x>y ) {
			z=x;
			x=y;
			y=z;
		}
		cout << x << " " << y << endl;
	}
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int main()
{
	int a, b, c;
	int cnt = 0;

	scanf(" %d %d %d", &a, &b, &c);

	for (int i = a; i <= b; ++i)
	{
		if(c % i == 0){
			cnt++;
		}
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
    int a,b;cin >> a >> b;
    vector<vector<char>> grid(100,vector<char>(100));
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(j<50) grid[i][j]='.';
            else grid[i][j]='#';
        }
    }
    int needa=a-1;
    int needb=b-1;
    for(int i=0;i<100;i++){
        if(i%2==0) continue;
        for(int j=0;j<100;j++){
            if(j<49){
                if(needb>0&&j%2==1){
                    grid[i][j]='#';
                    needb--;
                }
            }
            else if(j>=51&&j<=98){
                if(needa>0&&j%2==1){
                    grid[i][j]='.';
                    needa--;
                }
            }
        }
    }
    cout << 100 << " " << 100 << endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout << grid[i][j]; 
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int i,j,n;char p[1000000];
main(){
	while(scanf("%d",&n)!=EOF){
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<=n;i++)
		j+=p[i];
	printf("%d\n",j);
	}
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

/*
int main(void){
	int32 N;
	cin >> N;
	vector<int64> x(N), y(N);
	REP(i, N) cin >> x[i] >> y[i];
	int32 par = (abs(x[0])+abs(y[0]))%2;
	REP(i, N){
		if((abs(x[i])+abs(y[i]))%2 != par){
			cout << -1 << endl;
			return 0;
		}
	}
	int32 M = 40-par;
	cout << M << endl;
	REP(i,M) cout << 1 << " ";
	cout << endl;
	REP(i, N){
		int32 cnt = abs(x[i])+abs(y[i]);
		if(abs(x[i])+abs(y[i]) > 40) return 0;
		REP(j, abs(x[i])){
			if(x[i] > 0) cout << 'R';
			else cout << 'L';
		}
		REP(j, abs(y[i])){
			if(y[i] > 0) cout << 'U';
			else cout << 'D';
		}
		REP(j, (M-cnt)/2){
			cout << "LR";
		}
		cout << endl;
	}
	return 0;
}
*/

int main(void){
	string s;
	int32 n;
	cin >> s;
	n = s.size();
	if(s[0] == '0' || s[n-1] == '1'){
		cout << -1 << endl;
		return 0;
	}
	int32 cnt = 0;
	FOR(i, 1, n-1){
		if(s[i] != s[n-i-2]){
			cout << -1 << endl;
			return 0;
		}
	}
	int32 root = 2, now = 3;
	cout << 1 << " " << 2 << endl;
	FOR(i, 1, n-2){
		if(s[i] == '0'){
			cout << now << " " << root << endl;
			now++;
		}else{
			cout << now << " " << root << endl;
			root = now;
			now++;
		}
	}
	cout << root << " " << n << endl;
}


Measured memory_bytes: 1664
def examA():
    X = [I() for _ in range(5)]
    k = I()
    X.sort()
    ans = "Yay!"
    if X[-1]-X[0]>k:
        ans = ":("
    print(ans)
    return

def examB():
    X = [I() for _ in range(5)]
    ans = 0
    for i in range(5):
        ans += (X[i]+9)//10 *10
        X[i] = (X[i]-1)%10
    ans -= (9-min(X))
    print(ans)
    return

def examC():
    N = I()
    X = [I() for _ in range(5)]
    ans = max(0,(N-1)//min(X))+5
    print(ans)
    return

def examD():
    X, Y, Z, K = LI()
    A = LI(); B = LI(); C = LI()
    A.sort(reverse = True); B.sort(reverse = True); C.sort(reverse = True)
    que = [(-(A[0]+B[0]+C[0]),0,0,0)]
    heapify(que)
    used = defaultdict(bool)
    used[(0,0,0)] = True
    ans = []
    for _ in range(K):
        now,x,y,z = heappop(que)
        ans.append(-now)
        for ix,iy,iz in [[1,0,0],[0,1,0],[0,0,1]]:
            if used[(ix+x,iy+y,iz+z)]:
                continue
            used[(ix+x, iy+y, iz+z)] = True
            if ix+x>=X or iy+y>=Y or iz+z>=Z:
                continue
            next = A[ix+x]+B[iy+y]+C[iz+z]
            heappush(que,(-next,ix+x,iy+y,iz+z))
    for v in ans:
        print(v)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()


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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> W(N);
    for(int i = 0; i < N; i++){
        cin >> W[i];
    }
    int ans = 100000;
    for(int T = 0; T < N; T++){
        int l = 0, h = 0;
        for(int i = 0; i < N; i++){
            if(i <= T) l += W[i];
            else h += W[i];            
        }
        ans = min(ans, abs(l - h));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
typedef long long ll;

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> vs(n);
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
	}

	vector<int> gusu(100001,0);
	vector<int> kisu(100001,0);

	for (int i = 0; i < n / 2; i++) {	
		gusu[vs[2*i]]+=1;
		kisu[vs[2 * i + 1]]+=1;
	}
	
	int kotae = 0;

	int kin=0;
	int kin2=0;
	int kmax=0;
	int kmax2=0;
	for (int i = 0; i < 100001; i++) {
		if (kmax < kisu[i]) {
			kmax2 = kmax; kmax = kisu[i]; kin2 = kin; kin = i;
		}
		else if (kmax2 < kisu[i]) {
			kmax2 = kisu[i]; kin2 = i;
		}
	}

	int gin = 0;
	int gin2 = 0;
	int gmax = 0;
	int gmax2 = 0;
	for (int i = 0; i < 100001; i++) {
		if (gmax < gusu[i]) {
			gmax2 = gmax; gmax = gusu[i]; gin2 = gin; gin = i;
		}
		else if (gmax2 < gusu[i]) {
			gmax2 = gusu[i]; gin2 = i;
		}
	}
	if (gin != kin) {
		kotae = n - kmax - gmax;
	}
	else {
		int maxs = (kmax2+gmax > gmax2+kmax) ? kmax2 + gmax : gmax2 + kmax;
		kotae = n - maxs;
	}

	cout <<kotae<<  endl;
	return 0;
}

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

int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if ((a + b) > (c + d)) {
		cout << "Left" << endl;
	}
	else if ((a + b) < (c + d)) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {
	long long int N, a, x = 0, y = 0, z = 0;

	cin >> N;

	rep(i, N) {
		cin >> a;
		if (a % 4 == 0) {
			x++;
		}
		else if (a % 2 == 0) {
			y++;
		}
		else if (a % 2 == 1) {
			z++;
		}

	}

	if (y == N) {
		cout << "Yes";
	}
	else {
		if (y >= 1) {
			y = 1;
		}
		if (x + 1>= y + z) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int findCharactor(string S, string T){
  int counter=0;
  for(char C ='a'; C<='z'; C++){
    bool findS=false;
    bool findT=false;
    
    for (int j=0; j<S.length(); j++){
      if(S.at(j) == C){
        findS=true;
        break;
      }
    }
    for (int j=0; j<T.length(); j++){
      if(T.at(j) == C){
        findT=true;
        break;
      }
    }
    if (findS && findT){
      counter++;
    }
  }
  return counter;
}

int main() {
  int i,N,answer,count;
  string S,T;
  cin >> N>>S;
  answer=0;
  for(i=0;i<=N;i++){
    string subS , subT;
    subS = S.substr(0,i);
    subT = S.substr(i);
    int count =0;
    count = findCharactor(subS,subT);
    answer = max(answer,count);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i,z,u,l) for(i=z;i<u;i+=l)
#define f(i,n) for(i=0;i<n;i++)
using namespace std;
#define F first
#define S second
#define vi vector<int>
#define vll vector<long long>
#define vld vector<long double>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vb vector<bool>
#define all(v) v.begin(),v.end()
#define ump unordered_map
#define dbg(x) cout<<#x<<" : "<<x << endl;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define endl "\n"
const ll M = 1e9 + 7;


long long pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve()
{
	ll n,x,t;
	cin>>n>>x>>t;
	ll ans = ceil(n/double(x))*t;
	cout << ans << endl;
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	
	
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long int;

int main(){
    int N,W;
    cin>>N>>W;
    vector<int> w(N),v(N);
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    
    vector<vector<ll>> dp(N+1,vector<ll>(W+1));
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0){
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }
            else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    
    cout<<dp[N][W]<<endl;
    
    return 0;
}




Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;
vector<int> a(110);
set<string> rate;

int main(){
    int free=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[i]<400) rate.insert("gray");
        else if(a[i]<800) rate.insert("brown");
        else if(a[i]<1200) rate.insert("green");
        else if(a[i]<1600) rate.insert("lblue");
        else if(a[i]<2000) rate.insert("blue");
        else if(a[i]<2400) rate.insert("yellow");
        else if(a[i]<2800) rate.insert("orange");
        else if(a[i]<3200) rate.insert("red");
        else free++;
    }

    int minv=rate.size();
    int maxv=minv+free;
    if(minv==0) minv=1;
    cout<<minv<<" "<<maxv<<"\n";
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long double> data(n);
    long double sum = 0;
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
        sum += 1 / data.at(i);
    }
    cout << fixed << setprecision(10);
    cout << 1 / sum << endl;
}

Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            HashSet<Character> st = new HashSet<Character>();

            for (int i = 0; i < s.length(); i++) {
                st.add(s.charAt(i));
            }

            System.out.println(st.size() == 3 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 23124
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = 0, m = 0;
		int i = 0, j = 0;
		n = sc.nextInt();
		m = sc.nextInt();
		int Ln1[] = new int[m];
		int Ln2[] = new int[m];
		int Ln[] = new int[n];

		for (i = 0; i < m; i++) {
			Ln1[i] = sc.nextInt();
			Ln2[i] = sc.nextInt();
		}
		for (i = 0; i < m; i++) {
			for (j = 1; j <= n; j++)
				if (j == Ln1[i])
					Ln[j - 1]++;
			for (j = 1; j <= n; j++)
				if (j == Ln2[i])
					Ln[j - 1]++;
		}

		for (i = 0; i < n; i++)
			System.out.println(Ln[i]);

	}

}


Measured memory_bytes: 21844
N=int(input())
S=input()
r=S.count('R')
b=S.count('B')
g=S.count('G')
ans=r*b*g
for i in range(N):
    for s in range(N):
        j=i+s
        k=j+s
        if k>=N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans-=1
print(ans)

Measured memory_bytes: 9152
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
const int N = 3005;
int arr[N][N], dp[N][N];
char c1[N], c2[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> c1 + 1 >> c2 + 1;
    int i = 0, j = 0;
    while (c1[++i] != '\0')
    {
        j = 0;
        while (c2[++j] != '\0')
        {
            if (c1[i] == c2[j])
            {
                if (dp[i][j] < dp[i - 1][j - 1] + 1)
                {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    arr[i][j] = 1;
                }
            }
            if (dp[i - 1][j] > dp[i][j])
            {
                dp[i][j] = dp[i - 1][j];
                arr[i][j] = 2;
            }
            if (dp[i][j - 1] >= dp[i][j])
            {
                dp[i][j] = dp[i][j - 1];
                arr[i][j] = 3;
            }
        }
    }
    i--;
    j--;
    // cout << dp[i][j] << '\n';
    string s = "";
    while (i > 0 && j > 0)
    {
        if (arr[i][j] == 1)
        {
            s += c1[i];
            i--;
            j--;
        }
        else if (arr[i][j] == 2)
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(s.begin(), s.end());
    cout << s;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int k;
	cin>>k;
	long long int ans = 0;
	for (int i = 1; i <=k; ++i)
	{
		for(int j = 1; j <=k ; j++)
		{
			for(int l = 1; l<=k; l++)
			{
				ans += __gcd(l,__gcd(i,j));

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

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s, t; cin >> s;
	for(auto c : s){
		if(c == 'B'){
			if(!t.empty()) t.pop_back();
		} else t.push_back(c);
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <sstream>
#include <vector>

using namespace std;
string shell_sort(string, int, int, vector<int>, int&);
int* insert_sort_4_shell(int*, int, int, int&);
string intArrayToString(int*, int);

int main()
{
	string str;
	getline(cin, str);
	int num;
	stringstream num_ss(str);
	num_ss >> num;
	str = "";
	string buff;
	for (int i = 0; i < num; i++) {
		getline(cin, buff);
		if (i == num - 1) {
			str += buff;
		} else {
			str += buff + " ";
		}
	}
	int counter = 0;
	int m = 0;
	vector<int> G;
	while (pow(2, m+1) -1 <= num) {
		G.insert(G.begin(), pow(2, m+1) - 1);
		m++;
	}
	str = shell_sort(str, num, m, G, counter);
	cout << m << endl;
	string G_str = "";
	for (int i = 0; i < G.size(); i++) {
		if (i == G.size() - 1) {
			G_str += to_string(G[i]);
		}
		else {
			G_str += to_string(G[i]) + " ";
		}
	}
	cout << G_str << endl;
	cout << counter << endl;
	stringstream ans(str);
	while (getline(ans, buff, ' ')) {
		cout << buff << endl;
	}

	return 0;
}

string shell_sort(string str, int ary_size, int m, vector<int> G, int &counter) {
	int* ary = new int[ary_size];
	stringstream ss(str);
	string buff;
	int cnt = 0;
	while (getline(ss, buff, ' ')) {
		stringstream tss(buff);
		tss >> ary[cnt];
		cnt++;
	}

	// main.
	for (int i = 0; i < m; i++) {
		insert_sort_4_shell(ary, ary_size, G[i], counter);
	}

	return intArrayToString(ary, ary_size);
}

int* insert_sort_4_shell(int* ary, int ary_size, int g, int &counter) {

	// main.
	for (int i = g; i < ary_size; i++) {
		int v = ary[i];
		for (int j = i - g; j >= 0 && v < ary[j]; j -= g) {
			ary[j + g] = ary[j];
			ary[j] = v;
			counter++;
		}
	}

	return ary;
}

string intArrayToString(int* ary, int ary_size) {
	string str = "";
	for (int i = 0; i < ary_size; i++) {
		if (i == ary_size - 1) {
			str += to_string(ary[i]);
		}
		else {
			str += to_string(ary[i]) + " ";
		}
	}
	return str;
}

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

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

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

#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 REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


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

    mat P;
    P.pb({0});
    REP(i,1,SZ(S)+1) {
        REP(j,0,i) {
            if(j == 0) {
                vec v = {i};
                P.pb(v);
            }
            else {
                REP(k,1<<(j-1),1<<j) {
                    vec v = P[k];
                    v.pb(i-j);
                    P.pb(v);
                }
            }
        }
    }

    ll sum = 0;
    REP(i,SZ(P)/2,SZ(P)) {
        ll p = 0;
        FORR(j,P[i]) {
            sum += stoll(S.substr(p, j));
            p += j;
        }
    }
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 3712
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main()
{
    const double EPS = 1.0e-10;
    double a,b,c,d,e,f;
    double x1,x2,x3,y1,y2,y3;
    double x,y,r;
    int n;
	cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        a = x1 - x2;
        b = y1 - y2;
        c = (x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2) / 2;
        d = x1 - x3;
        e = y1 - y3;
        f = (x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3) / 2;
        x = (e * c - b * f) / (a * e - b * d);
        y = (a * f - d * c) / (a * e - b * d);
    	r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y));
        if(-0.0005 < x && x < 0.0+EPS) x = 0.0;
        if(-0.0005 < y && y < 0.0+EPS) y = 0.0;
 
        printf("%.3f %.3f %.3f\n",x,y,r);
    }
    return 0;
}


Measured memory_bytes: 3144
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,y = LI()
    y //= 1000
    for k in range(10**3*4+1):
        for j in range(10**3*2+1):
            if k+j>n:
                break
            i = n-k-j
            if i+j*10+k*5 == y:
                return '{} {} {}'.format(j,k,i)

    return '-1 -1 -1'

print(main())




Measured memory_bytes: 6484
import numpy as np
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
count_true = 0
for i in range(n):
  for j in range(i+1,n):
    a = 0
    for k in range(d):
      a += pow((x[i][k]-x[j][k]),2)
    a = math.sqrt(a)
    b = int(a)
    if a == b :
      count_true += 1
        
print(count_true)
        
        

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append((n//i, i))
            if i != n // i:
                divisors.append((n//i, i))
    return set(divisors)


pairs = list(make_divisors(n))
min_pair = n-1

for p in pairs:
    result = p[0] + p[1] -2
    if result < min_pair:
        min_pair = result

print(min_pair)


Measured memory_bytes: 3956
#include <iostream>
using namespace std;
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}
int main(){
    int H,i,A[MAX+1];

    cin>>H;
    for(i=1;i<=H;i++)cin>>A[i];

    for(i=1;i<=H;i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i)>=1)cout <<"parent key = " << A[parent(i)] << ", ";
        if(left(i)<=H)cout <<"left key = " << A[left(i)]<< ", ";
        if(right(i)<=H)cout <<"right key = " << A[right(i)]<< ", ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>


using namespace std;

int main() {
    int n,h[1000];
    cin>>n;
    for(int i=0;i<=n-1;i++){
        cin>>h[i];
    }
    int a=0;
    int ans=0;
    while(a==0){
        a=1;
        int b=0;
        for(int i=0;i<=n-1;i++){
            if(h[i]>0 && b==0){
                ans++;
                b=1;
                h[i]--;
                a=0;
            }else if(h[i]>0 && b==1){
                h[i]--;
            }else if(h[i]==0 && b==1){
                b=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll n, k; cin >> n >> k;
	ll y[50] = {};
	ll x[50] = {};
	rep(i, 0, n) {
		cin >> x[i] >> y[i];
	}

	ll rect = 1e20;
	rep(y1, 0, n) {
		rep(y2, 0, n) {
			rep(x1, 0, n) {
				rep(x2, 0, n) {
					ll cnt_k = 0;
					rep(k, 0, n) {
						if (x[x1] <= x[k] && x[k] <= x[x2] && y[y1] <= y[k] && y[k] <= y[y2]) {
							cnt_k++;
						}
					}
					if (cnt_k >= k) {
						rect = min(rect, abs(x[x1] - x[x2])* abs(y[y1] - y[y2]));
					}
				}
			}
		}
	}
	cout << rect << endl;

	return 0;
}

Measured memory_bytes: 256