akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            String S = sc.next();
            int[] s = new int[N];
            for (int i = 0; i < N; i++) {
                s[i] = S.charAt(i) == 'L' ? 0 : 1;
            }

            int score = score(s);
//            Utils.debug(score(s));
//            for (int l = 0; l < s.length; l++) {
//                for (int r = l + 1; r < s.length; r++) {
//                    reverse(s, l, r);
//                    Utils.debug(l, r, score(s));
//                    reverse(s, l, r);
//                }
//            }

            System.out.println(Math.min(N - 1, score + 2 * K));
        }
    }

    private static void reverse(int[] s, int l, int r) {
        for (int l2 = l, r2 = r; l2 < r2; l2++, r2--) {
            int swap = s[l2];
            s[l2] = s[r2];
            s[r2] = swap;
        }
        for (int i = l; i <= r; i++) {
            s[i] = 1 - s[i];
        }
    }

    private static int score(int[] s) {
        int score = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 0 && (i - 1 >= 0 && s[i - 1] == 0)) {
                score++;
            }
            if (s[i] == 1 && (i + 1 < s.length && s[i + 1] == 1)) {
                score++;
            }
        }
        return score;
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
    b[a[i]-1]=i+1;
  }
  for(int i=0;i<N;i++){
      cout << b[i] <<endl;
  }
}

Measured memory_bytes: 1664
n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

dict_d = {}
dict_t = {}
for number in set(list_d):
    dict_d[number] = 0
for number in set(list_t):
    dict_d[number] = 0
for number in list_d:
    dict_d[number] += 1

for number in set(list_t):
    dict_t[number] = 0
for number in list_t:
    dict_t[number] += 1

for number,value in dict_t.items():
    if dict_d[number] < value:
        print("NO")
        break
    else:
        pass
else:
    print("YES")


Measured memory_bytes: 65624
#include<iostream>
#include <string.h>
using namespace std;

