akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace atcoder.abc166.c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] paramArray = getIntParams();
            int N = paramArray[0];
            int M = paramArray[1];

            int[] H = getIntParams();

            List<int>[] route = new List<int>[N + 1];
            for (int c = 0; c <= N; c++)
            {
                route[c] = new List<int>();
            }

            for (int i = 1; i <= M; i++)
            {
                int[] data = getIntParams();
                int A = data[0];
                int B = data[1];

                if (!route[A].Contains(B))
                {
                    route[A].Add(B);
                }
                if (!route[B].Contains(A))
                {
                    route[B].Add(A);
                }
            }

            int ret = 0;
            for (int x = 1; x <= N; x++)
            {
                if (route[x].Count == 0)
                {
                    ret++;
                }
                else
                {
                    int err = 0;
                    for (int y = 0; y < route[x].Count; y++)
                    {
                        if (H[x - 1] <= H[route[x][y] - 1])
                        {
                            err++;
                        }
                    }
                    if (err == 0)
                    {
                        ret++;
                    }
                }
            }
            Console.WriteLine(ret);
        }
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
        static decimal getDecimalParam()
        {
            return decimal.Parse(Console.ReadLine());
        }
        static decimal[] getDecimalParams()
        {
            return Console.ReadLine().Split(' ').Select(i => decimal.Parse(i)).ToArray();
        }
    }
}


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

// N = Kのとき、答えは0
// N < Kのとき、答えはmin(K-N, N)
// N > Kのとき、答えはmin( N%K, (N+K-1)/K*K -N)

long long solve(long long N, long long K){
    if(N == K) return 0LL;
    if(N < K) return min(K-N, N);
    return min(N%K, (N + K-1)/K*K - N);
};

int main() {
    long long N, K;
    cin >> N >> K;
    cout << solve(N, K) << endl;
    return 0;
}

Measured memory_bytes: 256
def eratosthenes(n):
 is_p=[1]*n
# p_list=[]

 is_p[0]=0
 is_p[1]=0

 for i in range(2,n):
  if is_p[i]:
#   p_list.append(i)
   for j in range(i*i,n,i):
    is_p[j] = 0

 return is_p#, p_list

lim=10**5+1
#is_p, p_list=eratosthenes(lim)
is_p=eratosthenes(lim)

q=int(input())

'''
b=[0]
for i in range(1,lim+1):
 if is_p[i-1] and is_p[i//2]:
  b.append(b[i-1]+1)
 else:
  b.append(b[i-1])
'''
a = [0] * (10**5+2)
for i in range(3, 10**5+1, 2):
    if is_p[i] and is_p[(i+1)//2]:
        a[i] = 1
for i in range(1, 10**5+1):
    a[i+1] += a[i]

for i in range(q):
 l,r=map(int,input().split())
# print(b[r+1]-b[l])
 print(a[r]-a[l-1])

Measured memory_bytes: 9204
N = int(input())
H = list(map(int, input().split()))

ans = "Yes"

for i in reversed(range(1, N)):
    if H[i]+1 == H[i-1]:
        H[i-1] -= 1
    elif H[i] >= H[i-1]:
        continue
    else:
        ans = "No"
        break
print(ans)


Measured memory_bytes: 14252
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	vector<int> s(10, 160), t(101, 1150);
	s = {0, 125, 140};
	for (int i = 10; i < 101; i++)
		t[i] = t[i - 1] + s[(i - 1) / 10];
	for (int w; ~(w = in());)
		out(4280 - t[w], '\n');
}


Measured memory_bytes: 2376
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";
string T = "";
ll N;

