akhauriyash/Code-Regression huggingface dataset:
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=3005;double Pi=acos(-1.0);
double x[N],y[N],rx,ry,tmp;int a[N],n,L;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&L);Pi*=2.0/L;
	fp(i,1,n)scanf("%d",&a[i]),x[i]=cos(a[i]*Pi),y[i]=sin(a[i]*Pi);
	fp(i,1,n)fp(j,1,i-1){
		R int t=i-j-1;
		if(t){
			rx+=t*-cos((a[i]+a[j])*0.5*Pi);
			ry+=t*-sin((a[i]+a[j])*0.5*Pi);
		}
		t=n-i+j-1;
		if(t){
			rx+=t*cos((a[i]+a[j])*0.5*Pi);
			ry+=t*sin((a[i]+a[j])*0.5*Pi);
		}
	}
	tmp=1.0*n*(n-1)*(n-2)*0.5;
	rx/=tmp,ry/=tmp;
	rx*=3,ry*=3;
	printf("%.10lf %.10lf\n",rx,ry);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        while(true) {
            String x = stdIn.next();
            if(x.equals("0"))
                break;
            int sum = 0;
            for(int i = 0; i < x.length(); i++) {
                // sum += Character.digit(x.charAt(i), 10);
                sum += x.charAt(i) - '0';
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26160
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static int maxn = 200005;

    static class pair implements Comparable<pair> {
        int id;
        String s;
        int sc;

        pair(int a, String b, int c) {
            id = a;
            s = b;
            sc = c;
        }

        public int compareTo(pair a) {
            if (!this.s.equals(a.s))
                return this.s.compareTo(a.s);
            return a.sc - this.sc;
        }
    }

    static void solve() {
        int n = ni();
        int m = ni();
        List<Integer> sw[] = new ArrayList[n];
        for (int i = 0; i < n; i++)
            sw[i] = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            int k = ni();
            while (k-- > 0) {
                int s = ni() - 1;
                sw[s].add(i);
            }
        }
        int p[] = new int[m];
        for (int i = 0; i < m; i++)
            p[i] = ni();
        long ans = 0;
        int mask = 1 << n;
        for (int msk = 0; msk < mask; msk++) {
            int t[] = new int[m];
            for (int i = 0; i < n; i++) {
                if ((msk & (1 << i)) > 0) {
                    for (int h : sw[i])
                        t[h] = (t[h] + 1) % 2;
                }
            }
            int f = 0;
            for (int i = 0; i < m; i++) {
                if (t[i] != p[i]) {
                    f = 1;
                    break;
                }
            }
            if (f == 0)
                ans += 1;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 21460
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  cin>>s;
  string n=s;
  int a=s.size();
  if(s.size()<8)a=7;
  rep(i,a-7){
    string tmp=s.substr(i,8);
    sort(all(tmp));
    if(tmp=="AADINNUY")
      n.replace(i,8,"AIZUNYAN");
  }
  cout<<n<<endl;
}

Measured memory_bytes: 1212
N, M =map(int, input().split())
k_list = []
items = []
for i in range(N):
    tmp = tuple(map(int, input().split()))
    k_list.append(tmp[0])
    items.append(tmp[1:])

ans = set(items[0])

for i in range(1, N):
    item = items[i]
    item = set(item)
    ans = ans & item

print(len(ans))


Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (998244353)
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

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

int main() {
	int n;
	scanf("%d", &n);
	VI d(n);
	EACH(e, d) { scanf("%d", &e); }
	if(d[0] != 0) {
		puts("0");
		return 0;
	}
	sort(ALL(d));

	int last = 0;
	int lastIndex = 0;
	VI depth_nums(d[n - 1] + 1);
	REP(i, n) {
		if(d[i] != last) {
			depth_nums[last] = i - lastIndex;
			last = d[i];
			lastIndex = i;
		}
	}
	depth_nums[d[n - 1]] = n - lastIndex;

	ll result = 1;
	if(depth_nums[0] != 1) {
		puts("0");
		return 0;
	}
	REP(i, depth_nums.size() - 1) {
		if(depth_nums[i] == 0) {
			puts("0");
			return 0;
		}
		result = MOD(result * modpow(depth_nums[i], depth_nums[i + 1], MODNUM));
	}
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 1024
N = str(input())   # 単純な入力
# input = list(input()) # ひとかたまりの文字列をリスト化
# N = int(input())  # 整数一つ
# input = input().split()   # スペース区切りを文字としてリスト化
# X,Y = map(int,input().split())  # ２個や３個の整数をそれぞれ取得
for i in range(len(N)):
    for j in range(i,len(N)):
        if N[0:i] + N[j:len(N)] == "keyence":
            print("YES")
            exit()
print("NO")

Measured memory_bytes: 3060
#include <iostream>
long long n,a[300005],s=0,mod=1000000007,dp[100]={0};
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        long long cnt=0,t=a[i];
        while(t)
        {
            cnt++;
            if(t%2)
                dp[cnt]++;
            t/=2;
        }
    }
    long long ans = 0;
    for (int i = 0; i < 61; i++)
        ans =(ans%mod+ ((long long)(1LL << i)%mod*dp[i+1]%mod*(n-dp[i+1])%mod)%mod)%mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int a,l;
main()
{
	while(cin>>a>>l,l)
	{
		map<int,int>m;
		m[a]=1;
		for(int i=2;;i++)
		{
			int cnt[10]={};
			int p=10;
			for(int j=0;j<l;j++,p*=10)
			{
				cnt[a%p/(p/10)]++;
			}
			int maxa=0,mina=0;
			for(int i=9;i>=0;i--)
			{
				int nowcnt=0;
				while(cnt[i]>nowcnt)maxa=maxa*10+i,nowcnt++;
			}
			for(int i=0;i<10;i++)
			{
				int nowcnt=0;
				while(cnt[i]>nowcnt)mina=mina*10+i,nowcnt++;
			}
			a=maxa-mina;
			if(m[a])
			{
				cout<<m[a]-1<<" "<<a<<" "<<i-m[a]<<endl;
				break;
			}
			m[a]=i;
		}
	}
}


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

int main () {
    string s;
    cin >> s;
    int cntN = 0, cntW = 0, cntS = 0, cntE = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'N') cntN++;
        else if (s[i] == 'W') cntW++;
        else if (s[i] == 'S') cntS++;
        else cntE++;
    }

    if (cntN == 0 && cntS == 0 && cntW == 0 && cntE == 0) cout << "Yes" << endl;
    else if (cntN != 0 && cntS != 0 && cntW == 0 && cntE == 0) cout << "Yes" << endl;
    else if (cntN == 0 && cntS == 0 && cntW != 0 && cntE != 0) cout << "Yes" << endl;
    else if (cntN != 0 && cntS != 0 && cntW != 0 && cntE != 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c,d,ans = 0;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(d >= b && a <= c && c <= b){
    ans = b - c;
  }else if(d <= b && c <= a && a <= d){
    ans = d - a;
  }else if(a >= c && b <= d){
    ans = b - a;
  }else if(a <= c && b >= d){
    ans = d - c;
  }
  printf("%d\n",ans);
  return 0;
}

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

class stack{
public:
    int top;
    std::vector<int> value;

    stack(){
        top = 0;
        value.resize(100);
    }

    void push(int a){
        value[top] = a;
        top++;
    }

    int pop(void){
        top--;
        return value[top];
    }
};

void displayVector(std::vector<int> a, int n){
    for(int i = 0; i < n; i++){
        std::cout << a[i];
        if(i != n-1){
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}

int main(void){
    stack s;
    int ans = 0;
    std::string st;
    //std::istringstream ss;

    //std::cin.tie(0);
    //std::ios::sync_with_stdio(false);

    
    while(std::cin >> st){
        //std::cout << st << std::endl;
        int x, y;
        if(st != "+" && st != "-" && st != "*"){
            s.push(atoi(st.c_str()));
            //displayVector(s.value, s.value.size());
        }else{
            x = s.pop();
            y = s.pop();
            //std::cout << x << st << y << std::endl;
            if(st == "+"){
                ans = x + y;
                s.push(ans);
            }else if(st == "-"){
                ans = - x + y;
                s.push(ans);
            }else{
                ans = x * y;
                s.push(ans);
            }
            //std::cout << "ans:" << ans << std::endl;
            
        }
    }
    std::cout << ans << std::endl;

    
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    int p[N];
    for(int i=0; i<N; i++) scanf(" %d", &p[i]);

    int count = 0;
    for(int i=0; i<N; i++){
        if(p[i] != i+1) count++;
    }
    if(count == 0 || count == 2) std::cout << "YES" << std::endl;
    else std::cout << "NO" << std::endl;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

void dfs(st dokei, ll n){
  if(n == 1){
    cout << dokei << endl;
    return;
  }
  char max = 'a';
  vrep(i, dokei) if(max < i) max = i;
  rep(i, 0, max - 'a' + 2){
    st next = dokei;
    next.push_back((char)('a' + i));
    dfs(next, n - 1);
  }
}

int main(){
  ll n;
  cin >> n;
  dfs("a", n);
}

Measured memory_bytes: 1536
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s: String = sc.next()

    val tmp = s.split("/")
    val yyyy = tmp[0].toInt()
    val mm = tmp[1].toInt()
//    val dd = tmp[2].toInt()
    if (2018 >= yyyy) {
        print("Heisei")
        return
    }
    if (4 >= mm) {
        print("Heisei")
        return
    }
    print("TBD")
}


Measured memory_bytes: 35828
## global variables

$U = {}

### subroutines

def op_u(set0, set1)
  res = {}
  (set0.keys + set1.keys).each{|i| res[i] = 1}
  res
end

def op_i(set0, set1)
  res = {}
  set0.keys.each{|i| res[i] = 1 if set1.include?(i)}
  res
end

def op_d(set0, set1)
  res = {}
  set0.keys.each{|i| res[i] = 1 if ! set1.include?(i)}
  res
end

def op_s(set0, set1)
  op_u(op_d(set0, set1), op_d(set1, set0))
end

def op_c(set0)
  op_d($U, set0)
end

### <exp> := <term> (op2 <term>)*
### <term> := '(' <exp> ') | op1 <term> | sn
###   op2 := [uids], op1 := 'c', sn := [A-E]

def calc_exp()
  t0 = calc_term()

  while ! $expr[$pc].nil? && 'uids'.include?($expr[$pc])
    op2 = $expr[$pc]
    $pc += 1
    t1 = calc_term()

    case op2
    when 'u'
      t0 = op_u(t0, t1)
    when 'i'
      t0 = op_i(t0, t1)
    when 'd'
      t0 = op_d(t0, t1)
    when 's'
      t0 = op_s(t0, t1)
    end
  end

  t0
end

def calc_term()
  case $expr[$pc]
  when '('
    $pc += 1
    exp0 = calc_exp()
    $pc += 1
    return exp0
  when 'c'
    $pc += 1
    return op_c(calc_term())
  end

  ret = $sets[$expr[$pc]]
  $pc += 1
  ret
end

### main

while line = gets
  line.strip!

  $sets = {}
  ('A'..'E').each{|sn| $sets[sn] = {}}
  $U = {}

  while line != 'R 0'
    sn, k = line.split(' ')
    gets.strip.split(' ').each{|s| $sets[sn][s.to_i] = $U[s.to_i] = 1}
    line = gets.strip
  end
  #p $sets
  #p $U

  $expr = gets.strip
  $pc = 0

  ans = calc_exp()

  if ans.empty?
    puts 'NULL'
  else
    puts ans.keys.sort.join(' ')
  end
end

Measured memory_bytes: 6128
#include <iostream>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,j) for(int i=0;i<j;i++)

int main(void){

    int a,b,c;
    int x=0;
    cin >> a >> b >> c;

    REP(i,a,b+1){
        if(c % i == 0)
            x++;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 2");
            WillReturn.Add("3");
            WillReturn.Add("2 1 1");
            //1 1
            //2 3
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 5");
            WillReturn.Add("5");
            WillReturn.Add("1 2 3 4 5");
            //1 4 4 4 3
            //2 5 4 5 3
            //2 5 5 5 3
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1 1");
            WillReturn.Add("1");
            WillReturn.Add("1");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int H = wkArr[0];
        int W = wkArr[1];

        int[] AArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray();

        int UB_X = W - 1;
        int UB_Y = H - 1;

        int[,] BanArr = new int[UB_X + 1, UB_Y + 1];
        int CurrInd = 0;

        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                int TargetX = X;
                if (Y % 2 == 1) TargetX = UB_X - X;

                BanArr[TargetX, Y] = CurrInd + 1;
                AArr[CurrInd]--;
                if (AArr[CurrInd] == 0) {
                    CurrInd++;
                }
            }
        }

        var sb = new System.Text.StringBuilder();
        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                sb.Append(BanArr[X, Y]);
                if (X < UB_X) sb.Append(" ");
            }
            sb.AppendLine();
        }
        Console.Write(sb.ToString());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,inv,finv;
public:
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};


