akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
from collections import deque
n = int(input())

counter = [0]*n
G = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())  
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  counter[a-1] += 1
  counter[b-1] += 1
  
C = sorted(list(map(int,input().split())))[::-1]


root = 0
v = 0
for i in range(n):
  if v > counter[i]:
    root = i
    v = counter[i]


def bfs(s):
  que = deque()
  que.append(s)
  nodes = [-1]*n
  k = 0
  ans = 0
  while len(que)>0:    
    q = que.pop()    
    nodes[q] = C[k]    
    k += 1
    
    for v in G[q]:
      if nodes[v]<0:
        que.append(v)
  
  print(sum(C[1:]))
  print(*nodes)                

bfs(root)


Measured memory_bytes: 6496
def main():
    n = int(input())
    a = list(map(int,input().split()))

    b = a[0]
    for i in range(1,n):
        b = b * a[i] // gcd(b,a[i])
    ans = 0
    for i in a:
        ans = ans + b // i
    print(b/ans)

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m;
int x;
long long d[1000005];

int main()
{
    scanf("%d %d", &n, &m);
    d[m] = 1;
    while(n--)
    {
        scanf("%d",&x);
        for(int i = m;i >= 0;i--) d[i] += d[i+1];
        for(int i = 0;i < m;i++)
        {
            d[i] -= d[i+x+1];
            d[i] %= 1000000007;
        }
    }
    printf("%lld",d[0]);
}

#endif // 1++

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

using namespace std;

typedef long long ll;
int main(){
	int n; cin >> n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin >> a[i];

	vector<int> b(n+1,0);
	int ones = 0;
	for(int i=n;i>=1;i--){
		int parity = 0;
		// int num = i+1;
		for(int j=i+i;j<=n;j+=i){
			if(b[j] == 1) parity = (1-parity);
		}
		// cout << "parity: "<< parity << " | expected: "<<a[i] << endl;
		if(parity != a[i]){
			b[i] = 1;
			ones++;
		}
	}
	// if(ones == 0){
	// 	cout << ones << endl;
	// 	return 0;
	// }

	cout << ones << endl;
	int i=1,j=0;
	while(i<=n && j<ones){
		if(b[i]==1){
			cout << i ;
			j++;
			i++;
			break;
		}
		i++;
	}
	for(;i<=n;i++){
		if(b[i] == 1){
			cout << " " << i; 
		}
	}
	if(ones > 0) cout << endl;
	return 0;
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main{
   public static void main(String [] args){
      Scanner sc = new Scanner(System.in);
      int S = sc.nextInt();
      int h, m, s;
      h = S/3600;
      m = S%3600/60;
      s = S-((h*3600)+(m*60));
      System.out.println(h+":"+m+":"+s);
      sc.close();
   }
}


Measured memory_bytes: 26232
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};



//--------------8---------------->> coding space <<-----------------8-------------//

int H, W, d;
char col[2][2] = {{'R','G'},{'B','Y'}};

