akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, h, s, d; cin >> q >> h >> s >> d;
    ll n; cin >> n;
    n*=4;
    ll c8 = min({8*q, 4*h, 2*s, 1*d});
    ll c4 = min({4*q, 2*h, 1*s});
    ll c2 = min({2*q, 1*h});
    ll c1 = 1*q;
    
    ll ans = 0;
    ans += (n/8)*c8; n -= n/8*8;
    ans += (n/4)*c4; n -= n/4*4;
    ans += (n/2)*c2; n -= n/2*2;
    ans += n*c1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,l = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n)]
B = [map(int,input().split()) for i in range(m)]
B_T = list(map(list, zip(*B)))
for a in A:
    row = []
    for b in B_T:
        row.append(sum([x*y for (x,y) in zip(a,b)]))
    print(' '.join(map(str,row)))

Measured memory_bytes: 9208
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	int n,k;cin>>n>>k;
	vector<int>vec(n);
	FER(i,0,n)cin>>vec[i];
	sort(all(vec));
	int mn=INT_MAX;
	FER(i,0,n-k+1){
		mn=min(mn,vec[i+k-1]-vec[i]);
	}
	cout<<mn<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define ll long long

using namespace std;

void
solve() {
  string s, t;
  cin>>s>>t;

  ll sl = s.length(), tl = t.length();
  vector<vector<ll>> dp(sl+1, vector<ll>(tl+1, -1));
  vector<vector<ll>> prev(sl+1, vector<ll>(tl+1, 0));
  for (ll i=0; i<sl; i++)
    for (ll j=0; j<tl; j++) {
      if (i==0 || j==0) {
        dp[i][j] = s[i]==t[j] ? 1 : 0;
        if (i > 0 && dp[i-1][j] == 1) {
          dp[i][j] = max(dp[i][j], dp[i-1][j]);
          prev[i][j] = 1;
        }
        else if (j > 0 && dp[i][j-1] == 1) {
          dp[i][j] = max(dp[i][j], dp[i][j-1]);
          prev[i][j] = 2;
        }
        else {
          prev[i][j] = 3;
        }
      }
      else {
        ll v = max(dp[i-1][j], dp[i][j-1]);
        if (s[i] == t[j])
          v = max(v, dp[i-1][j-1] + 1);
        else 
          v = max(v, dp[i-1][j-1]);

        if (v == dp[i-1][j])
          prev[i][j] = 1;
        else if (v == dp[i][j-1])
          prev[i][j] = 2;
        else 
          prev[i][j] = 3;
        dp[i][j] = v;
      }
      //cout<<i<<","<<j<<"="<<dp[i][j]<<endl;
    }

  string ans = "";
  ll left = sl-1, right = tl-1;
  while (1) {

    if (prev[left][right] == 1)
      left--;
    else if (prev[left][right] == 2)
      right--;
    else {
      if (s[left] == t[right]) ans += s[left];
      left--;
      right--;
    }

    if (left < 0 || right < 0) break;
  }

  reverse(ans.begin(), ans.end());
  //cout<<dp[sl-1][tl-1]<<endl;
  cout<<ans<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 144180
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string s1, s2, s3; cin >> s1 >> s2 >> s3;
    transform (s1.begin(), s1.begin()+1, s1.begin(), ::toupper);
    transform (s2.begin(), s2.begin()+1, s2.begin(), ::toupper);
    transform (s3.begin(), s3.begin()+1, s3.begin(), ::toupper);
	cout << s1[0] << s2[0] << s3[0] << endl;
	return 0;
}

Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


A, B, C, X, Y = inpl()

ans = min(A + B, 2 * C) * min(X, Y)

if X > Y:
    ans += min(A, 2 * C) * (X - Y)
elif Y > X:
    ans += min(B, 2 * C) * (Y - X)

print(ans)


Measured memory_bytes: 3060
from collections import defaultdict

def read_input():
    n = int(input())
    alist = map(int, input().split())

    return n, alist


