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

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var cur = 1;
        var breakCount = 0;
        foreach (var a in A)
        {
            if (cur == a)
            {
                cur++;
            }
            else
            {
                breakCount++;
            }
        }

        if (n == breakCount)
        {
            breakCount = -1;
        }

        Console.WriteLine(breakCount);
    }
}

Measured memory_bytes: 35676
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n; double a, b, c, d, e, f;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> d >> e >> f; double C = sqrt((a - c)*(a - c) + (b - d)*(b - d));
		double B = sqrt((a - e)*(a - e) + (b - f)*(b - f)), A = sqrt((c - e)*(c - e) + (d - f)*(d - f));
		double A1 = 2 * (c - a), B1 = 2 * (d - b), A2 = 2 * (e - a), B2 = 2 * (f - b), C1 = a*a - c*c + b*b - d*d, C2 = a*a - e*e + b*b - f*f;
		double X = (B1*C2 - B2*C1) / (A1*B2 - A2*B1), Y = (C1*A2 - C2*A1) / (A1*B2 - A2*B1);
		double R = (A*B*C) / sqrt((A + B + C)*(-A + B + C)*(A - B + C)*(A + B - C));
		printf("%.3lf %.3lf %.3lf\n", X, Y, R);
	}
	return 0;
}

Measured memory_bytes: 1244
def knapsackBottomUp(wt,price,c,n):
    dp=[[0 for x in range(c+1)] for y in range(n+1)]
    for i in range(n+1):
        for w in range(c+1):
            if i==0 or w==0:
                dp[i][w]=0
            else:
                inc=exc=0
                if wt[i-1]<=w:
                    inc=price[i-1]+dp[i-1][w-wt[i-1]]
                exc=dp[i-1][w]
                dp[i][w]=max(inc,exc)
    
    return dp[n][c]
  
n,c=map(int,input().split())
wt=[]
price=[]
for _ in range(n):
    w,v=map(int,input().split())
    wt.append(w)
    price.append(v)
print(knapsackBottomUp(wt,price,c,n))

Measured memory_bytes: 171400
import java.util.Scanner
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  case class Place(number: Int, altitude: Int)

  def solve(sc: Scanner): String = {
    val n = sc.nextInt()
    val (t, a) = (sc.nextInt(), sc.nextInt())
    val places = Vector.fill(n)(sc.nextInt()).zipWithIndex.map { case (h, i) => Place(i + 1, h) }
    debug(n, t, a, places)

    places.map { place =>
      val temperature = t - place.altitude * 0.006
      (place, abs(a - temperature))
    }.minBy(_._2)._1.number.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 27724
from collections import deque

def is_solved(puzzle):
  check1 = puzzle[0]
  for i in range(1, 9):
    if puzzle[i] != check1:
      return False

  check2 = puzzle[9]
  if puzzle[10] != check2 or puzzle[11] != check2:
    return False

  check3 = puzzle[12]
  if puzzle[13] != check3 or puzzle[14] != check3:
    return False

  return True


def myhash(p):
  ret = 0
  for i in range(len(p)):
    ret += 200 ** i * p[i]
  return ret

def spin1(p):
  r = [i for i in p]
  r[0], r[3], r[6], r[23], r[26], r[29] = p[23], p[26], p[29], p[0], p[3], p[6]
  r[9], r[20] = p[20], p[9]
  r[15], r[17] = p[17], p[15]
  return r

def spin2(p):
  r = [i for i in p]
  r[2], r[5], r[8], r[21], r[24], r[27] = p[21], p[24], p[27], p[2], p[5], p[8]
  r[11], r[18] = p[18], p[11]
  r[12], r[14] = p[14], p[12]
  return r

def spin3(p):
  r = [i for i in p]
  r[0], r[1], r[2], r[27], r[28], r[29] = p[27], p[28], p[29], p[0], p[1], p[2]
  r[14], r[15] = p[15], p[14]
  r[18], r[20] = p[20], p[18]
  return r

def spin4(p):
  r = [i for i in p]
  r[6], r[7], r[8], r[21], r[22], r[23] = p[21], p[22], p[23], p[6], p[7], p[8]
  r[12], r[17] = p[17], p[12]
  r[9], r[11] = p[11], p[9]
  return r

def main():
  
  spin_lst = [spin1, spin2, spin3, spin4]
  
  n = int(input())
  
  for i in range(n):
    puz = list(map(int, input().split()))
    
    dic = {}
    dic[myhash(puz)] = 0
  
    que = deque()
    que.append((puz, 0))
  
    while que:
      p, score = que.popleft()
      
      if is_solved(p):
        print(score)
        break
  
      for spin in spin_lst:
        spined = spin(p)
        h = myhash(spined)
        if not h in dic:
          dic[h] = score + 1
          que.append((spined, score + 1))

main()


Measured memory_bytes: 6032
i,table[151201];main(j,n){for(;i<54;i++)for(j=0;j<97;j++)if((n=i*i*i+j*(j+1)*(j+2)/6)<151201)table[n]=1;for(;scanf("%d",&n),n;printf("%d\n",n))while(!table[n])n--;return 0;}

Measured memory_bytes: 0
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "YES"
#define NO  "NO"
#define MOD 1000000000+7
#define forit(v) for(auto it = v.begin(); it != v.end(); ++it)

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int n, k; cin >> n >> k;

  num = n - (k - 1);
  
  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (int)(v).size()
#define ll long long
#define mod 1000000007

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n; cin >> n;
        vector<int> v(22), d(22), c(22);
        lp(i, n) cin >> v[i];
        lp(i, n) cin >> d[i];
        lp(i, n - 1) cin >> c[i];
        int an = 0;
        lp(i, n) {
                if (v[i] + 1 == v[i + 1]) an += c[v[i] - 1];
                an += d[v[i] - 1];
        }
        cout << an;
return 0;
}



