akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;
bool lessPair(const P& l, const P& r){return l.second < r.second;}

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

    vector<lint> A(N);
    vector<lint> B(N);
    vector<lint> delta(N);

    REP(i, N) {
      lint x; cin >> x; A[i] = x;
    }

    REP(i, N) {
      lint x; cin >> x; B[i] = x;
    }

    REP(i, N) {
      delta[i] = A[i]-B[i];
    }

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

    //    EACHPRINT(delta, lint);

    lint pos_idx = N-1;
    lint current_delta = delta[pos_idx];

    if(delta[0] >= 0) {
      PRINT(0);
      return 0;
    }

    if(current_delta <= 0) {
      PRINT(-1);
      return 0;
    }

    lint res = 1;

    REP(i, N) {
      if(delta[i] >= 0) break;
      current_delta += delta[i];
      res += 1;
      while(current_delta < 0) {
        if(delta[pos_idx-1] <= 0) {
          PRINT(-1);
          return 0;
        }
        pos_idx--;
        current_delta += delta[pos_idx];
        res += 1;
      }
    }
    PRINT(res);
    return 0;
}


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

#define ll long long

int main()
{
    ll n,ans=0;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
            ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val (n,di) = f.readLine().split(" ").map{it.toInt()}
	val d = di.toLong()
	val d2 = d*d

	var answer = 0
	for(k in 0 until n){
		val (a,b) = f.readLine().split(" ").map{it.toLong()}
		if(a*a+b*b <= d2) answer++
	}
	println(answer)
}