def submit():
    n, alist = read_input()

    sides = defaultdict(int)
    for a in alist:
        sides[a] += 1

    sides = list(sides.items())
    sides.sort(key=lambda x: x[0], reverse=True)

    sides_four = [s for s in sides if s[1] >= 4]
    square = 0
    if sides_four:
        square = sides_four[0][0] * sides_four[0][0]

    sides_two = [s for s in sides if s[1] >= 2]
    rectangle = 0
    if len(sides_two) >= 2:
        rectangle = sides_two[0][0] * sides_two[1][0]

    print(max(square, rectangle))


if __name__ == '__main__':
    submit()

Measured memory_bytes: 73496
#include <stdio.h>

int main(void) {
  char line[512];
  FILE *fp;
  fp = stdin;
  if(!fgets(line, 512, fp)) return 0;
  int mass = 3;
  char res = 0;
  int i;
  for(i = 0; i < mass; i++) {
    res += (line[i] - '0');
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 128
let n = int (stdin.ReadLine())
let ln = n.ToString().Length
let a = if ln % 2 = 1 then n + 1 - (pown 10 (ln - 1)) else 0
printfn "%d" <| a + ([for i in 1..2..ln - 1 -> (pown 10 (i - 1)) * 9] |> List.sum)

Measured memory_bytes: 14044
def main():
    S = input()

    for i in range(2 ** 3):
        c = S[0]
        for j in range(3):
            if (i >> j) & 1:
                c += "+"
            else:
                c += "-"
            c += S[j + 1]
        if eval(c) == 7:
            print(c + "=7")
            exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 8924
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int a[10];
int b[10];
int c[10];
int mi = 10;
int k;

int main()
{
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
		b[i] = a[i] % 10;
		//1~9までの一番小さい数値を記録
		if (b[i] != 0) mi = min(mi, b[i]);
		if (b[i] != 0)
		{
			c[i] = a[i] - b[i] + 10;
		}
		else
		{
			c[i] = a[i];
		}
	}

	int sum = 0;

	for (int i = 0; i < 5; i++)
	{
		sum += c[i];
	}
	sum = sum - 10 + mi;
	cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
m = int(input())

work = sum(t)
for i in range(m):
  x = [list(map(int, input().split()))]
  a = x[0][0] - 1
  b = t[a] - x[0][1]
  print(work - b)
  

Measured memory_bytes: 9184
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = map(int, input().split())

AdivisibleC = (A - 1) // C
AdivisibleD = (A - 1) // D
AdivisibleCD = (A - 1) // lcm(C, D)
AindivisibleCD = (A - 1) - (AdivisibleC + AdivisibleD - AdivisibleCD)

BdivisibleC = B // C
BdivisibleD = B // D
BdivisibleCD = B // lcm(C, D)
BindivisibleCD = B - (BdivisibleC + BdivisibleD - BdivisibleCD)

print(BindivisibleCD - AindivisibleCD)

Measured memory_bytes: 5048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll h,w;
cin>>h>>w;
if(h==1||w==1){
cout<<1<<endl;
}
else if(h%2==0||w%2==0){
    cout<<(h*w)/2<<endl;
}else{
    cout<<(h*w)/2+1<<endl;
}
}










Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int n,k;
	cin >> n >> k;
	long long x[n];
	for(int i=1;i<=n;i++)
		cin >> x[i-1];
	
	long long ans=2000000009;

	for(int i=1;i<=n-k+1;i++)
	{
		long long c_ans=0;
		if(x[i-1]<=0 && x[i+k-1-1]<=0)
			c_ans=x[i-1]*(-1);
		else if(x[i-1]>=0 && x[i+k-1-1]>=0)
			c_ans=x[i+k-1-1];
		else
		{
			c_ans=2*(x[i-1]*(-1))+x[i+k-1-1];
			long long tmp=x[i-1]*(-1)+2*(x[i+k-1-1]);
			if(tmp<c_ans)c_ans=tmp;
		}
	
		if(c_ans<ans)ans=c_ans;
	}
	cout << ans << endl;
}
		

Measured memory_bytes: 1024
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

