akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define N 15
#define mod 1000000007
int n,m,f[1<<N],cnt[N+5][1<<N],g[N+5][1<<N],ans=1;
bool st[N+5][1<<N],ok[1<<N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		st[u][1<<(v-1)]=true;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<(1<<n);j++)
			cnt[i][j]=cnt[i][j^(j&(-j))]+st[i][j&(-j)],g[i][j]=(1<<cnt[i][j])-1;
	for(int i=0;i<(1<<n);i++) ok[i]=((i&1)>0)==((i&2)>0);
	f[0]=1;
	for(int i=1;i<(1<<n);i++)
		if(ok[i])
		{
			f[i]=1;
			for(int j=(i-1)&i;j;j=(j-1)&i)
				if(ok[j])
				{
					int k=i^j,s=f[i^j];
					for(int x=0;x<n;x++)
						if((1<<x)&k) s=1ll*s*g[x+1][j]%mod;
						else if((1<<x)&j) s=1ll*s*(1<<cnt[x+1][k])%mod;
					f[i]=(f[i]+s)%mod;
				}
		}
	for(int i=1;i<=m;i++) ans=ans*2%mod;
	ans=(ans-f[(1<<n)-1]+mod)%mod;
	printf("%d\n",ans);
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  vector<int> n;
    int k;
    string ans = ":(";
  REP(i, 5){
      int at;
      cin >> at;
      n.pb(at);
    }
    cin >> k;
    sort(n.begin(),n.end());

    if((n[4] - n[0]) <= k) ans = "Yay!";
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	vector<vector<pair<int, int>>> m(n);

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c;
			cin >> v >> c;
			m[u].emplace_back(v, c);
		}
	}

	vector<int> d(n, INF), color(n);

	d[0] = 0;
	color[0] = 1;
	while (true) {
		int minv = INF;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != 2) {
				u = i;
				minv = d[i];
			}
		}

		if (u == -1) {
			break;
		}

		color[u] = 2;
		for (auto e : m[u]) {
			if (color[e.first] != 2 && d[e.first] > d[u] + e.second) {
				d[e.first] = d[u] + e.second;
				color[e.first] = 1;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
	}
	return 0;
}



Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    double a[6], b[6];
    rep(i,6){
        cin>>a[i];a[i]/=100;
    }
    rep(i,6){
        cin>>b[i];b[i]/=100;
    }
    double l = 0, r = 1.0;
    auto calc = [&](double x){
        double ret = 0;
        rep(i,6)ret += max(x*a[i],(1-x)*b[i]);
        return ret;
    };
    rep(_,60){
        double l1 = (2*l+r)/3, r1 = (l+2*r)/3;
        if(calc(l1)>calc(r1))l=l1;
        else r=r1;
    }
    cout<<setprecision(12)<<calc(l)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    if(n%2){
        ll ma,mb;
        ma = a[n/2];
        mb = b[n/2];
        cout<<(mb-ma)+1<<endl;
    }else{

        ll ma,mb;
        ma = (a[n/2-1]+a[n/2])*10;
        mb = (b[n/2-1]+b[n/2])*10;
        ma/=2.0;
        mb/=2.0;
        cout<<(mb/5-ma/5)+1<<endl;





        
    }





return 0;
}


Measured memory_bytes: 6432
from operator import itemgetter

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[]

for i in range(m):
    x=list(map(int,input().split()))
    bc.append(x)

a.sort()
bc.sort(key=itemgetter(1),reverse=True)

k=0
for i in range(m):
    b=bc[i][0]
    c=bc[i][1]
    for j in range(b):
        if(a[k]>c):
            break
        a[k]=c
        k+=1
        if(k>n-1):
            break
    else:
        continue
    break

print(sum(a))