int main() {
	cin >> N;
	cin >> S >> T;
	int j = 0;
	for(int i = 0; i < S.size(); i++) {
		cout << S[i] << T[j];
		j++;
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int>> &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}



int main() {
  
  int n, tmp; cin >> n;
  vector<int> a(n); 
  for(int i = 2; i <= n; i++) {
    cin >> tmp;
    a[tmp-1]++;
  }
  

  for(int i : a) {
    cout << i << endl;
  }
    
}

Measured memory_bytes: 4048
#include <iostream>
#include <string>
using namespace std;
string n;
int f=0;
int main(void){
    cin>>n;
    for(int i=0;i<n.length();i++){
        if(n[i]=='7') f++;
    }
    for(int i=0;i<n.length();i++){
        if(n[i]=='7') f++;
    }
    if(f>0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int N, M;
int num[2100];

int main() {
    while (cin >> N >> M) {
        if (N == 0 && M == 0) break;
        for (int i = 0; i < N; ++i) cin >> num[i];
        
        int now = 0; int res = -1;
        for (int j = 0; j < M; ++j) {
            int a; cin >> a;
            now += a;
            if (now >= N-1 && res == -1) res = j+1;
            if (res == -1) now += num[now];
            if (now >= N-1 && res == -1) res = j+1;
            //cout << j << " : " << now << endl;
        }
        
        cout << res << endl;
    }
    return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> sunuke;
  for (int i=0 ; i<N ; i++)
    sunuke.push_back(i+1);
  
  vector<int> d(K);
  for (int i=0 ; i<K ; i++){
    cin >> d.at(i);
    vector<int> A(d.at(i));
    for (int j=0 ; j<d.at(i) ; j++){
      cin >> A.at(j);
      sunuke.erase(remove(sunuke.begin(), sunuke.end(), A.at(j)), sunuke.end());
    }
  }
  
  cout << sunuke.size() << endl;
}

Measured memory_bytes: 3620
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# a, b = MAP()
# n = INT()
# a, b, c = MAP()
count = 0
N = INT()
# for i in range(1,N):
    # print(i)
    # count += i
# print(count)
a = N-1
ans = a * (a+1)//2
print(ans)


Measured memory_bytes: 5704
import sys

read = sys.stdin.readline
N, K = map(int, read().split())
R, S, P = map(int, read().split())
T = input()
t = [0] * N

for i in range(N):
    s = T[i]
    if s == 'p':
        t[i] = S
    elif s == 's':
        t[i] = R
    else:
        t[i] = P

for i in range(K, N):
    if T[i] == T[i - K]:
        if t[i - K] != 0:
            t[i] = 0

print(sum(t))



Measured memory_bytes: 4084
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)

	var input string
	fmt.Scan(&input)
	inputRune := []rune(input)

	lines := make([]int, 0)
	for i := 0; i < n; i++ {
		if len(lines) == 0 || inputRune[i-1] != inputRune[i] {
			lines = append(lines, 0)
		}
		lines[len(lines)-1] += 1
	}

	if inputRune[0] == []rune("0")[0] {
		lines = append([]int{0}, lines...)
	}

	lineLength := len(lines)

	// indexが0の時を求める
	var result int
	for j := 0; j <= k*2; j++ {
		if j >= lineLength {
			break
		}

		result += lines[j]
	}

	output := result
	preValue := result

	// indexが1以上の時を求める
	for i := 1; (i+k)*2-1 < lineLength; i++ {
		result := preValue

		// 前のやつを引く
		for j := 2 * (i - 1); j < 2*i; j++ {
			result -= lines[j]
		}

		// 次のやつを足す
		for j := 2*(i+k-1) + 1; j <= 2*(i+k); j++ {
			if j >= lineLength {
				break
			}

			result += lines[j]
		}

		if result > output {
			output = result
		}
		preValue = result
	}

	fmt.Println(output)
}


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

int main(){
  int n,i,l,r;
  cin>>n;
  vector<int> d(n);
  for(i=0;i<n;i++) cin>>d[i];
  sort(d.begin(),d.end());
  
  r=d[n/2];
  l=d[n/2-1];

  cout<<r-l<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a+b, max(a * b, a-b));
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int n,i;
    cin>> n;
    int day[n];
    
    for(i=0;i<n;++i){
        cin>> day[i];
    }
    
    for(i=1;i<n;++i){
        cout<< day[n-i] <<" ";
    }
    
    cout<< day[0]<< endl;
}



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

int main()
{
  ll X,a,b,res = 0;
  
  cin >> X;
  
  a = X/500;
  b = (X-500*a)/5;

  
  res = 1000*a+5*b;
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int b = 0; 
      
      for(int i=0;i<3;i++){
        if(a.charAt(i)=='o'){
          b++;
        }
      }
            System.out.println(700+b*100);
    }
}