int main()
{
    while (true) { 
        int[3] s;
        string[] str = readln.chomp.split;
        s[0] = to!int(str[0]); s[1] = to!int(str[1]); s[2] = to!int(str[2]);
        if (s[0] == 0 && s[1] == 0 && s[2] == 0) break;
        s.sort;
        int n = readln.chomp.to!int;
        for (int i = 0; i < n; i++) {
            double r = readln.chomp.to!double;
            r *= 2.0;
            if (r > sqrt(to!float(s[0] * s[0] + s[1] * s[1]))) writeln("OK");
            else writeln("NA");
        }
    }
    
    return 0;
}

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

void solve();

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	for(int i = 0; i < t; i++){
		solve();
	}
	return 0;	
}

void solve(){
	double l;
	cin >> l;
	double d = l/3;
	cout << fixed;
	cout << d*d*d;
}




Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int h,w; ll k;
char g[2333][2333];
const ll MOD=1e9+7;
ll qp(ll a,ll b)
{
	ll x=1;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
struct mat
{
ll s[2][2];
};
mat operator * (mat a,mat b)
{
	#define p(x,y) g.s[x][y]=(a.s[x][0]*b.s[0][y]+a.s[x][1]*b.s[1][y])%MOD
	mat g; p(0,0);p(0,1);p(1,0);p(1,1); return g;
	#undef p
}
mat qp(mat a,ll b)
{
	mat x; x.s[0][0]=x.s[1][1]=1; x.s[0][1]=x.s[1][0]=0;
	while(b)
	{
		if(b&1) x=x*a;
		a=a*a; b>>=1;
	}
	return x;
}
int main()
{
	scanf("%d%d%lld",&h,&w,&k);
	int c=0;
	for(int i=1;i<=h;++i)
	{
		scanf("%s",g[i]+1);
		for(int j=1;j<=w;++j) c+=g[i][j]=='#';
	}
	int a=0,b=0,xa=0,xb=0;
	for(int i=1;i<=h;++i)
		if(g[i][1]=='#'&&g[i][w]=='#') a++;
	for(int i=1;i<=w;++i)
		if(g[1][i]=='#'&&g[h][i]=='#') b++;
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
			xb+=g[i][j]=='#'&&g[i+1][j]=='#'; 
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
			xa+=g[i][j]=='#'&&g[i][j+1]=='#';
	if(a&&b)
	{
		puts("1");
		return 0;
	}
	if(!(a+b))
	{
		ll g=qp(c,k-1);
		printf("%d\n",(int)g);
		return 0; 
	}
	mat s;
	s.s[0][0]=c; s.s[1][0]=0;
	if(a)
	{
		s.s[0][1]=(MOD-xa)%MOD;
		s.s[1][1]=a;
	}
	else
	{
		s.s[0][1]=(MOD-xb)%MOD;
		s.s[1][1]=b;
	}
	mat gg=qp(s,k-1);
	ll ans=gg.s[0][0]+gg.s[0][1];
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,i,x=0;
    cin>>k;
    cin>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            x=1;
            break;
        }
    }
    if(x==1) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3584
import sys
from collections import deque
import copy
import numpy as np

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = list(read_func().strip().split())
    #color_num_list = []
    #color_num_list = {}
    color_num_list = np.zeros((N))
    for i in range(N):
        color_num_list[i] = (int(input_raw[i]))

    index_list = np.argsort(color_num_list)[::-1]
    sorted_color_num = np.sort(color_num_list)[::-1]

    mat = np.zeros((H, W),'int')
    now_i = 0
    now_j = 0
    rev_flag = False
    #tmp_color_num_list = copy.deepcopy(color_num_list)
    #while len(color_num_list) > 0:
        #color_num = max(color_num_list.values())
        #color = color_num_list.keys()[color_num_list.values().index(color_num)]
        #color_num_list.pop(color)
        #tmp_color_num_list.remove(color_num)
    for i in range(N):
        color_num = sorted_color_num[i]
        color = index_list[i] + 1
        while color_num > 0:
            mat[now_i][now_j] = color
            if (now_j < W - 1 and rev_flag == False)  or  (now_j >= 1 and rev_flag == True):
                s = -1 if rev_flag == True else 1
                now_j += s
            else:
                now_i += 1
                rev_flag = not(rev_flag)
            color_num -= 1

    for i in range(H):
        for j in range(W):
            print mat[i][j],
        print


