akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define EPS 1e-10
#define INF 1e9
#define equal(a,b) (fabs(a-b) < EPS)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
  bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};

double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double dist(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

istream &operator >> (istream &is,Point &p){
  return is >> p.x >> p.y;
}

typedef Point Vector;

struct Segment{
  Point s,t;
  Segment(){}
  Segment(Point s,Point t) : s(s),t(t) {}
};

bool isParallelSS(const Segment &s1,const Segment &s2){
  Vector a = s1.t-s1.s;
  Vector b = s2.t-s2.s;
  return equal(cross(a,b),0);
}

Point getPoint(vector<Point> &p,int N){
  for(int i = 0 ; i < N/2 ; i++){
    Segment a = Segment(p[i],p[i+1]);
    Segment b = Segment(p[N/2+i],p[(N/2+i+1)%N]);
    if(!isParallelSS(a,b)){ return Point(INF,INF); }
    if(!equal(dist(a.s,a.t),dist(b.s,b.t))){
      return Point(INF,INF);
    }
  }
  return (p[0]+p[N/2])/2;
}

int main(){
  int N;
  cin >> N;
  vector<Point> p(N);
  for(int i = 0 ; i < N ; i++){
    cin >> p[i];
  }
  if(N&1){
    cout << "NA" << endl;
  }else{
    Point res = getPoint(p,N);
    if(res.x == INF && res.y == INF){
      cout << "NA" << endl;
    }else{
      printf("%.8f %.8f\n",res.x,res.y);
    }
  }
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)15;
const int mod = (int)1e9+7;

int h, w, k, ans = 0, cnt = 0;
char c[M][M];
int row[M], col[M];
string str;

string toBin(int n, int k)
{
    string t;
    if(n == 0) t = "0";
    while(n)
    {
        t += to_string(n%2)[0];
        n /= 2;
    }
    reverse(t.begin(), t.end());
    n = t.size();
    return str.substr(0, k-n) + t;
}

bool func(string s1, string s2)
{
	int curr = 0;
	int a = s1.size(), b = s2.size();
	vector <int> vr, vc;
	f(i, 0, a) if(s1[i] == '1') vr.pb(a-1-i);
	f(i, 0, b) if(s2[i] == '1') vc.pb(b-1-i);
	a = vr.size(), b = vc.size();
	f(i, 0, a) curr += row[vr[i]];
	f(i, 0, b) curr += col[vc[i]];
	// f(i, 0, a) cout<<vr[i]<<' '; cout<<endl;
	// f(i, 0, b) cout<<vc[i]<<' '; cout<<endl;
	// cout<<curr<<endl;
	f(i, 0, a)
	{
		f(j, 0, b)
		{
			// cout<<c[vr[i]][vc[j]]<<'\t';
			curr -= (c[vr[i]][vc[j]] == '#') ? 1 : 0;
		}
	}
	// cout<<cnt<<' '<<curr<<' '<<k<<endl;
	return (cnt-curr == k);
}

void solve()
{
    cin>>h>>w>>k;
	f(i, 0, h+w) str += "0";
    f(i, 0, h)
    {
    	f(j, 0, w)
    	{
    		cin>>c[i][j];
    		if(c[i][j] == '#') row[i]++, col[j]++, cnt++;
    	}
    }
    int ph = pow(2, h);
    int pw = pow(2, w);
    string sh[ph], sw[pw];
    f(i, 0, ph) sh[i] = toBin(i, h);
    f(i, 0, pw) sw[i] = toBin(i, w);
    // func(sh[1], sw[5]);
    f(i, 0, ph)
    {
    	f(j, 0, pw)
    	{
    		ans += func(sh[i], sw[j]);
    		// if(func(sh[i], sw[j])) cout<<sh[i]<<' '<<sw[j]<<endl;
    	}
    }
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4148
(* 配列版素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた集合同士を合併する *)
  (* 破壊的操作であるため注意 *)
  val unite : t -> Class.t -> Class.t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> Class.t -> int
end = struct
  type t = int array

  module Class = struct
    type t = int
    let compare = compare
  end

  let make n = Array.make n (-1)

  let rec find uf x =
    if uf.(x) < 0 then x
    else begin
      let y = find uf uf.(x) in
      uf.(x) <- y; y
    end

  let unite uf x y =
    if x <> y then begin
      let x, y = if uf.(x) <= uf.(y) then x, y else y, x in
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    end

  let cardinal uf x = ~- (uf.(x))
end

module WeightedGraph
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  (*
   * HashtblやMapを用いているとプリム法と大差ない計算時間になってしまうため，
   * より汎用的な実装が欲しければそちらを当たること
   *)
  val kruskal :
    (* 頂点の数n *)
    int ->
    (* 辺のリスト *)
    (* 頂点は0からn-1までの整数でなくてはならない
       ソートにList.sortを使っているせいでデータ構造が固定されており，あまり良くない… *)
    (int * int * Weight.t) church_list ->
    (* 最小全域木に含まれる辺のリスト
       畳み込む関数と初期値まで与えられて初めて計算を開始するので，
       最小全域木に対して色々な操作をしたい場合は，
       一度リストにして覚えておくとよい．
       最小全域木の重さの和だけ欲しいとか一回しか使わない場合は，
       直接畳み込む関数と初期値を与えるとdeforestationになっていい感じ． *)
    (int * int * Weight.t) church_list
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let kruskal n es =
    { fold = fun f init ->
      let uf = UnionFind.make n in
      let es = Array.of_list @@ es.fold (fun x xs -> x :: xs) [] in
      Array.sort (fun (_, _, w) (_, _, w') -> Weight.compare w w') es;
      Array.fold_left (fun acc (u, v, w) ->
        let c = UnionFind.find uf u in
        let d = UnionFind.find uf v in
        if UnionFind.Class.compare c d = 0
        then acc
        else (UnionFind.unite uf c d; f (u, v, w) acc)) init es }
end
 
module Int = struct
  type t = int
  let compare = compare
end
 
module G = WeightedGraph (Int)
 
let () =
  let n = Scanf.scanf "%d\n" @@ fun n -> n in
  let xys = Array.to_list @@ Array.init n @@ fun i ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y, i in
  let xedges =
    List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, x' - x) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  let yedges =
    List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, y' - y) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  Printf.printf "%d\n" @@
  (G.kruskal n { G.fold = fun f acc -> List.fold_right f xedges @@ List.fold_right f yedges acc }).G.fold (fun (_, _, d) -> ( + ) d) 0


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

namespace AtCoder_Beginner_Contest_126
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var S = Console.ReadLine();
            var s = new char[S.Length];
            for (int i = 0; i < S.Length; ++i)
            {
                s[i] = S[i];
                if (NK[1] == i + 1)
                    s[i] = char.ToLower(S[i]);
            }           
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N;
ll A[200020];

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%lld", A + i);
	sort(A+1, A+1+N);
	multiset <ll> X;
	for(int i=1;i<=N;i++) X.insert(A[i]);
	int ans = 0;
	for(int i=N;i;i--) {
		if(X.find(A[i]) == X.end()) continue;
		X.erase(X.find(A[i]));
		ll t = 1LL << (63 - __builtin_clzll(A[i]));
		ll r = 2 * t - A[i];
		if(X.find(r) != X.end()) ++ans, X.erase(X.find(r));
		else X.insert(A[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
using namespace std;
int main() {
	int N = 0;
	scanf("%d", &N);
	vector<long>v (N+1,0);

	/*
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				if ((x * x + y * y + z * z + x * y + x * z + z * y) != 0 && ((x * x + y * y + z * z + x * y + x * z + z * y) < v.size())) {
					v[(x * x + y * y + z * z + x * y + x * z + z * y) - 1]++;
				}
				
			}
			
		}
		
	}*/

	for (int i = 1; i <= 100; i++) {
		for (int w = 1; w <= 100; w++) {
			for (int y = 1; y <= 100; y++) {
				if (((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w)) <= v.size()) {
					v[((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w))]++;

				}

			}

		}
	}
	
	for (int i = 1; i <= N; i++) {
		string str = to_string(v[i]);
		const char* l = str.c_str();
		printf(l);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
#include<map>
using std::map;

#include <string>
using std::string;

#define ll long long

#define filoop(n) for(ll i=0;i<(n);i++)
#define fjloop(n) for(ll j=0;j<(n);j++)
map<string,int> memo;
int main()
{

        ll n;
        cin>>n;
        filoop(n)
        {
            string s;
            cin>>s;
            memo[s] +=1;
        }
        int mx = 0;
        map<string,int>::iterator it;
       for( it = memo.begin(); it!=memo.end(); it++)
        {
            int tmp = it->second;
            if(mx<tmp) mx = tmp;
        }

        for(it = memo.begin(); it!=memo.end(); it++)
        {
            if(it->second==mx) cout<< it->first<<"\n";
        }


    return 0;
}





Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> x;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        x.push_back(a);
    }
    vector<int> y;
    y = x;
    sort(y.begin(), y.end());
    int mid = y[n/2];
    for (int i = 0; i < n; i++) {
        if (x[i] < mid) {
            cout << y[n/2] << endl;
        } else {
            cout << y[(n-1)/2] << endl;
        }
    }
    return 0;
}


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	if((a!=7 && c!=7) || (a==5 && c==5))	cout << "YES\n";
	else if((b==5 && a==5 && c!=5))	cout << "YES\n";
	else if((b!=5))cout << "NO\n";
	else cout << "YES\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
ll INF = 1001001001;
int main() {
  int N, L; cin >> N >> L;
  vector<int> a(N);
  int sum = 0;
  rep(i, N) {
    a[i]=i+L; sum += a[i];
  }
  int mini = INF;
  rep(i, N) {
    if(abs(mini)>abs(a[i])) mini = a[i];
  }
  int ans = sum - mini;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define all(C) C.begin(),C.end()
typedef long long int Long;
typedef long double Double;
const int MAXN = 30;
 
string s;
char sz[MAXN] = {0};
 
bool has(string &s, char c) {
  for(char ch : s)
    if(ch == c)
      return false;
  return true;
}
 
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
  cin >> s;
 
  set<string> possibles;
  for(int i = 0; i <= int(s.length()); ++i) {
    string t = s.substr(0, i);
    char pad = 0;
 
    for(char j = i < int(s.length()) ? s[i] : 'a'; j <= 'z'; ++j)
      if(has(t, j)) {
        string t1 = s.substr(0, i + 1);
        string t2 = t + j;
        
        if(i < int(s.length()) && t2 == t1) {
        } else {
          pad = j;
          break;
        }
      }
 
    if(pad) {
      t += pad;
      if(t > s)
        possibles.insert(t);
    }
  }
 
  string ans = "-1";
  if(possibles.size())
    ans = *possibles.begin();

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


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

using namespace std;

int main(void)
{
    string l_r_arange;

    cin >> l_r_arange;

    int children_counts[100000] = {};

    int i = 0;
    while(i < l_r_arange.size()){
        int successive_r = 0;
        int successive_l = 0;
        int border_right;

        while(l_r_arange[i] == 'R'){
            successive_r += 1;

            i++;
        }
        
        border_right = i;
        while(l_r_arange[i] == 'L'){
            successive_l += 1;

            i++;
        }
        
        int right_count_from_left = successive_r / 2;
        int left_count_from_left = successive_r - right_count_from_left;
        int left_count_from_right = successive_l / 2;
        int right_count_from_right = successive_l - left_count_from_right;

        children_counts[border_right] = right_count_from_left + right_count_from_right;
        children_counts[border_right - 1] = left_count_from_right + left_count_from_left;
    }

    for(int i = 0; i < l_r_arange.size(); i++){
        cout << children_counts[i] << ' ';
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
  	int a1,b1,m,mn1=1e18,mn2=1e18,i;
  	cin>>a1>>b1>>m;
  	int a[a1],b[b1];
  	for(i=0;i<a1;++i)
    {
      	cin>>a[i];
      	mn1=min(mn1,a[i]);
    }
  	for(i=0;i<b1;++i)
    {
      	cin>>b[i];
      	mn2=min(mn2,b[i]);
    }
  	int mn=mn1+mn2;
  	for(i=0;i<m;++i)
    {
      	int x,y,c;
      	cin>>x>>y>>c;
      	mn=min(mn,a[x-1]+b[y-1]-c);
    }
  	cout<<mn;
}

Measured memory_bytes: 1792
n,y=map(int,input().split())
a=10000
b=5000
c=1000
sum_money=y
for i in range(0,n+1):
  for j in range(0,n+1-i):
    k=n-i-j
    if sum_money==a*i+b*j+c*k and k>=0:
      print(i,j,k)
      break
  else:
    continue
  break
else:
	print("-1","-1","-1")

Measured memory_bytes: 3064
/* In the name of Allah */

#include<bits/stdc++.h>
using namespace std;
const int MAXN =2 * 1000 * 100 + 100;
string arr[MAXN];
int main(){
	int n;
	cin >> n;
	int cnt = 0;
	while(n--){
		string s;
		cin >> s;
		arr[cnt] = s;
		cnt++;
	}
	int sum = 0;
	sort (arr, arr+cnt);
	for(int i = 0; i < cnt; i++){
		if(arr[i] != arr[i + 1]){
			sum++;
		}
	}
	cout << sum;
	return 0;  
}

Measured memory_bytes: 9848
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		String ans = "No";
		for(int i=0;i<3;i++){
			if(N%10==7){
				ans="Yes";
				break;
			}
			N=N/10;
		}


		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 25340
#include<iostream>
using namespace std;
int main() {
	int N;
	int A, B;
	int ans = 0;
	cin >> N >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % N == 0) {
			cout << "OK" << endl;
			ans++;
			break;
		}
	}
	if (ans == 0) {
		cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
	int n,i,max,count,j;
	max = 0;
	count = 0;
	scanf("%d", &n);
	int a[n];
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			for (j = 0; a[i] % 2 == 0; j++)
			{
				a[i] = a[i] / 2;
				count++;
			}
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func min(a string, b string) string {
	if a == b {
		return a
	}
	as := strings.Split(a, "")
	bs := strings.Split(b, "")
	if len(as) < len(bs) {
		for i, _ := range as {
			aInt, _ := strconv.Atoi(as[i])
			bInt, _ := strconv.Atoi(bs[i])
			if aInt < bInt {
				return a
			} else if aInt > bInt {
				return b
			} else {
				// 同じ場合
				continue
			}
		}
	} else {
		for i, _ := range bs {
			aInt, _ := strconv.Atoi(as[i])
			bInt, _ := strconv.Atoi(bs[i])
			if aInt < bInt {
				return a
			} else if aInt > bInt {
				return b
			} else {
				// 同じ場合
				continue
			}
		}
	}
	if len(as) < len(bs) {
		return a
	} else {
		return b
	}
}

func main() {
	var a, b int
	_, _ = fmt.Scan(&a)
	_, _ = fmt.Scan(&b)
	aStr := strconv.Itoa(a)
	bStr := strconv.Itoa(b)
	ab := ""
	for i := 0; i < b; i++ {
		ab += aStr
	}
	ba := ""
	for i := 0; i < a; i++ {
		ba += bStr
	}
	fmt.Println(min(ab, ba))
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

int main(void) {
    int n, l, left, right, eat;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> l;
    left = l;
    right = l + n - 1;
    if (right <= 0) {
        eat = right;
    } else if (left >= 0) {
        eat = left;
    } else {
        eat = 0;
    }

    cout << (right + left) * (right - left + 1) / 2 - eat << "\n";
    return 0;
}

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

int g(int x, int y, int z){
  int k = x + y + z;
 return k*k-x*y-y*z-z*x;
}

int main(void){
  int N;
  cin>>N;
  vector<int> ans(N+1,0);
  int a=6;
  int n=5;
  int k=3;
 for(int x =1;x<=100;x++){
   for(int y=1;y<=100;y++){
     for(int z=1;z<=100;z++){
       int t = g(x,y,z);
       if(t<=N)ans[t]++;
     }
   }
 }
  for(int i=1;i<=N;i++){
    cout<<ans[i]<<endl;}
  return 0; 
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/
int n;
int deg[200010];

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i=2; i<=n; i++)
    {
        int x;
        cin >> x;
        deg[i]++;
        deg[x]++;
    }
    //Forn(i, n) cout << deg[i] << " ";
    //cout << endl;
    cout << deg[1] << '\n';
    for(int i=2; i<=n; i++) cout << deg[i] - 1 << '\n';
}


Measured memory_bytes: 4448
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]

    mod = 10**9+7

    base_n = 0

    for i in range(N):
        for j in range(i+1,N):
            if A_list[i] > A_list[j]:
                base_n += 1
    
    all_n = 0
    for i in range(N):
        for j in range(N):
            if A_list[i] > A_list[j]:
                all_n += 1


    print(((base_n*K)+all_n*(K-1)*K//2)%mod)





if __name__ == "__main__":
    resolve()


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

Measured memory_bytes: 580
#include<stdio.h>
int main(){
  int n,m,c[100010]={};
  long long s=0,a,b,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    c[a]++;
    s+=a;
  }
  scanf("%d",&n);
  while(n--){
    scanf("%lld %lld",&a,&b);
    s-=a*c[a];
    s+=b*c[a];
    c[b]+=c[a];
    c[a]=0;
    printf("%lld\n",s);
  }
  return 0;
}
    


Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountll((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzll(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ double y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); } double euclidean(double first, double second){ return sqrt(first * first + second * second); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + ","; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }

int main(){
    lint H;
    cin >> H;
    cout << ((2ll << highest(H)) - 1) << endl;
}





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

int main(){
  int H,W;
  cin >> H >> W;
  
  vector<string> S(50);
  for( int i = 0; i < H; i++ ){
    cin >> S.at(i);
  }
  
  vector<int> dx;
  dx = { -1, -1, -1, 0, 0, 1, 1, 1 };
  vector<int> dy;
  dy = { -1, 0, 1, -1, 1, -1, 0, 1 };
  
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ){
      
      if( S.at(i).at(j) == '#' ){
        continue;
      }
      
      int count = 0;
      for( int d = 0; d < 8; d++ ){
        int ni = i + dx.at(d);
        int nj = j + dy.at(d);
        
        if( ni < 0 || H <= ni || nj < 0 || W <= nj ){
          continue;
        }
        
        if( S.at(ni).at(nj) == '#' ){
          count++;
        }
      }
      S.at(i).at(j) = char( count + '0' );
    }
  }    
  
  for( int i = 0; i < H; i++ ){
    cout << S.at(i) << endl;
  }
}

Measured memory_bytes: 256
main(n,m,e,j){for(;scanf("%d",&n),n;)for(;n--;){scanf("%d%d%d",&m,&e,&j);puts(m==100||e==100||j==100||m+e>179||m+e+j>239?"A":m+e+j>209||(m+e+j>149&&(m>79||e>79))?"B":"C");}return 0;}

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

int main() {
    long long int k,q;
    int n;
    cin >> n >> k >> q;
    vector<long long int> B(n);
    for (int i = 0; i < n; ++i){
      B[i]=0;
    }
    for (int i = 0; i < q; ++i){
      int a;
      cin >> a;
      ++B[a-1];
    }

    for(int i=0;i<n;++i){
      if((k-q)+B[i]>0){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	for(int i=0; i<n; i++){
		cin >> a.at(i);
	}
	
	sort(a.begin(), a.end());
		
	ll b,c;
	vector<pair<int, int>> pairs(m);
	for(int i=0; i<m; i++){
		cin >> b >> c;
		pairs[i] = make_pair(c,b);
	}
	sort(pairs.begin(), pairs.end());

	int flag=0;
	int changed=0;
	for(int i=0; i<m; i++){
		c=pairs[m-1-i].first;
		b=pairs[m-1-i].second;
		if(flag==1){
			break;
		}
		int cnt=0;
		for(int j=changed; j<n; j++){
			if(b<=0){
				break;
			}
			if(a.at(j)>=c){
				flag=1;
				break;
			}
			if(a.at(j)<c){
				a.at(j)=c;
				b--;
				cnt++;
				changed++;
			//	sort(a.begin(),a.end());
			}
		}

	}
	
	ll sum=0;
	for(int i=0; i<n; i++){
		sum += a.at(i);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1920
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
string s[3];
int dat[3][3][6005];
bool good(char a,char b){
	if(a=='?'||b=='?'||a==b)return 1;
	return 0;
}
void calc(int x,int y){
	//dat[x][y][i]: match(s[x][i...],s[y][0...])
	for(int i=0;i<6005;i++)dat[x][y][i]=1;
	for(int i=0;i<s[x].size();i++){
		for(int j=0;j<s[y].size();j++){
			if(i+j>=s[x].size()||good(s[x][i+j],s[y][j])){
				
			}else dat[x][y][i]=0;
		}
	}
}
int v[3];
bool valid(){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(v[i]<=v[j]){
				if(!dat[i][j][v[j]-v[i]])return 0;
			}
		}
	}
	return 1;
}
#ifdef LOCAL
const int limit=50;
#else
const int limit=4004;
#endif
int solve(int x){
	int id[2],p=0;
	for(int i=0;i<3;i++)if(i!=x)id[p++]=i;
	int ret=inf;
	for(int a=0;a<=limit;a++){
		for(int b=0;b<=limit;b++){
			if(a>=2002&&b>=2002)continue;
			v[x]=0;v[id[0]]=a;v[id[1]]=b;
			if(valid())
			ret=min(ret,(int)max({s[x].size(),s[id[0]].size()+a,s[id[1]].size()+b}));
		}
	}
	return ret;
}
int main(){
	cin>>s[0]>>s[1]>>s[2];
	for(int i=0;i<3;i++)for(int j=0;j<3;j++)calc(i,j);
	int ans=inf;
	for(int i=0;i<3;i++)ans=min(ans,solve(i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
import collections

N = int(input())
moji = [input() for i in range(N)]

moji_count = collections.Counter(moji)
max_kv = max(moji_count.items(), key=lambda x: x[1])

max_moji = []
for i, j in moji_count.items():
    #print(i, j)
    if j==max_kv[1]:
        max_moji.append(i)
#max_moji.append(max_kv[0])
max_sort = sorted(max_moji)
for i in max_sort:
    print(i)


Measured memory_bytes: 35572
n=int(input())
h=list(map(int,input().split()))
dp=[0 for _ in range(n)]
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    x=dp[i-1]+abs(h[i-1]-h[i])
    x1 = dp[i - 2] + abs(h[i - 2] - h[i])
    dp[i]=min(x,x1)
print(dp[-1])

Measured memory_bytes: 13928
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const ll inf = 9e18;
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

class debug
{
public:
    typedef long long ll;
    template<typename T> void vd(vector<T> vec);
    template<typename T> void vd2(vector<vector<T>> vec);
    template<typename T> void vpd(vector<pair<int, int>> vec);
    template<typename T> void ad(T *arr, ll n);
    template<typename T, size_t N> void ad2(T (&arr)[N], ll n);
    template<typename T> void md(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vd(vector<T> vec)
{
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T> void debug::vd2(vector<vector<T>> vec)
{
    for(auto vv : vec) for(auto vvv : vv) cout << vvv << " ";
    cout << endl;
}

template<typename T> void debug::vpd(vector<pair<int, int>> vec) {
    for(auto const& vv : vec) {
        cout << vv.first << " " << vv.second << endl;
    }
    cout << endl;
}

template<typename T> void debug::ad(T *arr, ll n)
{
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T, size_t N> void debug::ad2(T (&arr)[N], ll n)
{
    for(int i=0; i<=N; i++) for(int j=0; j<=n; j++) cout << arr[i][j] << " ";
    cout << endl;
}

template<typename T> void debug::md(T mp)
{
    cout << "key : value" << endl;
    for(auto const& m : mp) cout << m.first << " : " << m.second << endl;
    cout << endl;
}
debug debug;

class BIMissYou {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;
	    for(int i=0; i<s.length(); i++){
	        out << 'x';
	    }
	    out << endl;
	}
};


int main() {
	BIMissYou solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define MAX 100
using namespace std;

static const int INFTY = (1 << 21);
int n, M[MAX][MAX];
int d[MAX];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
	}
	d[s] = 0;
	int u;
	while (!q.empty())
	{
		u = q.front();
		q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0)
				continue;
			if (d[v] != INFTY)
				continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		int u, k, v;
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);

	return 0;
}


Measured memory_bytes: 3128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



//————————BFS迷路の最短経路————————————————

// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};



int main() {
    int r,c;
    cin >> r >> c;

    // 盤面入力受取 
    vector<string> p(r);
    rep(i,r) {
      cin >> p[i];
    }

    // BFS のためのデータ構造
    vector<vector<int>> dist(r,vector<int>(c,-1)); // 全マスを「未訪問」に初期化
    queue<pair<int,int>> que;

    // 初期条件 ((sx,sy) を初期ノードとする) 
    dist[0][0] = 0;
    pair<int,int> q=mp(0,0);
    que.push(q); // (sx,sy) を入れる

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        pair<int,int> v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
      
        //vの上下左右をすべて調べる
        rep(i,4) {
          int nh = v.fi + dx[i];
          int nw = v.se + dy[i];

          // 場外アウトしたり、移動先が壁の場合はスルー
          if (nh < 0 || nh >= r || nw < 0 || nw >= c) continue;
          if (p[nh][nw] == '#') continue;
          
          if (dist[nh][nw] != -1) continue; // すでに発見済みのマスは探索しない

          // 新たなマスについて距離情報を更新してキューに追加する
          dist[nh][nw] = dist[v.fi][v.se] + 1;
          pair<int,int> r=mp(nh,nw);
          que.push(r);
        }
    }

    // 結果出力 (goalのstartからの距離を見る)
    if(dist[r-1][c-1]==-1) cout << -1 << endl;
    else {
      int ans=0;
      rep(i,r){
        rep(j,c){
          if(p[i][j]=='.') ans++;
        }
      }
      
      cout << ans-(dist[r-1][c-1]+1) << endl;
    }
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

/*

3
1 3200 3200
//=> 1 3

9
3200 3200 3200 3200 3200 3200 3200 3200 3200
//=> 1 9

*/

fn main() {
    read!(usize);
    let A = read![[usize]];

    static COLORS: &'static [(usize, usize, &'static str)] = &[
        (1, 399, "灰色"),
        (400, 799, "茶色"),
        (800, 1199, "緑色"),
        (1200, 1599, "水色"),
        (1600, 1999, "青色"),
        (2000, 2399, "黄色"),
        (2400, 2799, "橙色"),
        (2800, 3199, "赤色"),
    ];

    let mut colors = vec![];
    let mut wild = 0;

    for &a in &A {
        if a >= 3200 {
            wild += 1;
            continue;
        }

        for &(lb, ub, name) in COLORS {
            if lb <= a && a <= ub {
                colors.push(name);
                break;
            }
        }
    }

    colors.sort();
    colors.dedup();
    let min_count = max(colors.len(), min(wild, 1));
    let max_count = colors.len() + wild;

    println!("{} {}", min_count, max_count)
}


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

int main(){
  ll n, k;
  cin >> n >> k;
  vector<vector<ll>> dp(n+1,vector<ll>(k+1));
  rep(i,k+1) dp[0][i] = 1;
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= k; j++) {
      if(i >= j) (dp[i][j] += dp[i-j][j]) %= mod;
      (dp[i][j] += dp[i][j-1]) %= mod;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}



Measured memory_bytes: 10716
#include <iostream>
using namespace std;
int a[100100];
int cost[100100];
int main() {
	int n;cin >> n;
	int def = 0;
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
	}

	for (int j = 0;j <= n;j++) {
		def += abs(a[j + 1] - a[j]);
	}

	for (int k = 1;k <= n;k++) {
		cost[k] = def - abs(a[k] - a[k - 1]) - abs(a[k + 1] - a[k]) + abs(a[k + 1] - a[k - 1]);
		cout << cost[k] << endl;
	}


	return 0;
}

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

typedef long long ll;

const ll inf = 1 << 30;

int n, a[1010], b[1010];

ll dp[1010][10010];

ll go(int pos, int mH) {
    if(mH < 0) return 0;

    if(pos == n) {
        if(mH > 0) return inf;
        return 0;
    }

    if(dp[pos][mH] != -1) return dp[pos][mH];

    ll op1 = b[pos] + go(pos, mH - a[pos]);
    ll op2 = go(pos + 1, mH);

    return dp[pos][mH] = min(op1, op2);
}

int main() {
    ios_base::sync_with_stdio(false);

    int h;
    cin >> h >> n;

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

    memset(dp, -1, sizeof dp);

    cout << go(0, h) << endl;
}


Measured memory_bytes: 79744
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
using ll = long long;

const int mx = 1e5+5;
const int inf = 1e9+9;
const int mod = 1e9+7;

int main(int argc, const char** argv) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5])
        cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [input() for _ in range(n)]
t = input(); l.append(t)
li = list(map(lambda x:x.replace('?', 'A'), l))
ho = list(map(lambda x:x.replace('?', 'z'), l))
li.sort(reverse=True); ho.sort()
x = n - li.index(t); y = ho.index(t)
print(' '.join(map(str, list(range(y+1,x+2)))))

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

int main(){
  int n, count=0;
  cin>>n;
  vector<int> a(n+1);
  for (int i=1; i<=n; i++) cin>>a[i];
  for (int i=1; i<=n; i++) if (i%2!=0 && a[i]%2!=0) count++;
  cout<<count<<endl;
}

Measured memory_bytes: 3568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		System.out.print("#");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	}

}

Measured memory_bytes: 33132
#include <iostream>

int main()
{
    int n = 0;
    int a_i = 0;
    int min = 1000000;
    int max = -1000000;
    long sum = 0;

    // input
    std::cin >> n;

    if (n <= 0 || n > 10000)
    {
        std::cout << "Error : n : out of range!" << std::endl;
        return -1;
    }

    for (int i = 0; i < n; ++i)
    {
        std::cin >> a_i;

        if (a_i < -1000000 || a_i > 1000000)
        {
            std::cout << "Error : a_i : out of range!" << std::endl;
            return -2;
        }

        if (max < a_i)
        {
            max = a_i;
        }

        if (min > a_i)
        {
            min = a_i;
        }

        sum += a_i;
    }

    // output
    std::cout << min << " " << max << " " << sum << std::endl;

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
int main()
{
    int n;
    int r[200001];
    std::cin >> n;
    for (int i = 0; i < n; i++)
    {
        std::cin >> r[i];
    }
    int tmp = r[0];
    int ans;
    int dif;
    for (int i = 1; i < n; i++)
    {
        dif = r[i] - tmp;
        if (i == 1)
        {
            ans = dif;
        }
        else
        {
            ans = std::max(ans, dif);
        }

        tmp = std::min(tmp, r[i]);
    }
    std::cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3884
#include <iostream>

using namespace std;

int n;
int a[200000];

int main(){
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=n-1;i>=0;i-=2){
        cout << a[i] << " ";
    }
    int s;
    if((n-1) % 2 == 0){
        s = 1;
    }else{
        s = 0;
    }
    for(int i=s;i<n;i+=2){
        cout << a[i];
        if(i < n-2) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).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>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
vl A;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    A = vl(N-2+1);
    for(int i = 0; i < N-2+1; ++i){
        cin >> A[i];
    }
    solve();
}

// 2 <= N <= 2 × 10^5
// 1 <= A_i < i

// ll N, vl A
// 社員番号 1,2,...,N のそれぞれの社員について、直属の部下が何人いるか、改行区切りで出力せよ。
void solve(){
    vl cnt(N);
    rep(i,N-1)++cnt[A[i]-1];
    rep(i,N)cout<<cnt[i]<<endl;
}


Measured memory_bytes: 6352
while 1:
	n=int(input())
	if n==0:
		break
	x=[0 for i in range(10)]
	for i in range(n):
		c=int(input())
		x[c]+=1
	for i in range(10):
		count='*'*x[i]
		if len(count)==0:
			print("-")
		else:
			print(count)


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n;
ll all, bll;
ll cou;
ll maxx;

int main(void)
{
	scanf("%lld", &n);
	
	while(n--)
	{
		scanf("%lld %lld", &all, &bll);
		
		if(all == bll)
			cou++;
		
		else
		{
			maxx = max(maxx, cou);
			cou = 0;
		}
	}
	
	maxx = max(maxx, cou);
	
	if(maxx >= 3)
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

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

	if (s.size() < 4)
	{
		cout << "No" << endl;
	}else if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
	{
		cout << "Yes" << endl;
	}else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include <stdio.h>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

int main(void)
{
	char A[10];
	cin >> A;
	rep(i, 3) {
		if (A[i] == '1') {
			cout << "9";
		}
		else {
			cout << "1";
		}
	}
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a_array=gets.chomp.split(" ").map(&:to_i).sort { |a, b| b <=> a }

ret = -1
(0..n-2).each do |i|
    ((i+1)..(n-1)).each do |j|
        prod = a_array[i] * a_array[j]        
        if ret != -1 && ret > prod
            next
        end
        prods = prod.to_s.split("").map(&:to_i)
        judge = true
        (1..(prods.length - 1)).each do |ind|
            if prods[ind] != prods[ind-1] + 1
                judge = false
                break
            end
        end
        if judge
            ret = prod
        end
    end
end

puts ret



Measured memory_bytes: 8868