Measured memory_bytes: 21204
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        string S = ReadLine();
        long ans = 0;
        StringBuilder sb = new StringBuilder();
        int max = Power(2, S.Length - 1);
        for(int i = 0; i < max; i++)
        {
            sb.Append(S);
            for(int j = 0; j < S.Length; j++)
            {
                if(((i >> j) & 1) == 1)
                {
                    sb.Insert(S.Length - 1 - j, " ");
                }
            }
            ans += sb.ToString().Split(' ').Select(long.Parse).Sum();
            sb.Clear();
        }
        WriteLine(ans);
    }
      static int Power(int _base, int _index)
    {
        int ans = 1;
        for(int i = 0; i < _index; i++)
        {
            ans *= _base;
        }
        return ans;
    }
}

Measured memory_bytes: 13268
let ()  =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.fold_left (fun (minm, maxm, sum) a -> (ref (min !minm a), ref(max !maxm a), ref (!sum + a))) (ref max_int, ref min_int, ref 0) as_
  |> (fun (x, y, z) -> Printf.printf "%d %d %d\n" !x !y !z) ;;


Measured memory_bytes: 4612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
struct edge{
    int to, cap, rev; ll cost;
    edge(int to, int cap, ll cost, int rev):to(to), cap(cap), cost(cost), rev(rev){}
};

int V;
vector<edge> g[2525];
ll h[2525];
ll dist[2525];
int prevv[2525], preve[2525];

void add_edge(int from, int to, int cap, ll cost){
    edge e=edge(to, cap, cost, g[to].size());
    g[from].push_back(e);
    e=edge(from, 0, -cost, g[from].size()-1);
    g[to].push_back(e);
}

ll min_cost_flow(int s, int t, int f){
    using P=pair<ll, int>;
    const ll INF=1e18;
    ll res=0;
    fill(h, h+V, 0);
    while(f>0){
        priority_queue<P, vector<P>, greater<P>> que;
        fill(dist, dist+V, INF);
        dist[s]=0;
        que.push({0, s});
        while(!que.empty()){
            P p=que.top(); que.pop();
            int v=p.second;
            if(dist[v]<p.first) continue;
            for(int i=0; i<g[v].size(); i++){
                edge &e=g[v][i];
                if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
                    prevv[e.to]=v;
                    preve[e.to]=i;
                    que.push({dist[e.to], e.to});
                }
            }
        }
        for(int v=0; v<V; v++) h[v]+=dist[v];
        if(dist[t]==INF) return -1;
        int d=f;
        for(int v=t; v!=s; v=prevv[v]){
            d=min(d, g[prevv[v]][preve[v]].cap);
        }
        f-=d;
        res+=d*h[t];
        for(int v=t; v!=s; v=prevv[v]){
            edge &e=g[prevv[v]][preve[v]];
            e.cap-=d;
            g[v][e.rev].cap+=d;
        }
    }
    return res;
}
int main()
{
    int n, m;
    cin>>n>>m;
    string s[55];
    for(int i=0; i<n; i++){
        cin>>s[i];
    }
    int S=n*m, T=S+1;
    V=S+2;
    int cnt=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(s[i][j]=='#') continue;
            if(s[i][j]=='o'){
                cnt++;
                add_edge(S, i*m+j, 1, 0);
            }
            add_edge(i*m+j, T, 1, 0);
        }
    }
    ll ans=0;
    const ll INF=100;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(s[i][j]=='#') continue;
            if(i+1<n && s[i+1][j]!='#'){
                int x=i*m+j, y=(i+1)*m+j;
                add_edge(x, y, INF, -1);
            }
            if(j+1<m && s[i][j+1]!='#'){
                int x=i*m+j, y=i*m+j+1;
                add_edge(x, y, INF, -1);
            }
        }
    }
    cout<<-min_cost_flow(S, T, cnt)<<endl;
    return 0;
}



Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	for (int i=0; i<s.size(); i++)
	{
		if (s[i]=='1') s[i]='9';
		else if (s[i]=='9') s[i]='1';
	}
	cout << s << endl;
	return 0;
} 

