akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;


ll factorial(ll n) {
    if (n == 0) return 1;
    return n * factorial(n-1);
}

int main() {
    int N; cin >> N;
    vector<ll> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

    vector<ll> array;
    for (int i = 0; i < N; i++) array.push_back(i);
    
    double res = 0;

    do {
        for (int i = 0; i < N-1; i++) {
            int a = array[i],b=array[i+1];
            res += sqrt((x[a]-x[b])*(x[a]-x[b]) +
                         (y[a]-y[b])*(y[a]-y[b]));
        }

    }while (next_permutation(array.begin(),array.end()));

    printf("%.8lf",res / (double)factorial(N));




    

}


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

    int T = N / 2;
    if (N % 2 == 1) {
        cout << "No\n"; return 0;
    }
    for (int i = 0; i < T; i++) {
        if (S[i] != S[i+T]) {
            cout << "No\n"; return 0;
        }
    }
    cout << "Yes\n";

}
*/
/*
int main() {
    int N; cin >> N;
    cout << N * N << endl;
}*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = Double.parseDouble(sc.next());
		double b = Double.parseDouble(sc.next());
		if(a>b){
			System.out.println("GREATER");
		}else if(a<b){
			System.out.println("LESS");
		}else{
			System.out.println("EQUAL");
		}
		sc.close();
	}

}

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

int main() {
	int num;
	cin >> num;
	vector<char> list;
	char color;
	for (int i = 0; i < num; ++i) {
		cin >> color;
		bool isExist = false;
		for (auto&& elm : list) {
			if (elm == color) {
				isExist = true;
				break;
			}
		}
		if (!isExist) {
			list.push_back(color);
		}

		if (list.size() == 4) {
			break;
		}
	}

	if (list.size() == 3) {
		cout << "Three" << endl;
	} else {
		cout << "Four" << endl;
	}
}



Measured memory_bytes: 888
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();
    if(k<=a){
      System.out.println(a - k);
      System.out.println(b);
    }else if(k <= a + b){
      System.out.println(0);
      System.out.println(a+b-k);
    }else{
      System.out.println(0);
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
    int x,y,c,z,i;
    char a[5];
    while(scanf("%d%d",&x,&y)!=EOF)
    {
        c=0;
        while(x<=y)
        {
            z=x;
            for(i=0; i<5; i++)
            {
                a[i]=z%10+'0';
                z=z/10;
            }
            if(a[0]==a[4]&&a[1]==a[3])
                c++;
            x++;
        }
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		Set<String> found = new HashSet<String>();
		String prevWord = sc.nextLine();

		boolean good = true;
		for(int i = 0; i < n; i++){
			String currWord = sc.nextLine();
			if(i != 0 && currWord.charAt(0) != prevWord.charAt(prevWord.length() - 1)){
				good = false;
			}
			if(found.contains(currWord)){
				good = false;
			}
			found.add(currWord);
			prevWord = currWord;
		}

		if(good){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
constexpr long INF = 1L << 62;
constexpr int MOD = 1e9 + 7;

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

    long n; cin >> n;
    vector<string> a(n);
    map<string, long> m;
    REP(i,n) {
        cin >> a[i];
        sort(a[i].begin(), a[i].end());
        ++m[a[i]];
    }
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(), a.end()),a.end());

    long ans = 0;
    for(auto itr = a.begin(); itr != a.end(); itr++) {
        ans += (m[*itr]-1) * m[*itr] / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,a,b,bis;cin>>n>>a>>b;bis=1;
  //caricurate
  if((a+2>=b)||(n-1<a)){
    cout<<n+1<<endl;return 0;
  }
  
  n-=(a+1);bis=b;
  bis+=(n/2)*(b-a);n%=2;
  if(n){bis++;}
  //output
  cout<<bis<<endl;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  string s;cin>>s;
  for(int i = 0; s.size() > i; i++){
    cout << 'x';
  }
  cout << endl;
}


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

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

    int N;
    cin >> N;

    int S1 = 0, S2 = 0;
    vector<int> W(N);
    for (int n = 0; n < N; n++) {
        cin >> W[n];
        S2 += W[n];
    }

    int min_abs = abs(S1 - S2);
    for (int n = 0; n < N; n++) {
        int n_S1 = S1 + W[n];
        int n_S2 = S2 - W[n];
        int n_abs = abs(n_S1 - n_S2);
        if (min_abs > n_abs) {
            min_abs = n_abs;
        }
        S1 = n_S1;
        S2 = n_S2;
    }

    cout << min_abs << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N)cin >> d[i];
    int ans = 0;
    rep(i,N){
        repX(j,N,i+1){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = pow(2, m) * (1900 * m + 100 * (n - m));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define ARRAY_MAX 305

const ll INF = 1e17+7;
const ll MOD = 1e9+7;


void warshall_floyd(int v,vector<vector<ll> >& d){
    /*頂点の個数、コスト:d[u][v]はe=(u,v)のコスト(存在しない場合はINF,ただしd[i][j]=0とする)*/

    for(int k = 0;k < v;k++){
        for(int i = 0;i < v;i++){
            for(int j = 0;j < v;j++){
                if(i == k || k == j || i == j){
                    continue;
                }
                d[i][j]= min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}


vector<vector<ll> > mp(ARRAY_MAX,vector<ll>(ARRAY_MAX,0));
vector<vector<bool> > memo(ARRAY_MAX,vector<bool>(ARRAY_MAX,true));

int main(){

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

    ll ans = 0;
    for(int k = 0;k < n;k++){
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                
                if(i == k || j == k){
                    //頂点Eから頂点Eへする場合は飛ばす
                    continue;
                }
                if(mp[i][j] > mp[i][k] + mp[k][j]){
                    //最短路（もっといいもの）があるのでこのようなグラフは存在しない
                    cout << "-1" << endl;
                    return 0; 
                }
                if(mp[i][j] == mp[i][k] + mp[k][j]){
                    //他の経路を使用したほうが最適な場合は道はいらない
                    memo[i][j] = false;
                }
            }
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(memo[i][j]){
                ans += mp[i][j];
            }
        }
    }
    cout << ans/2 << endl;//２回数えているので2で割る

    return 0;
}