int main(){
    int X,Y;
    cin >> X >> Y;
    if(X-2*Y>0 || 2*X-Y<0){
        cout << 0 << endl;
        return 0;
    }
    if((2*Y-X)%3!=0 || (2*X-Y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    int a = (2*Y-X)/3,b = (2*X-Y)/3;
    combination comb(a+b);
    mint ans = comb.comb(a+b,a);
    cout << ans.x << endl;
}

Measured memory_bytes: 15872
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int i,n;cin>>n;
	string ue;
	string st;
	llint ans=1,mae;
	cin>>ue;
	cin>>st;
	ue.pub('#');
	if(ue[0]==ue[1]){ans=6;mae=2;}
	else{ans=3;mae=1;}
	for(i=mae;i<n;i++){
		if(ue[i]==ue[i+1]){
			
			if(mae==2){ans*=3;ans%=mod;}
			else{ans*=2;ans%=mod;}
			i++;
			mae=2;
		}else{
			if(mae==1){ans*=2;ans%=mod;}
			mae=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 888
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,m,a[200111],dp[200111][2];
int main()
{
	get1(m);
	LL ans=0;
	for(int i=1,x;i<=m;i++)
	{
		get1(x);
		ans+=(x-1)/2;
		x-=(x-1)/2*2;
		while(x--)a[++n]=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=dp[i][1]=max(dp[i-1][0],dp[i-1][1]);
		if(i>1&&abs(a[i]-a[i-1])<=1)dp[i][1]=max(dp[i][1],dp[i-1][0]+1);
	}
	printendl(dp[n][1]+ans);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
typedef pair<LL,LL> P;

const LL MAX_N = 1 << 18;

//セグメント木を持つグローバル配列
LL n;
P dat[2*MAX_N-1];

//初期化
void init(LL n_){
   //簡単のために要素数を2のべき乗に
   n=1;
   while(n<n_) n*=2;
   //全ての値をINT_MAXに
   for(int i=0;i<2*n-1;i++) dat[i]=P(1e7,0);
}

//k番目の値(0-indexed)をaに変更
void update(int k,P p){
   //葉の節点
   k+=n-1;
  dat[k]=p;
  //登りながら更新
  while(k>0){
     k=(k-1)/2;
     dat[k] = min(dat[k*2+1],dat[k*2+2]);
  }
}
//[a,b)の最小値を求める
//後ろの方の引数は、計算の簡単のための引数
//kは節点の番号、l,rはその接点が[l,r)に対応していることを表す
//従って外からはquery(a,b,0,0,nと呼ぶ)
P query(int a,int b,int k=0,int l=0,int r=n){
    //[a,b)と[l,r)が交差しなければINT_MAX
    if(r<=a||b<=l) return P(1e7,0);
    //[a,b)が[l,r)を完全に含んでいればこの接点の値
    if(a<=l&&r<=b) return dat[k];
    else{
       //そうでなければ、2つの子の最小値
       P vl =query(a,b,k*2+1,l,(l+r)/2);
       P vr =query(a,b,k*2+2,(l+r)/2,r);
       return min(vl,vr);
    }
}


int N,M;
int L[250001];
int R[250001];
bool used[250001];
vector<P>v;
vector<LL>que;
int main(){
	cin>>N>>M;
	REP(i,N){
	    cin>>L[i]>>R[i];
	    v.push_back(P(R[i],L[i]));
	    //if(i%1000==0)cout<<i<<endl;
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());

	//初期化
	init(M+10);
	REP(i,M+10){
	    update(i,P(-i,i));
	    used[i]=false;
	    if(i>M){
	       used[i]=true;
	    }
	}
	update(0,P(1e7,0));
        used[0]=true;
        int c=0;
	//Riの大きい方から順に取り出す
	REP(i,N){
	    P q=query(0,v[i].second+1);
	    if(q.first>M){
	       if(used[q.second]==false){
	          int a=0;
	          int b=1/a;
	          return -1;
	       }
	       que.push_back(v[i].first);
	    }else{
              c++;
	       used[q.second]=true;
	       update(q.second,P(1e7,0));
	    }
	}
	sort(que.begin(),que.end());
	int count=0;
        for(int i=c+1;i<M+1;i++){
	   if(que.size()==count)break;
	   //if(used[i]==false){
	      if(que[count]<=i){
	         count++;
	      }
	   //}
	}
	cout<<max(max(N-M,0),(int)que.size()-count)<<endl;
	return(0);
}

Measured memory_bytes: 17260
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
      
  	Integer result=15;
  	for(int i=0;i<5;i++){
      Integer num = scan.nextInt();
      result-=num;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35464
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int X = Integer.parseInt(scan.next());
	int A = Integer.parseInt(scan.next());
	int B = Integer.parseInt(scan.next());

	int days = B - A;
	String ans = (days <= 0 ? "delicious" : (days <= X ? "safe" : "dangerous"));

	System.out.println(ans);
	scan.close();
    }
}


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

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    string ans = "NO";
    LL sz = SZ(s);
    for(int i = 0; i < sz; i++){
         for(int j = i; j <= sz; j++){
             string x = s;
             x.erase(i, j - i);
             if(x == "keyence"){
                 ans = "YES";
                 goto END;
             }
         }
    }

END:
    PUTS(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    int count=0;
    int count2=0;

    for (int i=1;i<=n;i++) {
        if(i%2==1){
            for (int j=1;j<=i;j++) {
                if(i%j==0){
                    count++;
                }
            }

            if(count==8){
                count2++;
            }
            count=0;
        }
    }

    cout<<count2<<endl;

}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
//#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define MOD (int)(1E9 + 7)
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++)
        if (!(i % k))
        {
            cout << "OK" << endl;
            GAME_OVER;
        }
    cout << "NG" << endl;
    GAME_OVER;
}

Measured memory_bytes: 3624
// 2014/06/16 Tazoe

#include <iostream>
using namespace std;

const int INF = 1000000000;

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;		// ���̑���

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(T[i][j] > T[i][k]+T[k][j])
            T[i][j] = T[i][k] + T[k][j];
        }
      }
    }
    int min_town_n;
    int min_town_time = INF;
    for(int k=0;k<m;k++){
      int sub = 0;
      for(int i=0;i<m;i++){
        if(T[k][i] != INF)
          sub += T[k][i];
          //cout << T[k][i] << ",";
      }
      //cout << " sub = " << sub << endl;
      if(min_town_time > sub){
        min_town_time = sub;
        min_town_n = k;
      }
    }
    cout << min_town_n << ' ' << min_town_time << endl;
	}

	return 0;
}



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