Measured memory_bytes: 256
INF = 10000000000

def merge(A, left, mid, right):
    global anw

    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]

    i, j= 0, 0

    for k in range(left, right):
        anw += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    global anw
    if left + 1 < right:
        mid = int(( left + right ) / 2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

if __name__ == '__main__':
    n = int(input())
    S = [int(x) for x in input().split()]
    anw = 0
    mergeSort(S, 0, n)
    print(*S)
    print(anw)


Measured memory_bytes: 61656
#include <bits/stdc++.h>
using namespace std; 
 
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=1e5;i++)
	{
		int a2=i*8/100,b2=i*10/100;
		if(a2==a&&b2==b)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int main(){
    int n=0;
    rep(i,4){
        int a;
        cin>>a;
        n+=a;
    }
    cout<<n/60<<endl;
    cout<<n%60<<endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1000;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<ll> s;
	ll n;
	cin>>n;
	FOR(i,0,n){
		ll k;
		cin>>k;
		if(s.count(k)==1){
			s.erase(k);
		}else{
			s.insert(k);
		}
	}
	cout<<s.size()<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
int H,W;
  cin>>H>>W;
  vector<vector<char>>A(H,vector<char>(W));
  for(int i=0;i<H;i++){
  string S;
    cin>>S;
    for(int j=0;j<W;j++)
      A.at(i).at(j)=S.at(j);
  
  }
  for(int i=0;i<H;i++){
  bool x=true;
    for(int j=0;j<W;j++){
  if(A[i][j]!='.'){
   x=false; break;
  }
  } if(x){
    for(int k=0;k<W;k++)
      A.at(i).at(k)='a';
    
    }
  
  }for(int i=0;i<W;i++){
  bool x=true;
    for(int j=0;j<H;j++){
  if(A[j][i]!='.' && A[j][i]!='a'){
   x=false; break;
  }
  } if(x){
    for(int k=0;k<H;k++)
      A.at(k).at(i)='a';
    
    }
  
  }for(int i=0;i<H;i++){
  for(int j=0;j<W-1;j++){
    if(A.at(i).at(j)!='a')cout<<A.at(i).at(j);
  }if(A.at(i).at(W-1)!='a')cout<<A.at(i).at(W-1)<<endl;
  else
    cout<<endl;
  }
  
  
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    return gcd(b,a%b);
}

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    int ans=A.at(0);
    rep(n,1,N){
        ans=gcd(ans,A.at(n));
    }

    cout<<ans<<endl;
}

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

int main() {
    int X;
    cin >> X;
    if (400 <= X && X <= 599) cout << 8;
    else if (600 <= X && X <= 799) cout << 7;
    else if (800 <= X && X <= 999) cout << 6;
    else if (1000 <= X && X <= 1199) cout << 5;
    else if (1200 <= X && X <= 1399) cout << 4;
    else if (1400 <= X && X <= 1599) cout << 3;
    else if (1600 <= X && X <= 1799) cout << 2;
    else cout << 1;
    return 0;
}

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

int main() {
  int x,y,fx;
  cin>>x;
  y=x;
  while(y>0){
    fx+=y%10;
    y/=10;  
  }
  if(x%fx==0)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long N=sc.nextLong(),A=sc.nextLong(),B=sc.nextLong();
        sc.close();
        long ans=(N/(A+B))*A;
        if(N%(A+B)<A) ans+=N%(A+B);
        else ans+=A;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35772
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;
    
    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

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

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs =
                Console.ReadLine().Split().Select(x => int.Parse(x));

            Console.WriteLine(
                inputs.Select((v, i) => (v, i)).First(x => x.v == 0).i + 1
            );
        }
    }
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    int sum = 0;
    for (int i = 0; i < n; i++) cin >> w[i], sum += w[i];

    int ret = 1145141919, now = 0;
    for (int i = 0; i <= n; i++) {
        ret = min(ret, abs(now - sum));
        if (i < n)now += w[i], sum -= w[i];
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s.size()==2){
    cout<<s<<endl;
  }else{
    cout<<s[2]<<s[1]<<s[0]<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
typedef pair<int,int> pii;
const int maxn=100005;
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    int k;
    cin>>k;
    int a=(k+1)/2,b=k/2;
    cout<<a*b<<endl;
}


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