if __name__ == '__main__':
    main()


Measured memory_bytes: 16256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	
	real[] as;
	foreach(i; 0 .. n) as ~= read.to!real;
	
	as.sort!"a>b"();
	
	real sum = 0.0;
	foreach(i; 0 .. n) sum += 1.0 / as[i];	
	
	real ans = 1.0 / sum;
	
	writefln("%10.10f", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int a[100500], b[100050];
vector<int> c;
vector<int> pathes[10050];
int sum = 0;
int val[100050];
void dfs(int now, int from) {
    val[now] = c.back();
    c.pop_back();
    for(int i = 0; i < pathes[now].size(); i++) {
        int to = pathes[now][i];
        if(to == from) continue;
        dfs(to, now);
    } 
}

int main() {
    //cout.precision(10);
    cin >> N;
    c.resize(N);
    for(int i = 1; i < N; i++) {
        cin >> a[i] >> b[i];
        pathes[a[i]].push_back(b[i]);
        pathes[b[i]].push_back(a[i]);
    }
    for(int i = 1; i <= N; i++) {
        cin >> c[i-1];
        sum += c[i-1];
    }
    sort(c.begin(), c.end());
    sum -= c[N-1];
    int leaf = 1;
    for(int i = 1; i <= N; i++) {
        if(pathes[i].size() == 1) leaf = i;
    }
    dfs(leaf, -1);
    cout << sum << endl;
    for(int i = 1; i <= N; i++) {
        cout << val[i];
        if(i < N) cout << " ";
    }
    cout << endl;
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, A, B; cin >> N >> A >> B;
	if (abs(B-A) & 1) {
		print("Borys");
	} else {
		print("Alice");
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,q;
    cin >> n >> q;
    vector<vector<int>> edge;
    int a,b;
    rep(i,n+1){
        edge.push_back({});
    }
    rep(i,n-1){
        cin >> a >> b;
        edge[a].push_back(b);
    }
    long long val[n+1]={0};
    long long ans[n+1]={0};
    long long p,x;
    rep(i,q){
        cin >> p >> x;
        val[p]+=x;
    }
    ans[1]=val[1];
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int tmp = que.front();
        que.pop();
        for(int i = 0;i<edge[tmp].size();i++){
            int tem = edge[tmp][i];
            ans[tem]+=ans[tmp]+val[tem];
            que.push(tem);
        }
    }
    rep(i,n){
        cout << ans[i+1] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 17516
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 2000000000
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
#define double float
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to, cost;
};

int main() {
    int n;
    cin >> n;
    vi t(n + 2, 0), a(n + 2, 0);
    rep(i, n) cin >> t[i + 1];
    rep(i, n) cin >> a[i + 1];
    ll ans = 1;
    rep(i, n) {
        if(t[i] == t[i + 1] && a[i + 2] == a[i + 1]) {
            ans *= min(t[i + 1], a[i + 1]);
        } else {
            if(a[i + 2] == a[i + 1] && t[i + 1] > a[i + 1]) {
                ans = 0;
            } else if(t[i] == t[i + 1] && a[i + 1] > t[i + 1]) {
                ans = 0;
            } else if(a[i + 2] != a[i + 1] && t[i] != t[i + 1] &&
                      a[i + 1] != t[i + 1]) {
                ans = 0;
            }
        }
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll h[100001];
ll a,b;
ll sum[100001];

bool C(ll v){
	int l=0,r=n;
	ll cnt=0;
	for(int i=0;i<n;i++){
		if(h[i]>b*v){
			cnt+=(h[i]-b*v+(a-b)-1LL)/(a-b);
		}
	}
	return cnt<=v;
}

int main(void){
	scanf("%d%lld%lld",&n,&a,&b);
	for(int i=0;i<n;i++){
		scanf("%lld",&h[i]);
	}
	sort(h,h+n);
	reverse(h,h+n);
	for(int i=0;i<n;i++){
		sum[i+1]=sum[i]+h[i];
	}
	ll l=0,r=h[0]/b+1;
	while(l+1<r){
		ll mid=(l+r)/2LL;
		if(C(mid))r=mid;
		else l=mid;
	}
	printf("%lld\n",r);
	return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, d;
	cin >> n >> d;
	d = d * 2 + 1;
	cout << (n + d - 1) / d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll r,d,x;
  cin >> r >> d >> x;

  for (int i = 0; i < 10; ++i) {
    cout << r * x - d << endl;
    x = r * x - d;
  }
}


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

int main(){
  int N,A,B;
  string S;
  cin>>N>>A>>B;
  cin>>S;
  int n=(A+B);
  int b=1;
  int p=0;
  for(int i=1; i<=N;i++){
    if(S.at(i-1)=='a'){
      if(p<n){cout<<"Yes"<<endl; p++;}
      else{cout<<"No"<<endl;}
    }
    if(S.at(i-1)=='b'){
      if(p<n && b<=B){cout<<"Yes"<<endl; b++; p++;}
      else{cout<<"No"<<endl;b++;}
    }
    if(S.at(i-1)=='c'){cout<<"No"<<endl;}
  }
}


Measured memory_bytes: 896
a, b, c = map(float, input().split())
import math
s=f"{0.5*a*b*(math.sin(c*(math.pi)/180)):.8f}"
L=f"{a+b+math.sqrt(a*a+b*b-2*a*b*(math.cos(c*(math.pi)/180))):.8f}"
h=f"{b*(math.sin(c*(math.pi)/180)):.8f}"
print(s)
print(L)
print(h)


Measured memory_bytes: 5708
n,d = gets.split.map(&:to_i)
ary = []
result = 0
n.times { ary << gets.split.map(&:to_i) }
n.times do |i|
  n.times do |j|
    if i >= j
      next
    end
    a = ary[i]
    b = ary[j]
    sum = 0
    d.times do |k|
      sum += (a[k] - b[k])**2
    end
    sum = sum ** (1.0/2)
    result += 1 if sum == sum.to_i
  end
end
puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    ll H,n,a[1000],b[1000];
    cin>>H>>n;
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    ll dp[20001]={};
    for(int i=1;i<=20000;i++) dp[i]=1e18;
    for(int h=1;h<=20000;h++){
        for(int i=0;i<n;i++){
            if(h-a[i]>=0) dp[h]=min(dp[h],dp[h-a[i]]+b[i]);
        }
    }
    cout<<*min_element(dp+H,dp+20001)<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int a,b,k;
    cin >> a >> b >> k;

    int l,r;
    int cnt = b-a+1;
    if ( cnt <= 2*k ){
      l = a; r = b;
      for ( int i = l ; i <= r ; i++ ) cout << i << endl; 
    }
    else {
      l = a+k-1; r = b-k+1;
      for ( int i = a ; i <= l ; i++ ) cout << i << endl;
      for ( int i = r ; i <= b ; i++ ) cout << i << endl;
    }
}

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

int main(void){
  int n,count = 0;
  string s;
  cin >> n;
  cin >> s;

  for(int i=0; i<n; i++){
    if(s[i] == 'A'){
      if(s[i+1] == 'B'){
        if(s[i+2] == 'C'){
          count++;
        }
      }
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<ll,ll>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int t;
    string s;cin>>t>>s;
    if(s.size()<=t) cout<<s;
    else cout<<s.substr(0,t)<<"...";

}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count = 0;
        for(int i = a; i <= b; i++) {
            String reversedNumber = new StringBuilder(String.valueOf(i)).reverse().toString();
            if(String.valueOf(i).equals(reversedNumber)) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 38740
#include <iostream>
#include <vector>
using namespace std;
const int N = 100010;

int main(){
    long long int n, k;
    cin >> n >> k;
    vector<long long int> array(N);
    for(int i = 0; i < N; i++) array[i] = 0;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        array[a] += b;
    }
    
    long long int count = 0;
    long long int index;
    for(index = 1; index < N; index++){
        count += array[index];
        if(k <= count) break;
    }
    
    cout << index << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

string fn(int N){
	string S(10,'0');
	REP(i,10){
		if(pow(2,9-i)<=N){
			S[i]='1'; 
			N-=pow(2,9-i);
		}
	}
	return S;
}
int main(void){
	int A,B,C;
	cin>>A>>B>>C;
	if(A+B>=C) print("Yes");
	else print("No");
	
	return 0;
}



Measured memory_bytes: 764
import java.util.*;  
class Main{  
    public static void main(String args[]){  
        Scanner sc=new Scanner(System.in);  
        while(sc.hasNext()){  
            int n=sc.nextInt();  
            int a[]=new int[n];  
            for(int i=0;i<n;i++){  
                a[i]=sc.nextInt();  
            }  
            int multipleAll=multiple(a,0);  
            System.out.println(multipleAll);  
        }  
    }  
    public static int divstor(int x,int y){//求2个数的最大公约数  
        int min = x < y ? x : y ;    //取两个数的较小的那个  
        for(int divstorX = min ; divstorX > 0 ; divstorX--){  
            if(x%divstorX==0&&y%divstorX==0){      
                //从较小的那个数开始逐渐往后寻找直到找到可以同时整除这2个数的数就是最大公约数  
                return divstorX;  
            }  
        }  
        return 1;  
    }  
    public static int multiple(int a[],int count){  
        //count表示从0开始，因为数组是从0开始的（后面也是这样）也就是从第一个数开始  
          
        int divstorX=divstor(a[count],a[count+1]);      
        //求第count-1个数与第count个数的最大公约数  
          
        int multipleX=a[count]/divstorX*a[count+1];  
        //求这2个数的最小公倍数      
        //这句不能是int multipleX=a[count]*a[count+1]/divstorX；  
        //虽然结果是一样的，但是先把2个int相乘可能会超过int的范围，所以先除，在乘，可以防止越界  
          
        a[count+1]=multipleX;          
        //把2个数的最小公倍数赋值给后面那个数也就是第count+2个数  
          
        count++;    //使标记转到第count+2个数  
          
        if(count!=a.length-1){    //如果count不是在倒数第二个数  
            return multiple(a,count);  
            //在求第count+1个数开始与第count+2个数的最小公倍数  
        }  
          
        return multipleX;    //求完之后返回这个数组的最小公倍数  
    }  
}  


Measured memory_bytes: 26336
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxd = 1e5+10;
ll p[maxd],a[maxd],sum,ans;
int t[maxd],tot,n;
void insert(ll x)
{
    for(int i=1;i<=tot;i++)
        if((x>>t[i])&1)
        {
            if(p[i]) x^= p[i];
            else
            {
                p[i]=x;
                break;
            }
        }
}
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++) sum ^= a[i];
    for(int i=60;i>=0;i--) if(( (sum>>i)&1) == 0) t[++tot]=i;
    for(int i=1;i<=n;i++) insert(a[i]);
    for(int i=1;i<=tot;i++) 
        if(((ans >>t[i])&1) == 0) ans ^=p[i];
    printf("%lld\n",ans+(sum^ans));


    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>

using namespace std;

char field[110][110];
int N, M, ans = 0;
int dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };

void dfs(int x, int y)
{
	char c;
	c = field[x][y];
	field[x][y] = '%';
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (nx >= 0 && nx <= N && ny >= 0 && ny <= M && field[nx][ny] == c)
			dfs(nx, ny);
	}
}

void solve()
{
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (field[i][j] != '%')
			{
				dfs(i, j);
				ans++;
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	while (1)
	{
		cin >> N >> M;
		if (!N && !M)
			break;
		for (int i = 0; i < N; i++)
			for (int j = 0; j < M; j++)
				cin >> field[i][j];
		solve();
		ans = 0;
	}

	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>

using ll = long long int;
using namespace std;

#define FOR(i,N) for(int i=0;i<N;i++)

int main() {
    ll N;
    cin >> N;

    if (N % 2 == 1) {
        cout << 0;
        return 0;
    }
    ll ans=0;
    N /= 2;
    FOR (i, 40) {
        ans += N / 5;
        N /= 5;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n), b(n), c(n - 1);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i]--;
	}
	
	for(int i = 0; i < n; ++i) {
		cin >> b[i];
	}

	for(int i = 0; i < n - 1; ++i) {
		cin >> c[i];
	}
	
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		ans += b[a[i]];
		
		if( i > 0 ) {
			if( a[i] == (a[i - 1] + 1) ) ans += c[a[i] - 1];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

    long long n, a, b, ans;
    cin >> n >> a >> b;

    ans = (a + (n - 1) * b) - ((n - 1) * a + b) + 1;
    cout << max(0LL, ans) << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a * b + " " + (a*2 + b*2));
    sc.close();
  }
}


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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int n, m, sum, i;
	int a, b;

	while(cin >> n >> m, n != 0 && m != 0) {

	int friends[500] = {0}; //1=友達 2=友達の友達
	int m1[10000] = {0};
	int m2[10000] = {0};
	for(i = 0; i < m; i++) {
		cin >> m1[i] >> m2[i];
	}
	for(i = 0; i < m; i++) {
		a = m1[i];
		b = m2[i];
		if(friends[a-1] == 1 && friends[b-1] == 1) {
		} else if(a == 1) {
			friends[b-1] = 1;
		} else if(b == 1) {
			friends[a-1] = 1;
		} else if(friends[a-1] == 1) {
			friends[b-1] = 2;
		} else if(friends[b-1] == 1) {
			friends[a-1] = 2;
		}
	}
	for(i = 0; i < m; i++) {
		a = m1[i];
		b = m2[i];
		if(friends[a-1] == 1 && friends[b-1] == 1) {
		} else if(a == 1) {
			friends[b-1] = 1;
		} else if(b == 1) {
			friends[a-1] = 1;
		} else if(friends[a-1] == 1) {
			friends[b-1] = 2;
		} else if(friends[b-1] == 1) {
			friends[a-1] = 2;
		}
	}
	sum = 0;
	for(i = 0; i < n; i++) {
		if(friends[i] > 0)
			sum++;
	}

	cout << sum << endl;

	}

	return 0;

}

Measured memory_bytes: 1244
#include <stdio.h>

int main() {

  int n, x, i, j, k, c = 0;

  while(1){
    scanf("%d %d", &n, &x);
    if ((n == 0) && (x == 0)) break;
    c = 0;
  for (i = 1; i <= n-2; i++){
    for (j = i + 1; j <= n-1; j++){
      for ( k = j + 1; k <= n; k++){
	if (i + j + k == x) c++;
      }
    }
  }
  printf("%d\n", c);
  }

  return 0;

}

Measured memory_bytes: 600
import System.IO
import Control.Applicative
import Data.Bits

main :: IO()
main = do
    hSetBuffering stdout LineBuffering
    n <- readLn
    print 0
    s <- getLine
    if s == "Vacant"
    then return ()
    else myAns 0 n s s
    where
        myAns l r sl sr = do
            print m
            s <- getLine
            let same = sl == s
            if s == "Vacant"
            then return ()
            else if xor same isEven then myAns l m sl s else myAns m r s sr
            where
                m = (l+r) `div` 2
                isEven = even (m-l)


Measured memory_bytes: 1104
#include <cstdio>

int n,a[3];

int gdb(int a,int b){
	if(b == 0){
		return a;
	}
	return gdb(b,a%b);
}

int main(){
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	int g;
	if(n == 2){
		g = gdb(a[0],a[1]);		
	}
	else{
		g = gdb(gdb(a[0],a[1]),a[2]);
	}
	for(int i = 1; i <= g/2; i++){
		if(g % i == 0){
			printf("%d\n",i);
		}
	}
	printf("%d\n",g);

	return 0;
}



Measured memory_bytes: 2692
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for(int i=0;i<values.length;i++){
         values[i]=i+1;
        } 
        for(int i=0;i<n;i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0])-1;
            int b = Integer.parseInt(ab[1])-1;

            int store = values[a];
            values[a]=values[b];
            values[b]=store;
        }

        for(int i=0;i<w;i++){
            System.out.println(values[i]);
        }
