akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>=(int)(y);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
int N;
int X[MAX_N], Y[MAX_N];
vector< pair<int, int> > xis, yis; // <coordinate, index>

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
            src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

Graph makeGraph(){
    Graph graph(N);
    sort(all(xis));
    sort(all(yis));

    REP(i, 0, N-1){
        int src_x = xis[i].first;
        int src_index = xis[i].second;
        int dst_x = xis[i+1].first;
        int dst_index = xis[i+1].second;
        Edge edge_src = Edge(src_index, dst_index, dst_x - src_x);
        graph[src_index].push_back(edge_src);
        Edge edge_dst = Edge(dst_index, src_index, dst_x - src_x);
        graph[dst_index].push_back(edge_dst);
    }

    REP(i, 0, N-1){
        int src_y = yis[i].first;
        int src_index = yis[i].second;
        int dst_y = yis[i+1].first;
        int dst_index = yis[i+1].second;
        Edge edge_src = Edge(src_index, dst_index, dst_y - src_y);
        graph[src_index].push_back(edge_src);
        Edge edge_dst = Edge(dst_index, src_index, dst_y - src_y);
        graph[dst_index].push_back(edge_dst);
    }
    return graph;
}

pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r = 0) {
    int n = g.size();
    Edges T;
    Weight total = 0;

    vector<bool> visited(n);
    priority_queue<Edge> Q;
    Q.push( Edge(-1, r, 0) );
    while (!Q.empty()) {
        Edge e = Q.top(); Q.pop();
        if (visited[e.dst]) continue;
        T.push_back(e);
        total += e.weight;
        visited[e.dst] = true;
        FOR(f, g[e.dst]) if (!visited[f->dst]) Q.push(*f);
    }
    return pair<Weight, Edges>(total, T);
}