int main() {
	cin >> H >> W >> d;
	for_(y,0,H) for_(x,0,W) {
		int yi = y + x, xi = y - x + W;
		cout << col[(yi/d)%2][(xi/d)%2] << (x < W-1 ? "" : "\n");
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 512
#include <stdio.h>

int main() {

    int i, n;
    double x, slope, max_slope = 0.0, xi, hi;
    scanf("%d %lf", &n, &x);

    for ( i=0; i<n; ++i ) {
	scanf("%lf %lf", &xi, &hi);
	slope = hi/xi;
	if ( slope > max_slope ) max_slope = slope;
    }

    printf("%lf\n", x*max_slope);
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main() {
	int n, buf;
	int* a;
	cin >> n;
	a = new int[n];
	a[0] = 1;
	for (int i = 1; i < n; i++) {
		a[i] = 0;
	}

	for (int i = 1; i < n; i++) {
		cin >> buf;
		a[buf]++;
	}

	for (int i = 0; i < n-1; i++) {
		cout << a[i+1] << "\n";
	}
	cout << 0 << "\n";
	delete[] a;

	return 0;
}

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

using namespace std;
const int MOD = 1e9 + 7;

int32_t main() {
    int h, w;
    cin >> h >> w;

    char mat[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> mat[i][j];
        }
    }
    int dp[h][w] = {};
    for (int k = 0; k < h; ++k) {
        if (mat[k][0] == '#')
            break;
        dp[k][0] = 1;
    }
    for (int k = 0; k < w; ++k) {
        if (mat[0][k] == '#')
            break;
        dp[0][k] = 1;
    }
    for (int i = 1; i < h; i++)
        for (int j = 1; j < w; j++) {
            if (mat[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = dp[i - 1][j]%MOD + dp[i][j - 1]%MOD;
        }

    cout << dp[h - 1][w - 1]%MOD;
}



Measured memory_bytes: 5120
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

vector<int> ps, pn;
int N, M;
int ans = 1;

void dfs(int pi, int t)
{
	if (pi == SZ(ps))
	{
		if (M / t >= N)
		{
			chmax(ans, t);
		}
		return;
	}

	rep(i, 0, pn[pi] + 1)
	{
		dfs(pi + 1, t * (int)pow(ps[pi], i));
	}
}

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

	cin >> N >> M;

	map<int, int> pmap;
	int t = M;
	for (int i = 2; i <= (int)sqrt(M); i += (i == 2 ? 1 : 2))
	{
		if (t%i == 0)
		{
			ps.push_back(i);
			pn.push_back(0);
		}
		while (t%i == 0)
		{
			pn.back()++;
			t /= i;
		}
	}
	if (t != 1)
	{
		ps.push_back(t);
		pn.push_back(1);
	}

	dfs(0, 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#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;
    set<int> s1, sn, sa;
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        if (min(a, b) == 1) {
            s1.insert(max(a, b));
            sa.insert(max(a, b));
        }
        if (max(a, b) == n) {
            sn.insert(min(a, b));
            sa.insert(min(a, b));
        }
    }
    if (s1.size() + sn.size() == sa.size()) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << "POSSIBLE" << endl;
    }
}


Measured memory_bytes: 18944
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;


//110 C
int main(void) {
	string s, t;
	cin >> s >> t;
	map<char, vector<ll>> indexT;
	map<char, vector<ll>> indexS;
	rep(0, t.length()) {
		indexT[t[i]].push_back(i);
	}
	rep(0, s.length()) {
		indexS[s[i]].push_back(i);
	}
	auto iterT = indexT.begin();
	bool ans = true;
	rep(0, indexT.size()) {
		vector<ll> v = iterT->second;
		char c = s[v[0]];
		for (int j = 1; j < v.size(); j++) {
			if (c != s[v[j]]) {
				ans = false;
				break;
			}
		}
		if (!ans)break;
		iterT = next(iterT, 1);
	}

	auto iterS = indexS.begin();
	rep(0, indexS.size()) {
		vector<ll> v = iterS->second;
		char c = t[v[0]];
		for (int j = 1; j < v.size(); j++) {
			if (c != t[v[j]]) {
				ans = false;
				break;
			}
		}
		if (!ans)break;
		iterS = next(iterS, 1);
	}
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 4988
s = input()

l = []
for i in range(len(s)):
    l.append(int(s[i]))

def fn(lll):
    if len(lll) < 2:
        return

    if lll[-1] != lll[-2]:
        lll.pop()
        lll.pop()
        fn(lll)

ll = []
for i in l:
    ll.append(i)
    fn(ll)

print(len(l) - len(ll))

Measured memory_bytes: 4724
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        int[][] D;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            D = new int[N][2];

            int cnt = 0;
            for (int i = 0; i < N; i++) {
                D[i] = in.Int(2);
                if (D[i][0] == D[i][1]) cnt++;
                else cnt = 0;
                if (cnt == 3) {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 33060
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rrep(i,n,ohara){
        s=to_string(i);
        set<char> st;
        rep(j,Size(s))st.insert(s[j]);
        if(Size(st)==1){
            Cout(i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static HashSet<Integer> visited;
    static int N;
    static int M;
    static int before[];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();
        before = new int[N + 1];
        Arrays.fill(before, -1);
        Map<Integer, HashSet<Integer>> path = new HashMap<Integer, HashSet<Integer>>();

        for (int i = 0; i < N + 1; i++) {
            path.put(i, new HashSet<>());
        }
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            path.get(A).add(B);
            path.get(B).add(A);
        }


        visited = new HashSet<>();
        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(1);
        visited.add(1);

        while (!queue.isEmpty()) {
            int v = queue.poll();
            HashSet<Integer> target = path.get(v);

            for (Integer i : target){
                if (!visited.contains(i)) {
                    queue.add(i);
                    visited.add(i);
                    before[i] = v;
                }
            }
        }

        StringBuilder sb = new StringBuilder();

        if (before[2] == -1) {
            sb.append("No");
        } else {
            sb.append("Yes");
            sb.append("\n");
        }
        for (int i = 2; i < N + 1; i++) {
            sb.append(before[i]);
            sb.append("\n");
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 104892
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> nums(N);
  for (int64_t n = 0; n < N; ++n) {
    int64_t A;
    cin >> nums[n];
    if (nums[n] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }    
  int64_t res = 1;
  for (int64_t A: nums) {
    if (1000000000000000000 / A < res) {
      cout << -1 << endl;
      return 0;
    }
    res *= A;
  }
  
  cout << res << endl;
  
  return 0;
}


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

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

int main()
{
	int count5 = 0;
	int count7 = 0;

	rep(i, 3)
	{
		int A;
		cin >> A;
		if (A == 5) ++count5;
		else if (A == 7) ++count7;
	}

	if (count5 == 2 && count7 == 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int r,g,b;
  cin>>r>>g>>b>>n;
  
  int cnt=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(n-i*r-j*g>=0&&(n-i*r-j*g)%b==0){
	cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  return(0);
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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

int main(){
  int k;
  cin >> k;
  ll ans = 0;
  for(int i=0;i<k;i++){
    for(int j=0;j<k;j++){
      for(int p=0;p<k;p++){
        ans += gcd(gcd(i+1,j+1),p+1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>
#include <iomanip>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810893;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/





void proc() {
	LOAD(int, M);
	LOAD(int, K);
	int MM = 1 << M;
	if (K == 0) {
		for (int i = 0; i < MM; ++i) {
			cout << i << ' ';
		}
		for (int i = 0; i < MM; ++i) {
			cout << MM - 1 - i;
			if (i != MM - 1) {
				cout << ' ';
			}
		}
	}
	else if (2 <= M && K < MM) {
		for (int i = 0; i < MM; ++i) {
			if (i != K) {
				cout << i << ' ';
			}
		}
		cout << K << ' ';
		for (int i = 0; i < MM; ++i) {
			if (MM - 1 - i != K) {
				cout << MM - 1 - i << ' ';
			}
		}
		cout << K;
	}
	else {
		cout << "-1";
	}
	cout << endl;

}


#endif


Measured memory_bytes: 1792
M = int(input())
dc = [[int(i) for i in input().split()] for _ in range(M)]

ret = 0
s = 0
for d, c in dc :
    s += d * c
    t = s // 10
    ret += t
    s %= 10
    s += t
    
while s >= 10 :
    t = s // 10
    ret += t
    s %= 10
    s += t

for d, c in dc :
    ret += c
        
print(ret - 1)

Measured memory_bytes: 78648
#include <iostream>

using namespace std;

int main()
{
   long long int a,b,c,d;
   long long int f,g,h,j;
   long long int maks=-10000000000000000000000;
   cin>>a>>b>>c>>d;
   f=a*c;
   g=a*d;
   h=b*c;
   j=b*d;
   maks=max(maks,f);
   maks=max(maks,g);
   maks=max(maks,h);
   maks=max(maks,j);
   cout<<maks<<endl;
   return 0;
}

Measured memory_bytes: 3632
MOD = 2019
L ,R = map(int, input().split())
k = L % MOD
t = R % MOD
if L + 2019 - k <= R:
    print(0)
else:
    ans = float('inf')
    for i in range(k, t+1):
        for j in range(i+1, t+1):
            ans = min(ans, (i*j) % MOD)
    print(ans)

Measured memory_bytes: 3060
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;
#define int long long
constexpr int mod = 1000000007;

#define LOADVECTOR(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;





signed main() {
	ios::sync_with_stdio(false);
	LOAD(int, A);
	LOAD(int, B);
	LOAD(int, C);
	cout << B + std::min({ C,A + B + 1 }) << endl;
	return 0;
}
#endif


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int h,w;
cin>>h;
cin>>w;
char a[h][w];
int cw[w],ch[h];
for(int i=0;i<w;i++){
    cw[i]=0;
}
for(int i=0;i<h;i++){
    ch[i]=0;
}
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin>>a[i][j];
    }
}
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(a[i][j] == '.'){
            ch[i]++;
            cw[j]++;
        }

    }
}
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
       if(ch[i]!=w&&cw[j]!=h){
            cout<<a[i][j];
        }

    }
     if(ch[i]!=w)
    cout<<endl;
}

    return 0;
}


Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

import math

p1 = []
p2 = []
p3 = []

for i in range(n):
    p1.append(abs(X[i] - Y[i]))
    p2.append(p1[i]**2)
    p3.append(p1[i]**3)
    
print(sum(p1))
print(sum(p2)**(1/2))
print(sum(p3)**(1/3))
print(max(p1))


Measured memory_bytes: 5696
import scala.io.StdIn
import scala.collection.mutable.HashSet

object Main extends App {
  val Array(h, w) = StdIn.readLine.split(" ").map(_.toInt)
  val table = Iterator.continually(StdIn.readLine)
    .take(h)
    .map(_.map(_ == '#').toArray)
    .toArray

  @inline
  def flat(i:Int, j:Int):Int = i * w + j

  val ans = {
    val dx = Array(0, 1, 0, -1)
    val dy = Array(-1, 0, 1, 0)
    val uft = new UnionFindTree(flat(h, w))

    for{
      i <- 0 until h
      j <- 0 until w
    } {
        val ij = flat(i,j)
        (0 until 4).foreach(k => {
          val y = i + dy(k)
          val x = j + dx(k)
          if(0 <= y && y < h && 0 <= x && x < w &&
              table(i)(j) != table(y)(x) ) {
            uft.unite(ij, flat(y,x))
          }
        })
    }
    uft.set./:(0L)((acc,e) => {
      acc + uft.black(e).toLong * uft.white(e).toLong
    })
  }

  println(ans)

  class UnionFindTree(n:Int) {
    private val par  = Array.range(0, n)
    private val rank = Array.fill(n)(1)

    val set = HashSet.empty[Int]
    val black = Array.ofDim[Int](n)
    val white = Array.ofDim[Int](n)
    for {
      i <- 0 until h
      j <- 0 until w
    } {
      if(table(i)(j)) black(flat(i,j)) = 1 else white(flat(i,j)) = 1
    }

    def root(x:Int):Int = {
      if(par(x) == x) x
      else { par(x) = root(par(x)); par(x) }
    }

    def isSame(x:Int, y:Int):Boolean = root(x) == root(y)

    def unite(x:Int, y:Int):Unit = {
      val rx = root(x)
      val ry = root(y)
      if(rx == ry) return

      if(rank(rx) < rank(ry)) {
        par(rx) = ry

        set += ry
        if(set.contains(rx)) set -= rx

        black(ry) += black(rx)
        white(ry) += white(rx)
        // black(rx) = 0
        // white(rx) = 0
      }
      else {
        par(ry) = rx
        if(rank(rx) == rank(ry)) rank(rx) += 1

        set += rx
        if(set.contains(ry)) set -= ry

        black(rx) += black(ry)
        white(rx) += white(ry)
        // black(ry) = 0
        // white(ry) = 0
      }
    }
  }
}

Measured memory_bytes: 40372
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[26];

int main() {
	ll h, w;
	cin >> h >> w;
	string s;
	rep(i, 0, h) {
		string a;
		cin >> a;
		s += a;
	}
	clr(d, 0);
	rep(i, 0, s.sz) {
		d[s[i] - 'a']++;
	}
	vector<ll> v;
	rep(i, 0, 26) {
		v.pb(d[i]);
	}
	sort(all(v));
	reverse(all(v));
	if (h < w)swap(h, w);
	ll a4 = (h / 2) * (w / 2);
	ll a2 = ((h % 2) * w) / 2 + ((w % 2) * h) / 2;
	while (a4 > 0) {
		if (v[0] >= 4) {
			v[0] -= 4;
			a4--;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
		sort(all(v));
		reverse(all(v));
	}
	while (a2 > 0) {
		if (v[0] >= 2) {
			v[0] -= 2;
			a2--;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
		sort(all(v));
		reverse(all(v));
	}
	cout << "Yes" << endl;
	return 0;
}








Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

int c[3][3];
int a[3], b[3];

int main() {
    rep(i, 3) rep(j, 3) scanf("%d", &c[i][j]);

    rep(a0, 101) rep(a1, 101) rep(a2, 101) {
        a[0] = a0; a[1] = a1; a[2] = a2;
        bool minus = false;
        rep(i, 3) {
            b[i] = c[i][i] - a[i];
            minus |= b[i] < 0;
        }
        if (minus) continue;
        bool ok = 1;
        rep(i, 3) rep(j, 3) ok &= (c[i][j] == a[i] + b[j]);
        if (ok) {
            puts("Yes"); return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
n, d = [int(s) for s in input().split()]

cnt = 0
for i in range(n):
  x, y = [int(s) for s in input().split()]
  dist = (x ** 2 + y ** 2) ** (1 / 2.0)
  cnt += 1 if dist <= d else 0

print(cnt)


Measured memory_bytes: 70676
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

const int NIL = -2000000010;

class Node{
public:
	int key;
	list<Node>::iterator parent,left,right;
};

class Tree{
public:
	list<Node> node_list;
	list<Node>::iterator root;
	vector<int> preorder,inorder;

	Tree(){
		root = node_list.end();
	}
	void insert(list<Node>::iterator z){
		list<Node>::iterator y = node_list.end();
		list<Node>::iterator x = root;

		while(x!=node_list.end()){
			y = x;
			if(z->key<x->key){
				x = x->left;
			}
			else{
				x = x->right;
			}
		}
		z->parent = y;
		if(y==node_list.end()){
			root = z;
		}
		else if(z->key<y->key){
			y->left = z;
		}
		else{
			y->right = z;
		}
	}
	bool find(int key,list<Node>::iterator z){
		if(z->key==key) return true;

		if(z->key>key && z->left!=node_list.end()){
			return find(key,z->left);
		}
		else if(z->key<key && z->right!=node_list.end()){
			return find(key,z->right);
		}
		return false;
	}
	bool find(int key){
		return find(key,root);
	}
	void DFS(list<Node>::iterator parent){
		preorder.push_back(parent->key);
		
		if(parent->left==node_list.end()){
			inorder.push_back(parent->key);
		}
		else{
			DFS(parent->left);
			inorder.push_back(parent->key);
		}

		if(parent->right!=node_list.end()){
			DFS(parent->right);
		}
	}
	void DFS(){
		preorder.clear();
		inorder.clear();
		DFS(root);
	}
};

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

	int N=in();
	Tree tree;
	REP(i,N){
		string S=in<string>();
		if(S=="insert"){
			Node n;
			n.key = in();
			n.parent=n.left=n.right=tree.node_list.end();
			auto z = tree.node_list.insert(tree.node_list.end(),n);
			tree.insert(z);
		}
		else if(S=="find"){
			int key = in();
			out(tree.find(key)?"yes":"no");
		}
		else{
			tree.DFS();
			int num = tree.preorder.size();
			REP(j,num){
				cout << ' ' << tree.inorder[j];
			}
			cout << endl;
			REP(j,num){
				cout << ' ' << tree.preorder[j];
			}
			cout << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 31200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m;
bool a[510][510],b[510][510];
int main(){
	int i,j;char s[510];
	n=read();m=read();
	for(i=1;i<=n;i++){
		scanf("%s",s);
		for(j=1;j<=m;j++){
			if(s[j-1]=='#') a[i][j]=b[i][j]=1;
		}
	}
	for(i=1;i<=n;i++) a[i][1]=1,b[i][m]=1;
	for(i=1;i<=n;i++){
		for(j=2;j<m;j++){
			if(i%2) a[i][j]=1;
			else b[i][j]=1;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(a[i][j]) putchar('#');
			else putchar('.');
		}
		putchar('\n');
	}
	putchar('\n');
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(b[i][j]) putchar('#');
			else putchar('.');
		}
		putchar('\n');
	}
} 

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

int n,m;
int dp[20100][300];
int x[20100],c[20];

int main(){
  while(cin >> n >> m, n||m){
    for(int i=0;i<m;i++)cin >> c[i];
    for(int i=0;i<n;i++)cin >> x[i];

    for(int i=0;i<=n;i++){
      for(int j=0;j<256;j++)dp[i][j] = 1000000000;
    }

    dp[0][128] = 0;

    for(int i=0;i<n;i++){
      for(int j=0;j<256;j++){
	for(int k=0;k<m;k++){
	  int tmp = j + c[k];
	  if(tmp<0)tmp = 0;
	  if(255<tmp)tmp = 255;
	  int sq = (x[i]-tmp)*(x[i]-tmp);
	  dp[i+1][tmp] = min(dp[i+1][tmp],dp[i][j]+sq);
	}
      }
    }

    int ans = 1000000000;
    for(int i=0;i<256;i++)ans = min(ans,dp[n][i]);
    cout << ans << endl;
  }
}
    

Measured memory_bytes: 23000
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int tmp,num = 0;

        while((tmp = sc.nextInt()) != 0) {
          System.out.println("Case " + (++num) + ": " + tmp);
        }

    }

}


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

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

	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}

	int a, b; cin >> a >> b;
		
	cout << a + b << endl;
		
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	int count=0;
	int maxi=a[0];
	for(int i=0;i<n;i++)
	{
		if(a[i]<=maxi)
		count++;
		maxi=min(maxi,a[i]);

	}
	cout<<count;
	
	return 0;
}

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

int main(){

    int n;
    cin >> n;
    vector<int> x(n),y(n);

    rep(i,n){
        cin >> x[i] >> y[i];
    }
    map<pair<int,int>,int> mp;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(j!=i){
                mp[{x[i]-x[j],y[i]-y[j]}]++;
                mp[{x[j]-x[i],y[j]-y[i]}]++;                
            }
        }
    }
    int ma=0;
    for(auto it=mp.begin();it!=mp.end();it++){
        if(it->second>ma){
            ma=it->second;
        }
        //cout << it->first.first << " " << it->first.second <<" "<< it->second <<endl;
    }

    cout << n-ma << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int n,h[101],f,s[101],b[101],i,j,k;
    scanf("%d",&n);
    while(n!=0){
        for(i=0;i<n+1;i++){
            scanf("%d",&h[i]);
        }
        for(i=0;i<n+1;i++){
            k=0;
            for(j=0;j<n+1;j++){
                if(i!=j){
                    b[k]=h[j];
                    k++;
                }
            }
            for(j=0;j<n-1;j++){
                s[j]=b[j+1]-b[j];
            }
            f=0;
            for(j=0;j<n-2;j++){
                if(s[j]!=s[j+1]){
                    f=1;
                }
            }
            if(f==0){
                printf("%d\n",h[i]);
                break;
            }
        }   
        scanf("%d",&n);
    }
    return 0;
}

Measured memory_bytes: 2744
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const int MOD=1000000007;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

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

int main()
{
    ull a, b;
    cin >> a >> b;
    ull m = gcd(a, b);
    ull M = floor(sqrt(m));

    vector<bool> is_prime(M+1,true);
    is_prime[0] = is_prime[1] = false;
    int ans = 1;
    for(ull i = 0; i <= M; i++) {
        if(is_prime[i]) {
            if(m%i == 0) {
                ans++;
                while(m%i == 0)
                    m /= i;
                if(m == 1)
                    break;
            }
            for(ull j = 2; i*j <= M; j++)
                is_prime[i*j] = false;
        }
    }

    if(m != 1)
        ans++;

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


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
	char str[10];
	scanf("%s",str);
	if(strcmp(str,"SUN")==0)
	{
		printf("7");
	}
	if(strcmp(str,"MON")==0)
	{
		printf("6");
	}
	if(strcmp(str,"TUE")==0)
	{
		printf("5");
	}
	if(strcmp(str,"WED")==0)
	{
		printf("4");
	}
	if(strcmp(str,"THU")==0)
	{
		printf("3");
	}
	if(strcmp(str,"FRI")==0)
	{
		printf("2");
	}
	if(strcmp(str,"SAT")==0)
	{
		printf("1");
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll res = INF;
    rep (i, n) cin >> a[i];
    rep (bit, 1 << n) {
        ll tmp = 0;
        int cnt = 0;
        vector<bool> s(n);
        rep (i, n) {
            if (bit & (1 << i)) {
                s[i] = true;
                cnt++;
            }
        }
        if (cnt != k) continue;
        ll prev = a[0];
        FOR (i, 1, n) {
            if (!s[i]) {
                if (a[i] > prev) prev = a[i];
                continue;
            } 
            if (a[i] <= prev) {
                tmp += prev - a[i] + 1;
                prev++;
            } else {
                prev = a[i];
            }
        }
        res = min(res, tmp);
    }
    cout << res << endl;
    
    return 0;
}

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

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		
		int[] num=sc.readIntL();
		int a=num[0];
		int b=num[1];
		
		boolean odd=false;
		
		for(int c=1; c<=3; c++){
			if((a*b*c)%2==1){
				odd=true;
			}
		}
		
		System.out.println((odd==true)? "Yes":"No");
	}
	
	static void solve(){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			int i=sc.nextInt();
			return i;
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 22356
#include<iostream>
#include<vector>
using namespace std;
vector<int> tr;
vector<int> ra;
int fset(int);
void uni(int,int);
void link(int,int);
int iss(int,int);
int main(){
  int n,q,f,a,b;
  cin >> n >> q;
  tr = vector<int> (n,0);
  ra = vector<int> (n,0);
  for(int i=0;i<n;i++){//mset
    tr[i]=i;
  }
  for(int i=0;i<q;i++){
    cin >> f >> a >> b;
    if(f==0){
      uni(a,b);
    }
    else{
      int ans;
      ans=iss(a,b);
      cout << ans << endl;
    }
  }
    return 0;
  }
void uni(int a,int b){
  link(fset(a),fset(b));
}
void link(int a,int b){
  if(ra[a]>ra[b]){
    tr[b]=a;
  }
  else{
    tr[a]=b;
    if(ra[b]==ra[a])ra[b]++;
  }
}
int iss(int a,int b){
  return fset(a)==fset(b);
}
int fset(int a){
  if(a!=tr[a])tr[a]=fset(tr[a]);
  return tr[a];
}

Measured memory_bytes: 3256
from sys import stdin
N = int(stdin.readline().rstrip())
CSF = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]
for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t < CSF[j][1]:
            t = CSF[j][1]
        elif t % CSF[j][2] == 0:
            pass
        else:
            t += CSF[j][2] - t % CSF[j][2]
        t += CSF[j][0]
    print(t)       

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    string ans = string(sz(s), 'x');
    cout << ans << endl;
}


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b == c){
		cout << "Yes" << endl;
	}else if (b+c==a){
		cout << "Yes" << endl;
	}else if (a+c==b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    rep(i, 0, N) { cin >> A[i]; }
    multiset<long long> se;
    rep(i, 0, N) {
        long long t = A[i];
        auto ite = se.lower_bound(t);
        if(ite != se.begin()) {
            se.erase((--ite));
        }
        se.insert(t);
    }
    cout << se.size() << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,i,j,k,x;
    string a,b;
    cin>>a>>b;
    ll ans=9999999;
    n=a.size(),x=b.size();
    for(i=0;i<=n-x;i++){
        ll aa=0;
        for(j=0;j<x;j++){
            if(a[i+j]!=b[j])
                aa++;
        }
        ans=min(ans,aa);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<assert.h>
#define ll long long
using namespace std;

int main() {
	long long n;
	ll X, MOD;
	cin >> n >> X >> MOD;
	vector<ll> v(MOD + 1);
	vector<int> seen(MOD + 1);
	v[1] = X;
	seen[X] = 1;
	long long ans = v[1];
	for (ll i = 2; i <= n; i++) {
		ll x = ((1LL * v[i - 1] % MOD) * (v[i - 1] % MOD)) % MOD;
		if (x == 0)
			break;
		if (x == 1) {
			ans += (n - i + 1);
			break;
		}
		if (seen[x]) {
			ll sz = i - seen[x];
			ll t = 0;
			for (int j = seen[x]; j < i; j++) {
				t += v[j];
			}
			ans += ((n - i + 1) / sz) * t;
			ll rem = (n - i + 1) % sz;
			assert(rem < MOD);
			for (int j = seen[x]; j < seen[x] + rem; j++) {
				ans += v[j];
			}
			break;
		}
		else {
			v[i] = x;
			seen[x] = i;
			ans += v[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 4556
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include <functional>
using namespace std;
typedef pair<int,int> mypair;

int main(void){
int n,r;
while(1)
{
cin>>n>>r;
if(n==0)break;
vector<mypair> huda(n);
mypair temp;
for(int i=0;i<n;i++){
	temp.first=n-i;
temp.second=n-i;
huda[i]=temp;
}


int p,c;
for(int i=0;i<r;i++){
	cin>>p>>c;
	for(int j=0;j<p-1;j++)
	huda[c+j].first=huda[j].second;
	for(int j=0;j<c;j++)
	huda[j].first=huda[p-1+j].second;
	for(int j=0;j<n;j++){
		huda[j].second=huda[j].first;
	}
	
}
//for(int i=0;i<n;i++)
//cout<<huda[i].first<<' '<<huda[i].second<<endl;
cout<<huda[0].second<<endl;
}
return 0;
}

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

int main() {
  vector<char> station(3);
  for (int i = 0; i < 3; i++) {
    cin >> station.at(i);
  }
  
  if (station.at(0) == station.at(1) && station.at(1) == station.at(2)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import Data.Vector (Vector, (!), fromList)
import Data.Functor ((<$>))

binarySearch :: Ord a => Vector a -> Int -> Int -> a -> Bool
binarySearch a left right x
  | left == right = False
  | x < y = binarySearch a left mid x
  | x > y = binarySearch a (mid + 1) right x
  | otherwise = True
  where mid = left + (right - left) `div` 2
        y = a ! mid

main = do
    n <- readLn :: IO Int
    s <- fromList . map read . words <$> getLine :: IO (Vector Int)
    q <- readLn :: IO Int
    t <- map read . words <$> getLine :: IO [Int]
    print $ (length . filter (binarySearch s 0 n)) t


Measured memory_bytes: 109004
#include<bits/stdc++.h>
using namespace std;
const int MAX_NUM = 2000000;

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

    int numbers[MAX_NUM];
    int i;
    for(i = 0 ;  i< N; i++){
        cin >> numbers[i];
    }
    int count = 0;
    for(i = 0; i < N-1; i++){
        int tmp = i;
        int j;
        for(j = i+1; j <N;j++){
            if(numbers[j]<numbers[tmp]){
                tmp = j;
            }
        }
        if(tmp != i ){
            swap(numbers[tmp], numbers[i]);
            count++;
        }
        
    }
    for(i = 0 ; i<N-1; i++){
        cout << numbers[i] << " ";
    }
    cout << numbers[i] << endl;
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 20000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 1000000000
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
	string s[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string t;
    cin>>t;
    int i=0;
    for(i;i<7;i++){
        if(t==s[i]) break;
    }
    OUT(7-i);
	return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u64,
    }

    let mut boss_cnt = vec![0; (n + 1) as usize];
    for i in 0..n - 1 {
        input! {
            a: usize,
        }
        boss_cnt[a] += 1;
    }

    for i in 1..n + 1 {
        println!("{}", boss_cnt[i as usize]);
    }
}


Measured memory_bytes: 3948
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, a[55];
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N);
	reverse(a, a + N);
	int ret = 0;
	for (int i = 0; i < K; i++) ret += a[i];
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int ans = 0;
        int prev = sc.nextInt();
        for (int i = 0; i < N - 1; i++) {
            int cur = sc.nextInt();
            if (cur - prev < T) {
                ans += cur - prev;
            } else {
                ans += T;
            }
            prev = cur;
        }
        ans += T;
        System.out.println(ans);
    }
}


Measured memory_bytes: 64100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  int d[101] = {0};
  rep(i, 0, n) {
    scanf("%d", &d[i]);
  }

  qsort(d, n, sizeof(int), acs);

  int ans = 0;
  rep(i, 0, n) {
    if ( d[i] == d[i+1] ) continue;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
int main(){
    int n,c;
    cin>>n>>c;
 int b[c];
 int sum=0;
  for(int a=0 ; a<c ; a++){
   cin>>b[c];
   sum=sum+b[c];
  }
 int r=sum/(n+1);
 int q=sum%(n+1);
 if(q==0){
     cout<<r<<endl;
 }else{
     cout<<r+1<<endl;
 }
 
      
  
}


Measured memory_bytes: 3100
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
        int n[] = new int[2];
        int d = 100;
      
     for (int i = 0; i < 2; i++) {n[i]=(S/d);S%=d;d/=100;}
     if(n[1]>00&&n[1]<13){
        if(n[0]>00&&n[0]<13){System.out.print("AMBIGUOUS");}
       else{System.out.print("YYMM");}
     }
     else if(n[0]>00&&n[0]<13){System.out.print("MMYY");}
     else{System.out.print("NA");}
      

	}
}


Measured memory_bytes: 21844