int main(){
    int n;
    int ans =0;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++)cin>>d[i];
    for(int i=0;i<n;i++)
    {
      for(int j=i+1;j<n;j++)
      {
        ans+=d[i]*d[j];
      }
    }
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int less(const void *x, const void *y)
{
	return *(char*)x - *(char*)y;
}
int greater(const void *x, const void *y)
{
	return *(char*)y - *(char*)x;
}
int main()
{
	int n, max, min;
	char str[10];
	scanf("%d\n", &n);
	while (n--) {
		fgets(str, 10, stdin);
		qsort(str, 8, 1, less);
		min = atoi(str);
		qsort(str, 8, 1, greater);
		max = atoi(str);
		printf("%d\n", max-min);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		long sum[] = new long[N];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		long count =0;
		if (A[0]==0) {
			count ++;
		}
		sum [0]=A[0];
		Map<Long,Long> map = new HashMap<Long,Long>();
		map.put(sum[0], 1l);
		for (int i=1;i<N;i++) {
			sum[i] =sum[i-1]+A[i];
			if (map.containsKey(sum[i])==true) {
				count +=map.get(sum[i]);
				long co=map.get(sum[i])+1;
				map.put(sum[i], co);
			} else {
				map.put(sum[i], 1l);
			}
			if (sum[i]==0) {
				count ++;
			}
		}
		System.out.println(count);
	}
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    while(true){
        bool res = true;
        int pos_x = 10, pos_y = 10;
        int N; cin >> N;
        if(N == 0) break;
        vector<pair<int, int>> jewel(N+1);
        rep(i, N){
            int x, y; cin >> x >> y;
            jewel[i] = make_pair(x, y);
        }
        jewel[N] = make_pair(-1, -1);
        int M; cin >> M;
        vector<int> get(N, 0);
        rep(i, M){
            char dir; int num; cin >> dir >> num;
            switch(dir){
                case 'N':
                    rep(j, num){
                        pos_y++;
                        rep(k, N) if(jewel[k].first == pos_x && jewel[k].second == pos_y) get[k] = 1;
                    }
                break;
                case 'E':
                    rep(j, num){
                        pos_x++;
                        rep(k, N) if(jewel[k].first == pos_x && jewel[k].second == pos_y) get[k] = 1;
                    }
                break;
                case 'S':
                    rep(j, num){
                        pos_y--;
                        rep(k, N) if(jewel[k].first == pos_x && jewel[k].second == pos_y) get[k] = 1;
                    }
                break;
                case 'W':
                    rep(j, num){
                        pos_x--;
                        rep(k, N) if(jewel[k].first == pos_x && jewel[k].second == pos_y) get[k] = 1;
                    }
                break;
                default:
                    cout << "in" << endl;
                break;
            }
        }
        rep(i, N) if(get[i] == 0) res = false;
        if(res) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=int(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=int(a);i>=(int)(b);i--)
const int mod = 1e9+7;
const int maxn = 3e5+10;
const int inf = 0x3f3f3f3f;
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int x;
    cin>>x;
    cout<<(x^1)<<'\n';
    return 0;
}


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

#define RANGE 1001

void customSort(int arr[], int n)
{
	int freq[RANGE];

	memset(freq, 0, sizeof(freq));

	for (int i = 0; i < n; i++)
		freq[arr[i]]++;

	int k = 0;
	for (int i = 0; i < RANGE; i++)
	{
		while (freq[i]--)
			arr[k++] = i;
	}
}

int main()
{
  	int N, K;
  	scanf("%d %d", &N, &K);
	int arr[N];
  	for(int i = 0; i < N; ++i)
      scanf("%d", &arr[i]);
	int n = sizeof(arr) / sizeof(arr[0]);

	customSort(arr, n);
	long long int sum = 0;
	for (int i = 0; i < K; i++)
    {
      sum += arr[i];
    }
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1724
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 reader = new BufferedReader(isr);
		
		String str[];
		int n, m, a, x, y, z;
		while(true){
			str = reader.readLine().split(" ");
			n = Integer.valueOf(str[0]);
			m = Integer.valueOf(str[1]);
			a = Integer.valueOf(str[2]);
			if((n|m|a) == 0) break;
			
			int node[][] = new int[n+1][1001];
			for(int i = 0; i < m; i++){
				str = reader.readLine().split(" ");
				x = Integer.valueOf(str[0]);
				y = Integer.valueOf(str[1]);
				z = Integer.valueOf(str[2]);
				
				node[y][x] = z;
				node[z][x] = y;
			}
			for(int h = 1000; h >= 0; h--){
				if(node[a][h] != 0) a = node[a][h];
			}
			System.out.println(a);
		}
		reader.close();
	}
}

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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    rep (i, dx) { cout << "R"; }
    rep (i, dy) { cout << "U"; }
    rep (i, dx) { cout << "L"; }
    rep (i, dy) { cout << "D"; }
    cout << "D";
    rep (i, dx+1) { cout << "R"; }
    rep (i, dy+1) { cout << "U"; }
    cout << "L";
    cout << "U";
    rep (i, dx+1) { cout << "L"; }
    rep (i, dy+1) { cout << "D"; }
    cout << "R" << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE];
int sgn[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&A[i]);
	int mn=0,pl=0;
	for(int i=0;i<n;i++)
	{
		if(A[i]>=0) pl++;
		if(A[i]<=0) mn++;
	}
	if(pl==0)
	{
		ll mx=A[0];
		for(int i=0;i<n;i++) mx=max(mx,A[i]);
		for(int i=0;i<n;i++)
		{
			if(mx==A[i])
			{
				sgn[i]=1;
				mx=0;
			}
			else sgn[i]=-1;
		}
	}
	else if(mn==0)
	{
		ll mn=A[0];
		for(int i=0;i<n;i++) mn=min(mn,A[i]);
		for(int i=0;i<n;i++)
		{
			if(mn==A[i])
			{
				sgn[i]=-1;
				mn=0;
			}
			else sgn[i]=1;
		}
	}
	else
	{
		pl=mn=0;
		for(int i=0;i<n;i++)
		{
			if(A[i]>0)
			{
				sgn[i]=1;
				pl++;
			}
			else if(A[i]<0)
			{
				sgn[i]=-1;
				mn++;
			}
		}
		for(int i=0;i<n;i++)
		{
			if(A[i]==0)
			{
				if(pl==0)
				{
					sgn[i]=1;
					pl++;
				}
				else sgn[i]=-1;
			}
		}
	}
	ll ret=0;
	queue <int> vp,vm;
	for(int i=0;i<n;i++)
	{
		if(sgn[i]==1)
		{
			ret+=A[i];
			vp.push(i);
		}
		else
		{
			ret-=A[i];
			vm.push(i);
		}
	}
	printf("%lld\n",ret);
	while(vp.size()>=2)
	{
		int v=vp.front();vp.pop();
		int u=vm.front();vm.pop();
		printf("%lld %lld\n",A[u],A[v]);
		A[u]-=A[v];
		vm.push(u);
	}
	while(vm.size()>=1)
	{
		int v=vp.front();vp.pop();
		int u=vm.front();vm.pop();
		printf("%lld %lld\n",A[v],A[u]);
		A[v]-=A[u];
		vp.push(v);
	}
	return 0;
}