int solve() {
    Graph g = makeGraph();
    return minimumSpanningTree(g).first;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i, 0, N){
        cin >> X[i] >> Y[i];
        xis.push_back(make_pair(X[i], i));
        yis.push_back(make_pair(Y[i], i));
    }
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 16360
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j;
    char a[4][4];
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
            scanf("%c",&a[i][j]);
        getchar();
    }
    printf("%c%c%c\n",a[0][0],a[1][1],a[2][2]);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){

	string s;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;

	ll n = s.size();
	if(s.size() < 26){
		vector<bool> used(n);
		for(int i = 0; i < n; i++){
			used[s[i]-'a'] = true;
		}
		for(int i = 0; i < 26; i++){
			if(used[i] == false){s += char(i+'a');break;}
		}
		cout << s << endl;
	}
	else{
		if(s == "zyxwvutsrqponmlkjihgfedcba"){
			cout << -1 << endl;
			return 0;
		}
		string s2 = s;
		next_permutation(s2.begin(),s2.end());
		for(int i = 0; i < n; i++){
			cout << s2[i];
			if(s2[i] != s[i])break;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
while(true)
{
    $in = explode(" ", trim(fgets(STDIN)));
    $a = $in[0];
    $op = $in[1];
    $b = $in[2];
    if($op == "?")
    {
        break;
    }
    else
    {
        switch ($op) {
            case '+':
                echo $a + $b;
                break;
            case '-':
                echo $a - $b;
                break;
            case '*':
                echo $a * $b;
                break;
            default:
                echo floor($a / $b);
                break;
        }
        echo "\n";
    }
}

Measured memory_bytes: 15248
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 5 * (int)1e5 + 100;
int dp[maxN];
string s;
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> s;
    n = s.size() + 1;
    for (int iter = 0; iter < 4; iter++) {
        for (int i = n - 1; i >= 1; i--) {
            if (s[i - 1] == '>') {
                dp[i - 1] = max(dp[i - 1], dp[i] + 1);
            }
        }
        for (int i = 0; i + 1 < n; i++) {
            if (s[i] == '<') {
                dp[i + 1] = max(dp[i] + 1, dp[i + 1]);
            }
        }
    }
    ll sum = 0;
    for (int i = 0; i < n; i++) sum += dp[i];
    cout << sum;
    return 0;
}

Measured memory_bytes: 2844
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long int;

int main()
{
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	auto x = [n](ll i) -> ll { return (n + i - 1) / i; };
	cout << 4 + max(x(a), max(x(b), max(x(c), max(x(d), x(e))))) << endl;
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, K; cin >> N >> K;
    vi x(N); REP(i, N) cin >> x[i];

    ll ans = INF;
    for(int i = 0; i < N - K + 1; i++)
    {
        ll d1 = abs(x[i]) + abs(x[i+K-1] - x[i]);
        ll d2 = abs(x[i+K-1]) + abs(x[i] - x[i+K-1]);
        if(x[i+K-1] < 0) ans = min(ans, (ll)abs(x[i]));
        else if(x[i] >= 0) ans = min(ans, (ll)abs(x[i+K-1]));
        else ans = min(ans, min(d1, d2));
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

typedef long long ll;

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

    vector<ll> A(N, 0);
    for(int i = 0; i < N; i++) cin >> A[i];

    vector<int> min_color(N, 1);
    vector<ll> color_min_val;
    color_min_val.push_back(A[0]);
    for(int i = 1; i < N; i++) {
        auto Iter = lower_bound(color_min_val.begin(), color_min_val.end(), A[i]);
        //int dist = distance(color_min_val.begin(), Iter);
        if(Iter == color_min_val.begin()) {//) {
            color_min_val.insert(color_min_val.begin(), A[i]);
            min_color[i] = min_color[i-1] + 1;
        } 
        else {
            *(Iter-1) = A[i];
            min_color[i] = min_color[i-1];
        }
    }

    cout << min_color[N-1] << endl;

}

Measured memory_bytes: 2552
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();
    String E = sc.next();
    char[]e = E.toCharArray();
  
    for(int i=0; i<E.length(); i++) {
      		System.out.print(ss[i]); 
    		System.out.print(e[i]); 
    	}
    if(S.length() != E.length()) {
    		System.out.print(ss[S.length()-1]);
    }
    }
}


Measured memory_bytes: 35684
#include <iostream>

int main()
{
  int N;
  std::cin >> N;
  bool can = false;
  int a = 1;
  int b = 1;
  for (a = 1; a <= 9; ++a)
  {
    for (b = 1; b <= 9; ++b)
    {
      if (a*b == N)
      {
        can = true;
        break;
      }
    }
    if (b <= 9)
      break;
  }  
  std::cout << (can ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int A,B,M,ans,a[100010],b[100010];

int main() {
	cin>>A>>B>>M;
	for(int i=1;i<=A;i++) a[i]=gi();
	for(int i=1;i<=B;i++) b[i]=gi();
	ans=*min_element(a+1,a+A+1)+*min_element(b+1,b+B+1);
	while(M--) {
		int x=gi(),y=gi(),c=gi();
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	
	public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
       int ar[]=new int[] {0,0,0,0};
       for(int i=0;i<3;i++)
       {
           int a=sc.nextInt();
           int b=sc.nextInt();
           ar[a-1]+=1;
           ar[b-1]+=1;
       }
       for(int i:ar)
       {
           if(i>2)
           {
               System.out.println("NO");
               System.exit(0);
           }
       }
       System.out.println("YES");
    }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	int n,m;
	double table[][];
	double memo[][];
	public static void main(String[] args) {
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);

		while(true){
			n=sc.nextInt();
			m=sc.nextInt();
			if(n+m==0) break;
			table=new double[n][n];
			memo=new double[n][m];

			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					table[i][j]=sc.nextDouble();
				}
			}
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					memo[i][j]=-1;
				}
			}
			for(int i=0;i<n;i++){
				memo[i][m-1]=1;
			}
			for(int i=0;i<n;i++){
				bt(i,0);
//				for(int j=0;j<n;j++){
//					for(int k=0;k<m;k++){
//						System.out.print(" "+j+","+k+" "+memo[j][k]);
//					}
//					System.out.println();
//				}
//				System.out.println();
			}
			
			double max=0;
			for(int i=0;i<n;i++){
				max=Math.max(max, memo[i][0]);
			}
			System.out.printf("%.2f\n",max);
		}
	}

	double bt(int x,int d){
		if(m<=d) return 1;

		if(memo[x][d]!=-1) return memo[x][d];

		double max=0;
		for(int i=0;i<n;i++){
			//System.out.println("x="+x+" d="+d+" i="+i+" x="+x);
			max=Math.max(max,bt(i,d+1)*table[i][x]);
		}

		return memo[x][d]=max;
	}

}

Measured memory_bytes: 63956
'use strict'

class Main {
  check(n) {
    const ret = [];
    n[1] = (n[1] == null ? 0 : n[1]);
    ret[0] = (n[0] == n[1]) ? 0 : 1;
    for (let i = 1; i< n.length; ++i) {
      const dig = ((n[i] == 1) && (n[0] == 0)) ? 1 : 0;
      ret.push(dig);
    } 
    return ret;
  }

  solve() {
    const nums = input.nextIntArr();
    if (nums[0] > 0) {
      --nums[0];
    }
    const a = Array.from(nums[0].toString(2)).reverse()
    .map(e => parseInt(e));
    const b = Array.from(nums[1].toString(2)).reverse()
    .map(e => parseInt(e));
    const ret = [];
    for(let i = 0; i < Math.max(a.length, b.length); ++i) {
      a[i] = (a[i] == null ? 0 : a[i]);
      b[i] = (b[i] == null ? 0 : b[i]);
    }
    const dig_a = this.check(a);
    const dig_b = this.check(b);
    for (let i = 0; i < dig_a.length; ++i) {
      ret.push(dig_a[i] == dig_b[i] ? 0 : 1);
    }
    
    console.log(parseInt(ret.reverse().join(''),2));
  }
}