Measured memory_bytes: 256
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, k = [int(x) for x in input().rstrip().split(" ")]

    h_list = [int(input().rstrip()) for _ in range(n)]
    h_list.sort()
    ans = 1000000000
    for i in range(n - k + 1):

        val = h_list[i+k-1] - h_list[i]
        if val < ans:
            ans = val
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 76568
s = input()
K = int(input())
S = set()

for i in range(len(s)):
    S.add(s[i])
    S.add(s[i:i+2])
    S.add(s[i:i+3])
    S.add(s[i:i+4])
    S.add(s[i:i+5])

S = sorted(list(S))
print(S[K-1])

Measured memory_bytes: 4592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000000;
// clang-format on

int H, A;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> H >> A;

  int ans = (int)ceil((double)H / A);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(reader.readLine());
		int[] As = new int[N];
		int[] Bs = new int[N];
		for(int i = 0;i<N;++i){
			String[] lo = reader.readLine().split(" ");
			int A = Integer.parseInt(lo[0]);
			int B = Integer.parseInt(lo[1]);
			As[i] = A;
			Bs[i] = B;
		}
		Arrays.sort(As);
		Arrays.sort(Bs);
		int max = N%2==0? Bs[N/2 -1]+Bs[N/2] : 2*Bs[N/2];
		int min = N%2==0? As[N/2 - 1] + As[N/2]:2*As[N/2];
		int res = N%2==0? 1 + (max-min):1+(max-min)/2; 
		System.out.println(res);
	}
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    for (int i=0; i<n; i++) {
        cin>>l[i];
    }
    int c=0,sum=0;
    for (int i=1; i<n-1; i++) {
        sum = l[i-1]+l[i]+l[i+1];
        if (sum-max({l[i-1],l[i],l[i+1]})-min({l[i-1],l[i],l[i+1]})==l[i]) {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int an[55566];
void search() {
    an[0] = 1,an[1] = 1;
    for(int i=2;i<=55555;i++){
        if(!an[i]){
            for(int j=2;j*i<=55555;j++){
                an[i*j] = 1;
            }
        }
    }
}
int main() {
  int n, count = 2;
  search();
  cin >> n;
  int prime[n];
  for (int i = 0; i < n;) {
    if ( !an[count] && count % 5 == 1) {
      prime[i] = count;
      i++;
    }
    count++;
  }
  for (int i = 0; i < n; i++) {
    cout << prime[i] <<" ";
  }
  cout<<endl;
  return 0;
}

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

int main(){
	int n, ans;
	cin >> n;
	vector<long long int> A(n);
	long long int sum = 0;
	for(int i = 0;i<n;i++){
		cin >> A[i];
		sum += A[i];
	}
	sort(A.begin(), A.end());
	ans = 1;
	for(int i = n-1; i>0;i--){
		sum -= A[i];
		if(A[i] > sum*2) break;
		else ans++;
	}
	cout << ans << endl;
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,m;
  cin >> n >> m;
  const int max_n = 1e5;
  // vector<int> a(n);
  priority_queue<int> a;
  for(int i = 0; i < n; i++) {
    int in;
    cin >> in;
    a.push(in);
  }

  // sort(a.begin(), a.end());
  
  for(int i = 0; i < m; i++){
    // int left = 0;
    // int right = n-1;
    // int price = a[n-1] / 2;
    // while(right - left > 1){
    //   int x = (right + left) / 2;
    //   if(a[x] > price) right = x;
    //   else left = x;
    // }
    // a.insert(a.begin() + right, price);
    // // for(int i = 0; i < n; i++) cout << a[i] << ", ";
    // // cout << endl;

    int price = a.top() / 2;
    a.pop();
    a.push(price);
  }
  long long sum = 0;
  // for(int i = 0; i < n; i++) sum += a[i];
  for(int i = 0; i < n; i++){
    sum += a.top();
    a.pop();
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(a) cerr << #a << ": " << a << endl
 
typedef long long ll;
typedef pair<int, int> ii;
 
#define x first
#define y second
 
const int N = 2005;
const int MOD = 1e9 + 7;

int n, k;
int a[N];
ll ans;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
  
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];

	for (int i = 1; i <= n; i++)
	for (int j = i + 1; j <= n; j++) {
		if (a[i] > a[j]) ans += k * 1LL * (k + 1) / 2;
		else if (a[i] < a[j]) ans += k * 1LL * (k - 1) / 2;
		ans %= MOD;
	}

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

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n;
	int r;
	int i,t,s,k;
	while(scanf("%d", &n)!=EOF){
		r = 0;
		for(i = 0;i <= 9 && i<=n;i++){
			for(t = 0;t <= 9 && i+t<=n;t++){
				for(s = 0;s <=9 && i+t+s<=n;s++){
					for(k = 0;k <=9 && i+t+s+k<=n;k++){
						if(i+t+s+k==n)r++;
					}
				}
			}
		}
		printf("%d\n", r);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	string s; cin >> s;
	int q; cin >> q;
	bool flag=0;
	string l="",r="";
	while(q--){
		int t; cin >> t;
		if(t==1){
			flag=(!flag);
		}
		else{
			int f; cin >> f; f--;
			char c; cin >> c;
			if(f^flag)
				r+=c;
			else
				l+=c;
		}
	}
	if(flag){
		reverse(ALL(r));
		reverse(ALL(s));
		cout << r << s << l << endl;
	}
	else{
		reverse(ALL(l));
		cout << l << s << r << endl;	
	}
	return 0;
}

Measured memory_bytes: 1088
<?php
fscanf(STDIN, '%d', $n);
//$flg = true;
//$c = 1;
//while($flg) {
//    if($c % $n === 0 && $c % 2 === 0) {
//        break;
//        $flg = false;
//    }
//    $c++;
//}
$ret = 0;
if($n % 2 == 0) {
    $ret = $n;
} else {
    $ret = $n * 2;
}
echo $ret. "\n";

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    
    return 0;
}



Measured memory_bytes: 3608
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

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

int main(){
	int i,q;
	scanf("%d",&n);
	for(i = 0;i < n;i ++){
		scanf("%d",&A[i]);
	}
	q = partition(0,n - 1);
	for(i = 0;i < n;i ++){
		if(i) printf(" ");
		if(i == q) printf("[");
		printf("%d",A[i]);
		if(i == q) printf("]");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2068
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int gcd(int a, int b, int c) {
    return gcd(gcd(a, b),c);
}
ll f(int k) {
    ll res = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                res += gcd(a, b, c);
            }
        }
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin >> k;
    cout << f(k) <<endl;
    return 0;
}

Measured memory_bytes: 3652
n,m=map(int,input().split())
d=[]
f=1
while f*f<m+1:
  if m%f==0:
    d.append(f)
    d.append(m//f)
  f+=1
d.sort(reverse=True)
for i in d:
  if  (m-i*n)>=0 and (m-i*n)%i==0 :break
print(i)
  

Measured memory_bytes: 9060
n = input()
len_n = len(n)

dp = [[0]*2 for _ in range(len_n + 1)]
dp[0][1] = 1

for i in range(1, len_n+1):
    tmp = int(n[i-1])

    dp[i][0] = min(dp[i-1][0] + tmp, dp[i-1][1] + (10-tmp))
    dp[i][1] = dp[i-1][1] + (9-tmp)
    if(tmp != 9):
        dp[i][1] = min(dp[i][1], dp[i-1][0] + tmp + 1)

ans = min(dp[-1][0], dp[-1][1] + 1)

print(ans)

Measured memory_bytes: 138568
#include <cstdio>
#include <cmath>

using std::floor;
using std::abs;

const double EPS=1e-8;

int main(){
	double N,w;
	scanf("%lf",&N);
	N=4/N;
	for(int i=1;i<=3500;++i){
		for(int j=1;j<=3500;++j){
			w=N-(double)1/i-(double)1/j;
			if(w<EPS) continue;
			if(abs(1/w-floor(1/w))<EPS){
				printf("%d %d %lld",i,j,(long long)(1/w+0.5));
				return 0;
			}
		}
	}
}

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

typedef long long ll;
const int inf=0x3f3f3f3f;
char ch[200005];
int a[100005];
int main()
{

    scanf("%s",ch);
    int ans1=0,ans2=0,ans3=0,ans4=0,f=0;
    int len=strlen(ch);
    if(ch[0]=='0')
    {
        f=1;
        int i=1;
        while(i<len)
        {
            if(ch[i-1]=='0')
            {
                if(ch[i]!='1')
                {ans1++;
                ch[i]='1';}
            }
            if(ch[i-1]=='1')
            {
                if(ch[i]!='0')
                {ans1++;
                    ch[i]='0';}
            }
            i++;
        }
        i=1,ch[0]='1';
        while(i<len)
        {
            if(ch[i-1]=='0')
            {
                if(ch[i]!='1')
                {ans2++;
                    ch[i]='1';}
            }
            if(ch[i-1]=='1')
            {
                if(ch[i]!='0')
                {ans2++;
                    ch[i]='0';}
            }
            i++;
        }
    }
    if(ch[0]=='1')
    {
        int i=1;
        while(i<len)
        {
            if(ch[i-1]=='0')
            {
                if(ch[i]!='1')
                {ans3++;
                    ch[i]='1';}
            }
            if(ch[i-1]=='1')
            {
                if(ch[i]!='0')
                {ans3++;
                    ch[i]='0';}
            }
            i++;
        }
        i=1,ch[0]='0';
        while(i<len)
        {
            if(ch[i-1]=='0')
            {
                if(ch[i]!='1')
                {ans4++;
                    ch[i]='1';}
            }
            if(ch[i-1]=='1')
            {
                if(ch[i]!='0')
                {ans4++;
                    ch[i]='0';}
            }
            i++;
        }
    }
    if(f==1)
        cout<<min(ans1,ans2)<<endl;
    else
        cout<<min(ans3,ans4)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	long long int n, sum;
	sum=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0){
			continue;
		}
		else {
			sum+=i;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').split()))
    lh = h[0]
    cnt = 0
    mcnt = 0
    for i in range(1, n):
        if lh >= h[i]:
            cnt += 1
            mcnt = max(mcnt, cnt)
        else:
            cnt = 0
        lh = h[i]
    print(mcnt)



if __name__ == '__main__':
    solve()


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

using namespace std;

#define mod 1000000007
#define mp make_pair
typedef long long ll;
const int oo = 0x3f3f3f3f;

int main(void)
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            //

            long A;long B;long C;
            Multi(out A, out B, out C);
            var gcd = GCD(A, B);
            var ans = YESNO(C % gcd == 0);

            Console.WriteLine(ans);

            //
            Console.Out.Flush();
            Console.ReadKey();
        }

        static void Solve()
        {

        }

        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int a[4];
char s[10];

bool dfs(int i, int sum) {
    if (i == 4)
        return sum == 7;

    if (dfs(i + 1, sum - a[i]) && i != 0) {
        s[i] = '-';
        return true;
    }
    if (dfs(i + 1, sum + a[i])) {
        s[i] = '+';
        return true;
    }

    return false;
}

int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}

int main() {
    char c[10];
    scanf("%s", c);
    rep(i, 4) a[i] = ctoi(c[i]);

    if (dfs(0, 0)) {
        cout << a[0];
        rep1(i, 3) { cout << s[i] << a[i]; }
        cout << "=7";
    } else {
        cout << "error";
    }

    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(_) for _ in input().split(' ')]

if any([i == 0 for i in a]):
    print(0)
else:
    ans = a[0]
    for i in range(n - 1):
        ans *= a[i + 1]
        if ans > int(1e18):
            break

    if ans > int(1e18):
        print(-1)
    else:
        print(ans)

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

int main() {
  long long H, W;
  cin >> H >> W;
 
  long long ans = 0;
  
  if (H%2 == 0 || W%2 == 0) ans = H*W/2;
  else ans = H*(W+1)/2 - (H-1)/2;
  
  if (H == 1 || W == 1) ans = 1;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = {0, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
		System.out.println(a[sc.nextInt()] == a[sc.nextInt()] ? "Yes" : "No");
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    REP(i,N){
        cin >> s[i];
    }

    ll ans = 0;
    FOR(i,1,N){
        if((N-1)%i == 0){
            ll tmp_ans = 0;
            ll current = 0;

            int l = 0;
            int r = N-1;
            while(l<r){
                current += s[l] + s[r];
                tmp_ans = max(tmp_ans, current);
                l += i;
                r -= i;
            }
            ans = max(ans, tmp_ans);
        }else{
            ll tmp_ans = 0;
            ll current = 0;

            int l = 0;
            int r = N-1;
            while(l<N-1 && r>i){
                current += s[l] + s[r];
                tmp_ans = max(tmp_ans, current);
                l += i;
                r -= i;
            }
            ans = max(ans, tmp_ans);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3800
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N, K;
    cin >> N >> K;
    unordered_set<ll> snukes;
    rep(k,0,K) {
        ll d;
        cin >> d;
        rep(i,0,d) {
            ll A;
            cin >> A;
            snukes.insert(A);
        }
    }
    cout << N - snukes.size() << endl;
}


Measured memory_bytes: 3232
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = 1;
    int count = 0;
    while (c < b) {
      count += 1;
      c += (a - 1);
    }
    System.out.println(count);
    sc.close();
  }
}


Measured memory_bytes: 35420
from itertools import permutations
h,w=map(int,input().split())
es=[[] for i in range(10)]

for i in range(10):
    e=list(map(int,input().split()))
    for j in range(10):
        if i!=j:
            es[i].append([e[j], j])

n=10
import heapq

def dijkstra_heap(s):
    d = [float("inf")] * n
    used = [True] * n
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in es[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in es[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

cost=[dijkstra_heap(i)[1] for i in range(10)]

from collections import defaultdict
count=defaultdict(int)
for i in range(h):
    A=list(map(int,input().split()))
    for a in A:
        count[a]+=1

ans=0
t=[x for x in range(10) if x!=1]
for i in t:
    ans+=cost[i]*count[i]
print(ans)

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

// ABC122B - ATCoder
// https://atcoder.jp/contests/abc122/tasks/abc122_b
void ABC122B() {
	string S;
	cin >> S;
	S += "E"; //終端を表す文字を付けておく

	string ans = ""; //初期値は空文字
	for (int i = 0; i < S.length(); i++) //部分文字列のスタート地点を決める
	{
		//cout << i << endl;
		//cout << S[i] << endl;
		//ACGT以外が出たら飛ばす
		if (S[i] != 'A' && S[i] != 'C' && S[i] != 'G' && S[i] != 'T') {
			continue;
		}

		for (int j = i; j < S.length(); j++) //部分文字列の終端を探す
		{
			//ACGT以外が出る、または最後まで来たら終了
			if (S[j] != 'A' && S[j] != 'C' && S[j] != 'G' && S[j] != 'T') {
				//一番長い部分文字列を更新
				string substr = S.substr(i, j-i);
				//printf("[i, j] = [%d, %d]\n",i, j);
				//cout << substr << endl;
				if (ans.length() < substr.length()) {
					ans = substr;
				}

				break;
			}
		}
	}

	//cout << ans << endl;
	cout << ans.length() << endl;
}

int main() {
	ABC122B();

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;
const int N=2e5+5;
char s[N];
int h,t,n;
int tmp[30], nxt[N][30], q[N], pre[N];
void print(int now){
	if (!now) return;
	print(pre[now]);
	putchar(s[now]);
}
void Bfs(){
	memset(pre,-1,sizeof pre);
	h=1,t=0;
	q[++t]=0; pre[0]=0;
	while (h<=t){
		int x=q[h++];
//		if (x==n+1) return (void)(print(pre[x]));
		for (int i=0,y;i<26;i++){
			y=nxt[x][i];
			if (y==n+1) {
				print(x);
				putchar('a'+i);
				return;
			}
			if (pre[y]==-1) pre[y]=x, q[++t]=y;
		}
	}
}
int main(){
	fread(s+1,1,200003,stdin);
	n=strlen(s+1);
	for (int i=0;i<26;i++) tmp[i]=n+1;
	for (int i=n;i>=0;i--){
		for (int j=0;j<26;j++) nxt[i][j]=tmp[j];
		tmp[s[i]-'a']=i;
	}
	Bfs();
	return 0;
}

Measured memory_bytes: 25472
/**
*    Username : adhoc_king
*    Name : adhoc_king
*    Institute : IIT Bombay
*/

#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
// #include <map>
// #include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, arr[5];
    cin>>n;
    for0(i,5) cin>>arr[i];
    sort(arr, arr+5);
    cout<<(n+arr[0]-1)/arr[0] + 4;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]

list = []

for b in range(0, N):
    list.append(A[b] - b)

md = int(np.median(list))

bb = 0
for b in range(0, N):
    bb += abs(list[b] - md)

print(bb)


Measured memory_bytes: 34164
#pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

map<int, int>mp;


signed main() {
    accell();
    int n;
    cin >> n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(rall(a));
    for (auto it : a)
        mp[it]++;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int c = 1;
        while (c <= a[i])
            c *= 2;
        int nd = c - a[i];
        if (mp[nd] > 0 && mp[a[i]] > 0 && a[i] != nd) {
            mp[nd]--;
            mp[a[i]]--;
            ans++;
        }
        if (nd == a[i] && mp[a[i]] >= 2) {
            mp[nd]--;
            mp[a[i]]--;
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 26880
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int dd(int n){
	if(n>=0) return n;
	else return -n;
}
int main() {
int n,b=0;
int c=0,ans=0;
int a[60000];
cin>>n;
for(int i=1;i<=n;i++){
	cin>>a[i];
	b+=a[i];
}
sort(a+1,a+1+n);
for(int i=0;i<=n;i++){
	c+=a[2*i+1];
}

cout<<dd(b-2*c);
cout<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int num = n / 2;
    int ans = a[num]-a[num-1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import sys
s=int(input())
a=[s]
t=s
for i in range(1000001):
    if t%2==0:
        t=t//2
    else:
        t=3*t+1
    a.append(t)
    if i>=2 and a[i+1]==a[i-2]:
        print(i+2)
        sys.exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline int read(void){
	reg char ch=getchar();
	reg int res=0;
	while(ch<'0'||'9'<ch)ch=getchar();
	while('0'<=ch&&ch<='9')res=10*res+ch-'0',ch=getchar();
	return res;
}

int x;

inline int gcd(reg int a,reg int b){
	return b==0?a:gcd(b,a%b);
}

int main(void){
	x=read();
	printf("%d\n",360/gcd(360,x));
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int now = 0;
    int ans = 0;
    set<int> st;
    while(1){
        now = a[now];
        ans++;
        if(now == 1){
            cout << ans << endl;
            break;
        }
        if(st.count(now) == 1){
            cout << -1 << endl;
            return 0;
        }
        else st.insert(now);
    }
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <complex>
using namespace std;
typedef complex<double> P;

double det(P a, P b) {
  return (conj(a)*b).imag();
}
double solve(P a,P b,P p) {
  return (conj(p)*b).imag()/det(a,b);
}
int main() {
  P a,b,c,p;
  while(cin>>a.real()>>a.imag()>>b.real()>>b.imag()>>c.real()>>c.imag()>>p.real()>>p.imag()) {
    double s=solve(b-a,c-a,p-a),t=solve(c-a,b-a,p-a);
    cout << ( 0<s&&s<1 && 0<t&&t<1 && s+t<1 ?"YES":"NO") << endl; // テヲツ閉ーテ・ツュツヲBテ」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?ョテ、ツクツ嘉ィツァツ津・ツスツ「テ・ツ??ゥツδィテ」ツ?ョテヲツ敖。テ、ツサツカテ・ツシツ湘」ツつ津ィツ、ツ?ァツエツ?・ツケツウテゥツ敖「テ、ツクツ甘」ツ?ァテ・ツ按ゥテァツ板ィ
  }
  return 0;

}

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

int main(){

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

    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int b, e, k;
        cin >> b >> e >> k;
        int res = a[b];
        cout << count(next(a.begin(), b), next(a.begin(), e), k) << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<ll> l(100);
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++){
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
}

Measured memory_bytes: 256
N = int(input())
 
S = {}
count = 0
for i in range(N):
  sorted_string = ''.join(sorted(input()))
  if sorted_string in S:
    S[sorted_string] += 1
    count += S[sorted_string]
  else:
    S[sorted_string] = 0
 
print(count)

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

struct Card {char suit, value;};

void bubble(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j].value < A[j - 1].value) {
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(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 t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(void){
    // Your code here!
    Card C1[100], C2[100];
    int N;
    
    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];
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    
    return 0;
    
    
    
    
    
    
    
    
}



Measured memory_bytes: 3116
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    int n, k;
    int h[100200];
    cin >> n >> k;
    rep(i, n) cin >> h[i];
    fill(begin(h) + n, begin(h) + n + 110, 0);

    int dp[100200];
    fill(begin(dp), begin(dp) + n + 110, INF);

    dp[0] = 0;
    rep(i, n) for(int ki = 1; ki <= k; ++ki) {
        dp[i + ki] = min(dp[i + ki], dp[i] + abs(h[i + ki] - h[i]));
    }

    print(dp[n - 1]);

    return 0;
}



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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            if (N % 2 == 0)
            {
                Console.WriteLine(0.5);
            }
            else
            {
                Console.WriteLine((float)(N / 2 + 1) / (float)N);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

#ifdef LOCAL
#include "local.h"
#endif

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


ll mod_pow(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            (res *= x) %= mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    n %= 10;
    ll r = mod_pow(n, m, 10);

    vector<ll> cyc;
    for (ll a = n; find(all(cyc), a) == cyc.end(); (a *= r) %= 10)
        cyc.push_back(a);

    ll res = 0;
    rep(i, cyc.size())
    {
        ll occur = k / cyc.size();
        if (k % cyc.size() > i)
            ++occur;
        res += cyc[i] * occur;
    }
    cout << res << endl;
}


Measured memory_bytes: 1212