akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=998244353;
const int maxn = 1e5+7;

int n,m,a[maxn];

int main(){

    char s[10];
    cin>>s;
    if(s[0]>='a'&&s[0]<='z') cout<<'a'<<endl;
    else cout<<"A"<<endl;



    return 0;
}

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


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

int main(void){
  string s;
  cin >> s;
  long long a = 0;
  for (long long i = s.size()-1; i >= 0; i--) {
    a += ctoi(s[i]);
  }

  if (stoi(s)%a == 0) {
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
#整数の入力
A = int(input())

list_a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list_a[A-1])

Measured memory_bytes: 3060
from itertools import product, compress


def main():
    h, w, k = list(map(int, input().split()))
    c = [None for _ in range(h)]
    for i in range(h):
        c[i] = input()
    ans = 0
    for columns in product([1, 0], repeat=w):
        columns = list(compress(list(range(w)), columns))
        for rows in product([1, 0], repeat=h):
            count = 0
            rows = list(compress(list(range(h)), rows))
            # print(rows, columns)
            for row in rows:
                for column in columns:
                    if c[row][column] == "#":
                        count += 1
            if count == k:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
	int N;
	map<char, int> m;

	cin >> N;
	for (int i = 0; i < N; i++) {
		char c;
		cin >> c;
		m[c] += 1;
	}

	if (m.size() == 3)cout << "Three" << endl;
	else cout << "Four" << 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() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long f[87];
int main(){
    cin>>n;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=n;i++) f[i]=f[i-1]+f[i-2];
    cout<<f[n];
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include <stdlib.h>

float spase(float a,float b,float c){
	return sqrt((a+b+c)*(b-a+c)*(a-b+c)*(a+b-c));
}

int main(){
	int b[9][9],i,j,a[8];
	for(i=0;i<8;i++){
		b[i][8]=0;
		b[8][i]=0;
	}
	while( scanf("%d",&a[0]) != EOF ){
		for(i=1;i<8;i++){
			scanf("%d",&a[i]);
				
		}
		for(j=0;j<8;j++){
			for(i=0;i<8;i++){
				b[i][7-j]=a[i]%10;
				a[i] /= 10;
			}
		}
		for(i=0;b[i/8][i%8]==0;i++){
		}
		j=i%8;
		i=i/8;
		if(b[i+1][j]&&b[i][j+1]&&b[i+1][j+1]){
			printf("A\n");
		}
		if(b[i+1][j]&&b[i+2][j]&&b[i+3][j]){
			printf("B\n");
		}
		if(b[i][j+1]&&b[i][j+2]&&b[i][j+3]){
			printf("C\n");
		}
		if(b[i+1][j]&&b[i+1][j-1]&&b[i+2][j-1]){
			printf("D\n");
		}
		if(b[i][j+1]&&b[i+1][j+1]&&b[i+1][j+2]){
			printf("E\n");
		}
		if(b[i+1][j]&&b[i+1][j+1]&&b[i+2][j+1]){
			printf("F\n");
		}
		if(b[i+1][j]&&b[i+1][j-1]&&b[i][j+1]){
			printf("G\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2500
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <map>
#include <utility>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define MOD 10000000007          //10億　= 10^9になってる
#define juu 100000               //10万 10e5
#define hyaku 1000000            //100万　10e6
#define mINF -922337200085470000 //llのmax-1桁の小さい方
#define pINF 922337203600070000  //llのmax-1桁のデカい方
#define uINF 1844674407300000000 //ullのmax-1桁してる
#define pi 3.1415926535897932384
#define all(v) v.begin(), v.end()
ll factor[300];
ll memory[300];
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num)
{
    int i = 0, kosuu = 0;
    while (*(factor + i) != 0)
    {
        while (num % *(factor + i) == 0)
        {
            num /= *(factor + i);
            memory[*(factor + i)] += 1;
        }
        if (num == 1)
            break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number)
{
    ll tmp = 0;
    int flag = 0;
    *factor = 2;
    for (int i = 3; i <= number; i++)
    {
        flag = 0;
        for (int j = 0; j <= tmp; j++)
        {
            if (i % (*(factor + j)) == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag)
            continue;
        tmp += 1;
        *(factor + tmp) = i;
    }
    return tmp + 2;
}

/*intで収まる範囲であってくれ*/
ll nCr(int n, int r)
{
    ll val = 1;
    int i;
    if (r == 0)
        return 1;
    for (i = 0; i < n - r; i++)
    {
        val *= (n - i);
        val /= (i + 1);
    }
    return val;
}
/*intで収まる範囲であってくれ*/
ll nPr(int n, int r)
{
    ll val = 1;
    int i;
    for (i = 0; i < r; i++)
    {
        val *= (n - i);
    }
    return val;
}
template <typename T>
bool chmin(T &a, const T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmax(T &a, const T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

/*aとbで大きい方を後ろにする。変更なしならtrue、ありならfalse */
template<typename T>
bool swapmax(T &a,T&b){
    T temp;
    temp = a;
    if(a > b){
        a = b;
        b = temp;
        return false;
    }
    return true;
}
ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/

int main()
{
    string S;
    cin >> S;
    ll a;
    a = S.size();
    sort(all(S));
    auto itr = unique(S.begin(),S.end());
    S.erase(itr,S.end());
    if(a != (ll)S.size()){
        cout << "no";
        return 0;
    }

    cout << "yes";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

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

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

// 10で何回割れるかは、min(2で何回割れるか, 5で何回割れるか)

ll g1(ll n, int p)
{
  if (n == 0)
    return 0;
  return n / p + g1(n / p, p);
}

ll g2(ll n, int p)
{
  if (n % 2 == 1)
  {
    return g1(n, p) - g2(n - 1, p);
  }
  ll res = g1(n / 2, p);
  if (p == 2)
  {
    res += n / 2;
  }
  return res;
}

int main()
{
  ll n;
  cin >> n;
  ll ans = min(g2(n, 2), g2(n, 5));
  cout
      << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,n;
    cin >> a >> b >> n;
    long long int ans;
    if(b==1)cout << 0 << endl;
    else if(n>=b){
        double fl=(double)((b-1)*1.0/b*1.0);
        fl *= (a*1.0);
        ans = fl; 
    cout << ans << endl;        
    }
    else{
        double fl=(double)(n*1.0/b*1.0);
        fl *= (a*1.0);
        ans = fl; 
    cout << ans << endl;
    }
}

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

using namespace std;

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

Measured memory_bytes: 1160
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  a,b,x = readline() |> split |> parseArray

  ans=if x>a^2*b/2
    atan(2(b/a-x/a^3))
  else
    pi/2-atan(2x/(a*b^2))
  end
  println(rad2deg(ans))
end

main()


Measured memory_bytes: 114856
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
using namespace std;

int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    cout<< Z <<" "<< X <<" "<< Y;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
grid = [sr() for _ in range(H)]

def bfs(sy, sx):
    d = [[float('inf')] * W for _ in range(H)]
    dy = [0, 1, 0, -1]
    dx = [1, 0, -1, 0]
    que = deque()
    que.append((sy, sx))
    d[sy][sx] = 0
    while que:
        p = que.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]                
            if 0 <= ny < H and 0 <= nx < W and \
                    grid[ny][nx] != '#' and d[ny][nx] == float('inf'):
                d[ny][nx] = d[p[0]][p[1]] + 1
                que.append((ny, nx))
    max = 0
    for row in d:
        for r in row:
            if r != float('inf') and r > max:
                max = r
    return max

answer = 0    
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            continue
        result = bfs(i, j)
        if result > answer:
            answer = result

print(answer)
# 49


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N, sum;
sum = 0;
cin >> N;
for(long long i = 0; i <= N; i++){
if(i % 3 != 0 && i % 5 != 0){
sum += i;
}

}
cout << sum << endl;
}


Measured memory_bytes: 3624
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

II = lambda: int(input())
MI = lambda: map(int, input().split())


N, A, B = MI()
print(min(A, B), max(A + B - N, 0))


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

using namespace std;

int main() {
	long n;
	scanf("%ld", &n);
	
    vector<long> v(5);
    for(int i = 0; i < 5; i++) scanf("%ld", &v[i]);
    sort(v.begin(), v.end());
    
	long ans;
	if(n % v[0]) ans = (n / v[0]) + 5;
	else ans = (n / v[0]) + 4;
	
	printf("%ld", ans);
}


Measured memory_bytes: 256
//Partition
#include <iostream>

using namespace std;

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

int main() {
    int n;
    cin >> n;
    int A[n];
    for(int i=0; i<n; i++) cin >> A[i];

    int x = partition(A, 0, n - 1);

    for(int i = 0; i < n; i++) {
        if(i != 0) cout << " ";
        if(i == x) {
            cout << "[" << A[i] << "]";
        }
        else cout << A[i];
    }
    cout << endl;
}


Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string S,K;
const int n = 1<<8;

int getlen(){
  int mx[n],res=1e9;
  memset(mx,-1,sizeof(mx));
  for(int i=0;i<S.size();i++){
    int ch = S[i];
    mx[ch] = max(mx[ch],i);
    int c=0,l=1e9;
    for(int j=0;j<K.size();j++)c+=mx[K[j]]>=0,l=min(l,mx[K[j]]);
    if(c<K.size()) continue;
    res=min(res,i-l);
  }
  return res;
}

int count(int len){
  int cnt[n]={},res=0;
  for(int i=0;i<S.size();i++){
    cnt[S[i]]++;
    int c=0;
    for(int j=0;j<K.size();j++)c+=cnt[K[j]]>0;
    if(c==K.size())res++;
    if(i-len>=0) cnt[S[i-len]]--;
  }
  return res;
}

string getstr(int len){
  int cnt[n]={},res=0;
  for(int i=0;i<S.size();i++){
    cnt[S[i]]++;
    int c=0;
    for(int j=0;j<K.size();j++)c+=cnt[K[j]]>0;
    if(c==K.size()) return S.substr(i-len,len+1);
    if(i-len>=0) cnt[S[i-len]]--;
  }
  return "";
}

int main(){
  while(1){
    S.clear();
    while(1){
      string s; 
      getline(cin,s);
      if(s.empty()) break;
      S+=s;
    }
    if(S.empty())break;
    getline(cin,K);
    
    int len = getlen();
    cout<<count(len)<<endl;
    string str = getstr(len);
    for(int i=0;i<str.size();i++){
      if(i!=str.size()-1&&i%72==0)cout<<endl;
      cout<<str[i];
    }
    cout<<endl;
    if(len<1e9)cout<<endl;
    getline(cin,K);      
  }
  return 0;
}

Measured memory_bytes: 3360
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };

//10^7までの素数を列挙する
bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 1000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.push_back(i);
			c++;
		}
	}
}
void no() {
	print("Brown"); exit(0);
}
void yes() {
	print("Alice"); exit(0);
}
void solve() {
	int A, B; cin >> A >> B;
	if (A > B)swap(A, B);
	int d = abs(A - B);
	if (d<=1)no();
	else yes();
}


signed main() {
	solve();
}



Measured memory_bytes: 256
s=input()
t=input()
lent=len(t)
num=lent
ls=[]
count=0

for i in range(len(s)-lent+1):
  st=s[i:i+num]
  num+=1
  
  for j in range(lent):
    if st[j]!=t[j]:
      count+=1
      
  ls.append(count)
  count=0
  
print(min(ls))

Measured memory_bytes: 9120
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }

    Scanner kbd = new Scanner(System.in);

    void run(){
	while(kbd.hasNext()){
	    int ans = 0;
	    for(int i=0; i<10; i++){
		ans += kbd.nextInt();
	    }
	    System.out.println(ans);
	}
    }
}

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

struct Line{
	int h,p,q;
	Line(){}
	Line(int h,int p,int q):h(h),p(p),q(q){}
	bool operator <(Line x)const{return h>x.h;}
};
int main(){
	int n,m,a;
	while(cin>>n>>m>>a,n|m|a){
		vector<Line> line;
		for(int i=0;i<m;i++){
			int h,p,q;
			cin>>h>>p>>q;
			line.push_back(Line(h,p,q));
		}
		sort(line.begin(),line.end());
		for(int i=0;i<line.size();i++){
			if(a==line[i].p)a=line[i].q;
			else if(a==line[i].q)a=line[i].p;
		}
		cout<<a<<endl;
	}
	return 0;
}

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

int main()
{
  int q;
  cin >> q;
  long long int p, n, count[2] = {};
  char c;
  for(int i = 0; i < q; i++){
    cin >> p >> c >> n;
    count[c == '('] += n;
    if(count[0] != count[1]) cout << "No";
    else cout << "Yes";
    cout << endl;
  }
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        string S;
        cin >>S;
        for (int i=0; i<S.size(); i++)
                if ('P'==S.at(i))
                        cout <<'P';
                else
                        cout <<'D';
        cout <<endl;
        return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#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<ll>l(n);
    rep(i, n)   cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
                    if(l[i] + l[j] > l[k]){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>

int num[3];
void swap(int i, int j);

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

Measured memory_bytes: 596
*I,t=open(0).read().split()
n,k,r,s,p=map(int,I)

d={'r':p,'s':r,'p':s}
b=['']*n
a=0

for i,c in enumerate(t[:n]):
    if c!=b[i-k]:
        b[i]=c
        a+=d[c]

print(a)

Measured memory_bytes: 3956
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) A[i] = cin.nextInt();

        int odd_cnt = 0;
        for(int i = 0;i<N;i++)
        {
            if (A[i] % 2 == 1) odd_cnt++;
        }

        if (odd_cnt % 2 == 1) Console.WriteLine("NO");
        else Console.WriteLine("YES");
        
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 12120
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,j;
    int first = 0, second = 0, third = 0;
    for (j = 0; j < 10; j++) {
        scanf("%d",&i);
        if (third < i) {
            if (second < i) {
                if (first < i) {
                    third = second;
                    second = first;
                    first = i;
                } else {
                    third = second;
                    second = i;
                }
            } else {
                third = i;
            }
        }
    }
    printf("%d\n%d\n%d\n",first ,second, third);
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;

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

    for(int& x:a){
        if(x-2>=0 && b[x-2]>0){
            b[x-1] = b[x-2]+1;
        }else{
            b[x-1] = 1;
        }
    }

    cout << n-*std::max_element(b.begin(), b.end()) << endl;
    
}


Measured memory_bytes: 1792
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();
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < 9; i++) {
            for (int j = i; j < 9; j++) {
                set.add(a[i] * a[j]);
            }
        }
        if (set.contains(n)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3030;
int ways[maxn][maxn], sways[maxn], coef[maxn][maxn], pw[maxn * maxn], pw2[maxn * maxn], ppw2[maxn];
int main(){
	int n, m; cin >> n >> m;
	auto add = [&](int a, int b){
		a += b;
		if(a >= m) a -= m;
		if(a < 0) a += m;
		return a;
	};
	auto mul = [](long long a, long long b, int m){
		return a * b % m;
	};
	auto pwr = [&](int a, int b, int m){
		int r = 1;
		for(; b; b >>= 1, a = mul(a, a, m)) if(b&1) r = mul(r, a, m);
		return r;
	};
	for(int i = 1; i <= n; i++){
		ways[i][0] = ways[i][i] = 1;
		for(int j = 1; j < i; j++){
			ways[i][j] = add(mul(ways[i - 1][j], j + 1, m), ways[i - 1][j - 1]);
		}
	}
	pw[0] = pw2[0] = 1;
	for(int i = 1; i <= n * n; i++){
		pw[i] = mul(2, pw[i - 1], m);
		pw2[i] = mul(2, pw2[i - 1], m - 1);
	}
	for(int i = 0; i <= n; i++){
		ppw2[i] = pwr(2, pw2[i], m);
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= i; j++){
			ways[i][j] = mul(mul(ways[i][j], pw[(n - i) * j], m), ppw2[n - i], m);
			sways[i] = add(sways[i], ways[i][j]);
		}
	}
	for(int i = 1; i <= n; i++){
		coef[i][0] = coef[i][i] = 1;
		for(int j = 1; j < i; j++){
			coef[i][j] = add(coef[i - 1][j - 1], coef[i - 1][j]);
		}
	}
	int ans = pwr(2, pwr(2, n, m - 1), m);
	for(int i = n; i > 0; i--){
		if(i & 1) ans = add(ans, m - mul(coef[n][i], sways[i], m));
		else ans = add(ans, mul(coef[n][i], sways[i], m));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 143616
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    List<Integer> list = new ArrayList<>();
    while (n > 0) {
        list.add(n % 10);
        n /= 10;
    }
    for(int i = 0; i < list.size(); i++){
        if(list.get(i).equals(7)){
            count++;
        }
    }
    if(count > 0){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
    
	}
}

Measured memory_bytes: 35804
#include <iostream> 
#include <string> 
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <map> 
#include <queue> 
#include <set> 
#include <stack>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll long long

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();

  println!("{}", (a - 1) * (b - 1));
}



Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;