Measured memory_bytes: 32964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll>> 
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define rep(i,start,end) for(int i=start;i<end;i++)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()  
#define sz(x) (ll)(x).size()
//////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
	fast;
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	vector<ll> left(n), right(n);
	left[0] = v[0];
	for(int i=1;i<n;i++)
		left[i] = __gcd(left[i-1],v[i]);
	right[n-1] = v[n-1];
	for(int i=n-2;i>=0;i--)
		right[i] = __gcd(right[i+1],v[i]);
	ll maxx = 1;
	for(int i=0;i<n;i++)
		maxx = max(maxx,__gcd(i>=1?left[i-1]:0,(i+1<n)?right[i+1]:0));
	cout<<maxx;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
//けんちょんさんの記事からコピペ
const int MAX = 2010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();

  int n,k;
  scanf("%d%d\n",&n,&k);
  for(int i = 1; i <= k; ++i){
    if(i <= n-k+1){
      printf("%lld\n",(COM(n-k+1,i) * COM(k-1,i-1)) % MOD);
    }else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
x, a = M()
if x < a:
    print(0)
else:
    print(10)

Measured memory_bytes: 38512
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
C = Counter(S)
l = []
max = C.most_common(1)[0][1]
for c in C.most_common():
    if max == c[1]:
        l.append(c[0])
    else:
        break
l.sort()
for x in l:
    print(x)

Measured memory_bytes: 45040
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new RitProE().doIt();
	}
	class RitProE{
		int n,m,e,start,end,days;
		boolean[][] map;
		int[][] eventMap;
		int[] a,b,c;
		void doIt(){
			n = in.nextInt();
			m = in.nextInt();
			e = in.nextInt();
			start = in.nextInt();
			end = in.nextInt();
			days = in.nextInt();
			map = new boolean[n][n];
			a = new int[e];
			b = new int[e];
			c = new int[e];
			for(int i=0;i<m;i++){
				int a = in.nextInt();
				int b = in.nextInt();
				map[a][b] = map[b][a] = true;
			}
			for(int i=0;i<e;i++){
				a[i] = in.nextInt();
				b[i] = in.nextInt();
				c[i] = in.nextInt();
			}
			int result = djkstra(start);
			System.out.println(result);
		}
		
		int djkstra(int v){
			PriorityQueue<Data> q = new PriorityQueue<Main.RitProE.Data>();
			int bbit = 0;
			for(int i=0;i<e;i++)if(c[i] == v){
				bbit |= 1 << i;
				break;
			}
			q.add(new Data(v, 0, bbit, 0));
			boolean[][][] close = new boolean[n][days+3][1<<8];
			while(q.size()>0){
				Data d = q.remove();
				int d_v = d.v;
				int cost = d.cost;
				int day = d.day;
				int bit = d.bit;

				if(days < day)continue;
//				System.out.println(" v= "+d_v+" cost= "+cost+" day= "+day+" bit= "+Integer.toBinaryString(bit));
				if(d.v == end)return d.cost;
				for(int i=0;i<e;i++)if(c[i] == d.v){
					bit |= 1 << i;
					break;
				}
				for(int i=0;i<n;i++){//normal mode
					if(map[d.v][i]){
						Data data = new Data(i, day+1, bit, cost+1);
						if (close[data.v][data.day][data.bit])continue;
						close[data.v][data.day][data.bit] = true;
						q.add(data);
						
					}
				}
				
				Data data = new Data(start, 0, bit, cost+1);
				if (close[data.v][data.day][data.bit] == false)q.add(data);
				close[data.v][data.day][data.bit] = true;
				
				for(int i=0;i<e;i++){
					if (((bit >> i) & 1) == 1) {
						if(a[i] == d.v){
							data = new Data(b[i], day+1, bit, cost+1);
							if (close[data.v][data.day][data.bit] == false)q.add(data);
							close[data.v][data.day][data.bit] = true;
						}else if(b[i] == d.v){
							data = new Data(a[i], day+1, bit, cost+1);
							if (close[data.v][data.day][data.bit] == false)q.add(data);
							close[data.v][data.day][data.bit] = true;
						}
					}
				}
			}
			return -1;
		}
		
		class Data implements Comparable<Data>{
			int v,day,bit,cost;
			public Data(int v,int day,int bit, int cost){
				this.v = v;
				this.day = day;
				this.bit = bit;
				this.cost = cost;
			}
			public int compareTo(Data o) {
				return this.cost-o.cost;
			}
		}
		
	}
}

