akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n = 0;
            while((n = scn.nextInt()) > 0) {
                int[] ary = new int[n];
                for(int i = 0; i < n; i++) {
                    ary[i] += scn.nextInt();
                    ary[i] += scn.nextInt();
                    ary[i] += scn.nextInt();
                    ary[i] += scn.nextInt();
                    ary[i] += scn.nextInt();
                }
                Arrays.sort(ary);
                System.out.println(ary[~-n] + " " + ary[0]);
            }
        }
    }
}

Measured memory_bytes: 39456
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class Main {
	final static long MOD = 1000000007L;
 
	public static void main(String[] args) {
		Reader in = new Reader();
		int n = in.nextInt();
		int w = in.nextInt();
		long[][] a = new long[n][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = in.nextLong();
			a[i][1] = in.nextLong();
		}
		long[] dp = new long[w + 1];
		Arrays.fill(dp, -1);
		dp[0] = 0;
		long ans = 0;
		for (int i = 0; i < n; i++) {
			int add = (int) a[i][0];
			for(int j = w; j>=add; j--) {
				if(dp[j-add]==-1) continue;
				dp[j] = Math.max(dp[j], dp[j-add]+a[i][1]);
				ans = Math.max(dp[j], ans);
			}
		}
		System.out.println(ans);
	}
 
	static class Reader {
		static BufferedReader br;
		static StringTokenizer st;
		private int charIdx = 0;
		private String s;
 
		public Reader() {
			this.br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		public int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public char nextChar() {
			if (s == null || charIdx >= s.length()) {
				if (st == null || !st.hasMoreTokens())
					try {
						readLine();
					} catch (Exception e) {
					}
				s = st.nextToken();
				charIdx = 0; 
			}
			return s.charAt(charIdx++);
		}
 
		public long[] nl(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[] nca() {
			return next().toCharArray();
		}
 
		public String[] nS(int n) {
			String[] a = new String[n];
			for (int i = 0; i < n; i++)
				a[i] = next();
			return a;
		}
 
		public int nextInt() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Integer.parseInt(st.nextToken());
		}
 
		public double nextDouble() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Double.parseDouble(st.nextToken());
		}
 
		public Long nextLong() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Long.parseLong(st.nextToken());
		}
 
		public String next() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return st.nextToken();
		}
 
		public static void readLine() {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
			}
		}
	}
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int main() {
	int n;
	cin >> n;
	VI a(3*n);
	rep(i, 0, 3*n) scanf("%d", &a[i]);
	sort(ALL(a), greater<int>());

	ll sum = 0;
	rep(i, 0, n){
		sum += a[2*i + 1];
	}
	cout << sum << "\n";
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
#include <algorithm>
#include <vector>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int H,W;
  cin>>H>>W;
  char s[55][55];
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      s[i][j]='A';
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>s[i][j];
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      int cnt=0;
      if(s[i][j]=='.'){
        if(s[i][j+1]=='#'){cnt++;}
        if(s[i][j-1]=='#'){cnt++;}
        if(s[i+1][j]=='#'){cnt++;}
        if(s[i-1][j]=='#'){cnt++;}
        if(s[i+1][j+1]=='#'){cnt++;}
        if(s[i-1][j-1]=='#'){cnt++;}
        if(s[i-1][j+1]=='#'){cnt++;}
        if(s[i+1][j-1]=='#'){cnt++;}
        s[i][j]=(char)(cnt+'0');
      }
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cout<<s[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>

int main () {
  std::string s, t = "";
  std::cin >> s;
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] == 'B') {
      if (!t.empty()) {
        t.pop_back();
      }
    } else {
      t += s[i];
    }
  }
  std::cout << t << "\n";
}

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

int keta(int num){
string s = to_string(num);
int sum = 0;
for (int i = 0; i < s.size(); i++){
sum += s[i] - '0';
}
return sum;
}

int main(){

  int n,a,b,ans = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++){
  if (a <= keta(i) && keta(i) <= b){
  ans += i;
  }
  }
    
   cout << ans << endl; 
return 0;
}

Measured memory_bytes: 256
num = int(input())

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

    divisors.sort()
    return divisors

numDivList = make_divisors(num)
midNum = len(numDivList) // 2

ans = 0
if len(numDivList) % 2 == 0:
	ans = numDivList[midNum-1] + numDivList[midNum] -2
else:
	ans = numDivList[midNum] * 2 -2

print(ans)