Measured memory_bytes: 1024
import itertools
n = int(input())
l = list(map(int, input().split( )))
pettern = 0
for v in itertools.combinations(l, 3):
    if v[0] != v[1] and v[1] != v[2] and v[2] != v[0]:
        if v[0]+v[1] > v[2] and v[1]+v[2] > v[0] and v[2]+v[0] > v[1]:
            pettern += 1
print(pettern)


Measured memory_bytes: 9180
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lld n,k;
	cin >> n >> k;
	long double val = ((long double)(n))/(k);
	lld equal = val;
	lld great = ceil(val);
	lld lower = floor(val);
	cout << min(llabs(n-(equal*k)),min(llabs(n-(great*k)),llabs(n-(lower*k))));
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c){
    	cout << "Yes";
    }else if(a == c && a != b){
    	cout << "Yes";
    }else if(b == c && a != b){
    	cout << "Yes";
    }else{
    	cout << "No";
    }
} 

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

typedef string::const_iterator State;

bool isnum(char c){
  return '0'<=c && c<='9';
}

int num(State& begin){
  int ret = 0;
  while(isdigit(*begin)){
    ret*=10;
    ret+=*begin-'0';
    ++begin;
  }
  ++begin; //skip ']'
  return ret;
}

int solve(State& begin){
  ++begin; //skip '['
  if(isdigit(*begin)) return (num(begin)+1)/2;
  vector<int> vote;
  while(*begin=='[')
    vote.push_back(solve(begin));
  ++begin; //skip']'
  sort(vote.begin(),vote.end());
  int ret = 0;
  for(int i=0;i<(vote.size()+1)/2;++i) ret+=vote[i];
  return ret;
}
int main(){
  int T;cin>>T;
  while(T--){
    string s;
    cin >> s;
    State b = s.begin();
    cout << solve(b) << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

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

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

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func inNum(c byte) bool {
	return c >= '0' && c <= '9'
}

func parseProblem() {
	a, b := scanInt(sc), scanInt(sc)
	s := scanString(sc)
	for i := 0; i < a; i++ {
		if !inNum(s[i]) {
			fmt.Println("No")
			return
		}
	}
	if s[a] != '-' {
		fmt.Println("No")
		return
	}
	for i := 0; i < b; i++ {
		if !inNum(s[a+i+1]) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func resolve(n int) int {
	return n
}

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


Measured memory_bytes: 1784
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	int N;
	std::string str;
	std::cin >> N >> str;
	if (std::all_of(str.begin(), str.end(), [](char c) {return c == 'R'; }) ||
		std::all_of(str.begin(), str.end(), [](char c) {return c == 'W'; }))
	{
		std::cout << 0 << std::endl;
		return;
	}
	int w = 0, r = N - 1;
	for (int i : boost::irange(N))
	{
		for (; w < N && str[w] == 'R'; ++w);
		for (; 0 <= r && str[r] == 'W'; --r);
		if (r < w)
		{
			std::cout << i << std::endl;
			return;
		}
		std::swap(str[w], str[r]);
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3736
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int A[200005],idx,d[200005];
v vec;
bitset<200005> vis;
void dfs(int node){
	if(vis[node]){
		idx=node;
		return ;
	}
	vec.pb(node);
	vis[node]=1;
	if(!vis[A[node]])d[A[node]]=d[node]+1;
	dfs(A[node]);
}
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int n,k;
	cin>>n>>k;
	for (int i = 1; i <= n; ++i)
		cin>>A[i];
	dfs(1);
	if(k<=d[idx])cout<<vec[k]<<"\n";
	else{ 
		k-=d[idx];
		cout<<vec[(k%(sz(vec)-d[idx]))+d[idx]]<<"\n";
	}	
	return 0;
}
//long long
//array bounds
//special cases
//binary search

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

#endif

#define mod 1000000007
//typedef pair<int, int> P;
#define INF (1LL<<60)




void solve(){
    string S;
    cin >> S;
    if(S=="hi" || S=="hihi" || S=="hihihi" || S=="hihihihi" || S=="hihihihihi")
        Yes;
    else No;
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

type key struct {
	Head rune
	Tail rune
}

func main() {
	var n int
	fmt.Scan(&n)

	m := make(map[key][]int)
	for i := 1; i <= n; i++ {
		s := strconv.Itoa(i)
		head := rune(s[0]) - '0'
		tail := rune(s[len(s)-1]) - '0'
		if tail == 0 {
			continue
		}
		k := key{head, tail}
		m[k] = append(m[k], i)
	}

	ans := 0
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			v1 := m[key{rune(i), rune(j)}]
			v2 := m[key{rune(j), rune(i)}]
			ans += len(v1) * len(v2)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long ll;



int main(){
  int n;
  cin >> n;
  int ai;
  int m = 1000000;
  int count = 0;
  for(int i=0; i<n; i++){
    cin >> ai;
    m = min(m, ai);
    if(m == ai){
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int D, G;

string conv(int _num) {
	string s = "0000000000";
	REP(i, D) {
		if (_num % 2 == 1) {
			s[i] = '1';
		}
		_num /= 2;
	}
	return s;
}

int main() {
	cin >> D >> G;
	int p[10], c[10];
	REP(i, D) {
		cin >> p[i] >> c[i];
	}

	int sum[10];
	REP(i, D) {
		sum[i] = (i + 1) * 100 * p[i] + c[i];
	}

	int ans = mod;
	REP(num, pow(2, D)) {
		string bits = conv(num);

		int total = 0, prob_num = 0;
		int zero_max_ix = -1;

		REP(ix, D) {
			// 全部解く
			if (bits[ix] == '1') {
				total += sum[ix];
				prob_num += p[ix];
			}
			// 全部解かない
			if (bits[ix] == '0') zero_max_ix = ix;
		}
		// 中途半端に解く
		if (total < G && zero_max_ix != -1) {
			int rest = G - total;
			int prob_num_ix;
			if (rest % ((zero_max_ix + 1) * 100) == 0) {
				prob_num_ix = rest / ((zero_max_ix + 1) * 100);
			}
			else {
				prob_num_ix = rest / ((zero_max_ix + 1) * 100) + 1;
			}

			if (prob_num_ix < p[zero_max_ix]) {
				total += prob_num_ix * 100*(zero_max_ix+1);
				prob_num += prob_num_ix;
			}
		}
		if (total >= G) {
			ans = min(ans, prob_num);
		}
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
main :: IO ()
main = do
  s <- getLine
  putStrLn $ solve s ""

solve :: String -> String -> String
solve "" s = s
solve (o : os) s | s == "" && o == 'B' = solve os s
                 | o == 'B'            = solve os $ init s
                 | otherwise           = solve os $ s ++ [o]


Measured memory_bytes: 380
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;cin>>n;
  	vi a(n+1,0);
  	for(int i=0;i<n-1;i++){
  	    int x;cin>>x;
  	    a[x]++;
  	}
  	for(int i=1;i<=n;i++){
  	    cout<<a[i]<<endl;
  	}
    return 0;
}

Measured memory_bytes: 4784
#include <stdio.h>
int main(void) {
  int fir=0, sec=0, thr=0, i;
  int p;
  for(i=0;i<10;i++) {
    scanf("%d",&p);
    if(p > fir) {
      thr = sec;
      sec = fir;
      fir = p;
    }
    else if(p > sec) {
      thr = sec;
      sec = p;
    }
    else if(p > thr) {
      thr = p;
    }
  }
  printf("%d\n%d\n%d\n",fir,sec,thr);
  return(0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  //ios_base::sync_wtih_stdio(0);
  //cin.tie(0);
  int n;
  cin>>n;
  string s,t,f;
  cin>>s>>t;
  for(int i=0;i<n;i++)
  {
    f.push_back(s[i]);
    f.push_back(t[i]);
  }
  cout<<f;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<char> p(n);
  vector<int> wcount(n);
  vector<int> ecount(n+1);
  int w = 0;
  for(int i = 0;i < n;i++){
    cin >> p[i];
    wcount[i] = w;
    ecount[i] = i-w;
    if(p[i] == 'W'){
      w++;
    }
  }
  ecount[n] = n-w;
  int answer = n;
  for(int i = 0;i < n;i++){
    if(answer > n-w-ecount[i+1]+ wcount[i]) answer = n-w-ecount[i+1]+ wcount[i];
  }
  cout << answer << endl;
}


Measured memory_bytes: 2944
n = int(input())
h = list(map(int,input().split()))
cost = [0]*n
cost[1] = abs(h[1]-h[0])
for i in range(2,n):
    cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]) , cost[i-2] + abs(h[i]-h[i-2]))
print(cost[n-1])

Measured memory_bytes: 13980
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>

using namespace std;
 
typedef long long ll;
const int N = 1e5+10;
const ll Maxn = 1e16;
const int MOD = 1e9 + 7;

int d[4];
int main(){
	int a, b ,c;
	while(~scanf("%d %d %d",&a, &b, &c)){
	d[1] = a, d[2] = b, d[3] = c;
	sort(d + 1, d + 4);
	int x = d[3] - d[1], y = d[3] - d[2];
	int sum = 0;
	if(x % 2 == 1 && y % 2 == 1){
		int k = (x - y) / 2;
		sum = sum + k + y;
	}
	else if(x % 2 == 1 && y % 2 == 0){
		int k = (x + 1)/2;
		int t = y / 2;
		sum = sum + k + t + 1;
	}
	else if(x % 2 == 0 && y % 2 == 1){
		int k = x / 2;
		sum += k;
		int t = (y + 1)/2;
		sum = sum + 1 + t;
	}
	else{
		int k = x / 2;
		int t = y / 2;
		sum = sum + k + t;
	}
	printf("%d\n",sum);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
#define mp make_pair
typedef long long ll;
using namespace std;

vector<pair<int, int> > graph[301];
ll dist[301][301][2];

void dijkstra(int start, int l){
	int tank = l;
	priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >, greater<pair<pair<int, int>, int> > > que;
	que.push(mp(mp(0, 0), start));
	dist[start][start][0] = 0;
	dist[start][start][1] = 0;

	while(!que.empty()){
		int q_num = que.top().first.first, q_used = que.top().first.second, q_to = que.top().second;
		que.pop();
		if (dist[start][q_to][0] < q_num || (dist[start][q_to][0] == q_num && dist[start][q_to][1] < q_used)) continue;

		for (auto x : graph[q_to]){
			if (l - q_used < x.second){
				if (dist[start][x.first][0] > dist[start][q_to][0] + 1 || (dist[start][x.first][0] == dist[start][q_to][0] + 1 && dist[start][x.first][1] > x.second)){
					dist[start][x.first][0] = dist[start][q_to][0] + 1;
					dist[start][x.first][1] = x.second;
					que.push(mp(mp(dist[start][q_to][0] + 1, x.second), x.first));
				}
			}else{
				if (dist[start][x.first][0] > dist[start][q_to][0] || (dist[start][x.first][0] == dist[start][q_to][0] && dist[start][x.first][1] > q_used + x.second)){
					dist[start][x.first][0] = dist[start][q_to][0];
					dist[start][x.first][1] = q_used + x.second;
					que.push(mp(mp(dist[start][q_to][0], q_used + x.second), x.first));
				}
			}
		}
	}
	return;	
}

int main(){
	int n, m, l;
	cin >> n >> m >> l;
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		if (l < c) continue;
		graph[a].push_back(mp(b, c));
		graph[b].push_back(mp(a, c));
	}
	for (int i = 0; i <= 300; i++){
		for (int j = 0; j <= 300; j++){
			dist[i][j][0] = 1000000000000000000;
		}
	}
	for (int i = 1; i <= n; i++) dijkstra(i, l);
	int q;
	cin >> q;
	for (int i = 0; i < q; i++){
		int s, t;
		cin >> s >> t;

		if (dist[s][t][0] == 1000000000000000000){
			cout << -1 << endl;
			continue;
		}
		cout << dist[s][t][0] << endl;
	}
	return 0;
}


Measured memory_bytes: 6760
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int N, M;
vector <int> G[20];
bool Matrix[20][20];
int DP[15000005];
int Conf[20];
const int MOD = 1000000007;
int Cnt[(1 << 15) + 5];
void precalcCnt()
{
    int lim = (1 << N);
    for(int i = 1; i < lim; i++)
        for(int j = 0; j < N; j++)
            if((i & (1 << j)) != 0)
            {
                Cnt[i] = 1 + Cnt[(i ^ (1 << j))];
                break;
            }
}
void Read()
{
    cin >> N >> M;
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        cin >> x >> y;
        --x;--y;
        G[x].push_back(y);
        //G[y].push_back(x);
        Conf[x] |= (1 << y);
        Matrix[x][y] = 1;
    }
    memset(DP, -1, sizeof(DP));
}
inline void Add(int& x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}
int Solve(int conf)
{
    if(DP[conf] != -1)
        return DP[conf];
    vector <int> V;
    bool X[20]; int C[20];
    for(int i = 0; i < N; i++)
    {
        X[i] = 0;
        C[i] = 0;
        if((conf & (1 << i)) != 0)
            V.push_back(i), X[i] = 1;
    }
    if(X[0] != X[1])
        return 0;
    for(int i = 0; i < V.size(); i++)
    {
        for(int j = 0; j < V.size(); j++)
            if(Matrix[V[i]][V[j]] == 1)
            {
                C[V[i]] |= (1 << V[j]);
            }
    }
    int sz = V.size();
    int ans = 1;
    for(int c = 1; c < (1 << sz) - 1; c++)
    {
        int mask1 = 0, mask2 = 0;
        int nb = 1;
        for(int j = 0; j < sz; j++)
        {
            if((c & (1 << j)) != 0)
            {
                mask1 = (mask1 ^ (1 << V[j]));
            }
            else
                mask2 = (mask2 ^ (1 << V[j]));
        }
        for(int j = 0; j < sz; j++)
        {
            if((c & (1 << j)) != 0)
            {
                int m = (Conf[V[j]] & mask2);
                int pw = (1 << Cnt[m]) - 1;
                nb = (1LL * nb * pw) % MOD;
            }
            else
            {
                int m = (Conf[V[j]] & mask1);
                int pw = (1 << Cnt[m]);
                nb = (1LL * nb * pw) % MOD;
            }
        }
        nb = (1LL * nb * Solve(mask1)) % MOD;
        Add(ans, nb);
    }
    DP[conf] = ans;
    return ans;
}
int main()
{
    Read();
    precalcCnt();
    int ans = Solve((1 << N) - 1);
    int p = 1;
    for(int i = 1; i <= M; i++)
        p = (1LL * p * 2) % MOD;
    ans = (p - ans) % MOD;
    if(ans < 0)
        ans += MOD;
    cout << ans << '\n';
    return 0;
}


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

int main(){
  int x,y;
  while(1){
  cin >> x >> y;
  if(x>y){
    cout << y <<  " " << x << "\n";
  }
  if(x<y){
    cout << x << " " << y << "\n";
  }
  if(x!=0 && y!=0 && x==y){
    cout << x << " " << y << "\n";   
  } 
 if(x==0 && y==0){
    break;
  }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    cout << (n * (n + 1) / 2) - n << endl;
    return 0;
}


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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

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

int main(){
  llong X;
  cin >> X;
  cout << (X/500)*1000 + ((X%500)/5)*5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    set<int> S;
    int count = 0, count_8 = 0;
    for (int i = 0; i < N; i++){
        a.at(i) /= 400;
        if (a.at(i) >= 8){
            count_8++;
        }
        else{
            if (S.count(a.at(i))){
                continue;
            }
            else{
                S.insert(a.at(i));
                count++;
            }
        }
    }
    cout << max(count, 1) << " " << count + count_8 << endl;
}

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

int N, K;
string S;
int main() {
	cin >> N >> K >> S; K--;
	if (S[K] == 'A')S[K] = 'a';
	if (S[K] == 'B')S[K] = 'b';
	if (S[K] == 'C')S[K] = 'c';
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}

using namespace std;

int u[14] = {} , n , sum , tot;
int w[52];
int memo[729][52];


int f(int s){
	if(memo[sum][s] >= 50) return false;
	else ++memo[sum][s];

	if(s==0){
		for(int i = n ; i > 0 ; i--){
			printf("%d%c",w[i],i!=1?' ':'\n');
		}
		return true;
	}
	if(s==n){
		for(int i = 13 ; i >= 1 ; i--){
			if(u[i]){
				--u[i];
				sum += i;
				w[s] = i;
				if( f(s-1) ) return true;
				sum -= i;
				++u[i];
			}
		}
	}else{

		bool chk = 0;
		for(int i = 13 ; i >= 1 ; i--){
			if(u[i] && tot % i == 0) chk = true;
		}
		
		if(!chk ){
			return false;
		}
		for(int i = 1 ; i <= 13 ; i++){
			if(u[i] && sum % i == 0){
				--u[i];
				sum += i;
				w[s] = i;
				if( f(s-1) ) return true;
				sum -= i;
				++u[i];
			}
		}
	}
	return false;
}
int main(){
	while(n=in() , n){
		
		tot = 0;
		memset(memo,0,sizeof(memo));
		for(int i = 1 ; i <= 13 ; i++){
			u[i] = 0;
		}
		for(int i = 0 ; i < n ; i++){ int a; a=in(); ++u[a]; tot += a; }
		sum = 0;
		if(!f(n)) cout << "No" << endl;
	}
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    int ans = 1e9;
    REP(i, 1, n){
        string a = to_string(i), b = to_string(n-i);
        int mid = 0;
        REP(l, 0, a.size()){
            mid += (a[l]-'0');
        }
        REP(l, 0, b.size()){
            mid += (b[l]-'0');
        }
        ans = min(ans, mid);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int64 a;
  string b;
  cin >> a >> b;
  int n = b.size();
  int64 sum = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i] == '.') continue;
    sum = sum * 10 + (b[i] - '0');
  }
  a = a * sum / 100;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3168
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   it.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> //indexed_set;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b,ll m) {ll res=1;a%=m;for(;b;b>>=1){if(b&1)res=res*a%m;a=a*a%m;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll k,n;
		cin>>k>>n;
		vector<ll>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		ll ans=v[n-1]-v[0];
		for(int i=1;i<n-1;i++){
			ll ans1=min(k-v[i]+v[i-1],k-v[i+1]+v[i]);
			ans=min(ans,ans1);
		}
		ans=min(ans,v[n-2]+k-v[n-1]);
		cout<<ans<<endl;
	}	
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void)
{
  char s[11],t[12];
  int flag=0;

  scanf("%s",s);
  scanf("%s",t);

  for(int i=0;i<strlen(s);i++)
  {
    if(s[i]!=t[i]) flag=1;
  }

  if(flag==1) printf("No\n");
  else printf("Yes\n");

  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll a[312345];
ll head[312345];
ll tail[312345];

int main2() {
  CLR(a, 0);
  CLR(head, 0);
  CLR(tail, 0);

  int N = nextInt();
  REP(i, 3*N) a[i] = nextInt();

  // pv(a, a + 3*N);

  {
    priority_queue<int, vector<int>, greater<int> > q; // min value comes top
    ll v = 0;
    for (int i = 0; i < N; i++) {
      v += a[i];
      q.push(a[i]);
    }
    for (int i = N; i < 3*N; i++) {
      head[i] = v;
      if (q.top() < a[i]) {
        v -= q.top();
        q.pop();
        v += a[i];
        q.push(a[i]);
      }
    }
  }
  // pv(head, head + 3*N+1);

  {
    priority_queue<int> q; // max value comes top
    ll v = 0;
    for (int i = 3*N-1; i >= 2*N; i--) {
      v += a[i];
      q.push(a[i]);
    }
    for (int i = 2*N-1; i >= 0; i--) {
      tail[i] = v;
      if (q.top() > a[i]) {
        v -= q.top();
        q.pop();
        v += a[i];
        q.push(a[i]);
      }
    }
  }

  // pv(tail, tail + 3*N+1);

  ll ans = -(1LL << 58);
  for (int i = N; i <= 2*N; i++) {
    ll v = head[i] - tail[i-1];
    // cout << head[i] << " " << tail[i-1] << endl;
    chmax(ans, v);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 8440
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double PI = acos(-1);
const double EPS = 1e-9;
#define tam 2234567
ll dp[tam];

int main()
{
    int n,prime;
    cin>>n>>prime;    
    string txt;
    ll ways=0;
    ll numero=0,pot=1;
    cin>>txt;
    if (prime!=2 && prime!=5)
    {
        dp[0]++;
        for(int i=txt.size()-1;i>=0;i--)
        {
            
            numero+=(txt[i]-'0')*pot;
            pot*=10;
            pot%=prime;
            numero%=prime;
            ways+=dp[numero];
            dp[numero]++;
        }
        cout<<ways<<endl;
    }
    else
    {
        forr(i,0,txt.size())
        {
            int aval=txt[i]-'0';
            if (aval%prime==0)
            {
                ways+=i+1;
            }
        }
        cout<<ways<<endl;
    }
    

}
// PLUS ULTRA!

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

using namespace std;

const int maxn = 100010;

int n, l[maxn], dp[maxn], e;
int cnt[21];

struct Edge {
	int v, x;
} E[maxn<<1];

inline void addEdge(int u, int v) {
	E[e].v = v; E[e].x = l[u]; l[u] = e++;
}

void dfs(int u, int f) {
	for (int p = l[u]; p >= 0; p = E[p].x) {
		int v = E[p].v;
		if (v != f) dfs(v, u);
	}
	for (int i = 0; i <= 20; i++) cnt[i] = 0;
	for (int p = l[u]; p >= 0; p = E[p].x) {
		int v = E[p].v;
		if (v != f) {
			for (int j = 0; j <= 20; j++) {
				if (dp[v] & (1<<j)) {
					++ cnt[j];
				}
			}
		}
	}
	int mn = 0;
	for (int i = 0; i <= 20; i++) if (cnt[i] >= 2) mn = i+1;
	int val = 0;
	for (int i = mn; i <= 20; i++) {
		if (!cnt[i]) {
			val = i;
			break;
		}
	}
	dp[u] ^= (1 << val);
	for (int i = val; i <= 20; i++) {
		if (cnt[i]) {
			dp[u] ^= (1<<i);
		}
	}
}

int main() {
	memset(l, -1, sizeof(l));
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addEdge(u, v);
		addEdge(v, u);
	}
	dfs(1, 0);
	int mx = 0;
	for (int i = 0; i <= 20; i++) {
		if (dp[1] & (1<<i)) {
			mx = i;
		}
	}
	printf("%d\n", mx);
	return 0;
}

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

int main(){
	int t,n,k,x_;
	
	cin >> t;
	for(int i=0 ; i<t ; i++ ){
		vector<int> x, y;
		int ans = 0;
		
		cin >> n >> k;
		for(int j=0 ; j<n ; j++ ){
			cin >> x_;
			x.push_back( x_ );
		}
		for(int j=1 ; j < (int)x.size() ; j++ ){
			y.push_back( x[j] - x[j-1] );
		}
		sort( y.begin() , y.end() );
		for(int j=0 ; j < k-1 ; j++ ) y.pop_back();
		
		//for(int j=0 ; j < (int)y.size() ; j++ )
			//cout << "y[" << j << "] : " << y[j] << endl;
		for(int j=0 ; j < (int)y.size() ; j++ ){
			ans += y[j];
		}
		if( n <= k ){
			cout << 0 << endl;
		}else{
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1548
n = 5
list=[int(input()) for i in range(n)]
a = 0
d = [0,0,0,0,0]
c = 0
b = 0
j = 1
k = 0

for j in reversed(range(11)):
  for i in range(n):
    b = (list[i]%10)
    if b == 0:
        b = 10
    if b == j:
        d[k] = list[i]
        k = k + 1


for i in range(n):
    a = a + c
    c = 10 - (d[i]%10)
    if c == 10:
        c = 0
    a = a + list[i]


print(a)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M],sm[M];

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

	ll k,n,i,ans;

	cin >> k >> n;
	ans = k;
	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		ar[i+n] = ar[i]+k;
	}

	for(i=2;i<2*n;++i)
	{
		sm[i-1] = sm[i-2];
		sm[i-1] += ar[i]-ar[i-1];
		if(i>=n)
			ans = min(sm[i-1]-sm[i-n],ans);
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8448