#define ll long long

int main(){

    ll a,b;
    cin>>a>>b;
    if(a<=0&&b>=0)cout<<"Zero"<<endl;
    else if(a>0)cout<<"Positive"<<endl;
    else if((b-a)%2==0)cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)
int gcj_out_cnt = 1;
#define gcj_put cout<<"Case #"<<gcj_out_cnt++<<": ";

/*Coding Space*/

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

  if(b - a  > 2){
    ans += (b-a) * (k/2);
    k = k % 2;
  }
  ans += k;
  cout << ans << endl;
}


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

typedef long long int ll;
typedef complex<ll> point;

ll cross(point a, point b) { return imag(conj(a) * b);}
ll dot(point a, point b) { return real(conj(a) * b);}
ll area2(point a, point b, point c) { return cross(b-a, c-a);}

namespace std
{
  bool operator< (const point& a, const point& b)
  {
    return real(a) < real(b) || (real(a) == real(b) && imag(a) < imag(b));
  }
}

const ll oo = 1e18;

struct dynamic_hull
{
  dynamic_hull(): hulls() {}
  
  void add_point(point p)
  {
    hull h;
    h.add_point(p);
    
    for(hull& _h: hulls)
      if(_h.empty())
      {
        h.swap(_h);
        break;
      }else h = merge(h, _h), _h.clear();
    
    if(!h.empty()) hulls.emplace_back(h);
  }
  