#define mp(x, y) make_pair(x, y)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;

int main ( void )
{
	int m;
	
	while (cin >> m)
	{
		vector<pii> v(m);
		
		for (int i = 0; i < m; ++i)
		{
			v[i].X = 0;
			v[i].Y = i+1;
		}
		
		int n;
		
		cin >> n;
		
		vector<pii> t(n);
		
		for (int i = 0; i < n; ++i)
		{
			cin >> t[i].X >> t[i].Y;
			--t[i].X;
			--t[i].Y;
		}
		
		bool hit = true;
		
		while (hit)
		{
			hit = false;
			
			for (int i = 0; i < n; ++i)
			{
				pii p = t[i];
				if (v[p.X].X < v[p.Y].X + 1)
				{
					v[p.X].X = v[p.Y].X + 1;
					hit = true;
				}
			}
		}
		
		sort(v.begin(), v.end(), greater<pii>());
		
		for (int i = 0; i < m; ++i)
		{
			cout << v.at(i).Y << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
int main(void){
    int N = 0;
    int i;
    
    scanf("%d",&N);
    
    char S[N];
    char T[N];
    
    scanf("%s",S);
    scanf("%s",T);
    
    for(i=0;i<N;i++){
        printf("%c%c",S[i],T[i]);
    }
    
    return 0;
    
}

Measured memory_bytes: 128
n=int(input())
*a,=map(int,input().split())

cnt=[0,0,0]
ans=1
mod=10**9+7

for aa in a:
    tmp=0
    for c in cnt:
        if aa==c:
            tmp+=1
    
    if tmp>0:
        for i in range(3):
            if cnt[i]==aa:
                cnt[i]+=1
                break
    
    ans*=tmp
    ans%=mod

print(ans)

Measured memory_bytes: 87876
#python3
from collections import deque
def main():
    n = int(input())
    a = [int(input())-1 for _ in range(n)]

    Q = deque()
    Q.append(a[0])
    
    cnt = 1
    flag = False
    for _ in range(n):
        x = Q.popleft()
        if x == 1:
            flag = True
            break
        cnt += 1
        Q.append(a[x])

    if not flag:
        print(-1)
    else:
        print(cnt)
main()


Measured memory_bytes: 7424
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = list(b)
print(*ans)

Measured memory_bytes: 25412
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
B = gets.chomp.split.map(&:to_i)
C = gets.chomp.split.map(&:to_i)

ans = 0
for i in 0..N - 1
  a = A[i] - 1
  ans += B[a] + (i > 0 && A[i] == A[i - 1] + 1 ? C[a - 1] : 0)
end

puts ans.to_s


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

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

    int r, D, x; cin >> r >> D >> x;
    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << "\n";
    }
}

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

public class Main {
    public static void main (String[] args) throws IOException {
        int c;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();        

        String data = reader.readLine();
        c = Integer.parseInt(data);
        int[] array = new int[c];

        data = reader.readLine();
        String[] number = data.split(" ");
        for (int i = 0; i < c ; i++ ) {
            array[i] = Integer.parseInt(number[i]);
        }
        int max = Max(array);
        int min = Min(array);
        long sum = Sum(array);
        builder
           .append(min)
           .append(" ")
           .append(max)
           .append(" ")
           .append(sum);
        System.out.println(builder);
        
    }
    public static int Max (int[] array){
        int i;
        int max = array[0];
        for (i = 0; i < array.length-1 ; i++ ) {
            if ( max < array[i+1])
                max = array[i+1];
        }
        return max;
    }
    public static int Min (int[] array){
        int i;
        int min = array[0];
        for (i = 0; i < array.length-1 ; i++ ) {
            if ( min > array[i+1])
                min = array[i+1];
        }
        return min;
    }
    public static long Sum (int[] array){
        int i;
        long sum = array[0];
        for (i = 0; i < array.length-1 ; i++ ) {
                sum += array[i+1];
        }
        return sum;
    }
}

Measured memory_bytes: 28640
#include<bits/stdc++.h>
#define int long long int 
#define MOD 1000000007 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
int gcd(int a,int b){if(a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (max(a,b)/gcd(a,b))*min(a,b);}
int powermodm(int x,int n,int M){int result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}



main()
{
    fastIO;
    int t;
    t=1;
    while(t--)
    {
        int n,k;
        cin >> n >>k;
        int h[n];
        for(int i=0;i<n;i++) cin >> h[i];
        int dp[n];
        for(int i=0;i<n;i++)
        {
            dp[i]=1000000000;
        }
        dp[0]=0;
        //dp[1]=abs(h[0]-h[1]);
        for(int i=1;i<n;i++)
        {
            for(int j=i-1;i-j<=k&&j>=0;j--)
            {
                dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
            }
        }
        cout << dp[n-1];
    }
    
    
    
    
    
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int  a[5];
  int k;
  rep(i,5) cin>>a[i];
  cin>>k;
  bool ok=true;
  
 if(a[4]-a[0]>k) ok=false;
  if(ok) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
/*ABC 140 B*/

int main(void)
{
  int N;
  int A[21] = {0};
  int B[21] = {0};
  int C[21] = {0};
  int sum   = 0;

  scanf("%d", &N);
  for (size_t i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  for (size_t i = 1; i <= N; i++) {
    scanf("%d", &B[i]);
  }
  for (size_t i = 1; i <= N-1; i++) {
    scanf("%d", &C[i]);
  }

  for (size_t i = 1; i <= N; i++) {
    sum += B[ A[i] ];
    if (A[i] - A[i-1] == 1 && A[i] != 1) {
      sum += C[ A[i-1] ];
    }
  }

  printf("%d\n", sum);
  return 0;
}


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

Measured memory_bytes: 23380
#include <stdio.h>

int main(void)
{
	int h[10];
	int i, j;
	int tmp;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &h[i]);
	}
	
	for (i = 0; i < 10; i++){
		for (j = i + 1; j < 10; j++){
			if (h[i] < h[j]){
				tmp = h[i];
				h[i] = h[j];
				h[j] = tmp;
			}
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", h[i]);
	}
	return (0);
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>

int main() {
	std::vector<std::string> v;
	bool flag = false;
	v.resize(3);

	for (auto&& x : v) {
		std::cin >> x;

	}


	for (int i = 0; i < 2; i++) {
		v[i].substr(v[i].size()-1, 1) == v[i + 1].substr(0, 1) ? flag = true : flag=false; //[条件式]? [代入] : break; にしたかった… 条件演算子でbreak文は無理そう…
		if (flag == false) {
			break;
		}
	}

	std::cout << (flag == true ? "YES" : "NO") << std::endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5 + 9;
int m[109];
signed main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(a * c, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    // ans = max(ans, 0LL);
    cout << ans << endl;
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

Measured memory_bytes: 3632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << " " << 2 * (a + b) << endl;

	return 0;
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main()
{
	int n;
	cin>>n;
	multimap<pair<string,int>,int> m;
	pair<string,int> p;
	for(int i=0;i<n;i++)
	{
		int x;
		string s;
		cin>>s;
		cin>>x;
		p={s,x};
		m.insert(pair<pair<string,int>,int>(p,i+1));
	}
	multimap<pair<string,int>,int> :: iterator it;
	vector<int> v;
	string s;

	for(it = m.begin();it!=m.end();it++)
	{
		if(it==m.begin())
		{
			v.pb(it->ss);
			s=it->ff.ff;
			continue;
		}
		if(it->ff.ff!=s)
		{
			for(int i=v.size()-1;i>=0;i--)
				cout<<v[i]<<endl;
			v.clear();
		}
		v.pb(it->ss);
		s=it->ff.ff;
	}
	for(int i=v.size()-1;i>=0;i--)
			cout<<v[i]<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int a,b,c,d;
  a = int(s[0] - '0');
  b = int(s[1] - '0');
  c = int(s[2] - '0');
  d = int(s[3] - '0');
  if(a-b-c-d == 7) cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
  else if(a+b-c-d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
  else if(a-b+c-d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
  else if(a-b-c+d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
  else if(a+b+c-d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
  else if(a+b-c+d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
  else if(a-b+c+d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
  else if(a+b+c+d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
  return 0;
}


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

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    auto d = vc(int, N);
    fa(i, d) cin >> i;
    sort(d.begin(), d.end());
    cout << (d[N/2] - d[N/2 - 1]) << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cstring>
#include <memory>
using namespace std;
typedef long long ll;
int dp[2001000];
int asc[2001000];
int ha;
char dt[2001000];
int l;
int r1,r2;
int main(){
	cin>>dt;
	l=strlen(dt);
	for(int i=0;i<l;i++)dt[i]-='0';
	memset(asc,1,sizeof(asc));
	memset(dp,1,sizeof(dp));
	dp[l]=0;
	for(int i=l-1;i>=0;i--){
		ha=(dt[i]+ha==10);
		if(!ha){
			dp[i]=dp[i+1]+dt[i];
			dp[i]=min(dp[i],asc[i+1]+dt[i]+1);
		}
		asc[i]=(10-dt[i]+dp[i+1]);
		asc[i]=min(asc[i],10-dt[i]-1+asc[i+1]);
	}
	cout<<min(asc[0]+1,dp[0])<<endl;
}

Measured memory_bytes: 16896
N, M, Q = map(int, input().split())

tbl = [[0] * (N + 1) for _ in range(N + 1)]
# tbl[L][R] = 累積和
# 1-indexed

for _ in range(M):
    l, r = map(int, input().split())
    tbl[l][r] += 1

for p in range(1, N + 1):
    for q in range(1, N + 1):
        tbl[p][q] += tbl[p][q - 1]
        tbl[p][q] += tbl[p - 1][q]
        tbl[p][q] -= tbl[p - 1][q - 1]

for _ in range(Q):
    p, q = map(int, input().split())
    # 1-indexed
    print(tbl[q][q] - tbl[p - 1][q] - tbl[q][p - 1] + tbl[p - 1][p - 1])

Measured memory_bytes: 13376
function candy_distribution_again(N, x, a) {
    a.sort(
        function(a, b) {
            return a - b;
        }
    );
    
    for (var i = 0; i < N; i++) {
        x -= a[i];
    
        if (x == 0) return i + 1;
        if (x < 0) return i;
        if (!a[i + 1]) return i;
        if (x < a[i + 1]) return i + 1;
    }
}
function main(input) {
    var input = input.split("\n");
    var Nx = input[0].split(" ");
    var a = input[1].split(" ");
    var N = Nx[0];
    var x = Nx[1];
    console.log(candy_distribution_again(N, x, a));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void){
    
    ll a, b, c, k, ans=0;
    
    cin >> a >> b >> c >> k;
    
    ans += a;
    k -= a;
    
    if(k<=0){
        
        cout << ans+k << endl;
        return 0;
        
    }
    
    k -= b;
    
    if(k<=0){
        
        cout << ans << endl;
        return 0;
        
    }
    
    ans -= c;
    k -= c;
    ans -= k;
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3620
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
void add_self(ll& a , ll b){a =  (a + b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n , k ; 
cin>>n>>k;
vector<ll> h(n) , dp(n);
for(ll i = 0 ; i<n ; i++)cin>>h[i] ; 

// dp[i] min(dp[i-1] +abs(h[i] - h[i-1]),dp[i-2] +abs(h[i] - h[i-2]))
dp[0] = 0 ;
for(ll i =1 ; i<n ; i++){
	dp[i] = INT64_MAX;
	for(ll j = 1 ; j<= k && i-j >=0 ;j++){
		dp[i] = min(dp[i] ,  dp[i-j] + abs(h[i] - h[i-j])  );
	}
}
	
cout<<dp[n-1];
	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i] -= (i+1);
  sort(whole(a));
  int b;
  if (n%2==1) {
    b = a[(n-1)/2];
  }
  else {
    b = (a[n/2-1]+a[n/2])/2;
  }
  ll ans = 0;
  rep(i, n) {
    ans += (ll)(abs(a[i]-b));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
unordered_map<ll, ll> hashMap;
ll f(ll v) {
    if (hashMap.count(v)) {
        return hashMap[v];
    }
    if (v == 0) {
        return 0;
    }
    if (v == 1) {
        return 1;
    }
    return hashMap[v] = f(v / 2) * 2 + 1;
}
int main() {
    ll H;
    cin >> H;
    cout << f(H) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    
    int W,H,x,y,r;
    scanf("%d",&W);
    scanf("%d",&H);
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&r);
    
    if((x-r) < 0 || (x+r) > W || (y-r) < 0 || (y+r) > H)
        printf("No\n");
    else
        printf("Yes\n");
    
	return 0;
}


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

using namespace std;

void twice(int &a, int &b, int &c) {
  int target = max({a, b, c});
  if (target == a) a = a * 2;
  if (target == b) b = b * 2;
  if (target == c) c = c * 2;
}
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  int m = max({a, b, c});
  int total = a + b + c;

  for (int i = 0; i < k; i++) {
    // twice(a, b, c);
    total += m;
    m *= 2;
  }

  cout << total << endl;

  return 0;
}

Measured memory_bytes: 256
import numpy as np
from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


N = input()
A = list(map(int, input().split()))
print(reduce(gcd, A, A[0]))

Measured memory_bytes: 23092
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> a(N), b(N);
    for(int i = 0; i < N; i++) cin >> a[i] >> b[i];

    vector<int64_t> count(1e6, 0);
    for(int i = 0; i < N; i++) count[a[i]] += b[i];

    for(int i = 0; i < count.size(); i++){
        K -= count[i];
        if(K <= 0){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 9600
n, m = map(int, input().split())
#n: 桁数　
a_1 = 0
a_2 = 0
a_3 = 0
check = [0]*n #既に指定された場合:1
for _ in range(m):
    s, c = map(int, input().split())
    if s == 1:
        if check[s-1] == 1: #既に指定してあった場合
            if a_1 != c:
                print(-1)
                exit()
        else:
            a_1 = c
            check[s-1] = 1
    elif s == 2:
        if check[s-1] == 1: #既に指定してあった場合
            if a_2 != c:
                print(-1)
                exit()
        else:
            a_2 = c
            check[s-1] = 1
    else:
        if check[s-1] == 1:
            if a_3 != c:
                print(-1)
                exit()
        else:
            a_3 = c
            check[s-1] = 1

if n==1:
    print(a_1)
elif n==2:
    if (check[0]==1):
        if a_1==0:
            print(-1)
        else:
            print(a_1*10+a_2)
    elif (check[0]==0):
        print(1*10+a_2)
else:
    if (check[0]==1):
        if a_1==0:
            print(-1)
        else:
            print(a_1*100+a_2*10+a_3)
    else:
        print(1*100+a_2*10+a_3)


Measured memory_bytes: 3064
def palindrome?(s)
  (s.length / 2).times do |i|
    return false unless s[i] == s[-1 - i]
  end
  true
end

s = gets.chomp
n = s.length
if palindrome?(s) && palindrome?(s[0, (n - 1) / 2]) && palindrome?(s[((n + 3) / 2 - 1) .. -1])
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = Console.ReadLine().Trim().Split(' ');
            int iD = int.Parse(sS[0]);
            int iX = int.Parse(sS[1]);
            List<int> lstA = new List<int>();
            for (int i = 0; i < iN; i++) { lstA.Add(int.Parse(Console.ReadLine().Trim())); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iX;
            for (int i = 0; i < lstA.Count; i++)
            {
                int j = 0;
                while (true)
                {
                    if (j * lstA[i] + 1 > iD) { break; }
                    iOut += 1;
                    j += 1;
                }
            }

            // 出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
	string s,t;
	cin>>s>>t;
	ll ans=t.length();
	ll a=s.length(),b=t.length();
	for(ll i=0;i<=a-b;i++){
		string p=s.substr(i,b);
		ll u=0;
		for(ll j=0;j<b;j++){
			if(t[j]!=p[j]) u++;
		}
		ans=min(ans,u);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;
double condition = 0.0;
void func()
{
	int L;
	cin >> L;
	cout << fixed << setprecision(15) << (double)(L*L*L)/27 << endl;
}

int main() {
//	while(1)
	func();
	return 0;
}


Measured memory_bytes: 3176