akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	string str = "";
	cin >> str;
	while (str.find ("chicken" ) != string::npos ){
		str = str.replace (str.find ("chicken"), 1, "C" );
	} // end while
	while (str.find ("egg" ) != string::npos ){
		str = str.replace (str.find ("egg"), 1, "E" );
	} // end while

	string s = "";
	int n = str.length();
	rep (i, n ) if (str[i] == 'C' || str[i] == 'E' ) s += str[i];

	vector<string> ans; ans.clear();
	string curr = "";
	curr += s[0];
	for (int i = 1; i < s.length(); i++ ){
		if (curr[curr.length()-1] != s[i] ){
			curr += s[i];
		}else{
			ans.push_back (curr );
			curr = s[i];
		} // end if
	} // end for
	if (!curr.empty() ) ans.push_back (curr );

	int maxlen = 0;
	string res = "";
	rep (i, ans.size() ){
		if (maxlen < ans[i].size() ){
 			maxlen = ans[i].size();
			res = (ans[i][ans[i].size()-1] == 'C' ? "chicken" : "egg" );
		} // end if
	} // end rep
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll t[MAXn];
int main(){
    IOS();
    ll n,c,k;
    cin >> n >> c >> k;
    for (int i=0;i<n;++i) cin >> t[i];
    sort(t,t+n);
    
    ll ans = 0;
    for (int i=0;i<n;++i) {
        debug(i);
        int cnt = 1;
        int idx = i+1;
        while (idx < n && cnt < c && t[idx] <= t[i]+k) {
            cnt++;
            idx++;
        }
        ans++;
        i = idx - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4364
#include<cstdio>
#include<iostream>
#include <algorithm>
#include<cstring>
using namespace std;

typedef long long ll;

char s[100200];
int ans,tot1,tot2;
int main()
{
    cin>>s;
    for(int i=0;i<strlen(s);i++)
    {
        if(s[i]=='0')   tot1++;
        else            tot2++;
    }
    ans=min(tot1,tot2)*2;
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int yen = sc.nextInt();

    int a = yen / 500;

    yen = yen - (500 * a);
    int b = yen / 5;

    System.out.println((a * 1000) + (b * 5));
  }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

void rotate(double r[2], const double pos0[2], const double pos1[2], double a){
    double x = cos(a)*(pos1[0]-pos0[0])-sin(a)*(pos1[1]-pos0[1]) + pos0[0];
    double y = sin(a)*(pos1[0]-pos0[0])+cos(a)*(pos1[1]-pos0[1]) + pos0[1];
    r[0] = x;
    r[1] = y;
}
void koch(double ans[20000][2], int &k, double s[2], double g[2], int n){
    if(n == 0){
        ans[0][0] = s[0];
        ans[0][1] = s[1];
        k++;
    }else{
        double pt1[2] = {s[0]+(g[0]-s[0])/3, s[1]+(g[1]-s[1])/3};
        double pt2[2] = {s[0]+(g[0]-s[0])*2/3,s[1]+(g[1]-s[1])*2/3};
        double pt3[2];
        rotate(pt3,pt1,pt2,M_PI/3);
        double t[5][2] = {
            {s[0],s[1]},
            {pt1[0],pt1[1]},
            {pt3[0],pt3[1]},
            {pt2[0],pt2[1]},
            {g[0],g[1]}
        };
        if(n == 0){
            ans[0][0] = s[0];
            ans[0][1] = s[1];
            k++;
        }else if(n == 1){
            for(int i = 0; i < 4; i++){
                ans[k][0] = t[i][0];
                ans[k++][1] = t[i][1];
            }
        }else{
            for(int i = 0; i < 4; i++){
                koch(ans,k,t[i],t[i+1],n-1);
            }
        }
    }
}
int main(){
    int n;
    scanf("%d",&n);
    double ans[20000][2], s[2] = {0,0}, g[2] = {100,0};
    int k = 0;
    koch(ans,k,s,g,n);
    ans[k][0] = g[0];
    ans[k++][1] = g[1];
    for(int i = 0; i < k; i++){
        printf("%f %f\n",ans[i][0],ans[i][1]);
    }
}

Measured memory_bytes: 3008
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	switch {
	case a >= 13:
		fmt.Println(b)
	case 6 <= a && a <= 12:
		fmt.Println(b / 2)
	default:
		fmt.Println(0)
	}
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    VSORT(a);
    ll ans = 0;
    if (n%2==0) {
        rep(i, (n-2)/2) ans += (ll)a[i] * (-2);
        ans += (ll)a[(n-2)/2] * (-1);
        ans += (ll)a[(n-2)/2+1];
        rep(i, (n-2)/2) ans += (ll)a[(n-2)/2+2+i] * 2;
    }
    else {
        ll sum1 = 0, sum2 = 0;
        rep(i, (n-2)/2) sum1 += (ll)a[i] * (-2);
        sum1 += ((ll)a[(n-2)/2] + (ll)a[(n-2)/2+1]) * (-1);
        rep(i, (n-1)/2) sum1 += (ll)a[(n-2)/2+2+i] * 2;
        rep(i, (n-1)/2) sum2 += (ll)a[i] * (-2);
        sum2 += (ll)a[(n-1)/2] + (ll)a[(n-1)/2+1];
        rep(i, (n-2)/2) sum2 += (ll)a[(n-1)/2+2+i] * 2;
        ans = max(sum1, sum2); 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int x,y;
  cin>>x>>y;
  int ans=x+y/2;
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

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


int main(){
  string s;
  cin>>s;
  if(s=="ABC") cout<<"ARC";
  else cout<<"ABC";
}

Measured memory_bytes: 3596
n = int(input())
lis_p = list(map(int,input().split()))

count = 0
for i in range(1,n - 1):
    if lis_p[i - 1] < lis_p[i] < lis_p[i + 1] or lis_p[i - 1] > lis_p[i] > lis_p[i + 1]:
      count += 1
print(count)


Measured memory_bytes: 2940
K,N=map(int,input().split())
l=list(map(int, input().split()))
x=0
for i in range(N-1):
    if x<(l[i+1]-l[i]):
        x=(l[i+1]-l[i])
if (K+l[0]-l[-1])>x:
    x=(K+l[0]-l[-1])

print(K-x)

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

int main(){
	int n;
	scanf("%d",&n);

	int* a = new int[n];
	int* b = new int[n];
	int* c = new int[n];


	for (int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for (int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for (int i=0;i<n-1;i++){
		scanf("%d",&c[i]);
	}

	int sum = 0;

	for (int i = 0;i<n;i++){
		sum += b[a[i]-1];
		if(i>0 && i<n){
			if (a[i] == a[i-1]+1){
				sum += c[a[i-1]-1];
			}
		}
	}

	printf("%d",sum);
	return 0;


}

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

#define _ ios::sync_with_stdio(0);
#define __ cin.tie(0);
#define ___ cout.tie(0);
#define endl "\n";
#define fr first
#define se second

using namespace std;

string s;
int k;
bool f = 0;

char get(char c) {
	if(c == 'a') return 'a';
	else {
		int t = (('z' - c) + 1);
		if(t <= k) {
			k -= t;
			return 'a';
		}
		else {
			f = 1;
			return 'a';
		}
	}
}

int main() { _ __ ___

cin >> s >> k;
for(int i=0; i<s.size(); i++) {
	if(k == 0) break;
	char xx = get(s[i]);
	if(f == 0) {
		s[i] = xx;
	}
	else f = 0;
}
if( k > 0) {
	int x = (((s[s.size()-1] - 'a') + k) % 26);
	s[s.size() - 1] = (char)(x + 'a');
}

cout << s << endl;
return 0;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }
    if(a>b){
        cout<<"a > b"<<endl;
    }
    if(a==b){
        cout<<"a == b"<<endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
using namespace std;
#define cpy(a,b) tront[a-1] = temp[b-1]

class dice {
public:
	int tront[6];
	int flag;

	dice() {
		flag = 0;
	}
	void ini() {
		for (int i = 0; i < 6; i++) {
			cin >> tront[i];
		}
	}

	void rotation(char c) {
		int temp[6], i;
		for (i = 0; i < 6; i++)
			temp[i] = tront[i];
		switch (c) {
		case 'E':
			cpy(1, 4);
			cpy(4, 6);
			cpy(6, 3);
			cpy(3, 1);
			break;
		case 'N':
			cpy(5, 1);
			cpy(1, 2);
			cpy(2, 6);
			cpy(6, 5);
			break;
		case 'S':
			cpy(2, 1);
			cpy(1, 5);
			cpy(5, 6);
			cpy(6, 2);
			break;
		case 'W':
			cpy(1, 3);
			cpy(3, 6);
			cpy(6, 4);
			cpy(4, 1);
			break;
		}
	}

	void print(int x) {
		cout << tront[x-1] << endl;
	}

	void check(dice d1) {
		for (int j = 0; j < 6; j++) {
			if (d1.tront[j] != tront[j])
				return;
		}
		flag = 1;
	}
};

int main() {
	int i, j, k, l, a, b;
	int ans[7][7] = {0};
	dice d1, d2;
	ans[5][4]=1;ans[4][2]=1;ans[2][3]=1;ans[3][5]=1;
	ans[1][4]=2;ans[4][6]=2;ans[6][3]=2;ans[3][1]=2;
	ans[1][2]=3;ans[2][6]=3;ans[6][5]=3;ans[5][1]=3;
	ans[1][5]=4;ans[5][6]=4;ans[6][2]=4;ans[2][1]=4;
	ans[1][3]=5;ans[3][6]=5;ans[6][4]=5;ans[4][1]=5;
	ans[3][2]=6;ans[2][4]=6;ans[4][5]=6;ans[5][3]=6;
	d1.ini(); d2.ini();
	for (i = 0; i < 2; i++) {
		d2.rotation('N');
		d2.rotation('E');
		d2.rotation('S');
		for (j = 0; j < 4; j++) {
			d2.rotation('N');
			for (k = 0; k < 4; k++) {
				d2.rotation('E');
				d2.check(d1);
			}
		}
	}
	if (d2.flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a == 1 || b == 1) {
		if (a == b) {
			printf("Draw\n");
		}
		else {
			if(a<b){
				printf("Alice\n");
			}
			else {
				printf("Bob\n");
			}
		}
	}
	else {
		if (a == b) {
			printf("Draw\n");
		}
		else {
			if (a > b) {
				printf("Alice\n");
			}
			else {
				printf("Bob\n");
			}
		}
	}
	return 0;
}

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

char a[1000], b[1000];
string ans;

int main() {
  scanf("%s %s", a, b);
  if (strlen(a) == strlen(b)) {
    for (int i = 0; i < strlen(b); i++) {
      ans += a[i];
      ans += b[i];
    }
  } else if (strlen(a) > strlen(b)) {
    for (int i = 0; i < strlen(b); i++) {
      ans += a[i];
      ans += b[i];
    }
    ans += a[strlen(a)-1];
  } else {
    for (int i = 0; i < strlen(b); i++) {
      ans += a[i];
      ans += b[i];
    }
    ans += b[strlen(b)-1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def xor(val):
	if val < 0: return 0
	mod = val % 4
	if mod == 0: return val
	elif mod == 1: return 1
	elif mod == 2: return val + 1
	else: return 0

A, B = map(int, raw_input().split())
print xor(A - 1) ^ xor(B)

Measured memory_bytes: 27628
a, b = input().split()
if (a == 'H' and b == 'H'):
    print('H')
elif (a == 'H' and b == 'D'):
    print('D')
elif (a == 'D' and b == 'H'):
    print('D')
elif (a == 'D' and b == 'D'):
    print('H')

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

using namespace std;


int main()
{
	int n,ans=0;
	int v[41];
	
	while(1){
		cin >> n;
		if(n==0)break;
		
		vector<string> s(n);
		
		for(int i=0;i<n;i++){
			cin >> s[i];
			v[i] = s[i].size();
		}
		
		for(int i=0;i<n-4;i++){
			int k=i,flag = 1;
			for(int j=i;j<n;j++){
				int a=0;
				for(int l=0;l<5;l++){
					if(k == n)break;
					if(a+v[k] == 5){
						k++;
						break;
					}else if(a+v[k] > 5){
						flag = 0;
						break;
					}else {
						a += v[k];
						k++;
					}
				}
				
				a = 0;
				for(int l=0;l<7;l++){
					if(k == n)break;
					if(a+v[k] == 7){
						k++;
						break;
					}else if(a+v[k] > 7){
						flag = 0;
						break;
					}else {
						a += v[k];
						k++;
					}
				}
				
				a = 0;
				for(int l=0;l<5;l++){
					if(k == n)break;
					if(a+v[k] == 5){
						k++;
						break;
					}else if(a+v[k] > 5){
						flag = 0;
						break;
					}else {
						a += v[k];
						k++;
					}
				}
				
				a = 0;
				for(int l=0;l<7;l++){
					if(k == n)break;
					if(a+v[k] == 7){
						k++;
						break;
					}else if(a+v[k] > 7){
						flag = 0;
						break;
					}else {
						a += v[k];
						k++;
					}
				}
				
				a = 0;
				for(int l=0;l<7;l++){
					if(k == n)break;
					if(a+v[k] == 7){
						k++;
						break;
					}else if(a+v[k] > 7){
						flag = 0;
						break;
					}else {
						a += v[k];
						k++;
					}
				}
				if(flag == 1)break;
			}
			if(flag == 1){
				ans = i+1;
				break;
			}
		}
		cout << ans << endl;
	}
	
		
		
		
		
	return 0;
}


Measured memory_bytes: 3208
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println(solve());
    }
    
    private static int solve() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a == b) {
            return a * 2;
        } else if(a > b) {
            return a * 2 - 1;
        } else {
            return b * 2 - 1;
        }
    }
}


Measured memory_bytes: 23124
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static void swap(ref long x, ref long y)
        {
            var tmp = x;
            x = y;
            y = tmp;
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var input = Reads();
            var k = input[0];
            var n = input[1];
            var a = Reads();
            var b = new long[n];
            for (int i = 0; i < n-1; i++)
            {
                b[i] = a[i + 1] - a[i];
            }
            b[n - 1] = a[0] + k - a[n - 1];
            Console.WriteLine(k - b.Max());
            
            

            

        Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 36068
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		try (PrintWriter out = new PrintWriter(System.out);) {

			int n = scan.nextInt();
			String s = scan.next();

			long ret = 1;
			char target = s.charAt(0);
			for (int i = 1; i < n; i++) {
				if (target != s.charAt(i)) {
					ret++;
					target = s.charAt(i);
				}
			}

			out.println(ret);
			out.flush();
		}
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23636
x,N=map(int,input().split())
p=list(map(int,input().split()))
p_set=set(p)
flag=0
if x not in p_set:
    ans=x
else:
    count=0
    while flag==0:
        count+=1
        if x+count not in p_set:
            ans=x+count
            flag=1
        if x-count not in p_set:
            ans=x-count
            flag=1
print(ans)


Measured memory_bytes: 9188
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int ans = 0;
        int tmp = Integer.parseInt(sc.next());
        int tmp2 = tmp;
        for(int i = 0;i<n;i++){
            tmp = tmp2;
            if(i < n - 1 && i != 0){
                tmp2 = Integer.parseInt(sc.next());
            }
            if(tmp2 > tmp){
                ans += tmp;
            }else{
                ans += tmp2;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
N = int(input())-1

stations = []
for i in range(N):
  stations.append(tuple(map(int,input().split())))


def helper(t,i):
  c,s,f = stations[i]

  n = max((t-s-1)//f+1,0)
  return s+f*n+c

for s in range(N):
  t = 0
  for i in range(s,N):
    t = helper(t,i)
  print(t)

print(0)

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    float res = 0;
    FOR(i, 1, n)
    {
        float x;
        cin >> x;
        res = res + 1 / x;
    }
    cout << fixed << setprecision(5) << 1 / res;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

    int A[300000];

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    for (int i = 1; i + K <= N; i++) {
        if (A[i] < A[i+K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> cnt(N, 0);
    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int a; cin >> a; a--;
            cnt[a]++;
        }
    }
    int ans = 0;
    rep(i, N) if(cnt[i] == 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3624
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
vector<int> adj[200001];
bool visited[200001];
int val;
void dfs(int p)
{
    visited[p]=true;
    val++;
    for(auto it=adj[p].begin();it<adj[p].end();it++)
    {
       if(!visited[*it])
       {
          dfs(*it); 
       }
    }
}
void solve()
{
int n,m;
cin>>n>>m;
for (int i = 0; i < m; i++)
{
    int a,b;
    cin>>a>>b;
    adj[a].push_back(b);
    adj[b].push_back(a);
}
for (int i = 0; i < n; i++)
{
    unique(adj[i].begin(),adj[i].end());
}
// now run the dfs
int ans=0;
for (int i = 0; i < n; i++)
{
    if(!visited[i])
    {
        dfs(i);
        ans=max(ans,val);
        val=0;
    }
}
cout<<ans<<endl;
}
int main()
{
FASTIO
 long long int t=1;
 while(t--)
  solve();
  return 0;
}


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

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

int main(){
    int x;
    cin >> x;
    while(true){
        if(is_prime(x)) break;
        else x += 1;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n,m,x,y;
  cin>>n>>m>>x;
  int ret1=0,ret2=0;
  int i;
  for(i=0;i<m;i++){
    cin>>y;
    if(y<x)
      ret1++;
    if(y>x)
      ret2++;
  }
  cout<<min(ret1,ret2);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
int used[5000];
 
void dfs(int v, const Graph& G, vector<int>& res) {
	used[v] = 1;
	for (auto to : G[v]) if (used[to] == 0) {
		dfs(to, G, res);
	}
	res.push_back(v);
}
 
int main()
{
	cin.sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	Graph G(n);
	vector<vector<bool>> ex(n, vector<bool>(n));
	vector<int> v(m), w(m);
	vector<int> ide(n);
	for (int i = 0; i < m; i++) {
		cin >> v[i] >> w[i]; v[i]--; w[i]--;
		G[v[i]].push_back(w[i]);
		ide[w[i]]++;
		ex[v[i]][w[i]] = true;
	}
	vector<int> res;
	for (int i = 0; i < n; i++) {
		if (ide[i] == 0) {
			dfs(i, G, res);
		}
	}
	reverse(res.begin(), res.end());
	for (int i = 0; i < n; i++) {
		cout << res[i] + 1 << endl;
	}
	bool db = false;
	for (int i = 1; i < n; i++) {
		if (!ex[res[i - 1]][res[i]]) {
			db = true;
			break;
		}
	}
	cout << db << endl;
	return 0;
}


Measured memory_bytes: 8332
n = int(input())
MOD = 10**9 + 7
nums = list(map(int, input().split()))

pref = [0]*n

for i in range(n)[::-1]:
    pref[i] = (pref[i + 1] if i < n - 1 else 0) + nums[i]
    pref[i] %= MOD

ans = 0
for i in range(n - 1):
    ans += (nums[i] * pref[i + 1])%MOD
    ans %= MOD

print(ans)

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

int main () {
    double A, B, C, D;
    cin >> A >> B >> C >> D;
    if(ceil(C / B) <= ceil(A / D))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main() {
  long long n,a,b;
  cin >> n >> a >> b;
  long long c = a + b;
  long long ans = a * (n / c);
  ans += min(a, n % c); 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use std::cmp::min;
// use itertools::Itertools;

#[fastout]
fn main() {
  input!{
    a: i32,
    b: i32,
    c: i32,
    mut k: i32
  };
  let mut ans = 0;
  ans += min(k, a);
  k -= min(k, a+b);
  if k > 0 {
    ans -= min(k, c);
  }
  println!("{}", ans);
}


Measured memory_bytes: 2172
from collections import defaultdict


dict = defaultdict(int)
n = int(input())
for _ in range(n):
    s = input()
    dict[s] += 1

maxim = max(dict.values())

candidates = []

for key, count in dict.items():
    if count == maxim:
        candidates.append(key)

candidates.sort()

for ans in candidates:
    print(ans)

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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

int main() {

    unsigned long long A;
    long double B;

    cin >> A >> B;

    unsigned long long B100 = B * 100 + 0.5;
    unsigned long long ans = (A * B100) / 100;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi t(n), a(n);
	REP(i, n) cin >> t[i];
	REP(i, n) cin >> a[i];
	if (t[n - 1] != a[0])
	{
		cout << 0 << endl;
		return 0;
	}
	vector<pii> v(n, pii(1, INF));
	v[0] = pii(t[0], t[0]);
	v[n - 1] = pii(a[n-1], a[n-1]);
	FOR(i, 1, n - 1)
	{
		if (t[i] != t[i - 1]) v[i] = pii(t[i], t[i]);
		else v[i].second = t[i];
	}
	for (int i = n - 2; i > 0; i--)
	{
		if (a[i] != a[i + 1]) v[i] = pii(a[i], a[i]);
		else chmin(v[i].second, a[i]);
	}
	ll ans = 1;
	REP(i, n)
	{
		int tmp = v[i].second - v[i].first + 1;
		if (tmp < 0) tmp = 0;
		ans = ans * tmp % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
  int n; cin >> n;
  int a[200000]; for (int i = 0; i < n; ++i) cin >> a[i];
  
  int l = 0, r = 0, sum = 0;
  long long ans = 0;
  while (r < n)
    if (sum + a[r] == (sum ^ a[r]))
      sum += a[r++];
    else {
      ans += r-l;
      sum -= a[l++];
    }
  ans += (long long)(r-l)*(r-l+1)/2;
  
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n){
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    int cnt = 0;
    for (auto u : mp){
        if(u.second%2==1) cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int dp[1001][1001];
char arr[1001][1001];
int flag[1001][1001];
int h,w;
int m=1e9+7;
signed  main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>arr[i][j];
            if(arr[i][j]=='#')
            {
            flag[i][j]=-1;
            dp[i][j]=0;
            }
 
        }
 
    }
 
    for(int i=1;i<=h;i++)
    {
        if (arr[i][1]=='#')
        {
        for(int j=i;j<=h;j++)
            {
                flag[j][1]=-1;
                dp[j][1]=0;
            }
        }
    }
    
    for(int i=1;i<=w;i++)
    {
        if(arr[1][i]=='#')
        {
            for(int j=i;j<=w;j++)
            {
                flag[1][j]=-1;
                dp[1][j]=0;
            }
        }
 
    }
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
 
            if(i==1||j==1)
            {
              if(flag[i][j]==0)
              dp[i][j]=1;
              else dp[i][j]=0;
 
            }
 
            else if(flag[i][j]!=-1)
            {
                dp[i][j]=(dp[i-1][j]%m+dp[i][j-1]%m)%m;
                
            }
            else if(flag[i][j]==-1)
            dp[i][j]=0;
            
        
        
        
        }
    }
 /*   for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cout<<dp[i][j];
        }
        cout<<"\n";    
        }
        */
        cout<<dp[h][w];
}

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

int main() {
  int a,b,c,s;

  cin >> s;
  
  a = s / 100;
  b = s / 10 - a * 10;
  c = s - a * 100 - b * 10;
  
  cout << a + b + c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, A, dp[5005][2];
    cin >> N;
    fill_n(*dp, 5005 * 2, (1 << 30) - 1);
    dp[1][0] = dp[0][1] = 0;
    for(int p = 1; p < N; p++) {
        cin >> A;
        for(int i = 5004; i > 0; i--) {
            dp[i][1] = min(dp[i][1], dp[i][0] + A);
            dp[i][0] = min(dp[i - 1][0], dp[i - 1][1] + A);
        }
    }
    cout << min(dp[N / 2][0], dp[N / 2][1]) << endl;
    return (0);
}



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

int main() {
  int N,M;
  cin >> N >>M;
  vector<int>a(500);
  vector<int>b(500);
  vector<int>c(500);
  for (int i=1;i<M+1;i++){
  cin >> a.at(i) >> b.at(i);
  }
  
  for(int i=1;i<N+1;i++){
    c.at(i)=0;
    for(int x=1;x<M+1;x++){
    	if(i==a.at(x)||i==b.at(x)){
    	 c.at(i)+=1;  
    	}
    }
      cout << c.at(i) << endl;
  } 	  	  
}




Measured memory_bytes: 256
n1, n2 = [int(i) for i in input().split()]

na3 = [0] * n1
for i4 in range(n1):
    na3[i4] = [int(j) for j in input().split()]

r1 = 0
for i5 in range(n1):
    for j6 in range(n1):
        if i5 >=  j6:
            continue
        else:
            s7 = 0
            for i8 in range(n2):
                s7 += (na3[i5][i8] - na3[j6][i8]) **2
            if  (s7 ** 0.5) % 1 == 0:
                r1 += 1

print(r1)

Measured memory_bytes: 3064
from collections import deque

N, M = map(int, raw_input().split())
nodes = {i:[] for i in range(1, N+1)}
for _ in range(M):
  a, b = map(int, raw_input().split())
  nodes[a] += [b]
  nodes[b] += [a]
stack = deque([[1, []]])
ans = 0
while stack:
  n, history = stack.pop()
  if len(history) == N - 1:
    ans += 1
    continue
  node = nodes[n]
  for next_node in node:
    if not next_node in history:
      stack.append([next_node, history+[n]])
print ans



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

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> a.at(i).at(j);
        }
        
    }
    vector<bool> all_empty_h(h,false);
    vector<bool> all_empty_w(w,false);
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            if (a.at(i).at(j) == '#') break;
            else if (j == w - 1) {
                all_empty_h.at(i) = true;
            }
        }
    }
    for(int i = 0; i < w; i++)
    {
        for(int j = 0; j < h; j++)
        {
            if (a.at(j).at(i) == '#') break;
            else if (j == h - 1) {
                all_empty_w.at(i) = true;
            }
        }
    }
    
    bool flag;
    for(int i = 0; i < h; i++)
    {
        if (all_empty_h.at(i)) continue;
        flag = false;
        for(int j = 0; j < w; j++)
        {
            if (all_empty_w.at(j)) continue;
            else {
                cout << a.at(i).at(j);
                flag = true;
            }
        }
        if (flag) cout << endl;
    }
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> R;
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    R.push_back(make_pair(a,b));
  }
  vector<pair<int, int>> B;
  for(int i=0; i<N; i++){
    int a,b;
    cin >> a >> b;
    B.push_back(make_pair(a, b));
  }
  sort(B.begin(),B.end());
  vector<bool> red(N, false);
  int ans=0;
  for(int i=0; i<N; i++){
    vector<bool> can(N,false);
    int ry_max=-1;
    for(int j=0; j<N; j++){
      if(B[i].first>=R[j].first && B[i].second>=R[j].second && !red[j]){
        can[N] = true;
        ry_max = max(ry_max, R[j].second);
      }
    }
    if(ry_max == -1){
      continue;
    }
    for(int j=0; j<N; j++){
      if(ry_max == R[j].second){
        red[j] = true;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import string

alphabets = string.ascii_uppercase

players_cards = {}
for i in range(3):
    players_cards[alphabets[i]] = [letter for letter in input()]

first_player = 'A'

next_player = first_player
while True:
    current_player = next_player
    current_player_cards = players_cards[current_player]
    if current_player_cards:
        next_player = current_player_cards[0].upper()
        current_player_cards.pop(0)
    else:
        winner = current_player
        print(winner)
        exit()

Measured memory_bytes: 3768
from cmath import rect, pi

def deg_to_rad(deg): return deg * pi / 180

a, b, h, m = map(float, input().split())
zh = rect(a, deg_to_rad((60*h+m) / 2))
zm = rect(b, deg_to_rad(m * 6))
print(abs(zh-zm))

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	set<string> s;
	bool ans = true;
	char lastChar;
	FOR(i, 0, n){
		string w;
		cin >> w;
		set<string>::iterator ite = s.find(w);
		if(ite != s.end()){
			ans = false;
			break;
		}
		s.insert(w);
		if(i > 0 && lastChar != w[0]){
			ans = false;
			break;
		}
		lastChar = w[w.size()-1];
	}
	Yes(ans);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = [list(map(int,input().split())) for i in range(N)]

dist = 0.0

for i in range(N):
    for j in range(N):
        dist += ((P[i][0] - P[j][0])**2 + (P[i][1] - P[j][1])**2)**0.5

print(dist / N)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 1000000

int  b[MAX];
int H; 

void maxheap(int i);
void buildmaxheap();

int main(){
    cin >> H;
    for(int i = 1; i <= H; i++){
        cin >> b[i];
    }

    buildmaxheap();

    for(int i = 1; i <= H; i++){
        cout << " " << b[i];
    }
    cout << endl;
    return 0;
}

void maxheap(int i){
    int ind;
    if(i*2 <= H &&  b[i*2] > b[i]){
        ind = i*2;
    }else{
        ind = i;
    }
    if(i*2+1 <= H && b[i*2+1] > b[ind]){
        ind = i*2+1;
    }
    if(ind != i){
        int w = b[i];
        b[i] = b[ind]; b[ind] = w;
        maxheap(ind);
    }
}

void buildmaxheap(){
    for(int i = H/2; i > 0; i--){
        maxheap(i);
    }
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> cnt(m, 0);
    for(int i=0;i<n;++i){
        int k;
        cin >> k;
        for(int j=0;j<k;++j){
            int a;
            cin >> a;
            --a;
            ++cnt[a];
        }
    }
    int ans = 0;
    for(int i=0;i<m;++i){
        if(cnt[i] == n){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a,b;
    char x;
    cin>>a>>x>>b;
    if(x=='+'){
        cout<<a+b<<endl;
    }
    else{
        cout<<a-b<<endl;
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
using namespace std;
char map[101][101];
int w,h,cnt;
char hoge;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
void dfs(int,int);
int main(){
  while(1){
    cnt=0;
    cin >> h >> w;
    if(w == 0 && h == 0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    cin >> map[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    if(map[i][j]!='.'){
      cnt++;
      hoge=map[i][j];
      dfs(j,i);
    }
      }
    }
    printf("%d\n",cnt);
  }
}
 
void dfs(int x,int y){
  map[y][x]='.';
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx >= 0&& nx < w && ny >= 0 && ny < h && map[ny][nx]==hoge){
    dfs(nx,ny);
      }
  }
}


Measured memory_bytes: 3344
#include <iostream>
#include <set>
using namespace std;
const int maxn = 111111;
struct Data
{
    int t, v;
    Data() {}
    Data(int _v, int _t):t(_t), v(_v) {}
    bool operator <(const Data &B) const
    { return (t == B.t) ? v < B.v : t > B.t; }
};
int n, a[maxn], T[maxn];
set<Data> S;
int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++)
    {
        cin>>a[i];
        T[a[i]]++;
    }
   // for(int i = 1; i <= n; i++) cout<<a[i]<<" "<<T[a[i]]<<endl;
    for(int i = 1; i <= n; i++) if(S.find(Data(a[i], T[a[i]])) == S.end()) S.insert(Data(a[i], T[a[i]]));
    int ans = 0;
    while((*S.begin()).t != 1)
    {
        Data x = *(S.begin());
        //cout<<x.v<<" "<<x.t<<endl;
        if(x.t > 2)
        {
            ans += (x.t-1)/2;
            S.erase(x);
            x.t = (x.t % 2 == 0) ? 2 : 1;
            S.insert(x);
        } else
        if(x.t == 2)
        {
            ans++;
            S.erase(x);
            Data y = (*S.begin());
            S.erase(y);
            x.t--; y.t--;
            if(y.t != 0) S.insert(y);
            S.insert(x);
        }
    }
    cout<<n - ans*2;
}


Measured memory_bytes: 5760
#if 0



#endif // 0

#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;
int N;
int mi[MAXN],len;

void work(){
    while(~scanf("%d",&N)){
        len=0;
        for(int i=1;i<=N;i++){
            int a; scanf("%d",&a);
            if(len==0) mi[++len]=a;
            else{
                int pos=lower_bound(mi+1,mi+len+1,a)-mi;
                if(pos>len) mi[++len]=a;
                else mi[pos]=a;
            }
        }
        printf("%d\n",len);
    }
}

int main(){
    work();
    return 0;
}



Measured memory_bytes: 3548