sc.close();
   }
}


Measured memory_bytes: 26216
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

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

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

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,k;
    cin >> n >> k;
    double sum = 0.0;
    REP(i,1,n+1) {
        double tmp = 1.0;
        int score = i;
        while (score < k) {
            tmp /= 2;
            score *= 2;
        }
        sum += tmp;
    }
    //cout << sum / n << endl;
    printf("%.10lf\n", sum/ n);
}

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

Measured memory_bytes: 256
N = int(input())
yama = []
total = 0
left=0
right=0
min=1000000
yama = list(map(int, input().split()))

for a in range(1,N):
    left=0
    right=0
    for b in range(a):
        left += yama[b]
    for c in range(a,N):
        right += yama[c]
    if(abs(left-right)<min):
        min=abs(left-right)

print(min)

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int parent,left,right;
};

struct Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;

  if(T[u].left!=NIL)
    h1=setHeight(T[u].left)+1;
  
  if(T[u].right!=NIL)
    h2=setHeight(T[u].right)+1;
     
  return H[u]=(h1>h2?h1:h2);

}

  int getSibling(int u){
    if(T[u].parent==NIL) return NIL;
    if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
    return NIL;
  }

  void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;

    if(T[u].left!=NIL) deg++;
    if(T[u].right!=NIL) deg++;

    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);

    if(T[u].parent == NIL){
      printf("root\n");
    }
    else if(T[u].left == NIL && T[u].right == NIL){
      printf("leaf\n");
    }
    else printf("internal node\n");
  }