typedef long long ll;

int main() {
    int N; cin >> N;
    string A,B,C;
    cin >> A >> B >> C;
    
    int ans=0;
    for(int i=0; i<N; i++){
        if(A[i] != B[i] && B[i] != C[i] && C[i] != A[i]){
            ans += 2;
        }
        else if(A[i] != B[i] || B[i] != C[i] || C[i] != A[i]){
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))
a = list(map(int,input().split()))
a.pop(0)
ans = a
for i in range(N-1):
    a = list(map(int,input().split()))
    a.pop(0)
    x = set(a) & set(ans)
    ans = list(x)
print(len(ans))

Measured memory_bytes: 38256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

//func nextInt() int {
//	sc.Scan()
//	i, e := strconv.Atoi(sc.Text())
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

func main() {
	a := nextString()
	r := a[0]

	if r >= 'a' && r <= 'z' {
		fmt.Println("a")
		return
	}
	fmt.Println("A")
	return
}


Measured memory_bytes: 1804
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<string> line(N);
    REP(i,N){
        cin >> line[i];
    }
    int ans = 0;
    int A=0;
    int B=0;
    int AB=0;
    REP(i,N){
        string nstring = "";
        for(int j=0;j<line[i].size();++j){
            if(j+1<line[i].size()&&line[i][j]=='A'&&line[i][j+1]=='B'){
                ++ans;
                ++j;
            }else{
                nstring += line[i][j];
            }
        }
        line[i] = nstring;
        string s = "AA";
        s[0] = line[i][0];
        s[1]= line[i][line[i].size()-1];
        if(s=="BA"){
            ++AB;
        }else if(s[1]=='A'){
            ++A;
        }else if(s[0]=='B'){
            ++B;
        }
    }
    if(AB >= 1){
        ans += AB - 1;
        if(A>0){
            ++ans;
            --A;
        }
        if(B>0){
            ++ans;
            --B;
        }
    }
    ans += min(A,B);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
n  = gets.to_i
now = 0
result = 0
ans,put = 0,0
for i in 0..n/2
	now = n - i
	while true do
		if now % 2 == 0
			result += 1
			now /= 2
			# p "re =+ #{result}, now = + #{now}"
		else
			break
		end
	end
	if ans < result
		ans = result
		put = n-i
	end
	result = 0
end
puts put == 0 ? 1 : put

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


#define INF 1000000000000

signed main()
 {
   int r;cin>>r;
   if(r<1200){cout<<"ABC";}
   else if(r<2800){cout<<"ARC";}
   else cout<<"AGC";
 }


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n;
int a[21][21];
int dp[22][1LL<<21];

signed main(){
    I(n);
    REP(i,n) REP(j,n) I(a[i][j]);

    dp[0][0] = 1;
    REPS(i,n){
        REP(j, 1 << n){
            if (__builtin_popcount(j) != i) continue;
            REP(k,n){
                if ((j & (1 << k)) && a[i-1][k]){
                    dp[i][j] += dp[i-1][j ^ (1 << k)];
                }
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n][(1 << n)-1] << endl;
}

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

#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl         "\n"
#define int          long long
#define all(v)       v.begin(),v.end()
#define sz(v)        (int)v.size()
#define pii          pair<int,int>
#define fi           first
#define se           second
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define deb(x)       cout << #x << ' ' << x << endl
#define clock        cerr << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms" << endl;

void INPUT() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

const int mod = 1e9 + 7;

const int N = 1005;
char a[N][N];
int cache[N][N];
int n, m;

int dp(int i, int j) {
	if (i >= n || j >= m) return 0;
	if (a[i][j] == '#') return 0;
	if (i == n - 1 && j == m - 1) return 1;
	int &ans = cache[i][j];
	if (ans != -1) return ans;
	ans = dp(i + 1, j) + dp(i, j + 1);
	ans %= mod;
	return ans;
}

int32_t main(){
    IOS //INPUT();
    cin >> n >> m;
    forn(i, 0, n) {
    	forn(j, 0, m) cin >> a[i][j];
    }
    memset(cache, -1, sizeof(cache));
    int ans = dp(0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<29;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int n;
vector<int> v[100001];
int d[2][100001];
void bfs(int i){
  queue<int> q;
  q.push(i);
  rep(j,n)
    d[i][j]=inf;
  d[i][i]=0;
  while(!q.empty()){
    int x=q.front();
    q.pop();
    rep(j,v[x].size())
      if(d[i][v[x][j]]==inf){
        d[i][v[x][j]]=d[i][x]+1;
        q.push(v[x][j]);
        }
    }
  }
int main(){
  cin>>n;
  int a,b;
  rep(i,n-1){
  cin>>a>>b;
  a%=n;
  b%=n;
  v[a].push_back(b);
  v[b].push_back(a);
    }
  bfs(0);
  bfs(1);
  int snuke,fennec;
  snuke=fennec=0;
  rep(i,n){
    if(d[0][i]<d[1][i])
      snuke++;
    else
      fennec++;
    }
  if(fennec>snuke)
    cout<<"Fennec"<<endl;
  else
    cout<<"Snuke"<<endl;
  return 0;
  
  }

  

Measured memory_bytes: 6656
from heapq import heappush, heappop


N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

MOD = 10**9 + 7

# case1. N == K のときは答えは確定
if N == K:
    ans = 1
    for i in range(K):
        ans *= A[i]
        ans %= MOD
    print(ans)
# case2. A が全部負の数のとき、 Kが奇数ならば残念ながら答えは負になるのでなるべく絶対値を小さくする
elif max(A) < 0 and K % 2 == 1:
    ans = 1
    for i in range(K):
        ans *= A[i]
        ans %= MOD
    print(ans)
else:
    # case3. それ以外は正にできる

    # K が奇数のとき、非負要素から1つ取って偶数の場合に帰着
    # K が偶数のとき、面倒なので 2 つセットで考えて K//2 個取る問題に帰着

    if K%2 == 1:
        ans = A.pop(0)  # あらかじめ最大値を確保
        n = (K-1)//2
    else:
        ans = 1
        n = K//2

    # 絶対値の降順にソートする
    A = sorted(A, key=lambda x: abs(x), reverse=True)

    # 候補テーブルを作成
    cand = []  # 非負要素、負要素をそれぞれ絶対値の大きい順に 2 つずつ掛けたもの

    BIGINT = 10**9 + 1  # tmp 用
    tmp1 = BIGINT
    tmp2 = BIGINT

    for a in A:
        if a >= 0:
            if tmp1 == BIGINT:
                tmp1 = a
            else:
                heappush(cand, -tmp1*a)
                tmp1 = BIGINT
        else:
            if tmp2 == BIGINT:
                tmp2 = a
            else:
                heappush(cand, -tmp2*a)
                tmp2 = BIGINT

    # あとは大きい方から n 個取る
    for i in range(n):
        ans *= -heappop(cand)
        ans %= MOD
    print(ans)


Measured memory_bytes: 33160
j,w,l,p[5];main(i){for(;1-scanf("%d%d%d%d%d",p,p+1,p+2,p+3,p+4);)for(i=0;i<5;i++,puts(w?l?"3":"1":l?"2":"3"))for(j=w=l=0;j<5;j++)p[i]-p[j]?p[i]%3+1==p[j]?w++:l++:0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main(){
	int x,y;
	while(cin>>x>>y){
		if(x==y)cout<<-1<<endl;
		else{
			if(x%y==0)cout<<-1<<endl;
			else cout<<x<<endl;
		}
	}
	return 0;	
}

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity() ? std::numeric_limits<T>::infinty() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n; cin >> n;
	vi v(n); cin >> v;
	min_queue<double> q;
	for (int x : v) q.push(x);
	while (int(q.size()) >= 2) {
		double lo = q.top(); q.pop();
		double hi = q.top(); q.pop();
		q.push((lo + hi) / 2);
	}
	cout << fixed << setprecision(6) << q.top() << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

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

// vim: fdm=marker


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

min_val = -1
for i in range(100):
    pos = i+1
    tmp = 0
    for x in x_list:
        tmp += (x - pos)**2
    if tmp < min_val or min_val == -1:
        min_val = tmp
print(min_val)


Measured memory_bytes: 2940
def main():
    s = input()
    t = input()

    rep = {}
    for ss, tt in zip(s, t):
        if ss in rep and rep[ss] != tt:
            print('No')
            return
        rep[ss] = tt

    if len(rep) == len(set(t)):
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,A;
    cin >> N;
    bool result = true;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if(A%2==0){
            if(A%3!=0&&A%5!=0){
                result = false;
                break;
            }
        }
    }
    if(result){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
}

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

x_list = []
u_list = []
for _ in range(N):
    x, u = input().split()
    x_list.append(float(x))
    u_list.append(u)
ans = 0
for x, u in zip(x_list, u_list):
    if u == 'JPY':
        ans += x
    elif u == 'BTC':
        ans += x * 380000

print(ans)


Measured memory_bytes: 3060
N = int(input())

S = []
T = []

for i in range(N):
  s, t = input().split()
  S.append(s)
  T.append(int(t))

X = input()

for i, s in enumerate(S):
  if s == X:
    idx = i
    break

print(sum(T[idx+1:]))

Measured memory_bytes: 3316
/*
* 最短経路の練習：「Warshall-Floyd法」
* ABC160 D
* https://atcoder.jp/contests/abc160/tasks/abc160_d
* 
* 期待する入力
* N X Y
* 3 <= N <= 2000
* 1 <= X, Y <= N
* X+1 < Y
*/

package main

import (
	"fmt"
)

func main() {
	var N, X, Y int
	fmt.Scanf("%d %d %d", &N, &X, &Y)
	
	// 距離計算「Warshall-Floyd法」
	// 今回、エッジの距離は全て１だが、1以外でも行けるはず...
	// 参考：https://qiita.com/ta-ka/items/a023a11efe17ab097433#warshall-floyd%E6%B3%95
	distance := make([][]int, N)
	counter := make([]int, N-1)
	ks := []int{0, X-1, Y-1}  // 0は初期化するため
	for index, k := range ks {
		for i := 0; i < N; i++ {
			if k == 0 {
				distance[i] = make([]int, N)
				if i == (X-1) {
					distance[i][Y-1] = 1
				} else if i == (Y-1) {
					distance[i][X-1] = 1
				}
			}
			for j := 0; j < i; j++ {
				if k == 0 {
					isSetedDistance := false
					isSetedDistance = isSetedDistance || i == j
					isSetedDistance = isSetedDistance || i == (X - 1) && j == (Y - 1)
					isSetedDistance = isSetedDistance || j == (X - 1) && i == (Y - 1)
					if !isSetedDistance {
						distance[i][j] = i - j  // 迂回路が無い場合の距離を計算
					}
				}
				distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j])
				distance[j][i] = distance[i][j]  // 無向グラフのため、対称行列
				if index == 2 {
					counter[distance[i][j]-1] += 1
				}
			}
		}
	}

	// 表示
	for _, num := range counter {
		fmt.Println(num)
	}

}

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


Measured memory_bytes: 60928
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstring>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using Graph = vector<vector<int>>;

ll INF = 1LL << 60;

Graph G;
vector<bool> seen;
vector<int> d, f;

void dfs(Graph& G, int v, int& num) {
	seen[v] = true;
	d[v] = num++;
	for (int nv : G[v]) {
		if (seen[nv]) continue;
		dfs(G, nv, num);
	}
	f[v] = num++;
}

int main() {
	int n;
	cin >> n;
	G.resize(n);
	seen.resize(n);
	d.resize(n);
	f.resize(n);
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			v--;
			G[u].push_back(v);
		}
	}

	int num = 1;
	for (int i = 0; i < n; i++) {
		if (!seen[i]) dfs(G, i, num);
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
 
 
	public void run() {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		if(A==1||B==1){
		    if(A<B){
		        System.out.println("Alice");
		    }else if(A==B){
		        System.out.println("Draw");
		    }else{
		        System.out.println("Bob");
		    }
		}else{
		    if(A<B){
		        System.out.println("Bob");
		    }else if(A==B){
		        System.out.println("Draw");
		    }else{
		        System.out.println("Alice");
		    }
		}
		
		
		sc.close();
	}
		
}


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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


void dijkstra(vector<ll>& dist, const vector<vector<ll>> G, ll s, ll N)
{
    priority_queue<P, vector<P>, greater<P>> Q;
    vector<ll> d(N, INF);
    d[s] = 0;
    Q.push(P(0, s));

    while(!Q.empty()) {
        P p = Q.top();
        Q.pop();
        ll v = p.second;
        if(d[v] < p.first) continue;
        FORR(nv,G[v]) {
            if(d[nv] > d[v] + 1) {
                d[nv] = d[v] + 1;
                Q.push(P(d[nv],nv));
            }
        }
    }
    REP(i,0,N) ++dist[d[i]];
}

int main()
{
    ll N, X, Y;
    cin >> N >> X >> Y;
    --X; --Y;
    vector<vector<ll>> G(N);
    REP(i,0,N-1) {
        G[i].pb(i+1);
        G[i+1].pb(i);
    }
    G[X].pb(Y);
    G[Y].pb(X);

    vector<ll> dist(N, 0);
    REP(i,0,N) dijkstra(dist, G, i, N);
    REP(i,1,N) _PR(dist[i]/2);

    return 0;
}

/*



*/ 

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


int main(){ 
  int N,K;
  cin >> N >> K;
  vector<int> H(1000000);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  vector<long long> dp(10000000,100000000000000);
  dp.at(0)=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<K+1;j++){
      dp.at(i+j)=min(dp.at(i+j),dp.at(i)+abs(H.at(i+j)-H.at(i)));
    }
  }
  cout << dp.at(N-1) << endl;
} 