Measured memory_bytes: 3296
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>
#include<string>
#include<iostream>

using namespace std;

int main(void){
    int N;
    scanf("%d",&N);
    string word;
    vector<string> v1;
    vector<string> v2;
    vector<int> c1;
    
    for(int i=0;i<N;i++){
        cin >> word;
        v1.push_back(word);
    }

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

    int count = 0;
    int maxlen = 0;

    for(int i=0;i<N;i++){
        if(v1[i]!=v1[i+1]){
            if(maxlen < count) maxlen = count;
            v2.push_back(v1[i]);
            c1.push_back(count);
            count = 0;
        }else{
            count ++;
        }
    }

    for(int i=0;i<c1.size();i++){
        if(c1[i]== maxlen){
            cout << v2[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 20204
#include <iostream>
#include <vector>
std::vector<bool> p;
std::vector<int> c(1001,1);
int n,i,j,inf=1e9+7;
long long a=1;
void sieve(long long n){
  p.resize(n+1, true);
  p[0] = false;
  p[1] = false;
  for(int i=0;i*i<n+1;++i){
    if(p[i]){
      for(int j=2;j*i<n+1;++j)p[i*j]=false;
    }
  }
}
void prime_factorize(long long n){
  while(n>1){
    for(j=2;j<n+1;++j){
      if(p[j])if(n%j==0){++c[j];n/=j;break;}
    }
  }
}
int main(){
  std::cin>>n;
  sieve(n);
  for(i=2;i<n+1;++i)prime_factorize(i);
  for(i=0;i<n+1;++i)a=(a*c[i])%inf;
  std::cout<<a<<"\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from queue import Queue
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort()
#%%
bound = [0]*N
idx = 0
right = 0
while idx<N:
    while right < N and (XH[right][0]-XH[idx][0])<=2*D:
        right += 1
    bound[idx] = right  
    idx += 1
def kiriage(n,m):
    return (n+(m-1))//m

heru = [0]*(N+1)
ans = 0
damage = 0
for i in range(N):
    damage -= heru[i]
    
    if XH[i][1]<=damage:
        continue
    cnt = kiriage(XH[i][1]-damage,A)
    ans += cnt
    damage += cnt*A
    heru[bound[i]] += cnt*A
print(ans)
            
        
        


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin>>N>>K;
    vi P(N);
    vll C(N);
    rep(i,N) cin>>P[i], P[i]--;
    rep(i,N) cin>>C[i];

    ll ans=(ll)-1e18;
    rep(i,N){
        ll cand=0;
        vll vec;
        vec.pb(C[i]);
        int cur=P[i];
        while(cur!=i){
            vec.pb(C[cur]);
            cur = P[cur];
        }
        int V = vec.size();
        vll sum(V+1);
        rep(i,V) sum[i+1]=sum[i]+vec[i];
        ll S = sum[V];
        rep(i,V-1) chmax(sum[i+2],sum[i+1]);
        if (S>0){
            // Max
            int t = K/V;
            cand = S*t + sum[K%V];
            // Max-1
            if (t>0){
                t = K/V-1;
                chmax(cand,S*t + sum[V]);
            }
        }else{
            cand = sum[min(K,V)];
        }
        chmax(ans,cand);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3828
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

S = input()
#print('S', S)
SS = list(S)
a = []
for i in range(97, 97+26):
    a.append(chr(i))

result = list(set(a)-set(SS))
#print('seta', set(a))
#print('setSS', set(SS))
# print(result)
if result == []:
    print('None')
else:
    print(sorted(result)[0])


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	x = m = l = 0;
	rep(i, n){
		cin >> m >> l;
		x += l-m+1;
	}
	cout << x << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,A[400000],i;
long long ans=0;
map<int,int> mp;
main(){
cin>>N;
for(i=0;i<N;cin>>A[i],mp[A[i]+i]++,++i);
for(i=0;i<N;ans+=mp[i-A[i]],++i);
cout<<ans<<endl;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

bool ask(ll n) {
    printf("? %lld\n", n);
    fflush(stdout);
    string s;
    cin >> s;
    return s == "Y";
}

void answer(ll n) {
    printf("! %lld\n", n);
    exit(0);
}

int main() {
    bool ten = ask(TEN(9));
    if (ten) {
        for (int i = 1;; ++i) {
            ll x = 5 * TEN(i - 1);
            bool r = ask(x);
            if (r) {
                answer(TEN(i - 1));
            }
        }
    } else {
        int k;
        for (k = 1;; ++k) {
            ll x = TEN(k - 1);
            bool r = ask(x);
            if (!r) {
                k--;
                break;
            }
        }
        ll lo = TEN(k - 1) - 1, hi = TEN(k);
        while (hi - lo > 1) {
            ll m = (lo + hi) / 2;
            if (ask(m * 10)) {
                hi = m;
            } else {
                lo = m;
            }
        }
        answer(hi);
    }
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
int main () {
    map<char, bool> m;
    char c;
    while (cin >> c) {
        m[c] = 1;
    }
    for (char i = 'a'; i <= 'z'; i++) {
        if (!m[i]) {
            cout << i << endl;
            return 0;
        }
    }
    puts("None");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	char a[3];
	int i,n;
	scanf("%s",&a);
	n=strlen(a);
	if(n==2)
		cout<<a<<endl;
	else
	{
		printf("%c%c%c\n",a[2],a[1],a[0]);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int total = 0;
    int now = 0;
    while(now<n) {
        total += a[now];
        if(total>x) {
            cout << now << endl;
            return 0;
        }
        now++;
    }
    if(total==x) cout << n << endl;
    else cout << n-1 << endl;
  return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define N 110
#define mr make_pair
using namespace std;
int n,c,f[N],a[N];
bool vi[N];
long double dp[310][310][34],no,su;
void dfs(int dep){
	if (dep==n){
		memset(dp,0,sizeof(dp));
		dp[0][a[n]][0]=1;
		for (int i=0;i<=c;i++){
			for (int j=i;j<=c;j++){
				for (int k=0;k<(1<<(n-1));k++){
					if (dp[i][j][k]==0)continue;
					dp[i+1][j][k]+=dp[i][j][k];
					if (i%n!=0){
						int x=f[i%n]-1;
						if ((k&(1<<x))==0)dp[i+1][min(c,max(j,i+a[x+1]))][k+(1<<x)]+=dp[i][j][k];
					}
				}
			}
		}
		no+=dp[c][c][(1<<(n-1))-1];su+=pow(c/n,(n-1));
	}else{
		for (int i=1;i<n;i++)
			if (vi[i]){vi[i]=0;f[dep]=i;dfs(dep+1);vi[i]=1;}
	}
}
int main(){
	cin>>n>>c;c*=n;
	for (int i=1;i<=n;i++){cin>>a[i];a[i]*=n;}
	sort(a+1,a+1+n); 
	for (int i=1;i<n;i++)vi[i]=1;
	dfs(1);
	printf("%.30Lf\n",no/su);
	return 0;
}

Measured memory_bytes: 51456
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *p=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    scanf("%d",&p[i]);
  }

  int count=0;
  rep(i,N){
    if(p[i]!=i+1){
      count++;
    }
  }
  if(count<=2){
    printf("YES\n");
  }
  else{
    printf("NO\n");
  }

  return 0;


}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    int n, l;
    cin >> n >> l;
    vector<int> pie(n);
    int sum = 0;
    REP(i, n){
        pie[i] = l + i;
        sum += pie[i];
    }

    pair<int, int> eat(-1, 1000);
    int m = 1000;
    REP(i,n){
        m = min(m, abs(pie[i]));
        if(m == abs(pie[i])){
            eat.first = i;
            eat.second = pie[i];
        }
    }
    cout << sum - eat.second << "\n";

}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
int n, u[100010], v[100010], w[100010],ans[100010];
vector<edge>g[100010];
bool used[100010];
void dfs(int a, int b) {
	if (used[a])return;
	used[a] = true;
	if (b % 2)ans[a] = 1;
	else ans[a] = 0;
	rep(i, g[a].size()) {
		dfs(g[a][i].to, g[a][i].cost + b);
	}
	return;
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> u[i] >> v[i] >> w[i];
		u[i]--; v[i]--;
		g[u[i]].push_back({ v[i],w[i] });
		g[v[i]].push_back({ u[i],w[i] });
	}
	dfs(0, 0);
	rep(i, n) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 12544
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;
#define FOR(x, a, b)       for (int x = a; x <= b; x++)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define se                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
	#include "DEBUG.hpp"
#else
	#define eprint(...) 0
#endif
template<class T> bool self_min(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool self_max(T &a, T b) { return a < b ? (a = b, true) : false; }

int x[6];

int main(void)
{
	int ans;
	for (int i = 1; i <= 5; i++) {
		scanf("%d", &x[i]);
		if (!x[i]) ans = i;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3760
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int i,j,k,l;
  int h,n,w,s;
  while(cin>>h,h){
    cin>>n>>w>>s;
    vector<string> a;
    string t;
    getline(cin,t);
    while(getline(cin,t),t[0]!='?'){
      int ln=t.length(),sz;
      if(ln){
	if(ln%w)
	  sz=ln/w+1;
	else
	  sz=ln/w;
      }else{
	sz=1;
      }
      for(i=0;i<sz-1;++i)
	a.push_back(t.substr(w*i,w));
      a.push_back(t.substr(w*i));
    }
    int sz;
    if(a.size()%(h*n))
      sz=a.size()/(h*n)+1;
    else
      sz=a.size()/(h*n);
    for(i=0;i<sz;++i){      
      for(j=0;j<h;++j){
	for(k=0;k<n-1;++k){
	  if(h*n*i+j+h*k<(int)a.size()){
	    cout<<a[h*n*i+j+h*k];
	    int ln=a[h*n*i+j+h*k].length();
	    for(l=0;l<w-ln;++l)
	      cout<<'.';
	  }else{
	    for(l=0;l<w;++l)
	      cout<<'.';
	  }
	  for(l=0;l<s;++l)
	    cout<<'.';
	}
	if(h*n*i+j+h*k<(int)a.size()){
	  cout<<a[h*n*i+j+h*k];
	  int ln=a[h*n*i+j+h*k].length();
	  for(l=0;l<w-ln;++l)
	    cout<<'.';
	}else{
	  for(l=0;l<w;++l)
	    cout<<'.';
	}
	cout<<endl;
      }
      cout<<'#'<<endl;
    }
    cout<<'?'<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
S = input()
T = input()

s = list(S)

cnt = 0
jdg = False
while cnt <= len(s):
    p = s.pop()
    s = list(p) + s
    if ''.join(s) == T:
        jdg = True
        break
    cnt += 1
print('Yes' if jdg else 'No')

Measured memory_bytes: 3060
use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n:usize = sc.next().unwrap();
    let mut a : Vec<i32>= vec![];

    let mut res = 0;
    for i in 0..n {
        a.push(sc.next().unwrap());
        res += a[i];
    }
    if res % 10 != 0 {
        println!("{}", res);
        return;
    }
    let mut res2 = 0;
    for i in 0..n {
        if a[i] % 10 != 0 {
            if res2 < res - a[i] {
                res2 = res - a[i];
            }
        }
    }
    println!("{}", res2);
}

/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next().unwrap());
/// assert_eq!(3.5, sc.next().unwrap());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector< vector<int> >g;
int main(){

    int s, f; cin >> n >> m;

    g.assign(n+5, vector<int>());

    while( m-- ){
        cin >> s >> f;
        g[s].push_back(f);
        g[f].push_back(s);
    }
    bool ok = false;
    for( auto it: g[1] ){
        for( auto ot: g[it] ){
            if( ot == n ){
                ok = true;
            }
        }
    }

    if( ok ) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";

}


Measured memory_bytes: 12016
#include<iostream>

using namespace std;

int main()
{
int x,y;

while (1)
{
cin >> x >> y;

if (x == 0 && y == 0)
break;

for (int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
 if ((i + j) % 2 == 0)
  cout << '#';
 else
  cout << '.';
}
cout << endl;
}
cout << endl;
}
return 0;
}

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	static int[] dp;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		dp = new int[n + 1];

		System.out.println(f(n));
	}

	static int f(int n) {

		if (n == 0)
			return 1;
		if (n == 1)
			return 1;

		if (dp[n] != 0)
			return dp[n];

		return dp[n] = f(n - 1) + f(n - 2);

	}

}

Measured memory_bytes: 24400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

ll n,a,b;
vector<ll> h(100010);

bool solve(ll x){
  ll cnt=0;
  rep(i,n){
    if(h[i]-b*x>0) cnt+=(h[i]-b*x+a-b-1)/(a-b);
  }
  return cnt<=x;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>a>>b;
  rep(i,n) cin>>h[i];
  ll high=1e10,low=-1,mid;
  while(high-low>1){
    mid=(high+low)/2;
    if(solve(mid)) high=mid;
    else low=mid;
  }
  cout<<high<<endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 02:20:28 2020

@author: liang
"""

S = input()
i = 0
max = 0
cnt = 0
chars = ['A', 'C', 'G', 'T']
for i in range(len(S)):
    if S[i] in chars :
        cnt += 1
    else:
        cnt = 0
    if cnt > max:
        max = cnt
print(max)

    
    

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N;
  // int M;
  array<int, 10000> A;
  // string S;
  // string T;

  int i;

  cin >> N >> i;
  cout << N - i + 1 << endl;
  
  
  // cin >> N;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   cin >> *it;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   if (*it % 2 == 0) ++num;
  // cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 768
# ABC109B - Shiritori
def main():
    N, *W = open(0).read().split()
    cur, used = W[0], {W[0]}
    for i in W[1:]:
        if cur[-1] == i[0] and i not in used:
            cur = i
            used.add(i)
        else:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES

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

using namespace std;

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

long long int a[110000];

int main(){
	
	long long int n, q;
	cin >> n >> q;
	
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	a[0] = 0;
	n++;
	
	for(int loop = 0; loop < q; loop++){
		long long int S;
		cin >> S;
		long long int ans = 0;
		long long int sum = 0;
		int id = 0;
		for(int i = 0; i < n; i++){
			sum -= a[i];
			if(id < i){
				sum = 0;
				id = i;
			}
			while(true){
				id++;
				if(id >= n){
					id--;
					break;
				}
				if(sum + a[id] > S){
					id--;
					break;
				}
				sum += a[id];
			}
			//cout << i << " " << id << endl;
			ans += id - i;
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3896
//Peaks

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int N,M;cin>>N>>M;
    vector<ll> H(N);
    vector<vector<ll>> A(M,vector<ll>(2));
    rep(i,0,N)cin>>H[i];
    rep(i,0,M)rep(j,0,2)cin>>A[i][j];
    map<int,bool> m{};
    rep(i,0,N)m[i]=true;
    rep(i,0,M){
        if(H[A[i][0]-1]>H[A[i][1]-1])m[A[i][1]-1]=false;
        else if(H[A[i][0]-1]==H[A[i][1]-1]){m[A[i][1]-1]=false;m[A[i][0]-1]=false;}
        else m[A[i][0]-1]=false;
    }
    ll ans=0;
    rep(i,0,N)if(m[i])ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14308
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
long long int dp[50005][2];
int main(void) 
{
	int N,P;
	scanf("%d %d",&N,&P);
	dp[0][0]=1;
	for(int i=1;i<=N;i++)
	{
		int a;
		scanf("%d",&a);
		if(a%2)
		{
			dp[i][1] = dp[i-1][1] + dp[i-1][0];
			dp[i][0] = dp[i-1][1] + dp[i-1][0];
		}
		else
		{
			dp[i][1] = dp[i-1][1] + dp[i-1][1];
			dp[i][0] = dp[i-1][0] + dp[i-1][0];
		}
	}
	printf("%lld\n",dp[N][P]);
	return 0;
}

Measured memory_bytes: 256
open Str

let read_list () =
  split (regexp " +") (read_line ())
                                                 
let () =
  let com = read_list () in
  let rec iter stack = function
      [] -> List.hd stack
    | "+" :: rs -> begin
        match stack with
          x :: y :: ys -> iter ((y + x) :: ys) rs
        | _ -> failwith "stack"
      end
    | "-" :: rs -> begin
        match stack with
          x :: y :: ys -> iter ((y - x) :: ys) rs
        | _ -> failwith "stack"
      end
    | "*" :: rs -> begin
        match stack with
          x :: y :: ys -> iter ((y * x) :: ys) rs
        | _ -> failwith "stack"
      end
    | n :: rs -> iter ((int_of_string n) :: stack) rs
  in
  iter [] com |> string_of_int |> print_endline

Measured memory_bytes: 2200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

ll tonum(string s){
	ll res=0;
	for(char c:s){
		res*=10;
		res+=c-'0';
	}
	return res;
}

ll make(int n,vector<int> v){
	ll res=0;
	for(int i=0;i<n;i++){
		res*=10;
		res+=v[i];
	}
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n=s.size();
	ll num=tonum(s);
	ll ten=1;
	for(int i=0;i<n;i++){
		ten*=10;
	}
	vector<int> v(10);
	ll ma=0;
	ll ans=ten;
	for(int i=0;i<10;i++){
		v[i]=i;
	}
	do{
		ll t=make(n,v);
		if(ma<min(abs(num-t),ten-abs(num-t))){
			ans=t;
		}
		else if(ma==min(abs(num-t),ten-abs(num-t))){
			ans=min(ans,t);
		}
		ma=max({ma,min(abs(num-t),ten-abs(num-t))});
	}while(next_permutation(v.begin(),v.end()));
	if(ans<ten/10)cout << 0;
	cout << ans << endl;
}


Measured memory_bytes: 3252
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
ll f(ll b, ll n) {
  if(n < b) return n;
  ll ret = n % b;
  ret += f(b, n / b);
  return ret;
}
int main()
{
  ll n, s;
  cin >> n >> s;
  if(n==s) {
    cout << n + 1 << endl;
    return 0;
  }
  FOR(i,2,sqrt(n)+1) {
    if(s == f(i, n)) {
      cout << i << endl;
      return 0;
    }
  }
  ll ans = 1e15;
  FOR(p,1,sqrt(n)+1) {
    if((n-s)%p==0 && (n-s)>=p) {
      if(s == f((n-s)/p+1, n)) {
        ans = min(ans, (n-s)/p+1);
      }
    }
  }
  if(ans != 1e15) {
    cout << ans << endl;
  } else {
    puts("-1");
  }
  return 0;
}

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

using namespace std;

#define INF 1 << 25

int dp[1500000];
int dp2[1500000];

int main()
{
  int n;
  int tetra[200];
  for(int i = 0; i < 200; i++) tetra[i] = (i+1)*(i+2)*(i+3)/6;
  for(int i = 0; i < 1500000; i++) dp[i] = dp2[i] = INF;
  dp[0] = dp2[0] = 0;
  for(int i = 0; i < 200; i++){
    dp[tetra[i]] = 1;
    if(tetra[i]%2 == 1) dp2[tetra[i]] = 1;
  }
  for(int i = 0; i < 200; i++){
    for(int j = 0; j + tetra[i] <= 1000000; j++){
      dp[j+tetra[i]] = min(dp[j+tetra[i]], dp[j] + dp[tetra[i]]);
      if(tetra[i]%2) dp2[j+tetra[i]] = min(dp2[j+tetra[i]], dp2[j] + dp2[tetra[i]]);
    }
  }
  while(cin >> n, n){
    cout << dp[n] << " " << dp2[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 12876
#include <bits/stdc++.h>
using namespace std;
int h,n,a[100010];
int main(){
	int sum=0;
	cin>>h>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		h-=x;
	}
	cout<<(h>0?"No":"Yes")<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String str = sc.next();
      int a = 0;
      int result = 0;
      for(int i = 0;i < str.length();i++){
      	a = getLength(str,i,0);
        result = Math.max(a,result);
      }
      System.out.println(result);
    }
  
  	public static int getLength(String s,int n,int total){
      if(n >= s.length()){
      	return total;
      }
      char x = s.charAt(n);
      if(x=='A'||x=='C'||x=='G'||x=='T'){
      	return getLength(s,n+1,total)+1;
      }else{
      	return total;
      }
    }
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(void) {

    int a, b, c, d;

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

    if (a > b) {

        d = a;
        a = b;
        b = d;

    }

    if (b > c) {

        d = b;
        b = c;
        c = d;

    }

    if (a > b) {

        d = a;
        a = b;
        b = d;

    }

    printf ("%d %d %d\n", a, b, c);


    return 0;
}



Measured memory_bytes: 2064
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  vector<int> B(N);
  int maxa = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    maxa = max(maxa, A[i]);
  }

  vector<int> dp(H+1,1<<30);
  dp[0] = 0;
  for (int h = 1; h <= H + maxa; ++h) {
    for (int i = 0; i != N; ++i) {
      auto j = max(0, h - A[i]);
      if (j >= H) continue;
      auto hh = min(H, h);
      dp[hh] = min(dp[hh], dp[j] + B[i]);
    }
  }

  cout << dp[H] << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> dist[n];
    rep(i,n) dist[i].assign(n,INF);
    
    rep(i,n) dist[i][i] = 0;

    rep(i,n){
        rep(j,n){
            char a;
            cin>>a;
            if(a=='1') dist[i][j]=1;
        }
    }
    
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
    int ng=0;
    int ans=0;
    rep(i,n){
        rep(j,n){
            ans=max(ans,dist[i][j]);
            rep(k,n){
                if(dist[i][j]%2!=(dist[i][k]+dist[k][j])%2) ng++;
            }
        }
    }
    // cout<<ng<<endl;
    if(ng==0){
        cout<<ans+1<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    IOS;
    //freopen("inputfile.txt","r",stdin);
    ll n;cin>>n;
    map <ll,ll> ma;
    //map <int,int>::iterator it;
    ll msum = 0;
    for(ll i=0;i<n;i++)
    {
        ll x;cin>>x;
        msum+=x;
        ma[x]++;
    }
    ll t;cin>>t;
    while(t--){
    ll v,val;cin>>v>>val;

    ma[val]+=ma[v];
    msum += (val-v)*ma[v];
    ma[v] = 0;
    cout<<msum<<endl;
    }
   return 0;
}



Measured memory_bytes: 9564
import java.util.Scanner;

class Main
{
	public static void main(String a[])
	{
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		if(x%y==0 || x==y)
		{
			System.out.println("-1");
			System.exit(0);
		}
		else if(y%x==0)
		{
			if((2*x)%y==0 || (2*x)==y)
			{
				System.out.println(3*x);
			}
			else
			{
				System.out.println(2*x);
			}
		}
		else
		{
			for(int i=2;i<10;i++)
			{
				if((i*x)%y!=0)
				{
					System.out.println(i*x);
					System.exit(0);		
				}
			}
			
		}
	}
}

Measured memory_bytes: 22612
def main():

    N = int(input())
    P = list(map(int, input().split()))
    count = 0
    for i in range(N-1):
        if P[i] == i+1:
            P[i], P[i+1] = P[i+1], P[i]
            count += 1
    if P[N-1] == N:
        count += 1
    return count
        
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 14008
n = int(input())
X = [int(_) for _ in input().split()]
Y = [int(_) for _ in input().split()]

d1, d2, d3, d = 0, 0, 0, 0 
for x, y in zip(X, Y):
    d1 += abs(x - y)
    d2 += abs(x - y) ** 2
    d3 += abs(x - y) ** 3
    d = max(d, abs(x - y))

print(d1)
print(d2 ** (1/2))
print(d3 ** (1/3))
print(d)



Measured memory_bytes: 5648
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

const int INF = 1000000000;
int a[10][1000];
int b[10][1000];
int H, W, K;

int main() {
  cin >> H >> W >> K;
  string s[10];
  rep(i, H) {
    cin >> s[i];
  }

  rep(i, H) {
    rep(j, W) {
      a[i][j] = s[i][j] - '0';
    }
  }

  rep(i, H) {
    rep(j, W) {
      b[i][j] = a[i][j];
    }
  }

  rep(i, H) {
    rep(j, W-1) {
      b[i][j+1] += b[i][j];
    }
  }

  rep(i, H-1) {
    rep(j, W) {
      b[i+1][j] += b[i][j];
    }
  }

  int ans = INF;
  
  // rep(i, H) {
  //   rep(j, W) {
  //     cout << b[i][j];
  //   }
  //   cout << endl;
  // }

  rep(bit, (1<<(H-1))) {
    int count = 0;
    vector<int> v;
    rep(i, H-1) {
      if(bit & (1<<i)) {
        v.push_back(i);
        count++;
      }
    }
      v.push_back(H-1);
      int key = -1;
      bool f = false;
      rep(j, W) {
        rep(k, v.size()) {
          // cout << j << " " << v[k] << " " << key << " " << count << endl;
            if(k == 0) {
              if(key == -1) {
                if(b[v[k]][j] > K) {
                  if(j - key == 1) {
                    f = true;
                    break;
                  } 
                  key = j-1;
                  count++;
                  break;
                }
              } else {
                if(b[v[k]][j] - b[v[k]][key] > K) {
                  if(j - key == 1) {
                    f = true;
                    break;
                  } 
                  key = j-1;
                  count++;
                  break;
                }
              }
            } else {
              if(key == -1) {
                if(b[v[k]][j] - b[v[k-1]][j] > K) {
                  if(j - key == 1) {
                    f = true;
                    break;
                  } 
                  key = j-1;
                  count++;
                  break;
                }
              } else {
                if((b[v[k]][j] - b[v[k-1]][j]) - (b[v[k]][key] - b[v[k-1]][key]) > K) {
                  if(j - key == 1) {
                    f = true;
                    break;
                  } 
                  key = j-1;
                  count++;
                  break;
                }
              }
            }
        }
        if(f) break;
      }
      // cout << count << endl;
    if(!f) ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h> 
using namespace std; 
#define endl "\n";
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,s1;
    cin>>s>>s1;
    ll max=0;
    if(s1==s)
        {cout<<"0"<<endl;return 0;}
    else if(s1.length()==s.length())
    {
        int c=0;
        for(int i=0;i<s.length();i++)
        {
            if(s[i]==s1[i])
                c++;
        }
        cout<<s1.length()-c<<endl;
    }
    else
    {
    for(int i=0;i<s.length()-s1.length();i++)
    {
        int c=0;
        string w=s.substr(i,s1.length());
        for(int j=0;j<w.length();j++)
        {
            if(w[j]==s1[j])
            c++;
        }
        if(c>max)
            max=c;
    }
    cout<<s1.length()-max<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define pb push_back
#define ll long long
#define PI 3.14159265
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define eps 1e-7
const int mod=1e9+7;
const int maxn=1e5+5;
using namespace std;
int a[1000];
ll n,y;
void slove()
{
    for(int i=0;i<=n;i++)
    for(int j=0;j<=n-i;j++)
    {
        if(i*10000+j*5000+(n-i-j)*1000==y)
        {
            cout<<i<<' '<<j<<' '<<n-i-j<<endl;
            return ;
        }
    }
    cout<<"-1 -1 -1"<<endl;
}
int main()
{
     std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>y;
    slove();
  /*  int tmp=y%10000;
    int t1=y/10000;
    int tmp2=tmp%5000;
    int t2=tmp/5000;
    int tmp3=tmp2%1000;
    int t3=tmp2/1000;
    if(tmp3==0&&t1+t2+t3<=n)
    {
        cout<<t1<<' '<<t2<<' '<<t3<<endl;
    }
    else
    {
        cout<<"-1 -1 -1"<<endl;
    }*/
    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }


const int MAX_N = 100000;
int n;
pii ba[MAX_N];
pii a[MAX_N];

int main()
{
  fastio();

  cin >> n;
  forn(i,n) cin >> ba[i].snd;
  forn(i,n) cin >> ba[i].fst;

  sort(ba,ba+n);

  forn(i,n) {
    a[i] = mp(ba[i].snd,i);
  }

  sort(a,a+n);

  forn(i,n) {
    if (a[i].fst > ba[i].fst) {
      cout << "No\n";
      return 0;
    }
  }

  int c = 1;
  int i = 0;
  while (a[i].snd != 0) {
    c++;
    i = a[i].snd;
  }

  if (c < n) {
    cout << "Yes\n";
    return 0;
  }

  forn(i,n-1) {
    if (a[i+1].fst <= ba[i].fst) {
      cout << "Yes\n";
      return 0;
    }
  }

  cout << "No\n";

  return 0;
}


Measured memory_bytes: 1792
// prakhsri_
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define ll int
#define pb push_back
#define mp make_pair
#define fi first    
#define se second
#define mod 1000000 
void solve()
{
    string s;
    cin>>s;
    ll i,j,k,f=0;
    for(i=0;i<s.size();i++)
    {
        if(i%2==0 && s[i]!='h')
            f=1;
        if(i%2!=0 && s[i]!='i')
            f=1;
    }
    if(f==1 || s.size()%2!=0)
        cout<<"No";
    else
        cout<<"Yes";
}
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    clock_t tStart = clock();
    // int t;
    // cin>>t;
    // while(t--)
       solve();
    // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}       

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long 
const int N=3e5+9;
using namespace std;
char s[N];
int vis[N],a[N];
LL ans;
int main()
{
	scanf("%s",&s);
	int len=strlen(s);
	for(int i=1;i<=len;++i) a[i]=s[i-1]-'a';
	
	vis[a[1]]++;
	for(int i=2;i<=len;++i)
	{
	   ans=ans+i-1-vis[a[i]];
	   vis[a[i]]++;	
	} 
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 1280
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
//class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
        BufferedReader stdReader =
            new BufferedReader(new InputStreamReader(System.in));
        String[] nums = stdReader.readLine().split(" ");
         
        int a = Integer.parseInt(nums[0]);
        int b = Integer.parseInt(nums[1]);
        
        if(a > b) {
        	System.out.println("a > b");
        } else if(a < b) {
        	System.out.println("a < b");
        } else {
        	System.out.println("a == b");
        }
	}
}

Measured memory_bytes: 17032