int main(){
  int v,l,r,root=0,i;
  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].parent = NIL;

  for(i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;

  }

  for(i=0;i<n;i++) if(T[i].parent == NIL) root=i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++) print(i);

  return 0;

}

Measured memory_bytes: 624
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	int k;
	cin >> n >> k;
	vector<int> stones(n);
	for(int i = 0; i < n; i++){
		cin >> stones[i];
	}
	vector<int> dp(n);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		int tmp = 999999999;
		for(int j = 1; j <= min(k, i); j++){
			dp[i] = min(tmp, abs(stones[i] - stones[i-j]) + dp[i-j]);
			tmp = dp[i];
		}
	}
	cout << dp[n-1] << endl;
}

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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define fr(i,n) for(i=1;i<=n;i++)

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

ll a[110];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll i,n,x,cnt=0;
    cin>>n>>x;
    fr(i,n) cin>>a[i], cnt+=a[i];
    sort(a+1, a+n+1);
    if(cnt==x)
        cout<<n<<endl;
    else if(cnt<x)
        cout<<n-1<<endl;
    else
    {
        cnt=0;
        for(i=1;i<=n;i++)
        {
            cnt+=a[i];
            if(cnt>x)
                break;
        }
        cout<<i-1<<endl;
    }
    return 0;
}


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

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");}

#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl             '\n'
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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 << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int string_to_int(string s){
	int ans = 0;
	int p=1;
	for(int i=s.size()-1;i>=0;i--){
		ans += (s[i]-'0')*p;
		 p *= 10;
	}
	return ans;
}

void t_c_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	string s; cin >> s;
	string s1; cin >> s1;
	int n = (int)s.size();
	int ans = 0;
	for(int i=0;i<n;i++){
		if(s[i]!=s1[i]){
			ans++;
		}
	}
	cout << ans << endl;
}

int32_t main()
{
	t_c_c();
	return 0;
}


Measured memory_bytes: 3800