class Input {
  constructor() {
	this.cursor = 0;
	this.inputAll();
  }

  inputAll() {
	this.data = (require("fs").readFileSync("/dev/stdin", "utf8")).split('\n');
	return this.data;
  }

  nextLine(n) {
	if (n) {
	  const ret = this.data.slice(this.cursor, this.cursor + n);
	  this.cursor += n;
	  return ret;
	}
	return this.data[this.cursor++];
  }

  nextStrArr() {
	return this.nextLine().split(' ');
  }

  nextIntArr() {
	return this.nextStrArr().map((e) => parseInt(e));
  }

  nextFloatArr() {
	return this.nextStrArr().map((e) => parseFloat(e));
  }

  nextIntLine(n) {
	return this.nextLine(n).map((e) => parseInt(e))
  }

  nextFloatLine(n) {
	return this.nextLine(n).map((e) => parseFloat(e))
  }

  nextStrRange(n) {
	return this.nextLine(n).map((line) => line.split(' '));
  }

  nextIntRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseInt(e)));
  }

  nextFloatRange(n) {
	return this.nextLine(n).map((line) => line.split(' ').map((e) => parseFloat(e)));
  }
}

const input = new Input();
(new Main()).solve();


Measured memory_bytes: 9420
//Let's play :)
#include<bits/stdc++.h>
using namespace std;

#define tarzan ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 

int rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
int cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

const int mod = 1e9 + 7;
const int N = 300050;

bool isok(string s) {
    string a = s;
    reverse(a.begin(), a.end());
    return (a == s);
}

signed main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    tarzan;
    int test = 1;
    //cin >> test;
    while(test--) {
        string s;
        cin >> s;
        int n = s.size();
        string a = s.substr(0, (n - 1) / 2);
        string b = s.substr(n / 2 + 1, (n - 1) / 2);
        if(isok(s) && isok(a) && isok(b)) {
            cout << "Yes\n";
        }
        else cout << "No\n";

    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,m = [int(i) for i in readline().split()]
a = [int(i) for i in readline().split()]

a.sort(reverse=True)
tot = sum(a)
if a[m-1] < tot/(4*m):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) = explode(" ",trim(fgets(STDIN)));
//$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

printf("%d\n",nCr($N,2)+nCr($M,2));

function nCr($n, $r)
{
    if ($r > $n) {
        return 0;
    }
    if ($n - $r < $r) {
        return nCr($n, $n - $r);
    }
    $return = 1;
    for ($i = 0; $i < $r; $i++) {
        $return *= ($n - $i) / ($i + 1);
    }
    return $return;
}


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

const int N = 3e5 + 7 ; 

long long n  , m ;
long long ans ; 