Measured memory_bytes: 85356
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,p;
    cin>>n;
    int sum=0,ex=0;
    rep(i,n){
        cin>>p;
        sum+=p;
        ex=max(ex,p);
    }
    cout<<sum-ex/2;
}

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

int insertionSort(int values[], int n, int g) {
  int count = 0;
  for (int i = g; i < n; i++) {
    int value = values[i];
    int j = i - g;
    while (j >= 0 && values[j] > value) {
      values[j + g] = values[j];
      j = j - g;
      count++;
    values[j + g] = value;
    }
  }
  return count;
}

int shellSort(int values[], int n, int gaps[], int m) {
  int count = 0;

  for (int i = 0; i < m; i++) {
    count += insertionSort(values, n, gaps[i]);
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  int values[n];

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

  int m = 0;
  int gaps[100];
  int gap = n - 1;
  for (int i = 0; i <= 100; i++) {
    gaps[i] = gap;
    m++;
    if (gap == 1) {
      break;
    }
    gap /= 4;
    if (gap < 1 || i == 100) {
      gap = 1;
    }
  }

  int count = shellSort(values, n, gaps, m);

  cout << m << endl;
  for (int i = 0; i < m; i++) {
    cout << gaps[i];
    if (i != m - 1) cout << " ";
  }
  cout << endl;
  cout << count << endl;

  for (int i = 0; i < n; i++) {
    cout << values[i] << endl;
  }
}



Measured memory_bytes: 6984