akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N,W; cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i];
    }
    vector<vector<int> > values(4, vector<int>());
    vector<int> cnts(4,0);

    const int w0 = w[0];
    for(int i=0;i<N;i++){
        values[w[i]-w0].push_back(v[i]);
        cnts[w[i]-w0]++;
    }
    for(int i=0;i<4;i++){
        sort(values[i].begin(), values[i].end(), greater<int>());
    }

    long long ans = 0ll;
    for(int n1=0;n1<=cnts[0];n1++){
        for(int n2=0;n2<=cnts[1];n2++){
            for(int n3=0;n3<=cnts[2];n3++){
                for(int n4=0;n4<=cnts[3];n4++){
                    long long tmp = 0ll;
                    long long weight = 0ll;
                    for(int i=0;i<n1;i++) tmp += values[0][i], weight += w0;
                    for(int i=0;i<n2;i++) tmp += values[1][i], weight += w0 + 1;
                    for(int i=0;i<n3;i++) tmp += values[2][i], weight += w0 + 2;
                    for(int i=0;i<n4;i++) tmp += values[3][i], weight += w0 + 3;
                    if(weight <= W) ans = max(ans, tmp);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
      public static void main(String args[]){
        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        int x = s.nextInt();
        
        int count = 0;
        for(int i=a;i>=0;i--){     
          for(int j=b;j>=0;j--){
            for(int k=c;k>=0;k--){
              int number = 500 * i + 100 * j + 50 * k;
              if(number == x){
              count++;  
              }  
            }
          
         }
            
        }
        
        System.out.println(count);
        
      }
}

Measured memory_bytes: 21844
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

void main() {
    int n, k; readf("%d %d\n", &n,&k);
    long[] a = Reads!(long);
    auto sum = a.dup;
    foreach(i; 0..n-1)
        sum[i+1] += sum[i];
    sum = [0L] ~ sum;

    long[] b;
    foreach (i; 0..n+1) foreach (j; i+1..n+1)
        b ~= sum[j] - sum[i];

    // O(m^2) where m = a.length = n(n+1)/2
    auto can = (long mask)
        => b.filter!(i => (i & mask) == mask)
            .array.length.to!int >= k;
    long ans;
    for (long mask = 1L<<50; mask; mask >>= 1) {
        if (can(ans + mask))
            ans += mask;
    }

    writeln(ans);
}

Measured memory_bytes: 11388
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007; // 10^9+7
const ll INF = 100000000;

int a[200010];

int main(void){
    ll k,n,count=0,ans=0;
    cin >> n >> k;

    vector<ll> b(n,0);
    rep(i,n){
        cin >> a[i];
        if(b[a[i]-1] == 0) count++;
        b[a[i]-1]++;
    }

    sort(b.begin(),b.end());
    //rep(i,n) cout << b[i] << endl;

    if(count > k){
        rep(i,n){
            if(b[i]==0) continue;
            if(count == k) break;
            ans += b[i];
            count--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s,t;
  int a,b;
  string u;
  
  cin>>s>>t>>a>>b>>u;
  
  if(s==u){
    cout<<a-1<<" "<<b<<endl;
  }else{
    cout<<a<<" "<<b-1<<endl;
  }
}

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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
int H,W,K,N;
char A[200][200]{};
int B[200][200]{};
vector <int> C;
int DFS(int x,int y){
  
}
int main()
{
  cin>>N;
  if(N>=30)cout<<"Yes";
  else cout<<"No";
  return 0;
}





Measured memory_bytes: 3624
import math
N = int(input())
city_list = [list(map(int, input().split())) for _ in range(N)]
average = 0
for x1, y1 in city_list:
    for x2, y2 in city_list:
        average += math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
print(average / N)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Card
    {
        internal int num, vol;
    }

    class Problem
    {
        readonly int MAX = 1000;
        readonly int m;

        Card[] cards;
        int[,] dp;

        public Problem(int m)
        {
            this.m = m;
            cards = new Card[m];
            dp = new int[m + 1, MAX + 1];
            dp[0, 0] = 1;
        }

        public void MakeMap()
        {
            for (int i = 0; i < m; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                cards[i].num = int.Parse(input[0]);
                cards[i].vol = int.Parse(input[1]);
            }

            for (int i = 0; i < m; i++)
            {
                for (int j = MAX; j >= 0; j--)
                {
                    if (dp[i, j] == 0) continue;

                    for (int k = 0; k <= cards[i].vol; k++)
                    {
                        int sum = j + cards[i].num * k;
                        if (sum > MAX) continue;
                        dp[i + 1, sum] += dp[i, j];
                    }
                }
            }
        }

        public int CountComb(int n)
        {
            return dp[m, n];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int m = int.Parse(Console.ReadLine());

                if (m == 0) break;

                Problem p = new Problem(m);
                p.MakeMap();

                int g = int.Parse(Console.ReadLine());

                while (g-- > 0)
                {
                    int n = int.Parse(Console.ReadLine());
                    sb.AppendLine(p.CountComb(n).ToString());
                }
            }
            Console.Write(sb);
        }
    }
}

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

int main(){
    int N;
    cin>>N;
    bool flg=false;
    for(int i=0;4*i<=N;i++){
        for(int j=0;7*j<=N;j++){
            if(4*i+7*j==N){
                flg=true;
                break;
            }
        }
    }
    if(flg){
        cout<<"Yes"<<endl;
    }
    if(!flg){
        cout<<"No"<<endl;
    }
}

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

int main(){
	ll n,k;
	cin>>n>>k;
	if (n>k){
		n-=k*(1+(n-k)/k);
	}
	//cout<<n<<endl;
	cout<<min(n,k-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::collections::BTreeSet;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let xy: Vec<(i32, i32)> = (0..n).map(|_| (read(), read())).collect();

    let mut ans = n;
    let set: BTreeSet<_> = xy.iter().cloned().collect();

    for i in 0..n {
        for j in 0..i {
            let dx = xy[i].0 - xy[j].0;
            let dy = xy[i].1 - xy[j].1;

            let count = xy
                .iter()
                .filter(|&&(x, y)| !set.contains(&(x - dx, y - dy)))
                .count();
            ans = std::cmp::min(ans, count);
        }
    }

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
table = [float("inf")] * (h + 10000)
table[0] = 0

for a, b in ab:
    for i in range(h):
        table[i+a] = min(table[i+a], table[i] + b)

print(min(table[h:]))


Measured memory_bytes: 50524
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M){
  cout << (N == M ? YES : NO) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  solve(N, M);
}


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

int main()
{
  string str,s[] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
  cin >> str;
  for(int i=0; i<7; i++) if(s[i] == str) cout << i+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    int N = in.read<int>();

    int X = N / 1.08;
    if (((int)X * 1.08) == N) {
        out << X;
    } else if ((int)((X + 1) * 1.08) == N) {
        out << X + 1;
    } else {
        out << ":(";
    }

    return 0;
}


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

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

  if (N%2 != 0) {
    cout << "No" << endl;
  } else {
    cout << ((S.substr(0,(N/2)) == S.substr(N/2, (N/2))) ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n,r;
    cin >> n >> r;
    if(n < 10){
        cout << 100 * (10-n)  + r << endl;
    }else{
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ps = []

n.times do |i|
  ps << gets.split.map(&:to_i)
end

ps.sort_by! { |xy| Math.atan2(xy[1], xy[0]) }

ps = ps + ps

mx = 0
n.times do |s|
  s.upto(s + n - 1) do |e|
    xsum = 0
    ysum = 0
    for i in s..e
      xsum += ps[i][0]
      ysum += ps[i][1]
    end

    mx = [xsum * xsum + ysum * ysum, mx].max
  end
end

p Math.sqrt(mx)


Measured memory_bytes: 1788
import math
from functools import reduce

# 最小公倍数
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N = int(input())
T = [int(input()) for _ in range(N)]
print(lcm_list(T))
# print(lcm(*T))


Measured memory_bytes: 9484
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const K = input;
  var array = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51
  ];

  console.log(array[Number(K)-1]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int n,m;
	cin >>n>>m;
	vector<pair<long long int,int>>p(n);
	rep(i,n){
		int a,b;
		cin >>a>>b;
		p[i]=make_pair(a,b);
	}
	sort(p.begin(),p.end());
	long long int ans=0;
	rep(i,n){
		int tmp=min(p[i].second,m);
		ans+=p[i].first*tmp;
		m-=tmp;
		if (m==0)
			break;
	}
	cout <<ans;
}

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


public class Main {
    static HashMap<Integer,Integer>[] g; //<toRoom, keyNecessary>
    static int n,m;
    static long mod = 1000000000+7;
    static HashSet<Integer>[] tree;
    static int[][] edge;
    static int[] c,res;
    public static void main(String[] args) throws Exception {
        //Scanner sc = new Scanner(System.in);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] buf = reader.readLine().split(" ");
        n = Integer.parseInt(buf[0]);
        tree = new HashSet[n];
        for(int i=0;i<n;i++) tree[i]=new HashSet<>();
        edge = new int[n-1][];
        for(int i=0;i<n-1;i++){
            buf = reader.readLine().split(" ");
            int u = Integer.parseInt(buf[0])-1, v = Integer.parseInt(buf[1])-1;
            edge[i] = new int[]{u,v};
            tree[u].add(v); tree[v].add(u);
        }
        c = new int[n];
        buf = reader.readLine().split(" ");
        for(int i=0;i<n;i++) c[i]=Integer.parseInt(buf[i]);
        Arrays.sort(c);
        res = new int[n];
        LinkedList<Integer> que = new LinkedList<>();
        boolean[] vis = new boolean[n];
        for(int i=0;i<n;i++){
            if(tree[i].size()==1) {
                que.add(i);
                vis[i] = true;
            }
        }
        int idx = 0;
        while(que.size()>0){
            int now = que.poll();
            res[now] = c[idx++];
            for(int w:tree[now]){
                if(tree[w].contains(now)){
                    tree[w].remove(now);
                    if(tree[w].size()==1) que.add(w);
                }
            }
        }
        int sum = 0;
        for(int[] e:edge){
            int u = e[0], v = e[1];
            sum += Math.min(res[u],res[v]);
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(sum);
        for(int i=0;i<n;i++) out.print(res[i]+" ");
        out.flush();
    }
}



Measured memory_bytes: 34772
import sys
import numpy as np

# N K 操作回数、K番目の値
n, k = map(int, input().split())

# ai, bi  追加する整数 ai, 追加する数 bi
s = []
for i in range(n):
    s.append(list(map(int, input().split())))

# ai, bi の順にソート
s.sort()

number = 0
for s_item in s:
    # kの位置以上に来たか
    number += s_item[1]
    if number >= k:
        number_k = s_item[0]
        break

print(number_k)

Measured memory_bytes: 36952
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int k = sc.nextInt();
    String s = sc.next();

    if (s.length()<=k) {
      System.out.println(s);
    }else{
      for (int i =0;i<k ;i++ ) {
        System.out.print(s.charAt(i));
      }
      System.out.print("...");
      System.out.println();
    }


  }
}


Measured memory_bytes: 35788
#include<bits/stdc++.h>
using namespace std;
int a[200010];
inline bool cmp(int a,int b){
	return a>b;
}
int main()
{
	std::ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(!a[x]) sum++;
		a[x]++;
	}
	sort(a+1,a+200010,cmp);
	int now=1;
	long long ans=0;
	while(a[now])
	{
		if(now>k) ans+=a[now];
		now++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  bool t = true;
  int a = S.size();
  for (int i = 0; i < a; i++){
    if(S[i] != T[i]){
      cout << "No" << endl;
      t = false;
      break;
    }
  }
  if(t){
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3624
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Printf("%.7f\n", resolve(parseProblem()))
}

func parseProblem() (int, int) {
	n, k := scanInt(sc), scanInt(sc)
	return n, k
}

func resolve(n, k int) float64 {
	sumOfExpectation := make([]float64, n+1)
	for i := 1; i <= n; i++ {
		sumOfExpectation[i] = sumOfExpectation[i-1] + expectation(scanInt(sc))
	}
	max := 0.0
	for i := 0; i+k < len(sumOfExpectation); i++ {
		v := sumOfExpectation[i+k] - sumOfExpectation[i]
		if max < v {
			max = v
		}
	}
	return max
}

func expectation(n int) float64 {
	exp := (n + 1) * n >> 1
	return float64(exp) / float64(n)
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4324
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
#define ll long long
ll a, b, c;
int main(){
	scanf("%lld%lld%lld", &a, &b, &c);
	if (c - 1 <= a + b){
		printf("%lld\n", b + c);
	} else {
		printf("%lld\n", b + (b + a + 1));
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    long N, T, a;
    cin >> N >> T >> a;
    int surplus[N], max_a[N], min_a[N], count=0, flag=0, count2=0;
    max_a[0] = a;
    min_a[0] = a;
    surplus[0] = max_a[0] - min_a[0];
    for (int i=1; i<N; i++){
        cin >> a;
        if (a > max_a[count]){
            max_a[count] = a;
            surplus[count] = max_a[count] - min_a[count];
            count2 = 0;
        }else if (a == max_a[count] && flag > 0){
            count2++;
            flag--;
        }else if (a == min_a[count]){
            flag++;
        }else if (a < min_a[count]){
            for(int j=1; j <= count2; j++){
                count ++;
                min_a[count] = min_a[count-1];
                surplus[count] = surplus[count-1];    
            }
            count ++; 
            flag = 0;
            min_a[count] = a;  
            max_a[count] = a;
            surplus[count] = max_a[count] - min_a[count];

        }
    }

    int cost=1, max_surplus;
    max_surplus = surplus[0];
    for (int i=1; i <= count; i++){
        //cout << surplus[i] << endl;
        if (surplus[i] > max_surplus){
            cost = 1;
            max_surplus = surplus[i];
        }else if(surplus[i] == max_surplus){
            cost++;
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 4024
#include<iostream>

int main(){

  int n,a;
  std::cin>>n;

  int Adj[n][n],adj[100][100]={0};
  int u[n],k[n];
  for(int i=0;i<n;i++){
    std::cin>>u[i];
    std::cin>>k[i];
    for(int j=0;j<k[i];j++){
      std::cin>>Adj[i][j];
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<k[i];j++){
      adj[u[i]-1][Adj[i][j]-1]=1;
    }
  }


  for(int i=0;i<n;i++){
    for(int j=0;j<n-1;j++){
      std::cout<<adj[i][j]<<" ";
    }
     std::cout<<adj[i][n-1]<<"\n";
    //std::cout<<"\n";
  }


  return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

map<int, int> cnt;
int a[100005];

int main(){
    int N, temp = 0;
    cin >> N;
    for(int i=1; i<=N; i++){
        int num;    
        cin >> num;
        cnt[num]++;
        if(i == 1){
            temp++;
            a[temp] = num;
        } else if(cnt[num] == 1){
            temp++;
            a[temp] = num;
        }
    }
    sort(a+1, a+temp+1);
    if (temp > 3){
        cout << "No" << endl;
    } else if(a[1] == 0 && cnt[0] == N){
        cout << "Yes" << endl;
    }else if (N % 3 != 0){
        cout << "No" << endl;
    } else if(a[1] == 0 && cnt[a[2]] == 2*N/3 && temp == 2){
        cout << "Yes" << endl;
    } else if(cnt[a[1]] == N/3 && cnt[a[2]] == N/3 ){
        if((a[1]^a[2]^a[3]) == 0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 4224
while gets.chomp.to_i != 0
  sequence = gets.split.map(&:to_i)
  before_sequence = sequence
  count = 0
  while true
    sequence = sequence.map {|item| sequence.count(item)}
    break if before_sequence == sequence
    before_sequence = sequence
    count += 1
  end
  puts count, sequence.join(" ")
end

Measured memory_bytes: 8888
S = input()
ret = 0


def calc(i=0, s=0, buf=''):
    global ret
    if i == len(S):
        if buf:
            s += int(buf)
        ret += s
    else:
        if buf:
            calc(i + 1, s + int(buf), S[i])
        calc(i + 1, s, buf + S[i])


calc()
print(ret)


Measured memory_bytes: 2940
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int c;//counter
      	int tri;//triplet
      	int x, y, z;
      	for (int n=1; n<=N; n++) {
          	c = 0;
        	for (int X=2; X<=(int)Math.sqrt(2*n/3); X++) {
            	for (int Y=X; Y<=(int)Math.sqrt((2*n - X*X)/2); Y++) {
                  	int Z =  (int)Math.sqrt(2*n - X*X - Y*Y);
                  	tri = X*X + Y*Y + Z*Z;
                  	x = (X + Y - Z) / 2;
                  	y = (X - Y + Z) / 2;
                  	z = (-X + Y + Z) / 2;
                  	if ((((1<=x)&&(tri == 2*n))&&(1<=y))&&(1<=z)) {
                    	if ((X==Y)&&(Y==Z)) {c++;}
                      	else if (X==Y) {c+=3;}
                      	else if (Y==Z) {c+=3;}
                      	else {c+=6;}
                    }
                }
            }
          	System.out.println(c);
        }
    }
}

Measured memory_bytes: 39076
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long


signed main(void){
  string a,b;
  cin >> a >> b;
  if(a.length() > b.length()){
    cout << "GREATER\r\n";
  }else if(a.length() < b.length()){
    cout << "LESS\r\n";
  }else{
    for(int i = 0; i < a.length(); i++){
      if((int)(a[i]-'0') > (int)(b[i]-'0')){
        cout << "GREATER\r\n";
        return 0;
      }else if((int)(a[i]-'0') < (int)(b[i]-'0')){
        cout << "LESS\r\n";
        return 0;
      }
    }
    cout << "EQUAL\r\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
using namespace std;

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b;
  cin>>a;
  for(int i=1; i<=9; i++){
      for(int j=1; j<=9; j++){
          if(i*j==a){
              cout<<"Yes"<<endl;
              return 0;
          }
      }
  }
    cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, k, q;
	cin >> n >> k >> q;
	vector<ll>ac_cnt(n+10, 0);
	for(int i = 0; i < q; i++){
		ll temp;
		cin >> temp;
		ac_cnt[temp] += 1;
	}
	vector<string>ac_res(n+10, "No");
	for(int i = 1; i <= n; i++){
		if(ac_cnt[i] + k - q > 0)ac_res[i] = "Yes";
	}

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

Measured memory_bytes: 6912
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int N = 200010, P = 1e9 + 7;
char s[N];
int num[N], f[N][3][2], n, tag[N], pre[N], ans, sam[N];
set <int> mp[3];
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
//	freopen("e.in", "r", stdin);
//	freopen("e.out", "w", stdout);
	scanf("\n%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++) num[i] = s[i] - 'a' + 1;
	for (int i = 1; i <= n; i++){
		if (sam[i - 1] >= i) sam[i] = sam[i - 1];
		else {
			sam[i] = n;
			for (int j = i; j < n; j++)
				if (num[j] == num[j + 1]){
					sam[i] = j;
					break;
				}
		}
	}
	for (int i = n; i >= 1; i--) tag[i] = tag[i + 1] | (num[i] == num[i - 1]); 
	for (int i = 1; i <= n; i++){
		pre[i] = (pre[i - 1] + num[i]) % 3;
		mp[pre[i]].insert(i);
	}
	mp[0].insert(n + 1), mp[1].insert(n + 1), mp[2].insert(n + 1);
	
	int cnt = 1;
	int j = *mp[1].upper_bound(sam[1]);
	if (num[1] == 1) j = 1;
	if (j <= n){
		if (j > 1) f[j][1][0] = (f[j][1][0] + cnt) % P;
			else f[j][1][1] = (f[j][1][1] + cnt) % P;
	}
	j = *mp[2].upper_bound(sam[1]);
	if (num[1] == 2) j = 1;
	if (j <= n){
		if (j > 1) f[j][2][0] = (f[j][2][0] + cnt) % P;
			else f[j][2][1] = (f[j][2][1] + cnt) % P;
	}
	
	for (int i = 1; i < n; i++){
		for (int j = 1; j <= 2; j++){
			int cnt = (f[i][j][0] + f[i][j][1]) % P;
			int k = *mp[(pre[i] + 1) % 3].upper_bound(sam[i + 1]);
			if (num[i + 1] == 1) k = i + 1;
			if (k <= n){
				if (k > i + 1 || j == 1) f[k][1][0] = (f[k][1][0] + cnt) % P;
					else f[k][1][1] = (f[k][1][1] + cnt) % P;
			}
			k = *mp[(pre[i] + 2) % 3].upper_bound(sam[i + 1]);
			if (num[i + 1] == 2) k = i + 1;
			if (k <= n){
				if (k > i + 1 || j == 2) f[k][2][0] = (f[k][2][0] + cnt) % P;
					else f[k][2][1] = (f[k][2][1] + cnt) % P;
			}
		}
	}
	
	for (int i = 1; i <= n; i++)
		if (pre[n] - pre[i] == 0){
			ans = ((ans + f[i][1][1]) % P + f[i][2][1]) % P;
			ans = ((ans + f[i][1][0]) % P + f[i][2][0]) % P;
		}
	if (sam[1] == n)
		printf("%d\n", 1);
		else printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10752
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A,B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

/* Find the minimum x∈(low, up] such that f(x) is true
        *--- (true)
    ----     (false)
*/
template<typename F> int binarySearchU(int low, int up, const F &f) {
  while (up - low > 1) {
    int mid = low + (up - low) / 2;
    (f(mid) ? up : low) = mid;
  }
  return up;
}

main {
  int n, a, b;
  cin >> n >> a >> b;
  vi h(n);
  cin >> h;
  int t = binarySearchU(0, 10000000000LL, [&](int x) {
    vi k = h;
    for (auto &e : k) e -= x * b;
    int c = 0;
    for (auto &e : k) {
      if (e > 0) c += (e + (a - b - 1)) / (a - b);
    }
    return c <= x;
  });
  cout << t << endl;
}


Measured memory_bytes: 1792
N = int(input())
A = [int(x) for x in input().split()]

genkin = 1000
kabu = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        kabu += genkin // A[i]
        genkin = genkin % A[i]
    if A[i] > A[i+1]:
        genkin += kabu * A[i]
        kabu = 0
    # print(genkin, kabu)

print(genkin + kabu * A[N-1])

Measured memory_bytes: 9196
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;

vector<int> to[MAXV];
int id[MAXN][MAXN];

int toId(int i, int j) {

    if(i > j) {
        swap(i, j);
    }
    return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV];
int dfs(int v) {

    if(visited[v]) {
        if(!calculated[v]) {
            return -1;
        }
        return dp[v];
    }

    visited[v] = true;
    dp[v] = 1;
    for(int u : to[v]) {
        int res = dfs(u);
        if(res == -1) {
            return -1;
        }
        dp[v] = max(dp[v], res+1);
    }
    calculated[v] = true;
    return dp[v];
}

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

    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i, n) {
        rep(j, n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    int V = 0;
    rep(i, n) {
        rep(j, n) {
            if(i < j) {
                id[i][j] = V++;
            }
        }
    }

    rep(i, n) {
        rep(j, n-1) {
             a[i][j] = toId(i, a[i][j]);
        }
        rep(j, n-2) {
            to[a[i][j]].push_back(a[i][j+1]);
        }
    }

    int ans = 0;
    rep(i, V) {
        int res = dfs(i);
        if(res == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, dfs(i));
    }

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

Measured memory_bytes: 38528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 3005;
string s, t;
int dp[MAX_N][MAX_N];

void solve()
{
	const int N = s.length();
	const int M = t.length();
	for(int i=1;i<=N;++i)for(int j=1;j<=M;++j){
		if(s[i-1]==t[j-1]){
			dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
		}else{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string ans;
	int i=N,j=M;
	while(i>=1 && j>=1){
	    if(s[i-1]==t[j-1]){
	        ans+=s[i-1];
	        i--,j--;
	    }else if(dp[i][j]==dp[i-1][j]){
	        i--;
	    }else{
	        j--;
	    }
	}
	reverse(ans.begin(),ans.end());
	cout << ans << '\n';
}

int main()
{
	cin >> s >> t;
	solve();
	return 0;
}

Measured memory_bytes: 35456
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Template
{
	static Scanner sc;
	static int N = 1000;
	static int M = 3;
	static char[,] lo = { { 'A', 'B', 'C' }, { 'D', 'E', 'F' }, { 'G', 'H', 'I' } };
	static int[] dx = { 1, -1, 0, 0 };
	static int[] dy = { 0, 0, 1, -1 };

	public static void Main(string[] args)
	{
		sc = new Scanner();
		LinkedList<string> ans = new LinkedList<string>();
		for (int i = 0; i < N; i++)
		{
			string s = sc.next();
			if (check(s, 0)) ans.AddLast(s);
		}
		foreach (var el in ans)
		{
			Console.WriteLine(el);
		}
	}

	static bool inside(int x, int y)
	{
		bool res = true;
		if (x < 0 || x >= M) res = false;
		if (y < 0 || y >= M) res = false;
		return res;
	}

	static bool check(string s, int id)
	{
		if (id == s.Length) return true;
		if (id == 0)
		{
			return check(s, 1);
		}
		if (s[id - 1] == s[id]) return false;

		int bx = 0, by = 0;
		for (int i = 0; i < M; i++)
		{
			for (int j = 0; j < M; j++)
			{
				if (s[id - 1] == lo[i, j])
				{
					bx = j; by = i;
					i = M; j = M;
				}
			}
		}

		bool res = false;
		for (int i = 0; i < 4; i++)
		{
			int nex = bx + dx[i];
			int ney = by + dy[i];
			if (!inside(nex, ney)) continue;
			if (lo[ney, nex] == s[id]) res = check(s, id + 1);
		}
		return res;
	}
}

public class Scanner
{
	public Scanner() { }
	public string next()
	{
		return Console.ReadLine();
	}
	public int nextInt()
	{
		return int.Parse(next());
	}
	public double nextDouble()
	{
		return double.Parse(next());
	}
	public long nextLong()
	{
		return long.Parse(next());
	}
	public string[] nextArray()
	{
		return next().Split(' ');
	}
	public int[] nextIntArray()
	{
		return Array.ConvertAll(nextArray(), e => int.Parse(e));
	}
	public long[] nextLongArray()
	{
		return Array.ConvertAll(nextArray(), e => long.Parse(e));
	}
	public double[] nextDoubleArray()
	{
		return Array.ConvertAll(nextArray(), e => double.Parse(e));
	}
}

Measured memory_bytes: 9824
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        priority_queue<ll, vector<ll>, less<ll>> pq;
        rep(i, 0, N) {
                ll a;
                cin >> a;
                pq.push(a);
        }
        rep(i, 0, M) {
                ll x = pq.top();
                pq.pop();
                x /= 2;
                pq.push(x);
        }
        ll ans = 0;
        while (! pq.empty()) {
                ans += pq.top();
                pq.pop();
        }
        cout << ans << endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0) return 1;
	else if(N % 2 == 0) return power(MOD(a * a), N / 2);
	else return MOD(a * power(a, N - 1));
}

int inverse(int a){
	return power(a, p - 2);
}
 
int combination(int N, int k){
	if(k == 0){
		return 1;
	}
	else{
		return MOD(combination(N - 1, k - 1) * MOD(N * inverse(k)));
	}
}

signed main(){
	int N, a, b;
	scanf("%lld%lld%lld", &N, &a, &b);
	printf("%lld\n", MOD(power(2, N) - 1 - combination(N, a) - combination(N, b)));
	return 0;
}

Measured memory_bytes: 6656
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

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

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N, K;
  std::cin >> N >> K;

  if (K == 0) {
    std::cout << N * (N - 1) / 2 << std::endl;
    for (usize i = 1; i <= N; i++) {
      for (usize j = i + 1; j <= N; j++) {
        std::cout << i << " " << j << std::endl;
      }
    }
    return;
  }

  usize M = N * (N - 1) / 2, cnt = 0;
  auto d = make_v<i32>(N + 1, N + 1);
  fill_v(d, 1);

  auto f = [&]() {
    for (usize i = 2; i <= N; i++) {
      for (usize j = i + 1; j <= N; j++) {
        d[i][j] = d[j][i] = 0;
        cnt++;
        M--;
        if (cnt == K) {
          return true;
        }
      }
    }
    return false;
  };

  if (!f() || M <= 0) {
    std::cout << -1 << std::endl;
    return;
  }

  std::cout << M << std::endl;

  for (usize i = 1; i <= N; i++) {
    for (usize j = i + 1; j <= N; j++) {
      if (d[i][j]) {
        std::cout << i << " " << j << std::endl;
      }
    }
  }
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char s[1000];
int flag;
int main(){
    cin>>s;
    int n=strlen(s);
    for(int i=0;i<n;i++){
    	if(s[i]=='C')flag=1;
    	if(flag&&s[i]=='F'){
    		cout<<"Yes";
    		return 0;
		}
	}
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    dic = {}
    ac, wa = "AC", "WA"
    for _ in range(m):
        p, s = input().split()
        if p not in dic:
            dic[p] = [0, False]  # (wa_count, accepted)
        if dic[p][1]:
            continue
        if s == wa:
            dic[p][0] += 1
        else:
            dic[p][1] = True

    ac_num, wa_num = 0, 0
    for _, (wa_count, accepted) in dic.items():
        ac_num += accepted
        if accepted:
            wa_num += wa_count

    print(ac_num, wa_num)


if __name__ == "__main__":
    main()

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

using namespace std;

const int INF = 1<<29;

int main(){
  int n, m;
  while(cin >> n >> m && (n|m)){
    vector<int> C(m);
    for(int i=0; i<m; i++) cin >> C[i];
    
    vector<int> dp(256, INF);
    dp[128] = 0;
    while(n--) {
      vector<int> next(256, INF);
      int in; cin >> in;
      for(int i=0; i<256; i++){
	if(dp[i] < INF) {
	  for(int j=0; j<m; j++){
	    int conv = i + C[j];
	    if(conv < 0)   { conv = 0;   }
	    if(conv > 255) { conv = 255; }
	    int diff = (in - conv) * (in - conv);
	    next[conv] = min(next[conv], dp[i] + diff );
	  }
	}
      }
      dp = next;
    }
    
    cout << *min_element(dp.begin(), dp.end()) << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define N (int)1e5
#define F first
#define S second
typedef pair<int, int> P;
typedef long long LL;
LL n, a[N * 4], s, l, ans;
int main()
{
	cin >> n;
	n *= 3;
	l = n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n / 3; i++)
	{
		l -= 2;
		ans += a[l];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c,x,sum=0,m;
  cin>>n>>c;
  for(int i=1;i<=c;++i){
    cin>>x;
    sum+=x;
  }
  m=sum/(n+1);
  if(sum%(n+1)) ++m;
  cout<<m<<endl;
  return 0;
}



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

int main(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2; i*i <= x; i++){
        int coans = i*i;
        for(int j = 2; coans <= x; j++){
            if(coans > ans) ans = coans;
            coans *= i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl visited;
ll n, m;
ll ans = 0;

void dfs(ll v) {
    // 行きの処理はこのへんに書く
    visited[v] = 1;
    bool ok = true;
    rep(v, n) {
        if(!visited[v]) {
            ok = false;
        }
    }
    if(ok) {
        ans++;
    }
    for(auto u : G[v]) { 
        if(visited[u]) {
            continue;
        }
        dfs(u);
        // 帰りの処理はこのへんに書く
    }
    visited[v] = 0;
}

int main() {
    
    cin >> n >> m;    
    
    G.resize(n);
    visited.resize(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    dfs(0);

    out(ans);
    re0;
}

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

int main() {
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        string temp = to_string(i);
        if(temp.length() % 2) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
remaining_cnt_2 = 0
cnt_other = 0

for x in a:
    if x % 4 == 0:
        cnt_4 += 1
    elif x % 2 == 0:
        cnt_2 += 1
    else:
        cnt_other += 1

remaining_cnt_2 = cnt_2 % 2

if cnt_2 > 0:
    if cnt_4 >= cnt_other:
        print("Yes")
    else:
        print("No")
else:
    if cnt_4 + 1 >= cnt_other:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 62704
#include <iostream>
using namespace std;
int main(void){
    int n, count, high;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    count = 1;
    high = h[0];
    for(int i = 1; i < n; i++){
        
        if(high <= h[i]){
            count ++;
            high = h[i];
        }
        
        /*
        if(h[i-1] < h[i]){
            for(int j = i-1; j >= 0; j--){
                
                if(h[j] < h[i]){
                    count++;
                    
                }
            }
        }else{
            break;
        }
        */
        
    }
    /*
    for(int i = 1; i < n; i++){
        if(h[0] <= h[i] && h[1] <= h[i] && h[i-1] <= h[i]){
            count++;
        }
    }*/
    printf("%d\n", count);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
int n;
ll a,b,c,d;
ll gcd(ll x,ll y){
    if(y==0)
        return x;
    return gcd(y,x%y);
}
int main(){
    cin>>n;
    while(n--){
        cin>>a>>b>>c>>d;
        if(a<b){
            cout<<"No"<<endl;
            continue;
        }
        if(b>d){
            cout<<"No"<<endl;
            continue;
        }
        if(c+1>=b){
            cout<<"Yes"<<endl;
            continue;
        }
        ll g=gcd(b,d);
        if((a-c-1ll)/g-(a-b)/g>0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,k,x,ans=0;
    
    cin >> n >>k;
    for (int i=0;i<n;i++) {
        cin >> x;
        if(x > k-x ) {
            ans += 2*(k-x);
        }else {
         ans += 2*x;   
        }
        
    }
    cout << ans << endl;
}


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

int main(){
  int N,M,A[101],i,j,sum=0,temp;
  cin>>N>>M;
  for(i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  for(i=0;i<N-1;i++){
	for(j=0;j<N-1;j++){
		if(A[j]<A[j+1]){
			temp=A[j+1];
			A[j+1]=A[j];
			A[j]=temp;
		}
	}
  }
  if((A[M-1]<=sum/(4*M) && sum%(4*M)!=0) || (A[M-1]<sum/(4*M) && sum%(4*M)==0)) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256