  ll max_dot(point p)
  {
    ll best = -oo;
    for(hull& h: hulls)
      if(!h.empty()) best = max(best, h.max_dot(p));
    
    return best;
  }
  
private:
  struct hull: vector<point>
  {
    void add_point(point p)
    {
      for(int s=size(); s> 1; --s)
        if(area2(at(s-2), at(s-1), p) < 0) break;
        else pop_back();
      push_back(p);
    }
    
    ll max_dot(point p)
    {
      int lo = 0, hi = (int) size() - 1, mid;
      while(lo < hi)
      {
        mid = (lo + hi) / 2;
        
        if(dot(at(mid), p) <= dot(at(mid + 1), p))
          lo = mid + 1;
        else hi = mid;
      }
    
      return dot(at(lo), p);
    }
  };
  
  static hull merge(const hull& a, const hull& b)
  {
    hull h;
    size_t i = 0, j = 0;
    
    while(i < a.size() && j < b.size())
      if(a[i] < b[j]) h.add_point(a[i++]);
      else h.add_point(b[j++]);
    
    while(i < a.size()) h.add_point(a[i++]);
    while(j < b.size()) h.add_point(b[j++]);
    
    return h;
  }
  
  vector<hull> hulls;
};

const int N = 2e5+7;

dynamic_hull ft[N];