Measured memory_bytes: 56136
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
  int a,b,c;
  cin>>a>>b>>c;
  set<int> s;
  s.insert(a);
  s.insert(c);
  s.insert(b);
  int x=s.size();
  if(x==2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;
const ll white=0;
const ll gray=1;
const ll black=2;

ll n;
ll m[105][105];
ll color[105];
ll d[105];
ll f[105];
ll tt;

void dfs_visit(ll u){
    color[u]=gray;
    d[u]=++tt;
    rep(v,n){
        if(m[u][v]==0) continue;
        if(color[v]==white){
            dfs_visit(v);
        }
    }
    color[u]=black;
    f[u]=++tt;
}
void dfs(){
    rep(u,n){
        color[u]=white;
    }
    tt=0;
    rep(u,n){
        if(color[u]==white){
            dfs_visit(u);
        }
    }
    rep(u,n){
        cout << u+1 << " " << d[u] << " " << f[u] << endl;
    }
}

int main()
{
    cin >> n;
    rep(i,n){
        rep(j,n){
            m[i][j]=0;
        }
    }
    rep(i,n){
        ll u,k;
        cin >> u >> k;
        u--;
        rep(j,k){
            ll v;
            cin >> v;
            v--;
            m[u][v]=1;
        }
    }
    dfs();
    return 0;
} 


Measured memory_bytes: 3156
#include <cstdio>
#include <cstring>
bool fun(char *c) {
    int len=strlen(c);
    for (int i = 0; i < len / 2; i++) {
        if (c[i] != c[len-1-i])
            return false;
    }
    return true;
}
int main() {
    int a, b;
    scanf("%d%d",&a,&b);
    char str[10];
    int ans = 0;
    for (int i = a; i <= b; i++) {
        int t = i;
        int cnt = 0;
        while (t!=0) {
            str[cnt++] = t%10 + '0';
            t /= 10;
        }
        str[cnt] = '\0';
        if (fun(str))
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a[n] = {};
    rep(i,n)a[i] = s[i] - '0';

    int ans = 0;

    rep(i,1000){
        int ii = i;
        int f[3] = {};
        rep(j,3){
            f[j] = ii % 10;
            ii /= 10;
        }
        int now = 0;
        rep(j,n){
            if(f[now] == a[j])now++;
            if(now == 3){
                ans++;
                break;
            }
        }
    }

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


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin >> n;
    k = n%10;
    if(k==2 || k==4 || k==5 || k==7 || k==9)
        cout << "hon" << endl;
    else if(k==0 || k==1 || k==6 || k==8)
        cout << "pon" << endl;
    else if(k==3)
        cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    bool ok = false;
    REP(i,n){
        bool f = true;
        REP(j,n){
            if (s[j] != t[(j+i) % n]) f = false;
        }
        ok |= f;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

int main()
{
  int N, i;
  int res=0;
  cin >> N >> i;

  res = N-i+1;

  cout << res << endl;
}

Measured memory_bytes: 256
N, K = [int(_) for _ in input().split()]

d = K.bit_length()
fmt = "0{}b".format(d)

Aa = [int(_) for _ in input().split()]
A = [format(int(_), fmt)[-d:] for _ in Aa]

X = 0
for i in range(d):

    count = 0
    temp = 1 << (d - i - 1)

    if X + temp > K:
        continue

    for j in range(N):
        if A[j][i] == '0':
            count -= 1
        else:
            count += 1
    if count < 0:
        X += temp

ans = 0
for ai in Aa:
    ans += (ai ^ X)

print(ans)

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

#define Death Komachi
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;i++)
#define DREP(i,a,b) for(int i=(a),i##_end_=(b);i>i##_end_;i--)
#define LL long long
#define M 1000004

int n,a,b;
int main(){
	scanf("%d%d%d",&n,&a,&b);
	puts((b-a)&1?"Borys":"Alice");
	return 0;
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
int val[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &val[i]);
	sort(val + 1, val + n + 1);

	int ans = 0;
	for(int i = 1; i <= n; ++i){
		int cnt = (val[i] - val[i - 1]) & 1;
		if(cnt)
			ans ^= n - i + 1;
	}
	
	puts(ans == 0 ? "second" : "first");
	return 0;
}

Measured memory_bytes: 640
package main

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	v := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range v {
		sc.Scan()
		v[i], _ = strconv.Atoi(sc.Text())
	}

	ans := 0
	for i := 0; i <= min(k, n); i++ {
		for j := 0; j <= min(k, n); j++ {
			if i+j > min(k, n) {
				continue
			}
			rem := k - i - j
			a := make([]int, 0, i+j)
			for i2 := 0; i2 < i; i2++ {
				a = append(a, v[i2])
			}
			for j2 := 0; j2 < j; j2++ {
				a = append(a, v[n-1-j2])
			}
			sort.Ints(a)
			s := 0
			for _, e := range a {
				s += e
			}
			for l := 0; l < len(a); l++ {
				if rem == 0 {
					break
				}
				if a[l] >= 0 {
					break
				}
				s -= a[l]
				rem--
			}
			ans = max(ans, s)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

#define P pair
#define X first
#define Y second

using namespace std;

int dist[21][21] = {};
char OK = '.', NG = '#';

void display_vec(vector<string> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int bfs(vector<string> v, P<int, int> s_p)
{
    // 上下左右
    int dx[4] = {0, 0, 1, -1};
    int dy[4] = {1, -1, 0, 0};
    int h = v.size(), w = v[0].size();
    vector<vector<int>> dist(h, vector<int>(w, -1));

    queue<P<int, int>> q;
    // cur_p: 現在地
    // next_p: 移動予定地
    P<int, int> cur_p, next_p;

    // set start point
    q.push(s_p);
    dist[s_p.Y][s_p.X] = 0;

    int res = -1;

    while (q.size())
    {

        // display_vec(v);
        // display_dis();

        cur_p = q.front();
        v[cur_p.Y][cur_p.X] = NG;
        q.pop();

        for (int i = 0; i < 4; i++)
        {
            next_p.Y = cur_p.Y + dy[i];
            next_p.X = cur_p.X + dx[i];

            if (next_p.Y >= 0 && next_p.Y < h && next_p.X >= 0 && next_p.X < w)
            {
                if (v[next_p.Y][next_p.X] == OK && dist[next_p.Y][next_p.X] == -1)
                {
                    dist[next_p.Y][next_p.X] = dist[cur_p.Y][cur_p.X] + 1;
                    q.push(next_p);
                    res = max(res, dist[next_p.Y][next_p.X]);
                }
            }
        }
    }
    return res;
}

int main(int argc, const char *argv[])
{
    int h, w;
    cin >> h >> w;

    vector<string> v;
    string s;
    for (int i = 0; i < h; i++)
    {
        cin >> s;
        v.push_back(s);
    }

    int x, ans = 0;
    P<int, int> s_p;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            s_p.Y = i;
            s_p.X = j;
            if (v[i][j] == OK)
            {
                ans = max(ans, bfs(v, s_p));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigInteger;

public class Main {  
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    BigInteger[] T = new BigInteger[N+1];
    for (int i =1; i<=N; i++) {
      T[i] = sc.nextBigInteger();
    }
    BigInteger ans = T[1];
    for (int i =2; i<=N; i++) {
      ans = lcm(T[i],ans);
    }
    System.out.print(ans);  
  }
  
  static BigInteger lcm(BigInteger a, BigInteger b) {
    BigInteger tmp = a.remainder(b);
    BigInteger c = a;
    c = c.multiply(b);
    while (!tmp.equals(BigInteger.ZERO)) {
      a = b;
      b = tmp;
      tmp = a.remainder(b);
      if (tmp.equals(BigInteger.ZERO)) break;
    }
    return c.divide(b);
  }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
int gcd(int a, int b){ if(a==0) return b; return gcd(b%a, a);}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	ci(n);
	vi h(n+1);
	fok(i,1,n+1){
		ci(h[i]);
	}
	vi dp(n+1);
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	fok(i,3,n+1){
		int a =abs(h[i-1]-h[i])+dp[i-1];
		int b =abs(h[i-2]-h[i])+dp[i-2];
		dp[i]= min(a,b);
	}
	co(dp[n]);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int N = 5005;
const int INF = 1234567;

// i番目,手前/真上は使用済み
int dp[N][2][2];

void init(){
    rep(i,N)rep(j,2)rep(k,2) dp[i][j][k] = INF;
}

vector<int> DG[10000];

int main(){
    int w,h,sp;
    scanf(" %d %d %d", &w, &h, &sp);

    int n;
    scanf(" %d", &n);
    rep(i,n){
        int x,y;
        scanf(" %d %d", &x, &y);
        DG[y].pb(x);
    }

    int m = (w+1)/2;

    sp -= m;
    if(sp<0){
        printf("-1\n");
        return 0;
    }

    int dog = 0;
    vector<int> D(w+1);
    for(int y=3; y<=h; y+=2){
        int dy = y-1;

        for(int x:DG[dy]) D[x] = 1;

        init();
        dp[0][1][0] = 0;
        rep(i,m)rep(j,2)rep(k,2)if(dp[i][j][k]<INF){
            // i-1
            if(i>0 && j==0){
                int dx = 2*i+1 - 1;
                dp[i+1][k][0] = min(dp[i+1][k][0], dp[i][j][k]+D[dx]);
            }

            // i
            if(k==0){
                int dx = 2*i+1;
                dp[i+1][1][0] = min(dp[i+1][1][0], dp[i][j][k]+D[dx]);
            }

            // i+1
            if(i+1<m){
                int dx = 2*i+1 + 1;
                dp[i+1][k][1] = min(dp[i+1][k][1], dp[i][j][k]+D[dx]);
            }
        }

        int add = INF;
        rep(i,2)rep(j,2) add = min(add, dp[m][i][j]);
        dog += add;

        for(int x:DG[dy]) D[x] = 0;
    }

    int normal = m*(h/2) - dog;
    // dbg(dog); dbg(normal);

    if(dog < sp){
        sp -= dog;
        dog = 0;
    }
    else{
        dog -= sp;
        sp = 0;
    }

    normal = max(0, normal - sp);

    printf("%d\n", 2*dog + normal);
    return 0;
}



Measured memory_bytes: 4384
"use strict";
function Main(input) {
    let N = input.split("\n")[0].split(/\s/).map((v) => v - 0)[0];
    let dp = new Array(N + 1).fill(0).map(() => new Array(4).fill(0).map(() => new Array(4).fill(0).map(() => new Array(4).fill(0))));
    const MOD = 1e+9 + 7;
    // A C G T -> 0 1 2 3
    dp[0][3][3][3] = 1;
    for (let len = 0; len < N; len++)
        for (let c1 = 0; c1 < 4; c1++)
            for (let c2 = 0; c2 < 4; c2++)
                for (let c3 = 0; c3 < 4; c3++) {
                    if (dp[len][c1][c2][c3] == 0) continue;
                    for (let a = 0; a < 4; a++) {
                        if (a == 2 && c1 == 1 && c2 == 0) continue; // 0 1 2
                        if (a == 2 && c1 == 0 && c2 == 1) continue; // 1 0 2
                        if (a == 1 && c1 == 2 && c2 == 0) continue; // 0 2 1
                        if (a == 2 && c1 == 1 && c3 == 0) continue; // 0 ? 1 2
                        if (a == 2 && c2 == 1 && c3 == 0) continue; // 0 1 ? 2
                        // S = ...... c3 c2 c1
                        // nextS = ...... c2 c1 a
                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= MOD;
                    }
                }
    let ans = 0;
    for (let c1 = 0; c1 < 4; c1++)
        for (let c2 = 0; c2 < 4; c2++)
            for (let c3 = 0; c3 < 4; c3++) {
                ans += dp[N][c1][c2][c3];
                ans %= MOD;
            }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    //隣の家との距離をパラメータbとする.bi = ai+1 - ai
    vector<int> b(n);
    rep(i,n-1){
        b[i] = a[i+1] - a[i];
    }
    b[n-1] = (k-a[n-1]) +a[0];   //端っこ
    
    //rep(i,n) cout << b[i] << " ";
    
    int maxi;
    maxi = *max_element(b.begin(),b.end());
    //cout << maxi;
    int ans;
    ans = k - maxi;
    cout << ans << endl;
    
    
}


Measured memory_bytes: 1920
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;


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

    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
        A[i] %= 2;
    }

    int dp[100][2];
    CLR(dp, 0);
    dp[0][0] = 1;
    REP(i, N) {
        if (A[i] == 1) {
            dp[i + 1][0] += dp[i][1] + dp[i][0];
            dp[i + 1][1] += dp[i][1] + dp[i][0];
        }
        else {
            dp[i + 1][0] += dp[i][0] * 2;
            dp[i + 1][1] += dp[i][1] * 2;
        }
    }
    cout << dp[N][P] << endl;
    return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function root(par::Vector{Int},x::Int)
    index=par[x]
    while par[index]!=index
        index=par[index]
    end
    return index
end

function unite(par::Vector{Int},x::Int,y::Int)
    rx,ry=root(par,x),root(par,y)
    if rx==ry
        return
    elseif rx>ry
        rx,ry=ry,rx
    end
    par[ry]=rx
end

function same(par::Vector{Int},x::Int,y::Int)
    return root(par,x)==root(par,y)
end

function main()
    n,m=parseMap(split(readline()))
    data=[parseMap(split(readline())) for i in 1:m]
    ans=0
    # 取り除く辺を全探索してUnion-Findを構築
    for ng in 1:m
        par=[i for i in 1:n]
        for i in 1:m
            if i==ng
                continue
            end
            unite(par,data[i][1],data[i][2])
        end
        renketsu=true
        r=root(par,1)
        for i in 2:n
            if root(par,i)!=r
                renketsu=false
                break
            end
        end
        if !renketsu
            ans+=1
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 112572
import sys
input = sys.stdin.readline
lis = {}
counter = 0
N = int(input().rstrip())
for i in range(N):
  str = "".join(sorted(list(input().rstrip())))
  if str in lis:
    lis[str] += 1
    counter += lis[str]
  else:
    lis[str] = 0
print(counter)

Measured memory_bytes: 22192
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0; i<N; i++)

using namespace std;

int main(){
  int a; cin >> a;
  int b; cin >> b;
  int ans = -1;

  bool flg = false;
  if( a >= 1 && a <=9){
    if( b >= 1 && b <=9){
      flg = true;
    }
  }

  if(flg) {
    ans = a * b;
  }

  cout << ans << endl;
}

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

void funcB() {
  int x, coin500 = 0, coin5 = 0;
  std::cin >> x;
  coin500 = x / 500;
  coin5 = (x - (500 * coin500)) / 5;
  std::cout << (1000 * coin500 + 5 * coin5);
}


int main(void) {
  funcB();
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	char c,a;
	c=getchar();
	while(c<='z'&&c>='a')
	{
		a=c;
		c=getchar();
	}
	c=getchar();
	if(c!=a) {printf("NO\n");return 0;}
	while(c<='z'&&c>='a')
	{
		a=c;
		c=getchar();
	}
	c=getchar();
	if(c!=a) {printf("NO\n");return 0;}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
n, k = gets.chomp.split.map(&:to_i)
as = gets.chomp.split.map(&:to_i)

path = [1]
loop_offset = 0

wps = {}
wps[1] = 0

(0...n).each do
    now = path.last
    nex = as[now - 1]

    wp = wps[nex]
    unless wp.nil?
        loop_offset = wp
        break
    end

    wps[nex] = path.count
    path << nex
end

if k < path.count
    puts path[k]
    exit
end

k = (k - path.count) % (path.count - loop_offset) + loop_offset
puts path[k]


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	while(true){
		int n; cin >> n;
		if(n == 0) break;
		vector<P> a;
		int t1,t2; int cnt = 1;
		cin >> t1;
		for (int i = 1;i < n;i++){
			cin >> t2;
			if(t1 != t2){
				a.push_back(P(t1,cnt));
				cnt = 1;
			}else{
				cnt++;
			}
			t1 = t2;
		}
		a.push_back(P(t1,cnt));
		int ans;
		if(a[1].second == 3 ) ans = n-4;
		else if(a[a.size()-1].second == 3) ans = n-4;
		else ans = n;
		for (int i = 1;i < a.size()-1;i++){
			cnt = 0;
			if(a[i].second == 1){
				int x = i-1, y = i+1;
				if(a[x].first == a[y].first && a[x].second+a[y].second >= 3){
					cnt += a[x].second+a[y].second+1;
					x--; y++;
					while(x >= 0 && y < a.size()){
						if(a[x].first == a[y].first && a[x].second+a[y].second >= 4){
							cnt += a[x].second+a[y].second;
							x--; y++;
						}else break;
					}
				}
			}
			
			ans = min(n-cnt,ans);
			cnt = 0;
			if(a[i-1].second == 3){
				cnt = 4;
				int x = i-2, y = i;
				if(a[x].first == a[y].first && a[x].second+a[y].second >= 5){
					cnt +=  a[x].second+a[y].second-1;
					x--;y++;
					while(x >= 0 && y < a.size()){
						if(a[x].first == a[y].first && a[x].second+a[y].second >= 4){
							cnt += a[x].second+a[y].second;
							x--; y++;
						}else break;
					}
				}
			}
			ans = min(n-cnt,ans);
			if(a[i+1].second == 3){
				cnt = 4;
				int x = i, y = i+2;
				if(a[x].first == a[y].first && a[x].second+a[y].second >= 5){
					cnt +=  a[x].second+a[y].second-1;
					x--;y++;
					while(x >= 0 && y < a.size()){
						if(a[x].first == a[y].first && a[x].second+a[y].second >= 4){
							cnt += a[x].second+a[y].second;
							x--; y++;
						}else break;
					}
				}
			}
		}
		cout << ans << endl;
	}

	return 0;

}



Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;
  for (int i = a; i < b+1; i++) {
    int ii = i;
    vector<int> vec(5);
    rep(j, 5) {
      vec.at(j) = (ii % 10);
      ii /= 10;
    }
    if (vec.at(0) == vec.at(4)) {
      if (vec.at(1) == vec.at(3)) {
        count++;
      }
    }
  }
  cout << count << endl;
}
      


Measured memory_bytes: 3624
import java.util.Scanner;


public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // Scanner sc = new Scanner("4 1 2 2 1");
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i=0;i<n;i++){
            h[i] = Integer.parseInt(sc.next());
        }
        boolean flag = true;
        int cnt = 0;

        while(flag){
            flag = false;
            boolean prevPlus = false;
            for(int i=0;i<n;i++){
                if(prevPlus){
                    if(h[i]>0){
                        h[i]--;
                        continue;
                    }else{
                        prevPlus = false;
                        continue;
                    }
                }else{
                    if(h[i]>0){
                        flag = true;
                        prevPlus = true;
                        cnt++;
                        h[i]--;
                        continue;
                    
                    }else{
                        continue;
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}

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

using namespace std;

inline void read() {}
template <class S>
inline void read(S &arg) {
  cin >> arg;
}
template <class S>
inline void readA(S Lptr, S Rptr) {
  while (Lptr != Rptr) {
    read(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void read(S &arg, T &... rest) {
  read(arg);
  read(rest...);
}

inline void write() {}
template <class S>
inline void write(S arg) {
  cout << arg;
}
template <class S>
inline void writeA(S Lptr, S Rptr) {
  if (Lptr != Rptr) {
    write(*Lptr);
    Lptr++;
  }
  while (Lptr != Rptr) {
    write('\n');
    write(*Lptr);
    Lptr++;
  }
}
template <class S, class... T>
inline void write(S arg, T... rest) {
  write(arg);
  write(' ');
  write(rest...);
}

#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

template <class T, class S>
inline bool smin(T &a, S b) {
  return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
  return a < (T)b ? a = b, 1 : 0;
}

constexpr int MOD = 1e9 + 7;
constexpr int N = 1e6 + 10;

template <typename T>
inline T mod(T &v) {
  return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}

ll po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

int n, m, Q[N], L, R, par[N];
int a[N], b[N], in[N];
vi adj[N];

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  read(n, m);

  rep(i, 1, n + m) {
    read(a[i], b[i]);
    adj[a[i]].pb(b[i]);
    in[b[i]]++;
  }

  rep(i, 1, n + 1) if (!in[i]) Q[R++] = i;

  while (L < R) {
    int v = Q[L++];
    for (auto e : adj[v]) {
      in[e]--;
      if (!in[e]) {
        par[e] = v;
        Q[R++] = e;
      }
    }
  }

  writeA(par + 1, par + 1 + n);

  return 0;
}


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

using namespace std;

double f(int n, double d, double x) {
    if(n == 0) return 0.0;
    else return f(n-1, ((2*n+2)*d + 5*x)/(2*n), ((n+2)*x)/n) + d + (x*(2*n-1)/2); 
} 

int N, d, x;

int main() {
    cin >> N >> d >> x;
    cout << setprecision(12) << f(N, (double)d, (double)x) << endl;
}

Measured memory_bytes: 9964
package main

import (
	"fmt"
	"math"
)

func main() {
	var X int
	fmt.Scan(&X)

LOOP:
	for A := -2500; A < 2500; A++ {
		for B := -2500; B < 2500; B++ {
			if int(math.Pow(float64(A), 5)-math.Pow(float64(B), 5)) == X {
				fmt.Println(A, B)
				break LOOP
			}
		}
	}
}

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

using namespace std;

int main(){
        int n, ans;
        string c;
        cin >> n >> c;

        if((count(c.begin(), c.end(), 'R') == 0)or(count(c.begin(), c.end(), 'W') == 0)){
                ans = 0;
        }

        int r = count(c.begin(), c.end(), 'R');
        ans = count(c.begin(), c.begin() + r, 'W');

        cout << ans << endl;
}

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

using namespace std;

int NumWin(const auto &you, const auto &me, size_t pass) {
    int res = 0;
    for (size_t i = 0, j = 0; i < you.size() && j < me.size(); ) {
        if (j != pass && you[i] < me[j]) { ++res; ++i; }
        ++j;
    }
    return res;
}

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

    int n;
    cin >> n;

    vector<int> you(n), me(n);
    for (auto &&x : you) cin >> x;
    for (auto &&x : me) cin >> x;

    vector<int> ord(you);
    sort(you.begin(), you.end());
    sort(me.begin(), me.end());

    int max_win = NumWin(you, me, n);

    vector<int> ans; ans.reserve(n);
    for (const int x : ord) {
        swap(you.back(), *find(you.begin(), you.end(), x));
        you.pop_back();
        sort(you.begin(), you.end());

        int lb = 0, ub = me.size();
        int idx = distance(me.begin(), lower_bound(me.begin(), me.end(), x + 1));
        if (idx == ub || (x < me[idx]) + NumWin(you, me, idx) != max_win) ub = idx;
        else lb = idx;

        while (1 < ub - lb) {
            int mid = (lb + ub) >> 1;
            if ((x < me[mid]) + NumWin(you, me, mid) == max_win) lb = mid;
            else ub = mid;
        }

        if (x < me[lb]) --max_win;
        ans.push_back(me[lb]);
        swap(me.back(), *find(me.begin(), me.end(), me[lb]));
        me.pop_back();
        sort(me.begin(), me.end());
    }

    for (int i = 0; i < n; ++i)
        cout << ans[i] << " \n"[i == n - 1];

    return 0;
}



Measured memory_bytes: 3292
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    writeln(a.sort!"a < b".uniq.array.length == n ? "YES" : "NO");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 11224
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main() {
    ios;
	int n;cin>>n;
 	string s;cin>>s;
   int c=0;
 	f(i,2,n)
	{
	    if(s[i]=='C'&&s[i-1]=='B'&&s[i-2]=='A')
	      c++;
	      
	}
	cout<<c;
 
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;

int main() {

    string S;
    cin >> S;
    int numOfZero = 0;
    int numOfOne = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') {
            numOfZero += 1;
        } else {
            numOfOne += 1;
        }
    }

    cout << S.size() - abs(numOfOne - numOfZero) << "\n";


    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		if ((Math.abs(a-b) <= d && Math.abs(b-c) <= d) || (Math.abs(c-a) <= d))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

int main(void)
{
	char string[81], *p;
	int i, j, count, flag;
	
	/** üÍá "uijt jt b qfo"
	    oÍá "this is a pen" **/
	while (1) {
		if (fgets(string, 80, stdin) == NULL)
			break;
		if ((p = strrchr(string, '\n')) != NULL)
			*p = '\0';
			
		flag = 0;
		
		for (count = 0; count < 26 && flag == 0; count++) {
			/** ¶ð1¶ãëÖ 'a'->'b' **/
			for (i = 0; string[i] != '\0'; i++) {
				if (string[i] == 'z')
					string[i] = 'a';
				else if (string[i] >= 'a' && string[i] <= 'z')
					string[i] = string[i] + 1;
			}
			
			/** PêPÊÉæØèo· **/
			for (i = 0; string[i] != '\0'; i++) {
				char word[20] = "";
				for (j = 0; string[i] != ' ' && string[i] != '\0'; i++, j++) {
					word[j] = string[i];
				}
				
				/** "this"Æêv·é© **/
				if (strcmp(word, "the") == 0 || strcmp(word, "this") == 0 ||
					strcmp(word, "that") == 0) {
					/** êvµ½ÈçA¶ñð«oµÄI¹ **/
					printf("%s\n", string);
					flag = 1;
					break;
				}
			}
		}
	}
	return 0;
}
	

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a,b,k;cin>>a>>b>>k;
    priority_queue<int>pq;
    for(int i=1;i<=min(a,b);i++){
        if(a%i==0 && b%i==0){
            pq.push(i);
        }
    }
    rep(i,k-1){
        pq.pop();
    }
    int ans=pq.top();
    cout<<ans<<endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
vector<int> v[3005];
pair<int,int> arr[3005];
bool w[3005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&arr[i].first);
		arr[i].second=i;
	}
	for (int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if (arr[a].first>arr[b].first)
		v[a].push_back(b);
		if (arr[b].first>arr[a].first)
		v[b].push_back(a);
	}
	sort(arr+1,arr+n+1);
	for (int i=1;i<=n;i++)
	{
		for (int u:v[arr[i].second])
		w[arr[i].second]|=!w[u];
	}
	for (int i=1;i<=n;i++)
	{
		if (w[i])
		printf("%d ",i);
	}
}

Measured memory_bytes: 384
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, s.size()) {
        int a = s.size() - i -1;
        if (s[i] != s[a] && i > a) ++cnt; 
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
N,K = map(int,input().split())
V = list(map(int,input().split()))

loop=min([K+1,N+1])
lists=[]
for j in range(1,loop):
    for i in range(j+1):
        temp1 = V[:i]
        temp2 = V[N-(j-i):]
        temp =[]
        temp+=temp1
        temp+=temp2
        lists.append([temp,K-(i+((j-i)))])


max_value=0

for row in lists:
    ks = min([row[1],len(row[0])])
    sort_row = sorted(row[0])

    for k in range(ks+1):
        max_value=max([sum(sort_row[k:]), max_value])

print(max_value)

Measured memory_bytes: 3572
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] array = new int[n], array2=new int[n];
		for(int i=0;i<n;i++) {
			array2[i]=sc.nextInt();
			array[i]=array2[i];
		}
		sc.close();
		Arrays.sort(array);
		int mid1=array[n/2],mid2=array[n/2-1];
		for(int i=0;i<n;i++) {
			if(array2[i]<=mid2) System.out.println(mid1);
			else System.out.println(mid2);
		}
	}
}

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

template<class T>
struct WarshallFloyd {
	const int V;
	// オーバーフロー注意
	const T INF = numeric_limits<T>::max() / 3;
	vector<vector<T>> d;
	WarshallFloyd(const int V) :
		V(V),
		d(vector<vector<T>>(V, vector<T>(V, INF)))
		{}
	bool addEdge(int from, int to, T cost) {
		if(cost >= d[from][to]) return false;
		d[from][to] = cost;
		return true;
	}
	void build() {
		for(int i = 0; i < V; ++i) {             // 経由点 i
			for(int j = 0; j < V; ++j) {         // 始点 j
				for(int k = 0; k < V; ++k) {     // 終点 k
					d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
				}
			}
		}
	}
	T dist(int from, int to) {
		if(d[from][to] >= INF) throw "INVALID";
		return d[from][to];
	}
	void debug() {
		for(int i = 0; i < V; ++i) {
			for(int j = 0; j < V; ++j) {
				cout << d[i][j] << " ";
			}
			cout << endl;
		}
	}
};

int main() {
	int n, m, l; cin >> n >> m >> l;
	WarshallFloyd<int64_t> wf1(n);
	for(int i = 0; i < n; ++i) {
		wf1.addEdge(i, i, 0);
	}
	while(m--) {
		int a, b, c; cin >> a >> b >> c;
		--a, --b;
		wf1.addEdge(a, b, c);
		wf1.addEdge(b, a, c);
	}
	wf1.build();
	WarshallFloyd<int64_t> wf2(n);
	for(int i = 0; i < n; ++i) {
		wf2.addEdge(i, i, 0);
		for(int j = 0; j < n; ++j) {
			try {
				if(wf1.dist(i, j) <= l) {
					wf2.addEdge(i, j, 1);
					wf2.addEdge(j, i, 1);
				}
			}
			catch(...) {
				continue;
			}
		}
	}
	wf2.build();
	int q; cin >> q;
	while(q--) {
		int s, t; cin >> s >> t;
		--s, --t;
		try {
			cout << wf2.dist(s, t) - 1 << '\n';
		}
		catch(...) {
			cout << -1 << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 1920
import math

n =int(input())
x = [];y = []
x = list(map(int,input().split()))
y = list(map(int,input().split()))
d1 = 0
d2 = 0
d3 = 0
dx = -1e9
for i in range(n):
    d1 += abs(x[i]-y[i])
    d2 += (x[i]-y[i])**2
    d3 += (abs(x[i]-y[i]))**3
    dx = max(dx,abs(x[i]-y[i]))

d1 = d1**1
d2 = d2**0.5
d3 = d3**(1/3)
dx = dx
print("%.5f"%d1)
print("%.5f"%d2)
print("%.5f"%d3)
print("%.5f"%dx)


Measured memory_bytes: 5704
N,K = map(int,input().split())
S = input() + "#"
A = []
cnt = 1
for i in range(N) :
    if S[i] == S[i+1] :
        cnt += 1
    else :
        A.append(cnt)
        cnt = 1

if S[0] == "1" :
    ans = sum(A[:2*K+1])
    calc = ans
    for i in range(2*K+1, len(A)) :
        calc += A[i]
        if i % 2 == 1 :
            calc -= (A[i-1-2*K] + A[i-2*K])
        ans = max(ans, calc)
else :
    ans = sum(A[:2*K])
    calc = ans
    for i in range(2*K,len(A)) :
        calc += A[i]
        if i == 2*K :
            calc -= A[0]
        elif i % 2 == 0  :
            calc -= (A[i-1-2*K] + A[i-2*K])
        ans = max(ans, calc)

print(ans)


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"  
char ch[20000010];  
//std::vector<int> v, a;


int main(){
  
	#ifndef ONLINE_JUDGE  
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);  
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);  
#endif
       ios_base::sync_with_stdio(false);    
 ll d ,t ,s;
  cin>>d>>t>>s;  
  ll r = (d + s -1)/s;         
  if(r <= t){  
  	cout<<"Yes"<<endl;  
  }
  else{
  	cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3564
#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(){
  ll n,ans=0;cin >> n;ll a[n];
  rep(i,n)cin >> a[i];
  sort(a,a+n);ll u[n];u[0]=a[0];ll y = n/2-1;
  rep(i,n-1)u[i+1]=u[i]+a[i+1];
  if(n%2==0){
    cout << (u[n-1]*2-u[y]-u[y+1])-(u[y]*2-a[y]) << endl;
  }
  else {
    cout << max(u[n-1]*2-u[y]*2-a[y+1]-a[y+2]-u[y]*2,
                u[n-1]*2-u[y+1]*2-u[y+1]*2+a[y]+a[y+1]) << endl;
  }
}

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

int main(){
	int a,b;
	char c='a';
	while (c!='?'){
	cin>>a>>c>>b;
	if (c=='+')cout<<a+b<<endl;
	if (c=='-')cout<<a-b<<endl;
	if (c=='*')cout<<a*b<<endl;
	if (c=='/')cout<<a/b<<endl;
	if (c=='?')return 0;
	}
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>


using ull = unsigned long long;

std::string in = "insert", fi = "find";


auto make_code(const std::string& s) {
	ull code{1};
	for (const auto&e : s) {
		code <<= 2;//*= 4;
		code +=
			e == 'A'?0:
			e =='T'?1:
			e =='G'?2:3;
	}
	return code;
}

auto die() {

	std::cout.sync_with_stdio(false);

	std::vector< std::pair<std::string, ull> > dict;

	std::vector<std::string> results;

	ull N{};
	std::cin >> N;
	dict.reserve(  1000000);
	results.reserve(500000);
	for (ull i{}; i < N; ++i) {
		std::string op,s;
		std::cin >> op >> s;

		auto&& c = make_code(s);
//		std::cout << ">>" << c << "\n";

		if (op == in) {
			//dict.emplace_back(s,c);
			dict.push_back({ s,c });

		}


		if (op == fi) {
			auto en_ = std::end(dict);
			auto it = std::find_if(
				std::begin(dict)
				, en_
				,[&](auto x)->bool {
					return x.second == c;
				});

			results.push_back(
				(it != en_ ? "yes" : "no")
			);
		}
	}
	for (const auto&e : results) {
		std::cout << e << "\n";
	}

}


int main() {
	std::cout.sync_with_stdio(false);

	std::set<std::string>st,st2,st3;
	std::vector<std::string>rv;
	rv.reserve(500000);
	ull N;
	std::cin >> N;
	for (ull i{}; i < N; ++i) {
		std::string op, tmp; std::cin >> op >> tmp;
		decltype (st)* sp;
		if (8<tmp.size() &&tmp.size()<11)	sp = &st2;
		else if (11 <= tmp.size())sp = &st3;
		else sp = &st;

		auto&st = (*sp);
		if (op == in) {
				st.emplace(tmp);
		}
		else if (op == fi) {
			auto en = std::end(st);
			auto it = st.find(tmp);//std::find(std::begin(st), en, tmp);
			rv.push_back(it != en ? "yes":"no");
		}
	}

	for (const auto&e : rv)
		std::cout <<e<< "\n";

}


Measured memory_bytes: 52264
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
 
using namespace std;
 
constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;
using ll = long long int;
 


 
 
int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
  //ll N,M,K;
  string S,A = "ABC",B = "ARC";
 
	cin >> S;

  if(S == A){
    cout << B << endl;
  }
  else{
    cout << A << endl;
  }

}

Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 30 20:12:26 2020

@author: black
"""


X = int(input())
Hapiness = 0

a = X//500
b = (X - a * 500)//5

Hapiness = 1000 * a + 5 *b
print(Hapiness)

Measured memory_bytes: 3060
#include <stdio.h>
#define S 100

int main(void)
{
    int i, j, n, N[S], c=0;
    int temp, min;
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", &N[i]);
    for(i=0; i<n-1; i++){
        min=i;
        for(j=i+1; j<n; j++){
            if(N[j]<N[min]) min=j;
        }
        if(min!=i){
         temp=N[min];
         N[min]=N[i];
         N[i]=temp;
         c++;
         }
    }
    for(i=0; i<n; i++){
        if(i==n-1) printf("%d\n", N[i]);
        else printf("%d ", N[i]);
    }
    printf("%d\n", c);
    return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


string s;


bool solve(){
	if((SIZE(s)%2 == 0) ^ (s.front() == s.back())) return false;
	return true;
}


signed main(){
	cin >> s;

	if(solve()) cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}

Measured memory_bytes: 512