Measured memory_bytes: 3456
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char b = sc.next().toCharArray()[0];

		if (b == 'A') {
			pr.println('T');
		} else if (b == 'T') {
			pr.println('A');
		} else if (b == 'C') {
			pr.println('G');
		} else if (b == 'G') {
			pr.println('C');
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

int main()
{
    int a, b, c, mul ;
    cin >> a >> b >> c ;
    mul = (a*100) + (b*10) + c ;
    if(mul % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n,int l,int m,int r){
  int i,j,k;
  int n1=m-l;
  int n2=r-m;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for(k=l;k<r;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
  }
}

void mergesort(struct Card A[],int n,int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergesort(A,n,l,m);
    mergesort(A,n,m,r);
    merge(A,n,l,m,r);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quicksort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quicksort(A,n,p,q-1);
    quicksort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergesort(A,n,0,n);
  quicksort(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit !=B[i].suit)stable=0;
  }
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



Measured memory_bytes: 4080
import qualified Data.ByteString.Char8 as C
import Data.List

r' = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main = getLine >> r' >>= print.solve

solve :: [Int] -> Int
solve xs = minimum $ do
    t <- [-100..100]
    return $ sum $ map ((^2).(t-)) xs

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

int main() {
  int a, b;
  cin >> a >> b;
  int sum = 0;
  int sa = b - a;
  int ans = ((b-a)*(b-a+1))/2 - b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
r,g,b,n = map(int,input().split())
f = [r,g,b]
f.sort()
r,g,b = f[2],f[1],f[0]

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 1
     
print(ans)

Measured memory_bytes: 41068
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
 
$n = (int)$input[0];
$m = (int)$input[1];
$p = (int)$input[2];

$routes = [];
$edges = [];
$r_edges = [];
for ($i=0; $i < $n; $i++) { 
	$edges[$i+1] = [];
	$r_edges[$i+1] = [];
}
for ($i=0; $i < $m; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$routes[] = [
		(int)$input[0],
		(int)$input[1],
		((int)$input[2] - $p) * (-1),
	];
	$edges[(int)$input[0]][] = (int)$input[1];
	$r_edges[(int)$input[1]][] = (int)$input[0];
}
// 到達可能なnodeを絞る
$reachable1 = reachable($edges, 1);
$reachable2 = reachable($r_edges, $n);
$reachable_node = [];
foreach ($reachable1 as $node) {
	if (in_array($node, $reachable2)) {
		$reachable_node[] = $node;
	}
}
sort($reachable_node);

$reachable_route = [];
foreach ($routes as $r) {
	if (in_array($r[0], $reachable_node) && in_array($r[1], $reachable_node)) {
		$reachable_route[] = $r;
	}
}
// var_dump($reachable1);

$dists = [];
$inf = 1000000000;
for ($i=0; $i < $n; $i++) { 
	$dists[$i+1] = $inf;
}
$dists[1] = 0;

 
// ベルマンフォード法
for ($i=0; $i < $n-1; $i++) { 
	$updated = false;
	foreach ($reachable_route as $tmp_e) {
		// var_dump($tmp_e);
		if ($dists[$tmp_e[0]] !== $inf && $dists[$tmp_e[1]] > $dists[$tmp_e[0]] + $tmp_e[2]) {
			$dists[$tmp_e[1]] = $dists[$tmp_e[0]] + $tmp_e[2];
			$updated = true;
			// predecessorは今回不要
		}
	}
	if (!$updated) {
		break;
	}
}
foreach ($reachable_route as $tmp_e) {
	if ($dists[$tmp_e[0]] !== $inf && $dists[$tmp_e[1]] > $dists[$tmp_e[0]] + $tmp_e[2]) {
		// $dists[$tmp_e[1]] = $dists[$tmp_e[0]] + $tmp_e[2];
		echo '-1';
		exit();
	}
}
// var_dump($dists);
echo max(0, $dists[$n] * (-1));


function reachable($edges, $start){
	$q = new SimpleQueue();
	$q->enq($start);
	$reachable = [];
	$reachable[$start] = true;
	while (!$q->isEmpty()) {
		$cur = $q->deq();
		foreach ($edges[$cur] as $next) {
			if (!isset($reachable[$next])) {
				$reachable[$next] = true;
				$q->enq($next);
			}
		}
	}
	$reachable = array_keys($reachable);
	sort($reachable);
	return $reachable;
}
/**
 * 
 */
class SimpleQueue
{
	private $data = [];
	private $idx = 0;

	function enq($d){
		$this->data[] = $d;
	}

	function deq(){
		$d = $this->data[$this->idx];
		$this->idx += 1;
		return $d;
	}

	function isEmpty(){
		return count($this->data) === $this->idx;
	}
}

Measured memory_bytes: 8824
// C - Energy Drink Collector
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);i++)

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

	vector<pair<int,int>> AB;
	rp(i,N){
		int a,b; cin>>a>>b;
		AB.emplace_back(a,b);
	}

	sort(AB.begin(), AB.end());

	ll yen = 0;
	rp(i,N){
		int a,b; tie(a,b) = AB[i];
		int c = min(M,b);
		yen += (ll)c*a;
		M -= c;
		if(M<=0)break;
	}
	cout<< yen <<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	if(A <= 8 && B <= 8){
		cout << "Yay!\n";
	}
	else{
		cout << ":(\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}
vi a,b;
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int n;cin>>n;
    a.resize(100005,0);
    b.resize(100005,0);
    rep(i,n){
        int x;cin>>x;
        if(i%2==0) a[x]++;
        else b[x]++;
    }

    int mx1=*max_element(all(a)), mx2=*max_element(all(b));

    vi in1, in2;
    rep(i,sz(a)) if(a[i] == mx1) in1.pb(i);
    rep(i,sz(b)) if(b[i] == mx2) in2.pb(i);

    if(sz(in1)==sz(in2) && sz(in1)==1 && in1[0]==in2[0]){
        int mx3=0, mx4=0;
        rep(i,sz(a)) if(i != in1[0]) mx3=max(mx3,a[i]); 
        rep(i,sz(b)) if(i != in2[0]) mx4=max(mx4,b[i]); 
        cout << min(n-mx1-mx4, n-mx3-mx2) << endl;
    }
    else cout<<n-mx1-mx2;

	return 0;
}
 



Measured memory_bytes: 1660
h, w = map(int, input().split(' '))
a1 = 0
if ((h == 1) or (w == 1)):
    a1 = 1
elif(((h * w) % 2) == 1):
    a1 = ((h * w) // 2) + 1
elif(((h * w) % 2) == 0):
    a1 = (h * w) // 2
print(a1)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> mp(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
	  for (int j = 0; j < W; j++) {
		cin >> mp.at(i).at(j);
      }
  }
  
  vector<vector<char>> rt(H);
  for (int i = 0; i < W; i++) {
    bool f = false;
    for (int j = 0; j < H; j++) {
      if (mp.at(j).at(i) != '.') {
        f = true;
        break;
      }
    }
    if (f) {
      for (int j = 0; j < H; j++) {
        rt.at(j).push_back(mp.at(j).at(i));
      }
    }
  }
  for (int i = 0; i < H; i++) {
    bool f = false;
    for (char c:rt.at(i)) {
      if (c != '.') {
        f = true;
        break;
      }
    }
    if (f) {
	  for (char c:rt.at(i)) {
        cout << c;
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, K;
    cin >> N >> K;
    if (K % 2 == 1) {
        ll ans = (N / K) * (N / K) * (N / K);
        cout << ans << endl;
    } else {
        ll ans = (N / K) * (N / K) * (N / K);
        N += K / 2;
        ans += (N / K) * (N / K) * (N / K);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
s = str(input())
K = int(input())

n = len(s)

dp = [[[0]*2 for i in range(4)] for j in range(105)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])
            for d in range(10):
                ni = i+1
                nj = j
                nk = k
                if d != 0:
                    nj += 1
                if k == 0:
                    if d > nd:
                        continue
                    elif d < nd:
                        nk = 1
                    else:
                        pass
                if 0 <= nj <= 3:
                    dp[ni][nj][nk] += dp[i][j][k]

print(dp[n][K][0] + dp[n][K][1])

Measured memory_bytes: 42416
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		while(true){
			int a=s.nextInt();
			int b=s.nextInt();
			int c=s.nextInt();
			if(a+b+c==0)System.exit(0);
			double dp[][]=new double[a+1][b*a+1];
			dp[0][0]=1.0;
			for(int i=0;i<a;i++){
				for(int j=i;j<=i*b;j++){
					for(int k=1;k<=b;k++)
						dp[i+1][j+k]+=dp[i][j]/b;
				}
			}
			double ret=0;
			for(int i=0;i<b*a+1;i++){
				ret+=(double)Math.max(1,i-c)*dp[a][i];
			//	System.out.println(dp[a][i]);
			}
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 22532
#include <iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int a[3];
    int i;
    for(i=0;i<3;i++)
        scanf("%d",&a[i]);
    int ans=min(a[0]+a[1],a[1]+a[2]);
    ans=min(ans,a[2]+a[0]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long d = sc.nextLong();


    int count = 0;//

    long x = 0;
    long y = 0;

    for(int i=0; i<n; i++){
      x = sc.nextLong();
      y = sc.nextLong();
      if(x*x+y*y<=d*d){count++;}
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 60376
def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

s = input()
ans  = 0
tmp = 0
for i in s:
    if i == 'R':
        tmp += 1
        ans  = max(ans, tmp)
    else:
        tmp = 0
    
print(ans)

Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

int main(){	

char ch;

while(1){
  
    scanf("%c", &ch);
    
    if(islower(ch)){
      printf("%c",toupper(ch));
      }
    else if(isupper(ch)){
      printf("%c",tolower(ch));
      }
    else{
      printf("%c",ch);
      }
    
    if ( ch == '\n' ) break;
}
	 
}

Measured memory_bytes: 3120
#include<iostream>
#include<vector>

using namespace std;

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

	if (a <= 5)
	{
		cout << 0 << endl;
	}
	else if (a <= 12)
	{
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from math import atan, pi

a, b, x = map(int, input().split())

if x >= a * a * b / 2:
    print(atan((a*a*b-x)/(a*a*a/2))/(2 * pi)*360)
else:
    print(90 - atan(x/(a*b*b/2))/(2 * pi)*360)


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

struct card { char suit, value; };

void BabbleSort(struct card a[], int n) { //バブルソート、安定
    for (int i = 0; i<n; i++) {
        for (int j=n-1; j>i; j--) {
            if (a[j].value < a[j-1].value) {
                card temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
            }
        }
    }
}

void SelectionSort(struct card a[], int n) { //選択ソート、不安定
    for (int i=0; i<n; i++) {
        int minj = i;
        for (int j=i; j<n; j++) {
            if (a[j].value < a[minj].value) {
                minj = j;
            }
        }
        card temp = a[i];
        a[i] = a[minj];
        a[minj] = temp;
    }
}

void print(struct card a[], int n) { //cardの全出力
    for (int i=0; i<n; i++) {
        if (i>0) cout << " ";
        cout << a[i].suit << a[i].value;
    }
    cout << endl;
}

void isStable(struct card c1[], struct card c2[], int n) {
    bool flag = true;
    for (int i=0; i<n; i++) {
        if (c1[i].suit != c2[i].suit) flag = false;
    }
    if (flag) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}

int main(){
    int n;
    card c1[100],c2[100];
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> c1[i].suit >> c1[i].value;
    }
    for (int i=0; i<n; i++) c2[i] = c1[i];
    BabbleSort(c1, n);
    print(c1, n);
    isStable(c1, c1, n);
    SelectionSort(c2, n);
    print(c2, n);
    isStable(c1, c2, n);
    return 0;
}


Measured memory_bytes: 3112
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A
 */
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>

using namespace std;

template <typename T_char>
T_char
ToLower(T_char c)
{
  return tolower(c);
}

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

  string W;
  getline(cin, W);

  int count = 0;
  while (true) {
    string line;
    getline(cin, line);

    if (line == "END_OF_TEXT") {
      break;
    }
    transform(line.begin(), line.end(), line.begin(), ToLower<char>);
    stringstream ss(line);
    while (!ss.eof()) {
      string s;
      ss >> s;
      if (s == W) { count++; }
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3200
import collections

n = int(input())
a = list()

for i in range(n):
    a.append(int(input()))

dic = collections.Counter(a)
    
dic_list = list(dic.values())
ans = 0
for i in range(len(dic_list)):
    if dic_list[i] % 2 == 1:
        ans += 1

print(ans)


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) { 
	cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

void solve() {
	string s;
    sc(s);
    if(sz(s) >= 4 && s.substr(0, 4) == "YAKI") {
        cout << "Yes";
    } 
    else {
        cout << "No";
    }
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1){
            res*=a;
        }
        a*=a;
        x>>=1;
    }
    return res;
}

int main(){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    vector<ll> s(n+1,0);
    for(int i=0;i<n;i++) s[i+1]=a[i]+s[i];
    int ans=1;
    for(int i=n-1;i>0;i--){
        if(s[i]*2<a[i]) break;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4556
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val red = (0 until n).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        a to b
    }
    val blue = (0 until n).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        a to b
    }.sortedBy { it.first }

    val selected = BooleanArray(n) { false }

    blue.filter { b ->
        red.mapIndexed { index, pair -> index to pair }
                .filter { it ->
                    val i = it.first
                    val r = it.second
                    if (selected[i]) {
                        false
                    } else {
                        r.first < b.first && r.second < b.second
                    }
                }
                .maxBy { it.second.second }
                ?.let {
                    selected[it.first] = true
                    true
                } ?: false
    }.count().let { println(it) }

}


Measured memory_bytes: 38232
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
void moebius(vl&f){int n=sz(f);FOR(i,0,__builtin_ctz(n))FOR(j,0,n)if(j&(1<<i))f[j]-=f[j^(1<<i)];}

struct Prime{
  vector<ll> pl;
  void init(int a){ // a以下の素数列挙
    pl.resize(0);
    vector<bool> z(a+1, true);
    FOR(i, 2, a+1){
      if(z[i])pl.push_back(i);
      for(int b=i*2; b <= a; b+=i) z[b]=false;
    }
  }
  void prime_division(ll a, vector<pair<ll, int> >&v){ // vに素因数分解の結果が入る
    v.resize(0);
    for(ll b: pl){
      if(b*b > a) break;
      if(a%b) continue;
      int c = 0;
      while(a%b==0) a/=b, c++;
      v.push_back(make_pair(b, c));
    }
    if(a>1) v.push_back(make_pair(a, 1));
  }
} prime;
ll n, m, k;
vector<pair<ll, int> > v;
vl c;

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

  prime.init(33000);
  cin >> n;
  prime.prime_division(n, v);
  m = sz(v);
  k = 1<<m;
  c.resize(k);
  c[0] = 0;
  FOR(bit, 1, k){
    ll d = 1;
    FOR(i, 0, m)if(bit&1<<i) d *= v[i].fi;
    c[bit] = n/d;
  }
  moebius(c);
  cout << n - abs(c[k-1]) << endl;
  return 0;
}


Measured memory_bytes: 3296
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 500000, A = 26;

int ft[A][N];

void update(int a, int i, int n, int x) {
	while (i < n) {
		ft[a][i] += x;
		i |= i + 1;
	}
}

int query(int a, int i) {
	int x = 0;
	while (i >= 0) {
		x += ft[a][i];
		i &= i + 1, i--;
	}
	return x;
}

int main() {
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < n; i++)
		update(s[i] -= 'a', i, n, 1);
	int q; cin >> q;
	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			int i; cin >> i, i--;
			int a = s[i];
			string tmp; cin >> tmp;
			int b = tmp[0] - 'a';
			if (a != b) {
				s[i] = b;
				update(a, i, n, -1);
				update(b, i, n, 1);
			}
		} else {
			int l, r; cin >> l >> r, l--, r--;
			int cnt = 0;
			for (int a = 0; a < A; a++)
				if (query(a, r) - query(a, l - 1) > 0)
					cnt++;
			cout << cnt << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 54684
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int dijkstra(const vector<vector<int>>& to, const vector<vector<int>>& w, int s, int t, int n) {
  vector<int> weight(n, 1000000000);
  weight[s] = 0;
  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
  q.push(make_pair(0,s));
  while(!q.empty()){
    auto p = q.top(); q.pop();
    if(p.first > weight[p.second]) continue;
    for(int i = 0;i < to[p.second].size(); ++i) {
      if (weight[to[p.second][i]] > p.first + w[p.second][i]) {
        weight[to[p.second][i]] = p.first + w[p.second][i];
        q.push(make_pair(weight[to[p.second][i]], to[p.second][i]));
      }
    }
  }
  return weight[t];
}


int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n) break;
    vector<vector<int>> to(m);
    vector<vector<int>> cost(m);
    vector<vector<int>> time(m);
    for (int i = 0; i < n; ++i) {
      int a, b, c, t;
      cin >> a >> b >> c >> t;
      --a;--b;
      to[a].push_back(b);
      to[b].push_back(a);
      cost[a].push_back(c);
      cost[b].push_back(c);
      time[a].push_back(t);
      time[b].push_back(t);
    }
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int p,q,r;
      cin >> p >> q >> r;
      --p;--q;
      if (r == 0) {
        cout << dijkstra(to,cost,p,q, m) << endl;
      } else {
        cout << dijkstra(to,time,p,q, m) << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int in()
{
  int x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  string s , s1 ;
  cin >> s >> s1 ;
  if(s1.substr(0 , s.size()) == s) puts("Yes") ;
  else puts("No") ;
  return 0 ;
}
/*
*/


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

using namespace std;

int a, b, c;

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

  if (60 % (a + b) == 0) {
    int k = 60 / (a + b);
    bool ok = false;
    for (int i = 0; i < k; i++) {
      if (i * (a + b) <= c && c <= i * (a + b) + a) ok = true;
    }
    if (ok)
      cout << c << endl;
    else
      cout << -1 << endl;
  } else {
    int loop = 0;
    bool p = true;
    int sum = 0;
    int ans = 0;
    if (c <= a) {
      cout << c << endl;
      return 0;
    }
    while (0 <= loop) {
      if (p) {
        sum += a;
        ans += a;
      } else {
        sum += b;
        ans += b;
      }
      sum %= 60;

      if (p && sum == a && loop != 0) {
        cout << -1 << endl;
        return 0;
      }
      if (!p) {
        if (sum <= c && c <= sum + a) {
          ans += c - sum;
          cout << ans << endl;
          return 0;
        }
      }

      p = !p;
      loop++;
    }
  }

  return 0;
}


Measured memory_bytes: 3112
char m[7][7]={
  "      ",
  " abcde",
  " fghij",
  " klmno",
  " pqrst",
  " uvwxy",
  " z.?! "
};

main(f,i,j){
  char s[201],z[101];
  for(;~scanf("%s",s);){
    if(strlen(s)&1){puts("NA");goto l;}
    for(i=0;i<strlen(s)/2;i++){
      if(!('1'<=s[2*i]&&s[2*i]<='6'&&'1'<=s[2*i+1]&&s[2*i+1]<='5')){puts("NA");goto l;}
      z[i]=m[s[2*i]-'0'][s[2*i+1]-'0'];
    }
    z[i]=0;
    puts(z);
    l:;
  }
  return 0;
}

Measured memory_bytes: 524
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int    N = reader.nextInt();
        long[] H = new long[N];
        for (int i=0; i<N; i++) {
            H[i] = reader.nextLong();
        }
        long[] C = new long[N];
        C[0] = 0;
        C[1] = Math.abs(H[0]-H[1]);

        for (int i=2; i<N; i++) {
            C[i] = Math.min(C[i-2]+Math.abs(H[i-2]-H[i]), C[i-1]+Math.abs(H[i-1]-H[i]));
        }
        System.out.println(C[N-1]);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 24240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
ll max(ll a,ll b)
{
  if (a>b) {

    return a;
  }
  return b;
}

ll min(ll a,ll b)
{
  if (a<b) {

    return a;
  }
  return b;
}

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

ll lcm(ll a,ll b)
{
  return a/gcd(a,b)*b;
}
int main()
{
 ll k;
 cin>>k;
 ll sum=0;
 for(ll i=1;i<=k;i++)
 {
   for(ll j=1;j<=k;j++)
   {
       for(int p=1;p<=k;p++)
       {
           sum+=gcd(i,gcd(j,p));
       }
   }
 }
 cout<<sum<<endl;
  return 0;
}



Measured memory_bytes: 3640
n=int(input())
a=list(map(int,input().split()))
suma=sum(a)
b=[0]*(n-1)
total=0
for i in range(n-1):
  total+=a[i]
  b[i]+=total
mini=abs((suma-b[0])-b[0])
for i in range(n-1):
  if mini>abs((suma-b[i])-b[i]):
    mini=abs((suma-b[i])-b[i])
print(mini)

Measured memory_bytes: 23800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int INF=1001001001;
const int MAX_N = 200005;
 
vector<int> a, ans, dp;
vector<vector<int>> to;
void dfs(int s, int p=-1){
 int i = lower_bound( dp.begin(), dp.end(), a[s]) - dp.begin();
  int old = dp[i];
  dp[i] = a[s];
  ans[s] = i;
  if(p != -1) ans[s] = max(ans[s], ans[p]); //exclude first turn
  
  	for(int t : to[s]){
       if(t == p) continue;  //parent
       dfs(t, s);
  	}
  //roll back
  	dp[i] = old;
}
 
int main(){
	int n;
  cin >> n;
  a = ans = vector<int>(n);
  rep(i, n){
    cin >> a[i];    
  }
  to = vector<vector<int>>(n);
  rep(i, n-1){
    int u, v;
    cin >> u >> v;
    u--, v--;
    to[u].push_back(v);
    to[v].push_back(u);
  }
 
  dp = vector<int>(n);
  rep(i ,n) dp[i] = INF;
  dp[0] = -INF;
  
  dfs(0);  
  rep(i, n){
    cout << ans[i] << endl;
  }      
    return 0;
  }

Measured memory_bytes: 28024
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


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

const int SIZE = 300000;

bool table[SIZE];

int main() {
    for (int i = 0; i < SIZE; i++) {
        table[i] = true;
    }
    table[0] = table[1] = false;

    for (int n = 2; n * n < SIZE; n++) {
        if (!table[n]) continue;
        for (int i = 2; i * n < SIZE; i++) {
            table[n * i] = false;
        }
    }
    int n;
    while (cin >> n, n) {
        int ans = 0;
        for (int i = n + 1; i <= 2 * n; i++) {
            if (table[i]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3344
#include<bits/stdc++.h>
#define int long long
#define N 2000005
using namespace std;
int n,a[N],dp[N][6];
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++){
		dp[i][1]=dp[i-1][1]+a[i];
		if (a[i]%2){
			dp[i][2]=min(dp[i][1],dp[i-1][2]+1);
			dp[i][3]=min(dp[i][2],dp[i-1][3]);
			dp[i][4]=min(dp[i][3],dp[i-1][4]+1);
		}
		else {
			if (!a[i]){
				dp[i][2]=min(dp[i][1],dp[i-1][2]+2);
				dp[i][3]=min(dp[i][2],dp[i-1][3]+1);
				dp[i][4]=min(dp[i][3],dp[i-1][4]+2);
			}
			else {
				dp[i][2]=min(dp[i][1],dp[i-1][2]);
				dp[i][3]=min(dp[i][2],dp[i-1][3]+1);
				dp[i][4]=min(dp[i][3],dp[i-1][4]);
			}
		} 
		dp[i][5]=min(dp[i][4],dp[i-1][5]+a[i]);
	}
	printf("%lld\n",dp[n][5]);
	return 0;
}

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

int main() {
  
 	string S,P;
    cin >> S;
  
  	P = S;
    reverse(P.begin(),P.end());
  
  	int i = 0;
    int count = 0;
    while ( i < S.size() / 2 ){
      if ( S.at(i) != P.at(i) ){
        count ++;
      }
      i ++;
    }
  
  	cout << count << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  string s;
  cin >> s;
  int ans=0;
  for (int i=1;i < s.size();i++){
    if (s[i-1] != s[i]) ans++;
    else continue;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
"""
imos
"""
N, M = map(int,input().split())
from itertools import accumulate
imos = [0]*(N+2)
for i in range(M):
    L,R = map(int,input().split())
    imos[L] += 1
    imos[R+1] -= 1
acc = list(accumulate(imos))
print(sum([1 for a in acc if a == M]))

Measured memory_bytes: 8636
n,q=map(int,input().split())
s=list(input())

c=[0]
for i in range(n-1):
  if s[i]+s[i+1]=='AC':
    c.append(1)
  else:
    c.append(0)
  
cs=[c[0]]
for i in range(1,n):
  cs.append(cs[i-1]+c[i])
#print(cs)
for _ in range(q):
  l,r=map(int,input().split())
  print(cs[r-1]-cs[l-1])

Measured memory_bytes: 9224