Measured memory_bytes: 30968
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

type node struct {
	item   int
	prev   *node
	rank   int
	weight int
}

func (n *node) root() *node {
	if n.prev == nil {
		return n
	}
	r := n.prev.root()
	n.weight += n.prev.weight
	n.prev = r
	return r
}

func diff(nodeX, nodeY *node) int {
	return nodeY.Weight() - nodeX.Weight()
}

func issame(nodeX, nodeY *node) bool {
	return nodeX.root() == nodeY.root()

}

func (n *node) Weight() int {
	n.root()
	return n.weight
}

func merge(nodeX, nodeY *node, w int) {
	w += nodeX.Weight()
	w -= nodeY.Weight()

	nodeX = nodeX.root()
	nodeY = nodeY.root()
	if nodeX.item == nodeY.item {
		return
	}

	if nodeX.rank < nodeY.rank {
		nodeX, nodeY = nodeY, nodeX
		w *= -1
	}

	if nodeX.rank == nodeY.rank {
		nodeX.rank += 1
	}

	if nodeX.prev != nil || nodeY.prev != nil {
		panic(fmt.Sprintf("%v, %v", nodeX, nodeY))
	}

	nodeY.prev = nodeX
	nodeY.weight = w

}

func main() {
	sc.Split(bufio.ScanWords)
	var n, q int
	fmt.Scanf("%d %d", &n, &q)

	groups := make([]*node, n)
	for i := 0; i < n; i++ {
		groups[i] = &node{item: i, prev: nil, rank: 0}
	}

	for i := 0; i < q; i++ {
		com, x, y := next(), next(), next()
		if com == 0 {
			z := next()
			merge(groups[x], groups[y], z)

		} else {
			if issame(groups[x], groups[y]) {
				fmt.Println(diff(groups[x], groups[y]))
			} else {
				fmt.Println("?")
			}
		}
	}

}




Measured memory_bytes: 9508
def cycle(n, x, c):
    if c == 0:
        return 1 if n >= x >= 1 else 0
    a = 0
    for i in range(min(n, x - c), c - 1, -1):
        a += 0 if c == 1 and i == x - i else cycle(i - 1, x - i, 1 if c == 3 else 0)
    return a

while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    print(cycle(n, x, 3))


Measured memory_bytes: 5596
import sys
readline = sys.stdin.readline

N = int(readline())

stack = [3,5,7]
ans = 0

all = {"3","5","7"}
def isOk(x):
  return len(all - set(str(x))) == 0
  
while stack:
  num = stack.pop()
  if num > N:
    continue
  if isOk(num):
    ans += 1
  for i in (3,5,7):
    stack.append(num * 10 + i)
  
print(ans)