int main() 
{
  
    //freopen("in.in" , "r",  stdin) ; 
    cin>>n>>m;
    long long k = n / m ; 
    if(m%2==0)
    {
        if(n>=m/2)
        {
            ans+=powl(k , 3) ; 
            long long k2 = (n-m/2)/m;
            ans+=powl(k2+1 , 3);            
        }
    }
    else 
    {
        ans+=powl(k , 3) ; 
    }
    cout<<fixed<<setprecision(0) <<ans ; 
    return 0 ;  
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    string s;
    cin >> s;

    string target = ",";     // 検索文字列
    string replacement = " "; // 置換文字列

    // cout << s << endl;
    
    if (!target.empty()) {
        string::size_type pos = 0;
        while ((pos = s.find(target, pos)) != std::string::npos) {
            s.replace(pos, target.length(), replacement);
            pos += replacement.length();
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,t;cin>>n>>t;
    vector<pair<int,int>> c(n);
    for(int i=0;i<n;i++){
        cin>>c[i].first>>c[i].second;
    }
    sort(c.begin(),c.end());
    
    int i=0;
    while(i<n){
        if(c[i].second <= t){
            cout<<c[i].first<<endl;
            return 0;
        }
        else{i++;}
    }
    cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<i32>();

  if 888 < n {
    println!("999");
  } else if 777 < n {
    println!("888");
  } else if 666 < n {
    println!("777");
  } else if 555 < n {
    println!("666");
  } else if 444 < n {
    println!("555");
  } else if 333 < n {
    println!("444");
  } else if 222 < n {
    println!("333");
  } else if 111 < n {
    println!("222");
  } else {
    println!("111");
  }
}



Measured memory_bytes: 4352
#include <cstdio>

const int MOD = 1e9 + 7, MAX_N = 2e5 + 5;
typedef long long LL;

LL factorial[MAX_N + 1];
LL inverse_factorial[MAX_N + 1];

LL power_mod(LL x, LL power, LL MOD)
{
    LL answer = 1;

    while(power)
    {
        if(power%2 == 1)
            answer = (answer*x)%MOD;

        x = (x*x)%MOD;
        power = power >> 1;
    }

    return answer;
}

LL choose(LL n, LL r, LL MOD)
{
    LL numerator = factorial[n];
    LL denominator_inverse = (inverse_factorial[r]*inverse_factorial[n - r])%MOD;

    return (numerator*denominator_inverse)%MOD;
}

int main()
{
    const int MOD = 1e9 + 7;

    factorial[0] = 1;
    for(int i = 1; i <= MAX_N; i++)
        factorial[i] = (i*factorial[i - 1])%MOD;

    inverse_factorial[MAX_N] = power_mod(factorial[MAX_N], MOD - 2, MOD);
    for(int i = MAX_N - 1; i >= 0; i--)
        inverse_factorial[i] = ( (i + 1)*inverse_factorial[i + 1] )%MOD;

    int no_of_factors, n;
    scanf("%d %d", &no_of_factors, &n);

    LL answer = 1;
    for(int i = 2; i*i <= n; i++)
    {
        int exponent = 0;

        while(n%i == 0)
        {
            n = n/i;
            exponent++;
        }

        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    if(n > 1)
    {
        int exponent = 1;

        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    printf("%lld\n", answer);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
void chmin(ll& a,ll b){
    a = min(a, b);
}
void chmax(ll& a,ll b){
    a = max(a, b);
}
int n;
ll a[5005], prt[5005];
vll edges[5005];
ll dp0[5005][5005], dp1[5005][5005];
//dp0[i][j]:iの部分木をj個切断したとき、j+1個にわかれて、全て正かどうか
//正なら整数値、正にできないならinfl
//dp1[i][j]:上と同じで、負を含む場合の最小値
void read(){
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i,n-1){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges[u].eb(v);
        edges[v].eb(u);
    }
}
void init(){
    rep(i,n){
        rep(j,n){
            dp0[i][j] = dp1[i][j] = infl;
        }
    }
    rep(i, n) prt[i] = -1;
}
int dfs(int now){
    int child = 1;
    if (a[now]>0)
        dp0[now][0] = a[now];
    dp1[now][0] = a[now];
    for (auto nex:edges[now]){
        if (nex==prt[now])
            continue;
        prt[nex] = now;
        int c = dfs(nex);
        //dp0[nex]dp1[nex]が求まった
        //dp0[now]dp1[now]にマージしていく
        //このとき、now側で既に決まっているのは数を考えなければならない。
        //配るDPでマージするといいかも
        /*
        子の部分木をそのままくっつつける
        ：くっつつける切断数足す。dp1の値を足す
        dp0が実数かつ、遷移前のdp0が実数なら実数。
        子の部分木を切り離す。
        ：切断数+1を足す。dp0が実数か、dp1が負でなければならない。
        値はそのまま
        */
        repr(i,child-1,-1){
            ll tmp0 = dp0[now][i], tmp1 = dp1[now][i];
            dp0[now][i] = dp1[now][i] = infl;
            repr(j,c-1,-1)
            {
                chmin(dp0[now][i + j], tmp0 + dp0[nex][j]);
                chmin(dp1[now][i + j], tmp1 + dp1[nex][j]);
                if (dp0[nex][j]<infl/2 || dp1[nex][j]<0){
                    chmin(dp0[now][i + j + 1], tmp0);
                    chmin(dp1[now][i + j + 1], tmp1);
                }
            }
        }
        child += c;
    }
    return child;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    read();
    init();
    dfs(0);
    //make result
    rep(i,n){
        if (dp0[0][i]<infl/2 || dp1[0][i]<0){
            cout << i << ENDL;
            return 0;
        }
    }
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

ll dp[105][100010];

signed main()
{
    int n,W; cin>>n>>W;
    vi w(n+1);
    vll v(n+1);
    reps(i,n){
        cin>>w[i];
        cin>>v[i];
    }
    
    reps(i,n){
        reps(j,W){
            if(w[i]<=j) dp[i][j]=max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]);
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    cout<<dp[n][W]<<endl;
}


Measured memory_bytes: 79360
w,h,n = map(int,input().split())
a = [0,w,0,h]
for i in range(n):
    xi,yi,ai = map(int,input().split())
    if ai == 1:
        a[0] = max(a[0],xi)
    elif ai == 2:
        a[1] = min(a[1],xi)
    elif ai == 3:
        a[2] = max(a[2],yi)
    else:
        a[3] = min(a[3],yi)

print(max(0,a[1]-a[0])*max(0,a[3]-a[2]))

Measured memory_bytes: 38256
#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 A,B;
	cin>>A>>B;
	int ans=0;
	for(int i=A;i<=B;i++){
		string S=to_string(i);
		string T=S;
		reverse(S.begin(),S.end());
		if(S==T){
			ans++;
		}
	}
	//cout<<to_string(222)+to_string(222)<<endl;
	cout<<ans;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

bool IsPrime(int num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

signed main(){
  int A,B,ans=1;
  //map<int,int> mp;
  cin >> A >> B;
  int C[3]={A,B,abs(A-B)};
  sort(C,C+3);
  int h=gcd(C[0],C[1]);
  int i=2;
  //int l=0;
  if(IsPrime(h)){
    cout << 2 << endl;
    return 0;
  }
  vector<int> x=getDivisor(h);
  /*while(1){
    if(i>h) break;
    if(h%i==0){
      //if(i==2) l++;
      while(h%i==0) h/=i;
      //mp[i]++;
      //if(mp[i]==1) ans++;
      ans++;
    }
    if(i==2) i++;
    else i+=2;
  }*/
  rep(i,x.size()){
    if(IsPrime(x[i])) ans++;
  }
  /*if(IsPrime(A) || IsPrime(B)){
  cout << 1 << endl;
  return 0;
}
if(A<B) swap(A,B);
int i=2;
while(1){
if(i>B) break;
if(A%i==0 && B%i==0){
A/=i;
B/=i;
mp[i]++;
if(mp[i]==1) ans++;
i=2;
}
i++;
}*/

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


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

int main()
{
    while(1)
    {
        int fre[501] = {0,1},a[10000],b[10000];
        int n,l,ans = 0;
        scanf("%d%d",&n,&l);
        if(n == 0&&l == 0)break;
        for(int i = 0; i < l; i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            if(a[i] == 1||b[i] == 1)fre[a[i]] = 1,fre[b[i]] = 1;
        }
        for(int i = 0; i < l; i++)
        {
            if(fre[a[i]] == 1&&fre[b[i]] == 0)ans++,fre[b[i]] = 2;
            if(fre[a[i]] == 0&&fre[b[i]] == 1)ans++,fre[a[i]] = 2;
        }
        for(int i = 0; i < n + 1; i++)
        {
            if(fre[i] == 1)ans++;
        }
        printf("%d\n",ans - 1);
    }

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int count=700 ;
  if(S[0]=='o') count=count+100;
  if(S[1]=='o') count=count+100;
  if(S[2]=='o') count=count+100;
  cout << count<< endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) { cin >> a[i]; }
  vl ans(n, 0);
  ans[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    ll p = 2 * (i + 1);
    ll tmp = 0;
    while (p <= n) {
      tmp += ans[p - 1];
      p += (i + 1);
    }
    tmp = tmp % 2;
    if (tmp == a[i]) {
      ans[i] = 0;
    } else {
      ans[i] = 1;
    }
    // cout << i << endl;
  }

  ll m = 0;
  rep(i, n) {
    if (ans[i] == 1) m++;
  }
  cout << m << endl;
  rep(i, n) {
    if (ans[i] == 1) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3968
n,m = map(int, input().split())

c = [1 for i in range(n)]
p = [0 for i in range(n)]
p[0]=1

for i in range(m):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    c[x]-=1
    c[y]+=1
    if p[x]==1:
        p[y]=1
    if c[x]==0:
        p[x]=0

print(p.count(1))

Measured memory_bytes: 47792
#include<stdio.h>
#include<string.h>
int length(char *s){
  int len =0;
  while(*s++){
    len++;
  }
  return len;
}
int main(void)
{
  int n,len;
  char w[110][11];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s",w[i]);
    for(int j=0;j<i;j++){
      if(strcmp(w[i],w[j])){

      }else{
        puts("No");
        return 0;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(i>0){
      if(w[i-1][len-1]==w[i][0]){

      }else{
        puts("No");
        return 0;
      }
    }
    len=length(w[i]);
  }
  puts("Yes");
  return 0;
}


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

int main(){
  cout << fixed << setprecision(12);

  int a, b;
  cin>>a>>b;

  cout<< a / b <<" ";
  cout<< a % b <<" ";
  cout<<(double)a / b <<endl;

  return 0;

} 



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

const int MX=4015,md=1000000007;

int n,m,k,f[MX][MX],s[MX];
int main(){
	int i,j;
	cin>>n>>m>>k;
	f[0][0]=1;
	for(i=1;i<n+m;i++){
		memcpy(s,f[i-1],sizeof(int)*(m+1));
		for(j=1;j<=m;j++)s[j]=(s[j-1]+s[j])%md;
		for(j=0;j<=m;j++)f[i][j]=(s[j]+md-(j>=k?s[j-k]:0))%md;
	}
	int ans=0;
	while(m>0){
		ans=(ans+f[(n+m-1)/(k-1)][m])%md;
		m-=k-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 62208
import sys
import io


def main():
    f = sys.stdin.buffer
    n = int(f.readline())
    h = list(map(int, f.readline().split()))
    p0, p1 = 0, abs(h[1] - h[0])
    for i in range(2, n):
        p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
        p0, p1 = p1, p2
    print(p1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12216
H,W = gets.chomp.split(" ").map(&:to_i)
math = []
H.times do |i|
  gyou = gets.chomp.split("")
  math << gyou
end

new_math = []
math.each_with_index do |gyou, i|
  if gyou.count(".") != W
    new_math << gyou
  end
end

delete_math = []
new_math[0].length.times do |i|
  delete = true
  new_math.each_with_index do |gyou, j|
    if gyou[i] == "#"
      delete = false
    end
  end
  delete_math << delete
end


answer = []
new_math.each_with_index do |gyou,i|
  new_array = []
  delete_math.each_with_index do |n,j|
    if n == false
      new_array << gyou[j]
    end
  end
  answer << new_array
end


answer.each_with_index do |gyou, i|
  output = ""
  gyou.each do |char|
    output = output+char
  end
  print(output+"\n")
end


Measured memory_bytes: 3836
#include<stdio.h>
#include<math.h>
int main()
{  
   int X,Y,K,N,M;
   scanf("%d%d%d%d",&N,&K,&X,&Y);
   if(N>K)
   {  M=X*K+(N-K)*Y;
}
   else
   {  M=X*N;
}
   printf("%d",M);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

void makec(int);
void rec(int);
void sold(void);

//組み合わせの配列生成まではできた
//kumiawase no array made ha dekita

//m 最初のDataArrayの個数
//n 二つめのたしてくやつの個数
//qa[] dataarray
//s[] たしてくやつ
//ans[] s[]の組み合わせ
//qaa[]

int m,n,s[200],ans[20],qa[20],de[200];

int main(){
  int i,k;

  //for(i=0;i<20;i++)qaa[i]=0;

  scanf("%d",&m);
  for(i=0;i<m;i++)scanf("%d",&qa[i]);

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  
  makec(n);

  for(i=0;i<n;i++){
    // printf("%d  ",i);
    if(de[i]==1){
      printf("yes\n");
      //printf(" %d",)
    }else{
      printf("no\n");
    }
  }

  //qaa[i]==1/other
  //i行目にyes/no
  return 0;
}


void makec(int n){
  int i;
  for(i=0;i<m;i++)ans[i] = 0;
  for(i=0;i<n;i++)de[i] = 0;
  
  rec(0);
}

//組み合わせの0,1をつくる
void rec(int i){
  int kaunto;
  if(i==m){
    //for(kaunto=0;kaunto<m;kaunto++){
      //printf("%d ",ans[kaunto]);
      //sold();
    //}
    sold();
    //printf("\n");
  }else{
    rec(i+1);
    ans[i] = 1;
    rec(i+1);
    ans[i] = 0;
  }
}

void sold(void){
  int i,cal=0;
  for(i=0;i<m;i++){
    if(ans[i]==1){
      cal+=qa[i];
    }
  }
  //printf("#%d#\n",cal);
  for(i=0;i<n;i++){
    if(cal==s[i]){
      //printf("yes");
      // printf("%d is s[%d]!!\n",cal,i);
      de[i]=1;
    }
  }
}




Measured memory_bytes: 2100
#include<stdio.h>
#include<math.h>

int main(void){
  double xa,ya,ra,xb,yb,rb,N,m;

  scanf("%lf",&N);

  while(N--){
    scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
    m=sqrt(pow(xa-xb,2)+pow(ya-yb,2));
    if(m<=ra+rb && m<ra-rb)printf("2\n");
    else if(m<=ra+rb && m<rb-ra)printf("-2\n");
    else if(m>ra+rb)printf("0\n");
    else printf("1\n");

  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(0<i&&i<H-1&&0<j&&j<W-1){
                    cout<<'.';
                }
                else{
                    cout<<'#';
                }
                
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3108
#include <stdio.h>
int max(int x, int y) {
	return x > y ? x : y;
}
int c[100000][3];
int dp[100000][3];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &c[i][j]);
			dp[i][j] = 0;
		}
	}
	for (int i = 0; i < 3; i++) {
		dp[0][i] = c[0][i];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k)
					continue;
				dp[i][k] = max(dp[i][k], dp[i - 1][j] + c[i][k]);
			}
		}
	}
	printf("%d\n", max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
  	cin>>s>>t;
  	int count=0;
  	for(int i=0;i<s.length();i++)
    {
    	if(s[i]==t[i])
        {
        	count++;
        }
    }
	cout<<count<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int x; cin >> x;
  int y; cin >> y;
  int prise[3]={300000,200000,100000};
  int ans=0;
  if(x < 4) ans+=prise[x-1];
  if(y < 4) ans+=prise[y-1];
  if((x==1)&&(y==1)){
    ans +=400000;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
     long long int t,n,i,j,k,l,sum,sum1,cnt1,flag,flag1,m,x,y,a,b,c,d,mid;
  cin>>t;
  long long int cnt=0;
  sum=100;
  for(i=100;;)
  {
     n=(i/100)*1;
     sum=sum+n;
     i=sum;
     cnt++;
     if(sum>=t)break;
  }
  cout<<cnt<<endl;
    return 0;

}



Measured memory_bytes: 3632
# ABC 109
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0 for i in range(n)]
def gcd(x, y):
    m = max(x,y)
    n = min(x,y)
    while m%n != 0:
        w = m%n
        m = n
        n = w
    return n
def db(x): 
    global debug
    if debug: print(x)
debug = False
N,X = getIntList()
x = getIntList()
dif = zeros(N)
for i in range(N-1):
    dif[i] = x[i+1] - x[i]
dif[N-1] = x[N-1] - X
db(dif)
cd = dif[N-1]
for i in range(N-1):
    cd = gcd(cd,dif[i])
cd = abs(cd)
print(cd)

Measured memory_bytes: 14484
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, k, n, a, b, ans=0, po=0;
    scanf("%lld %lld %lld", &n, &a, &b);
    ans += a*(n/(a+b));
    po = n%(a+b);
    if(po>a) ans += a;
    else ans += po;
    printf("%lld", ans);

    
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

void Eratos(int* p);

int main(void){
	int* p;
	p = (int*)calloc(1000000, sizeof(int));
	int n;
	int cnt;
	int i;

	Eratos(p);

	while(scanf("%d", &n) != EOF){
		cnt = 0;
		for(i=2; i<=n; i++){
			if(p[i] == 1) cnt++;
		}

		printf("%d\n", cnt);
	}

	return 0;
}

void Eratos(int* p){
	int i, j;
	for(i=0; i<1000000; i++){
		p[i] = 1;
	}

	for(i=2; i < 1000; i++){
		for(j=2; i*j < 1000000; j++){
			p[i*j] = 0;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int gcd(int a, int b)
{
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

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

	int n, i, j, k, g;
	cin >> n >> k;
	vector<int> a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) g = a[i];
		else g = gcd(g, a[i]);
	}

	bool solved = false; 
	for (i = 0; i < n; i++) {
		if ((a[i] >= k) && ((a[i] - k) % g == 0)) solved = true;
	}

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

	return 0;
}


Measured memory_bytes: 640
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	uf := NewUnionFind(N)
	for i := 0; i < M; i++ {
		A, B := ReadInt()-1, ReadInt()-1
		uf.Union(A, B)
	}
	m := make(map[int]bool)
	for i := 0; i < N; i++ {
		m[uf.Find(i)] = true
	}
	fmt.Println(len(m) - 1)
}

type UnionFind struct {
	parent []int
}

func NewUnionFind(n int) *UnionFind {
	uf := &UnionFind{
		parent: make([]int, n),
	}
	for i := 0; i < n; i++ {
		uf.parent[i] = i
	}
	return uf
}

func (uf *UnionFind) Find(a int) int {
	if a == uf.parent[a] {
		return a
	}
	uf.parent[a] = uf.Find(uf.parent[a])
	return uf.parent[a]
}

func (uf *UnionFind) Union(a, b int) {
	a = uf.Find(a)
	b = uf.Find(b)
	if a == b {
		return
	}
	uf.parent[a] = b
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


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

int main(){
    int sum = 0;
    int amari_max = -1;
    for (int i = 0;i < 5;i++){
        int time;
        cin >> time;
        int up = (time + 9) / 10 * 10;
        sum += up;
        amari_max = max(amari_max, up - time);
    }

    cout << sum - amari_max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  const ll n=26;
  ll N;
  cin >> N;

  string ans;
  while(N>0){
    --N;
    ans=(char)('a'+N%n)+ans;
    N/=n;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <utility>

const int MAX_A = 300 * 300;

std::vector<int> costs(MAX_A + 1, 0);

int rec(const std::vector<std::pair<int ,int>>& positions, const int& D, int l) {
  if (positions.size() <= l + D) {
    return 0;
  }

  int x = positions[l].second, y = positions[l].first;
  int nx = positions[l + D].second, ny = positions[l + D].first;

  return costs[l] = std::abs(x - nx) + std::abs(y - ny) + rec(positions, D, l + D);
}

int main() {
  int H, W, D;
  std::cin >> H >> W >> D;

  std::vector<std::pair<int, int>> positions(H * W + 1);

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      int A;
      std::cin >> A;

      positions[A] = std::make_pair(y, x);
    }
  }

  for (int i = 1; i <= H * W; i++) {
    if (costs[i] == 0) {
      rec(positions, D, i);
    }
  }

  int Q;
  std::cin >> Q;

  for (int i = 0; i < Q; i++) {
    int L, R;
    std::cin >> L >> R;

    std::cout << costs[L] - costs[R] << std::endl;
  }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    vector<int> a(5);
    int ans = 0;
    int m = 0;
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        ans += a[i]+(10-a[i]%10)%10;
        m = max(m,(10-a[i]%10)%10);
    }
    cout << ans-m << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;
    lint dis=llabs(A-B);
    lint sp=V-W;
    if(sp<=0) cout << "NO" << endl;
    else{
        if(((dis+sp-1)/sp)<=T) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n,t;
    cin >> n >> t;
    ll ans = 0;
    vector<int> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < n-1; i++){
        ans += min(x[i+1]-x[i],t);
    }
    ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
X = [int(x) for x in input().split()]
X_bit = [x%2 for x in X]
flag = sum(X_bit)
if flag==0 or flag==3:
    diff = [max(X)-x for x in X]
    print(sum(diff)//2)
elif flag==1:
    X_ = [x+1 if x%2==0 else x for x in X]
    diff = [max(X_)-x for x in X_]
    print(sum(diff)//2+1)
elif flag==2:
    X_ = [x+1 if x%2==1 else x for x in X]
    diff = [max(X_)-x for x in X_]
    print(sum(diff)//2+1)

Measured memory_bytes: 3064
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;



int main()
{
	int n;
	cin >> n;
	vector<int> v;
	vector<int> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		v.push_back(in);
	}
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		c.push_back(in);
	}

	for (int i = 0; i < n; i++) {
		if (v[i] >= c[i]) {
			ans += v[i] - c[i];
		}
	}
	
	


	cout << ans << endl;
	return 0;

}

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

using namespace std;

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

int main(){
 long long int a,b;
  cin >> a >> b;
  
  cout <<3*(a-gcd(a,b)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define mod 1000000007
using namespace std;
long long n,m,i,j,a[100005],dp[100005],sum,l,r,l1,l2;
int main()
{
	scanf("%lld%lld%lld",&n,&l1,&l2);
	if(l1<l2) swap(l1,l2);
	fz1(i,n){
		scanf("%lld",&a[i]);
	}
	fz1(i,n-2){
		if(a[i+2]-a[i]<l2){
			puts("0");
			return 0;
		}
	}
	dp[l=r=0]=sum=1;
	fz1(i,n){
		while(a[i]-a[r+1]>=l1) inc(sum,dp[++r])
		if(l<=r) dp[i]=sum;
		if(i>1&&a[i]-a[i-1]<l2){
			while(l<i-1) dec(sum,dp[l++])
		}
	}
	long long ans=0;
	fd0g(i,n){
		inc(ans,dp[i])
		if(i<n&&a[i+1]-a[i]<l2) break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
function Main(input) {
	var data = input.split("\n");
	var kazu = parseInt(data[0],10);
	var n =  data[1].split(" ").map((n) => parseInt(n, 10));
	
	n.sort(function(a, b) {
		return a-b;
	});
	
	var tmp = 0;
	
	for(var i=0;i < kazu -1; i++){
		tmp = (n[0]+n[1])/2;
		n.shift();
		n[0] = tmp;
	}
	console.log(n[0])
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

vector<ll> divisor(ll n){
	vector<ll> res;
	for(ll i = 1; i*i <= n; i++){
		if(n%i == 0){
			res.push_back(i);
			if(i != n/i) res.push_back(n/i);
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll ans = 0;
	for(auto p : divisor(n)){
		if(p == 1) continue;
		if(n/(p-1) == n%(p-1)) ans += p-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main(){
    int L;
    scanf("%d", &L);
    printf("%.12lf\n", (double) (L/3.0 * L/3.0 * L/3.0));
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int  MAX = 1e5;

int main(){
    int N;
    cin >> N;
    vector<int> odd(MAX+1,0);
    vector<int> even(MAX+1,0);
    for(int i=1;i<=N;i++){
        int v; cin >> v;
        if(i%2 == 0){
            even[v]++;
        }
        else{
            odd[v]++;
        }
    }

    int in1=-1,in2=-1;
    int m11,m12,m21,m22;
    m11 = m12 = m21 = m22 = 0;
    for(int i=0;i<=MAX;i++){
        if(odd[i] >= m11){
            in1 = i;
            m12 = m11;
            m11 = odd[i];
        }
        else if(odd[i] >= m12){
            m12 = odd[i];
        }
        if(even[i] >= m21){
            in2 = i;
            m22 = m21;
            m21 = even[i];
        }
        else if(even[i] >= m22){
            m22 = even[i];
        }
    }

    int ans;
    if(in1 != in2){
        ans = N-m11-m21;
    }
    else{
        ans = min(N-m11-m22,N-m12-m21);
    }
    cout << ans << endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    int i,j,d[105],n,ans;
    while(~scanf("%d",&n))
    {
        memset(d,0,sizeof(d));
        ans=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&j);
            if(d[j]==0)
            {
                d[j]++;
                ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;


}


Measured memory_bytes: 256