void upd(int x, point p)
{
  for(;x < N; x += x&-x)
    ft[x].add_point(p);
}

ll qry(int x, point p)
{
  ll res = 0;
  for(;x;x-=x&-x)
    res = max(res, ft[x].max_dot(p));
  return res;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int n; cin >> n;
  
  vector<ll> h(n), w(n);
  
  for(ll& i: h) cin >> i;
  for(ll& i: w) cin >> i;
  
  
  ll ans = w[0];
  
  upd(h[0], point(w[0], 1));
  
  for(int i=1;i<n;++i)
  {
    auto p = point(1, w[i]);
    
    ll q = qry(h[i], p);
    if(!q) ans = max(ans, w[i]), q = w[i];
    else ans = max(ans, q);
    
    upd(h[i], point(q, 1));
    //~ cerr << q <<  ' ' << ans << endl;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 37504
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k = i_input()
    print("ACL"*k)


    

 

if __name__=="__main__":
    main()

    

Measured memory_bytes: 65580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


using Edge = pair<int,int>;
int N,M;
vector<vector<Edge>> G;
vector<int> dist;
vector<int> used;
bool ok = true;

void dfs(int i){
   
   used[i] = 1;

   for(auto v : G[i]){
      if(used[v.first] == 1){
         if(dist[v.first] != (dist[i] + v.second)) ok = false;
         continue;
      }
      dist[v.first] = v.second + dist[i];
      dfs(v.first);
   }
}

int main(){
   cin >> N >> M;
   G.resize(N);
   dist.resize(N);
   used.resize(N,-1);
   rep(i,M){
      int L,R,D;
      cin >> L >> R >> D;
      L--; R--;
      G[L].push_back(Edge{R,D});
      G[R].push_back(Edge{L,-D});
   }

   rep(i,N){
      if(used[i] == -1){
         dfs(i);     
      }
   }
   if(ok) cout << "Yes" << endl;
   else cout << "No" << endl;
  
}



Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    if((a<=c && c<=b)||(b<=c&&c<=a))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int A = int.Parse(str[0]);
		int B = int.Parse(str[1]);
		int K = int.Parse(str[2]);
		int a = 0;
		for(var i=100;i>=1;i--){
			if(A%i==0&&B%i==0){
				a++;
				if(a==K){
					Console.WriteLine(i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 11092
require 'prime'

def key(n)
	qs = []
	Prime.each(Math.sqrt(n).to_i){|q|
		k = 0
		while n % q == 0 
			n /= q
			k += 1
		end
		qs << q if k > 0
	}
	qs << n if n > 1
	qs.pop - qs.inject(0, :+)
end

while gets
	a, b = $_.split.map &:to_i
	break if a == 0
	puts key(a) > key(b) ? ?a : ?b
end

Measured memory_bytes: 6260
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        String S=sc.next();
        int res=0;
        for(int i=0;i<S.length();i++){
            res+=S.charAt(i)-'0';
            res%=9;
        }
        System.out.println(res==0?"Yes":"No");
    }
}

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

struct ts
{
	long long s, a, b;
	bool operator<(const ts &r) const {
		return s > r.s;
	}
};

ts p[100009];	

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i].a >> p[i].b;
		p[i].s = p[i].a + p[i].b;
	}
	sort(p, p + n); 
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) ans += p[i].a;
		else ans -= p[i].b;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N, L;

int main() {
	cin >> N >> L;
	if (L >= 0) {
		cout << N*(N + 1) / 2 + N*(L - 1) - L << endl;
	}
	else if (L + N - 1 <= 0) {
		cout << N*(N + 1) / 2 + N*(L - 1) - (L + N - 1) << endl;
	}
	else {
		cout << N*(N + 1) / 2 + N*(L - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
in_time = int(input())
if 0 <= in_time < 86400:
    tmp1 = 60 ** 2
    h = in_time // tmp1
    tmp2 = in_time % tmp1
    m = tmp2 // 60
    t = tmp2 % 60
    print(str(h) + ':' + str(m) + ':' + str(t))

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

using namespace std;

#define il inline
#define Rep(i, s, e) for (int i = s; i <= e; ++i)
#define Dep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int main() {
    int k = read(), now = 0;
    Rep(i, 1, k) {
        now = (now * 10 + 7) % k;
        if (!now) return printf("%d", i) & 0;
    }
    return puts("-1") & 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cmath>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <vector>
#include <map>

#define ll long long

using namespace std;

//bool isPal(string s) {
//    string s2 = s;
//    reverse(s.begin(), s.end());
//    if (s2 == s) {
//        return true;
//    } else {
//        return false;
//    }
//}

int main() {

    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cout.setf(ios::fixed);
    cout.precision(15);

    double x;
    cin >> x;
    cout << (x / 3) * (x / 3) * (x / 3);

}


Measured memory_bytes: 256
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 = sc.nextInt();

        int temp = 0;

        if(a > b){
            temp = a;
            a = b;
            b = temp;
        }

        if(b > c){
            temp = b;
            b = c;
            c = temp;
        }

        if(a > b){
            temp = a;
            a = b;
            b = temp;
        }

        System.out.println(a + " " + b + " " + c);
    }
}


Measured memory_bytes: 26412
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String[] st = sc.nextLine().split(" ");
    	String mregedNumber = st[0] + st[1];
    	double heihou = Math.sqrt(Double.parseDouble(mregedNumber));
    	int intHeiohou = (int) heihou;
    	double compHeihou = (double) intHeiohou;
    	
    	String result = "";
    	if(heihou == compHeihou) {
    		result = "Yes";
    	}else {
    		result = "No";
    	}
    	System.out.println(result);
    	
    	
    	
    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
隣接行列をK回掛けると、a[i][j]はiからjの長さkのパスの総数
行列累乗
*/

ll n,k,a[60][60],b[60][60],dp[60][60],mod=1e9+7,ans=0;

const ll matrix_size=60;
void mat_prod(){
	ll _ans[matrix_size][matrix_size];
	rep(i,n){
		rep(j,n){
			_ans[i][j]=0;
			rep(k,n){
				_ans[i][j]=(_ans[i][j]+(dp[i][k]*b[k][j])%mod)%mod;
			}
		}
	}
	rep(i,n)rep(j,n)dp[i][j]=_ans[i][j];
}
void mat_prod2(){
	ll _ans[matrix_size][matrix_size];
	rep(i,n){
		rep(j,n){
			_ans[i][j]=0;
			rep(k,n){
				_ans[i][j]=(_ans[i][j]+(b[i][k]*b[k][j])%mod)%mod;
			}
		}
	}
	rep(i,n)rep(j,n)b[i][j]=_ans[i][j];
}
void mat_prod_k(){
	while(k){
		if(k&1)mat_prod();
		mat_prod2();
		k>>=1;
	}
}

int main(void){
	cin>>n>>k;
	rep(i,n)rep(j,n)cin>>a[i][j];
	//
	rep(i,n)rep(j,n)b[i][j]=a[i][j];
	rep(i,n)rep(j,n)dp[i][j]=0;
	rep(i,n)dp[i][i]=1;
	//
	mat_prod_k();
	rep(i,n)rep(j,n)ans=(ans+dp[i][j])%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
for i in range(n):
    if a[i]<=b[i]:
        ans+=a[i]
        ans+=min(a[i+1],b[i]-a[i])
        a[i+1]=max(a[i+1]-(b[i]-a[i]),0)
    else:
        ans+=b[i]
print(ans)


Measured memory_bytes: 19244
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int A, B;

signed main(){
    cin >> A >> B;
    if(A <= 9 && B <= 9) cout << A*B << endl;
    else cout << "-1" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    fast;
    double n,x,t,i;
    ll j;
    cin>>n>>x>>t;
    i=ceil(n/x);
    j=i*t;
    cout<<j<<endl;
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve() {
	ll k, n;
	cin >> k >> n;
	ll a[n], ans = INT_MIN;
	rep(i, n) {
		cin >> a[i];
		if (i > 0) {
			ans = max(ans, a[i] - a[i - 1]);
		}
	}
	cout << min((a[n-1] - a[0]), k - ans) << endl;
}

int main() {
	IOS;
	//io_set();
	ll tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}

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


struct position{
    int i,j;
    bool operator == (const position& x) const {return (i==x.i&&j==x.j);}
};
template<typename T>
class Grid{
    public:

    int Height_num,Width_num;
    vector<T>*grid;

    Grid(int Height,int Width){
        Height_num=Height;
        Width_num=Width;
        grid=new vector<T>[Height];
        for(int i=0;i<Height;i++)grid[i]=*new vector<T>(Width);
        //vector<vector<T>>grid(Height,vector<T>(Width));
    }

    void input(){
        for(int i=0;i<Height_num*Width_num;i++)cin>>grid[i/Width_num][i%Width_num];
    }

    void check(){
        for(int i=0;i<Height_num*Width_num;i++)cout<<grid[i/Width_num][i%Width_num]<<" \n"[i%Width_num==Width_num-1];
    }
};

template<typename T>
vector<vector<int>> BFS(Grid<T>g,int start_i,int start_j){
    position start={start_i,start_j};
    const int unreachable=1000000000;
    vector<vector<int>>d(g.Height_num,vector<int>(g.Width_num,unreachable));
    //vector<vector<bool>>visited(g.Height_num,vector<bool>(g.Width_num,false));
    deque<position>q;
    q.push_front(start);
    //visited[start.i][start.j]=true;
    d[start.i][start.j]=0;
    
    int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
    while(!q.empty()){
        position state=q.front();q.pop_front();
        for(int i=0;i<4;i++){
            position neighbor={state.i+dx[i],state.j+dy[i]};
            //out of range
            if(!(0<=neighbor.i&&neighbor.i<g.Height_num&&0<=neighbor.j&&neighbor.j<=g.Width_num))continue;
            //unreachable
            if(g.grid[neighbor.i][neighbor.j]=='#')continue;
            //visited
            if(d[neighbor.i][neighbor.j]<=d[state.i][state.j])continue;
            //update distance
            d[neighbor.i][neighbor.j]=d[state.i][state.j];
            //push 
            q.push_front(neighbor);
        }

        for(int i=0;i<5*5;i++){
            position neighbor={state.i+i/5-2,state.j+i%5-2};
            //out of range
            if(!(0<=neighbor.i&&neighbor.i<g.Height_num&&0<=neighbor.j&&neighbor.j<=g.Width_num))continue;
            //unreachable
            if(g.grid[neighbor.i][neighbor.j]=='#')continue;
            //visited
            if(d[neighbor.i][neighbor.j]<=d[state.i][state.j]+1)continue;
            //update distance
            d[neighbor.i][neighbor.j]=d[state.i][state.j]+1;
            //push 
            q.push_back(neighbor);
        }
    }
    return d;
}
int H,W,Ch,Cw,Dh,Dw;
int main(){
    cin>>H>>W>>Ch>>Cw>>Dh>>Dw;
    Grid<char>g(H,W);
    g.input();
    auto d=BFS(g,Ch-1,Cw-1);
    cout<<(d[Dh-1][Dw-1]==1000000000?-1:d[Dh-1][Dw-1])<<endl;
    return 0;
}

Measured memory_bytes: 9588
#include <array>
#include <cstdlib>
#include <iostream>
using namespace std;

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

	array<array<int, 11>, 128> to;
	for(int i = '0'; i <= '9'; ++i) {
		for(int j = 0; j < 11; ++j) {
			to[i][j] = (j * 10 + i - '0') % 11;
		}
	}

	for(string s; cin >> s && s != "0";) {
		int ans = 0;
		array<int, 11> dp;
		dp.fill(0);

		for(int i = 0; i < static_cast<int>(s.size()); ++i) {
			if(s[i] != '0') ++dp[0];

			array<int, 11> tmp;
			tmp.fill(0);
			for(int j = 0; j < 11; ++j) {
				tmp[to[s[i]][j]] += dp[j];
			}

			ans += tmp[0];
			dp.swap(tmp);
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1320
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
cnt = 0
for i in range(1, n):
    if a[i] == a[i - 1]:
        a[i] = 0
        cnt += 1
print(cnt)


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

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

  int64_t ans;
  if(N==1 && M==1)      ans= 1;
  else if(N==1 || M==1) ans= max(N,M)-2;  // 角(2):表, 辺(3):裏           (括弧内は隣接マスの数)
  else                  ans= (N-2)*(M-2); // 角(4):表, 辺(6):表, 面(9):裏

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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; }

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

vector< vector<int> > Graph;
vector< int > value;



int main(int argc, const char * argv[]) {
    
   
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    
    int n; cin >> n;
    rep(i,100000){
        if(i*i == n) {
            cout << i*i << endl;
            break;
        }else if(i*i > n) {
            cout << (i - 1)*(i-1) << endl;
            break;
        }
    }
    
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1);

int main()
{
	int a,b,x;
	while(cin >> a >> b >> x){
		double s,ang;
		if(x > (a * a * b)/2){
			s = (2.00 * a * a * b - 2.00 * x) / (a * a * a * 1.00);
			ang = atan(s) * 180.0f / PI;
		}
		else if(x <= (a * a * b)/2){
			s = (a * b * b * 1.00) / (2.00 * x);
			ang = atan(s) * 180.0f / PI;
		}
		printf("%lf",ang);
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <stdio.h>
using namespace std;

#define NELEMS(array) (sizeof(array) / sizeof(array[0]))

void strchr(char* c, int n)
{
	const char* alp = "abcdefghijklmnopqrstuvwxyz";
	bool ch[26] = {false};
	for(int i = 0; i < n; ++i) {
		ch[c[i] - 'a'] = true;
	}
	for(int i = 0; i < 26; ++i)
		if(!ch[i]) {
			cout << alp[i] << endl;
			return;
		}
	cout << "None" << endl;
}

int main(void)
{
	char s[100000];
	cin >> s;
	int i = 0;
	while(s[i] != '\0')
		++i;
	strchr(s, i);

	return 0;
}

Measured memory_bytes: 384