Measured memory_bytes: 3064
class cmbs(object):
    def __init__(self, mod):
        self.mod = mod
        self.g1 = [1, 1]
        self.g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, 10 ** 6 + 1):
            self.g1.append((self.g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            self.g2.append((self.g2[-1] * inverse[-1]) % mod)

    def cmb(self, n, r):
        if n > 10 ** 6:
            return self.cmbl(n, r)
        return self.cmbr(n, r)

    def cmbr(self, n, r):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.mod

    def cmbl(self, n, r):
        t = 1
        r = min(r, n-r)
        for i in range(n - r + 1, n + 1):
            t = t * i % self.mod
        return t * self.g2[r] % self.mod
def main():
    H, W, A, B = map(int, input().split())
    mod = 10**9 + 7
    c = cmbs(mod)
    r = c.cmb(H+W-2, H-1)
    for i in range(1, B+1):
        r -= c.cmb(H-A+i-2, i-1) * c.cmb(A-1+W-i, A-1)
    return r % mod
print(main())


Measured memory_bytes: 127560
use std::collections::HashMap;
use std::cmp;

fn main() {
    const INF : i32 = 10000;
    let ascii_lower = String::from("abcdefghijklmnopqrstuvwxyz");

    let mut vec = vec![];

    let n = read();
    for _ in 0..n {
        let mut map = HashMap::new();
        let s = read_line_str();
        for c in s.chars() {
            if map.contains_key(&c) {
                *map.get_mut(&c).unwrap() += 1;
            } else {
                map.insert(c, 1);
            }
        }
        vec.push(map);
    }

    let mut table = HashMap::new();

    for c in ascii_lower.chars() {
        let mut cnt = INF;
        for map in &vec {
            if map.contains_key(&c) {
                cnt = cmp::min(*map.get(&c).unwrap(), cnt);
            } else {
                cnt = 0;
            }
        }
        if cnt >= 1 {
            table.insert(c, cnt);
        }
    }

    let mut ans = String::from("");
    for c in ascii_lower.chars() {
        if table.contains_key(&c) {
            for _ in 0..*table.get(&c).unwrap() {
                ans.push(c);
            }
        }
    }

    // println!("{:?}", table);
    println!("{}", ans);
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_line_str() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  int cl, op;
  cl = op = 0;
  int n;
  cin>>n;
  string s;
  cin>>s;
  rep(i, 0, n)
  {
    if(s[i] == '(')
    {
      op++;
    }
    else
    {
      if(op >= 1) op--;
      else cl++;
    }
  }
  rep(i, 0, cl) cout<<'(';
  cout<<s;
  rep(i, 0, op) cout<<')';
  cout<<endl;
  return 0;
}


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

int main(){
    int n,d;
    cin >> n >> d;
    int ans = n/(2*d+1);
    if(n%(2*d+1))ans ++;
    cout << ans;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
using namespace std;
int main(){
  int h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int lastm=m2-k;
  int lasth=h2;
  while(lastm<0){
    lastm=60+lastm;
    lasth--;
  }
  int ans=0;
  if((lasth<h1)||(lasth==h1&&lastm==m1)) ans=0;
  else if(lastm<m1) ans=60*(lasth-h1-1)+(60-m1+lastm);
  else ans=60*(lasth-h1)+(lastm-m1);
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>

using namespace std;


int main() {
  int n;
  int v1sum = 0, v2sum = 0;
  cin >> n;
  vector<int> v1(n);
  vector<int> v2(n);
  for (int i = 0; i < n; i++) cin >> v1[i];
  for (int i = 0; i < n; i++) { cin >> v2[i]; v2sum += v2[i]; }

  int x = 0;

  for (int i = 0; i < n; i++) {
    v1sum += v1[i];
    x = max(v1sum + v2sum, x);
    v2sum -= v2[i];
  }

  cout << x;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int ans1 = 1;
    for (int i = 0; i < n-1; ++i) {
        if(v[i] >= v[i+1]) ans1++;
    }
    cout << ans1 << "\n";
    cout << n << "\n";
    return 0;
}


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

int main(void){
  int N, M;
  cin >> N >> M;
  const int nmax = 50;
  char A[nmax][nmax], B[nmax][nmax];
  
  rep(i, N){
    rep(j, N){
      cin >> A[i][j];
    }
  }
  
  rep(i, M){
    rep(j, M){
      cin >> B[i][j];
    }
  }
  
  bool exist = false;
  rep(i, N){
    rep(j, N){
      bool match = true;
      
      rep(k, M){
        rep(l, M){
          if (A[i+k][j+l] != B[k][l]) match = false;
        }
      }
      if (match) exist = true;
    }
  }
  
  if (exist) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int inf = 1e8;
const int sz = 1005;
ll n;

int main() {

    while (cin >> n) {
        
        ll ans = 0;

        ans = (n * (n + 1)) / 2ll;

        ans -= n;

        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
l = []
cnt = [0 for i in range(N+1)]
k_id = [0 for i in range(M)]
for i in range(M):
    P, Y = map(int, input().split())
    l.append([Y, P , i])
l.sort(key=lambda x: x[0])
for i in range(M):
    y, p, idx = l[i][0], l[i][1], l[i][2]
    cnt[p] += 1
    k_id[idx] = [p, cnt[p]]
for i in range(M):
    print(str(k_id[i][0]).zfill(6)+str(k_id[i][1]).zfill(6))

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

void fnInput(vector<string>& rvsStrX, vector<string>& rvsStrY)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i)
  {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string>& cnrvsStrX, const vector<string>& cnrvsStrY)
{
  for (int i = 0; i < cnrvsStrX.size(); ++i)
  {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();
    vector<vector<int>> vvnLcsDP(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}

Measured memory_bytes: 6972
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;


signed main(){
    string s;
    int k;
    cin >> s >> k;

    for(int i = 0;i < s.size() ;i++){
        if(s[i] !=  'a' && k >= 'z'-s[i]+1){
            k -= 'z'-s[i]+1;
            s[i] = 'a';
        }
    }

    s[s.size()-1] =  'a' + (k+s[s.size()-1]-'a')%26; 

    cout << s << endl;


    

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0.0 0.0
2.0 0.0
1.0 1.0

output:
1.41421356237
"""

import sys
from operator import attrgetter


class ClosestPair(object):
    def __init__(self, ):
        """
        Init closest pairs points set.
        """
        _input = sys.stdin.readlines()
        p_num = int(_input[0])
        points = map(lambda x: x.split(), _input[1:])
        p_list = [complex(float(x), float(y)) for x, y in points]
        # pre_sort by axis_X
        p_list.sort(key=attrgetter('real'))

        ans = self.closest_pair(array=p_list, array_length=p_num)
        print(('{:.6f}'.format(ans)))

    def closest_pair(self, array, array_length):
        if array_length <= 1:
            return float('inf')
        mid_idx = array_length // 2
        div_line = array[mid_idx].real
        d_min = min(self.closest_pair(array[:mid_idx], mid_idx),
                self.closest_pair(array[mid_idx:], array_length - mid_idx))

        # sort array_part by axis_Y while recursively comparing
        array.sort(key=attrgetter('imag'))

        min_stack = list()
        for ele in array:
            size = len(min_stack)

            if abs(ele.real - div_line) >= d_min:
                continue

            for j in range(size):
                alt = ele - min_stack[size - j - 1]
                if alt.imag >= d_min:
                    break
                d_min = min(d_min, abs(alt))

            min_stack.append(ele)

        return d_min


if __name__ == '__main__':
    case = ClosestPair()

Measured memory_bytes: 23472
#include<iostream>

int data[201][3],result[201];

int main(){	
	int n;
	std::cin>>n;
	for(int i=0;i<n;i++)std::cin>>data[i][0]>>data[i][1]>>data[i][2];
	for(int i=0;i<3;i++){
		for(int j=0;j<n;j++){
			int count=-1;
			for(int k=0;k<n;k++){
				if(data[j][i]==data[k][i])count++;
			}
			if(count==0)result[j]+=data[j][i];
		}
	}
	for(int i=0;i<n;i++)std::cout<<result[i]<<std::endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
 	long long int a,b,c;
 	cin>>a>>b>>c;
 	if((a%2==0)||(b%2==0)||(c%2==0))
 		cout<<0<<endl;
 	else
 	{
 		cout<<min(a*b,min(b*c,a*c))<<endl;;
	}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007
    #define ALL(v) v.begin(), v.end()
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
     
    using namespace std;
     
    const int MAX = 1100000;
     
    ll fac[MAX], finv[MAX], inv[MAX];
     
    // テーブルを作る前処理
    void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
     
    // 二項係数計算
    ll COM(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll X,Y;
      cin >> X >> Y;
      if( (Y+X)%3 != 0 ){
        cout << "0";
        return 0;
      }
      if(Y > 2 * X || X > 2 * Y){
        cout << "0";
        return 0;
      }
      ll count = (X+Y)/3; //動かす回数
      
      COMinit();
      cout << COM(count, Y-count);
      return 0;
    }

Measured memory_bytes: 25984
import java.util.Scanner;

public class Main {

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

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println((x - a) % b);

		sc.close();
	}

}




Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}

ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}

int main() {
  cout << fixed << setprecision(30);
  ll n,k;
  cin>>n>>k;
  vec a(n);
  loop(i,n)cin>>a[i];
  sort(all(a));
  reverse(all(a));
  loop(i,min(n,k))a[i]=0;
  putout(sum(a));
}

Measured memory_bytes: 1792
fn main() {
    // N
    let n = read_line::<u32>();
    solve(n);
}

fn solve(n: u32) {
    let ans = (0..n)
        // 桁数が奇数
        .filter(|d| {
            (((d + 1) as f64).log10() as u32) % 2 == 0
        })
        .count();
    println!("{}", ans);
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int n,a,i;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>n;
	REP(i,n)
	{
		cin >>a;
		if (a%2==1) continue;
		if (a%3!=0 && a%5!=0)
		{
			cout <<"DENIED"<<endl;
			return 0;
		}
	}
	cout <<"APPROVED"<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int a[3];

int main()
{
    for(int i = 0; i < 3; ++i)
        scanf("%d", a+i);
    sort(a, a+3);
    printf("%d\n", a[2]*10+a[0]+a[1]);
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;

    int num = 1;
    REP(i, n){
        num = min(num + k, num * 2);
    }
    cout << num << endl;
}


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

/**
 * Created by zzt on 17-2-11.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a < b) {
            if (a == 1)
                System.out.println("Alice");
            else
                System.out.println("Bob");
        } else if (a == b)
            System.out.println("Draw");
        else {
            if (b == 1)
                System.out.println("Bob");
            else
                System.out.println("Alice");
        }
    }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  vector<int> a(n+1);
  rep(i, n) cin >> a[i];

  int maxv = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      chmax(maxv, abs(a[i] - a[j]));
    }
  }

  cout << maxv << "\n";

  return 0;
}

Measured memory_bytes: 256
""" AtCoder """

import sys
input = sys.stdin.readline

s = int(input())

def f(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return 3*n+1

ans_list = []
ans_list.append(s)

i = 1

while True:
    if f(ans_list[i-1]) in ans_list:
        print(i+1)
        break
    ans_list.append(f(ans_list[i-1]))
    i += 1


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

using namespace std;

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

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

	vector<long long> x;
	x.resize(n);

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

	long long ans = 0;

	for(int i = 0; i + 1 < n; ++i) {
		ans += min((x[i + 1] - x[i]) * a, b);
	}

	cout << ans << '\n';

	return 0;

}


Measured memory_bytes: 1024
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(solve(s[0], s[1], a));
    }
    static int solve(int n, int k, int[] a) {
        int[] list = new int[n];
        for (int i = 0; i < n; i ++) list[a[i]-1] ++;
        Array.Sort(list);
        return list.Where((x,y) => y < n-k).Sum();
    }
}

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

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(q);
    for(int i = 0; i < q; i++){
        cin >> a.at(i);
    }
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        p[i] = k;
    }
    for(int i = 0; i < q; i++){
        p[a[i]-1] = p[a[i]-1] + 1;
    }
    for(int i = 0; i < n; i++){
        if(p[i] > q){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, ans = 0, n, max = 0, a;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    ll t = (a - 1) / (max + 1);
    ans += t;
    if(!max) max = 1;
    if(!t && max < a) max = a;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
struct edge{
	int u,v,w;
	bool operator <(const edge b)const{
		return w<b.w;
	}
}e[2005];
int fa[1005];
int d[1005][1005];
vector<pair<int,int> >E[1005];
void dfs(int x,int fa,int r){
	for(int i=0;i<E[x].size();i++)if(E[x][i].first!=fa){
		d[r][E[x][i].first]=max(d[r][x],E[x][i].second);
		dfs(E[x][i].first,x,r);
	}
}
map<long long,int> f;
inline int getfa(int x){return (fa[x]==x?x:fa[x]=getfa(fa[x]));}
const int mod=1e9+7;
inline int power(int x,int y){
	int z=1;
	while(y){
		if(y&1)z=1ll*z*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return z;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	long long X;
	scanf("%lld",&X);
	for(int i=1;i<=m;i++)scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
	sort(e+1,e+m+1);
	for(int i=1;i<=n;i++)fa[i]=i;
	long long res=0;
	for(int i=1;i<=m;i++){
		int u=getfa(e[i].u),v=getfa(e[i].v);
		if(u!=v){
			res+=e[i].w;
			fa[u]=v;
			E[e[i].u].push_back(make_pair(e[i].v,e[i].w));
			E[e[i].v].push_back(make_pair(e[i].u,e[i].w));
		}
	}
	for(int i=1;i<=n;i++)dfs(i,0,i);
	for(int i=1;i<=m;i++)f[e[i].w-d[e[i].u][e[i].v]]++;
	if(X==res){
		printf("%d\n",1ll*(power(2,f[0])-2)*power(2,m-f[0])%mod);
		return 0;
	}else{
		int sum=0;
		for(map<long long,int>::iterator it=f.begin();it!=f.end();it++){
			if(it->first==X-res){
				sum+=it->second;
				// printf("%d %d\n",it->second,sum);
				printf("%d\n",2ll*(power(2,it->second)-1)*power(2,m-sum)%mod);
				return 0;
			}else sum+=it->second;
		}
	}
	puts("0");
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;




int main(){
  ll h, w;
  cin >> h >> w;
  vector<string> f(h);
  rep(i, h) cin >> f[i];


  ll dx[4] = {0, 1, 0, -1};
  ll dy[4] = {-1, 0, 1, 0};
  vector<vector<ll>> memo(h, vector<ll>(w, 1));
  rep(hx, h){
    ll sum = 0;
    rep(wx, w){
      if(f[hx][wx] == '#'){
        memo[hx][wx] = 0;
        sum = 0;
        continue;
      }
      memo[hx][wx] += sum;
      sum++;
    }
  }

  rep(hx, h){
    ll sum = 0;
    for(ll wx = w-1; 0 <= wx; wx--){
      if(f[hx][wx] == '#'){
        sum = 0;
        continue;
      }
      memo[hx][wx] += sum;
      sum++;
    }
  }

  rep(wx, w){
    ll sum = 0;
    rep(hx, h){
      if(f[hx][wx] == '#'){
        sum = 0;
        continue;
      }
      memo[hx][wx] += sum;
      sum++;
    }
  }

  rep(wx, w){
    ll sum = 0;
    for(ll hx = h-1; 0 <= hx; hx--){
      if(f[hx][wx] == '#'){
        sum = 0;
        continue;
      }
      memo[hx][wx] += sum;
      sum++;
    }
  }

  ll maxx = 0;
  rep(hx, h){
    rep(wx, w) maxx = max(maxx, memo[hx][wx]);
  }

  cout << maxx << endl;
  


  return 0;
}


Measured memory_bytes: 35840
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
    
        
        DecimalFormat df = new DecimalFormat("0.00000");
        int n = Integer.parseInt(br.readLine());
    	String[] xninput = br.readLine().split(" ");
    	String[] yninput = br.readLine().split(" ");
    	
    	double dxy = 0d;
		double[] ab = new double[n];
		for (int j = 0; j < n; j++)
		{
			double xn = Double.parseDouble(xninput[j]);
			double yn = Double.parseDouble(yninput[j]);
			ab[j] = Math.abs(xn - yn);
		}
		
    	for (int i = 1; i <= 3; i++)
    	{
    		double po = 0d;
    		for (int j = 0; j < n; j++)
    		{
    			po += Math.pow(ab[j], i);
    		}
    		double ruijou =  1 / (double)i;
    		dxy = Math.pow(po, ruijou);
    		System.out.println(df.format(dxy));
    	}
    	
    	dxy = 0d;
    	for (double value: ab)
    	{
    		dxy = Math.max(dxy, value);
    	}
    	System.out.println(df.format(dxy));
	}
}

Measured memory_bytes: 26232
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

use std::cmp::*;

fn main() {
    let nk: Vec<i64> = read_vec();
    let mut h: Vec<i64> = read_vec();
    // ソート
    h.sort_by(|a, b| a.cmp(b));

    let k = nk[1];

    // k回分必殺技を使う
    for i in 0..k as usize
    {
        h.pop();
    }

    // 和を求める
    let sum_h: i64 = h.iter().sum();

    println!("{}", sum_h);
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n,0);
	for (int i =0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int ans = 0;
	for (int i = 0; i < n-2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			if (a[i] == a[j]) continue;
			int add = 0;
			for (int k = j+1; k < n; k++) {
				if (a[k] == a[j]) continue;
				else if (a[k] < a[i] + a[j]) add ++;
				else break;
			}
			ans += add;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<fstream>
#define vi vector<int>
#define vii vector<vi>
#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define pb push_back
#define sz(v) (int)v.size()
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
using namespace std;
int main(){
	CIN;
	ll sum1 = 0,sum2=0,n;
	cin >> n;
	vl v(n),pref(n),suf(n+1,0);
	rep(i,0,n){
		cin >> v[i];
		if(i%2){
			sum1 += -v[i];
			sum2 += v[i];
			pref[i]=sum1;
		}else{
			sum1 += v[i];
			sum2 += -v[i];
			pref[i]=sum2;
		}
	}
	sum1=0,sum2=0;
	per(i,n-1,-1){
		if(i%2){
			sum1 += -v[i];
			sum2 += v[i];
			suf[i]=sum2;
		}else{
			sum1 += v[i];
			sum2 += -v[i];
			suf[i]=sum1;
		}
	}
	vl klo(n,0);
	rep(i,0,n){
		if(i){
		klo[i] = pref[i-1] + suf[i+1] +v[i];
	    }else{
		klo[i] = suf[i+1]+v[i];
	    }
	}
	cout << klo[n-1] << " ";
	rep(i,0,n-1){
		cout << klo[i] << " ";
	}
}

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

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

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fs first
#define se second

#define debug(x) cout<<#x<<" = "<<(x)<<endl;

int main(){
  int N;cin>>N;
  map<string, int> list;

  string buf;
  int m = 0;
  for(int i=0; i<N; i++){
    cin>>buf;
    auto itr = list.find(buf);
    if(itr == list.end()){
      //初めての文字列
      list.insert(mp(buf, 1));
      m = max(m, 1);
    }else{
      itr->se += 1;
      m = max(m, itr->se);
    }
  }

  //debug(m);

  for(auto x: list){
    if(x.se==m){
      cout<<x.fs<<endl;
    }
  }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(abs(a-b)%2==0){
    cout << min(a,b)+abs(a-b)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

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

using vi = vector<int>;

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

    vi v(2 * n);

    for(auto& x : v) cin >> x;

    sort(begin(v), end(v));

    int ans = 0;

    for(int i = 0; i < 2 * n - 1; i += 2)
        ans += min(v[i], v[i + 1]);

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,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 (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

lint N, K;
ModInt dp[101][100000];
ModInt sdp[100000]; //累積和
ModInt num[100000];

int main() {
	cin >> N >> K;
	int itr = 0;
	for (int i = 1; i <= N;) {
		int j = N / i;
		if (i <= j) num[itr++] = 1, ++i;
		else num[itr++] = N / j - i + 1, i = N / j + 1;
	}

	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	REP(i, K) {
		memset(sdp, 0, sizeof(sdp));
		REP(j, itr + 1) sdp[j + 1] = sdp[j] + dp[i][j];
		REP(j, itr) dp[i + 1][j] = sdp[itr - j] * num[j];
	}
	ModInt ans = 0;
	REP(i, itr + 1) ans += dp[K][i];
	cout << ans.a << endl;
}

Measured memory_bytes: 83756